
On 02/24/14 11:55, MM wrote:
On 24 February 2014 14:28, Larry Evans <cppljevans@suddenlink.net <mailto:cppljevans@suddenlink.net>> wrote:
On 02/24/14 05:04, Krzysztof Czainski wrote:
2014-02-24 11:55 GMT+01:00 MM <finjulhich@gmail.com <mailto:finjulhich@gmail.com> <mailto:finjulhich@gmail.com <mailto:finjulhich@gmail.com>>>__:
Hello,
I just wanted to confirm there's no provided method to get the n'th element of say a fusion vector where n is known at runtime, except of handling it explicitkly with a switch case?
Thanks
MM
If such a function existed, what return type would it have?
Regards, Kris
What about: variant<T1,T2,T3> get(unsigned n, vector<T1,T2,T3>) ? For example:
vector<T1,T2,T3> vec(T1(),T2(),T3()); variant<T1,T2,T3> var; var = get(2,vec); assert(var.which(),2);
-regards, Larry
Possible, a variant over the unique types in the sequence.
It has to be over unique types because boost::variant cannot handle duplicates. However, if, instead of boost::variant, a truly tagged union: http://en.wikipedia.org/wiki/Tagged_union were used, then the types could be duplicated and there would be any need to program some metafunction to find the unique types in the fusion::vector<T1,T2,...,Tn>. Tagged unions were also requested here: http://stackoverflow.com/questions/17727563/tagged-unions-aka-variant-in-c-w... which also provided a link to an implementation of a tagged union.
What would the impl look like though?
MM
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users