Hi.
I'm making my own std::conditional<> implementation.
Look at this simple example:
1 2 3 4 5
|
template<typename T>
struct S
{
using theType = T;
};
|
Why can't I do
1 2
|
S<double> my; // my is now a struct
my.theType my2; // expected my2 to be a double
|
With my std::conditional<> i'm in a similar case
1 2 3
|
gcondition<true, char*, char**> my;
my2.gtype t; // expected t to be a char*
|
Where gtype is declared as:
1 2 3 4 5
|
using gtype = T; // true case: gtype is the T type
//or
using gtype = F; // false case: gtype is the F type
|
I know I can't do that. The using is just a newer typedef, not a member
But how can I accomplish this in another way?
Last edited on
Thanks for the reply.
I can't access theType as if it were a struct-member using my.theType
But I can access it by using the scope resolutor StructName<eventual_parameters>::theType
because it is a Type Alias, right?
Last edited on
Yes. The name of a nested type is in the scope of its enclosing class.