I am trying to use a class local type definition in a constructor declaration. both the classes are templates, here is the code.
template < typename T>
class complexType
{
public:
using value_type = T;
complexType( T t ) {}
};
template <typename containedType >
class container
{
public:
container ( containedType::value_type v ) { return; }
//container ( int v ) { return; }
};
int main(int ac, char **av)
{
container <complexType<int>> c(100);
return 0;
}
if i use the second constructor definition which is being passed an int, the code builds fine. i cannot reason why the code won't build.
value_type
is dependent name, which depends on template argument, in such case you need to use typename
to indicate that value_type
is type:
template <typename containedType >
class container
{
public:
container ( typename containedType::value_type v ) { return; }
^^^^^^^
//container ( int v ) { return; }
};