#How to: multiple names for one field?

15 messages · Page 1 of 1 (latest)

magic driftBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

slate rampart
#

Can you link to the exact requirements the function has?

#

Which function in that file?

#

Okay, but can you show me your code? What function are you calling or what template are you instantiating?

#

I'm more interested in this over the exact place where it fails internally

#

The value_type of the edge iterator must be a std::pair (or at least have first and second members). The first_type and second_type of the pair must be the same

#

So while you don't have to use std::pair, you'll have to rename the members to match it, and add the first_type,second_type typedefs

hardy venture
#

How to: multiple names for one field?

slate rampart
#

There's no good way to have multiple member names in a struct. But that's not necessary I think, because you can write a really clever iterator

#

I'm not sure if there's a builtin iterator for that, but you can write one where operator* returns by value something like struct Blah {std::string &first, &second; using first_type = std::string; using second_type = std::string;};

#

If this library is written properly and can handle operator* returning by value, this should just work

pearl rain
#

Wouldn't a conversion operator work? I mean converting MyObject to std::pair

slate rampart
#

No, because even with that operator my_obj.first wouldn't compile

magic driftBOT
#

This question is being automatically marked as stale.
If your question has been answered, type !solved.
If your question is not answered feel free to bump the post or re-ask.
Take a look at !howto ask for tips on improving your question.