f



is this legal c++0x?

If subscript operator is legal as non-member function in c++0x, could
we write?



template <typename...Types, int N>
auto operator[](tuple<Types...> && tup, int n = N) -> constexpr
decltype(get<N>(tup))
{
	return get<N>(tup);
}


is this legal c++0x? Because if it is. We could write.

tuple<int, float, string> mytuple;

mytuple[2] = 12;

and expressions in array-like notation.

-- 
      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]

0
german
5/9/2009 11:04:01 AM
comp.lang.c++.moderated 10738 articles. 1 followers. allnor (8506) is leader. Post Follow

1 Replies
355 Views

Similar Articles

[PageSpeed] 13

german diago wrote:
> If subscript operator is legal as non-member function in c++0x, could
> we write?
> 
> 
> 
> template <typename...Types, int N>
> auto operator[](tuple<Types...> && tup, int n = N) -> constexpr
> decltype(get<N>(tup))
> {
> 	return get<N>(tup);
> }
> 
> 
> is this legal c++0x? Because if it is. We could write.
> 
> tuple<int, float, string> mytuple;
> 
> mytuple[2] = 12;

Sorry, but N cannot be deduced in this way.

Furthermore, we would get functions with weird signatures,
since default values are not part of it.

-- 
Dragan

      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]

0
Dragan
5/15/2009 5:43:39 AM
Reply: