Hello
I have 2 classes (parser and caller class).
Caller class calls a function (.parse()) which is a member of parser class and should return 3 strings (objects).
I could create 3 basic strings, and pass their references to parse() function which would then set/modify each of them. However, I dont like this kind of design so I decided to return a tuple (multi-pair) instead.
I decided to wrap tuple<std::string, std::string, std::string> in a boost smart/shared pointer.
Now when I want to access one of tuple members I have to call get function.
The code becomes something like this:
The problem is I dont want to call ptr.get() each time to be able to access tuple members because I think its not a good way to do it because then I loose the real benefit of shared/smart pointers.Code:typedef boost::tuple<std::string, std::string, std::string> data_type; boost::shared_ptr<data_type> ptr = parser.parse(); std::string first_string = boost::tuples::get<0>(*ptr.get()); std::string second_string = boost::tuples::get<1>(*ptr.get()); //etc..
Do you guys have any better idea how I could solve this problem?
Maybe some different design would be more suitable?
Thanks a lot for help