Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested structure as request? #15

Closed
byzhang opened this issue Apr 27, 2015 · 3 comments
Closed

Nested structure as request? #15

byzhang opened this issue Apr 27, 2015 · 3 comments

Comments

@byzhang
Copy link
Contributor

byzhang commented Apr 27, 2015

I try to change the "Hello World" to "Hello FirstName LastName" like

_my_scope = D(_test2(_name=D(_first, _second), _age=int()) = [] (auto p) {
  return D(_message = "hello " + p.name.first + " " +p.name.second + " " + std::to_string(p.age));
  }),

with

#ifndef IOD_SYMBOL_first
#define IOD_SYMBOL_first                                                                                                                                                                                   iod_define_symbol(first)
#endif

#ifndef IOD_SYMBOL_second
#define IOD_SYMBOL_second
iod_define_symbol(second)
#endif

And I got such error message

error: ‘s::_name_t::variable_type<iod::sio<s::_first_t, s::_second_t> >::value_type’ has no member named ‘second’
       return D(_message = "hello " + p.name.first + " " +p.name.second + " " + std::to_string(p.age));
error: ‘s::_name_t::variable_type<iod::sio<s::_first_t, s::_second_t> >::value_type’ has no member named ‘first’
       return D(_message = "hello " + p.name.first + " " +p.name.second + " " + std::to_string(p.age));

What's the correct syntax to use nested structure?

@matt-42
Copy link
Owner

matt-42 commented Apr 27, 2015

The default string type is not supported on nested objects. This should fix your problem:
_name=D(_first = std::string(), _second = std::string()), _age = int()

@byzhang
Copy link
Contributor Author

byzhang commented Apr 27, 2015

It works!

@byzhang byzhang closed this as completed Apr 27, 2015
@matt-42
Copy link
Owner

matt-42 commented Apr 27, 2015

Good to know! Thanks for closing this issue :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants