Reputation: 1
I have a template class that basically implements registry design pattern. Values are registered with Keys and are stored in some container:
template <typename Key, typename Value,
template <typename...> class Container >
class registry
{
public:
typedef Key key_type;
typedef Value value_type;
typedef std::pair<key_type, value_type> element_type;
typedef Container<element_type> container_type;
Then, I can use it with sequence containers like this:
registry<const char*,void*, std::list> r1;
registry<const char*,void*, std::vector> r2;
I can even use it with alias:
template <typename T>
using alias_container = std::array<T, 10>;
registry<const char*,void*, alias_container > r4;
But I can't figure out how to use it with typedef like this:
template <typename T>
class my_container2
{
typedef std::array<T,3> type;
};
I basically want something like this:
registry<const char*,void*, my_container2::type > r5;
Thanks a lot for your help.
Upvotes: 0
Views: 194
Reputation: 180585
type
is dependent on the template type provided to my_container2
. In order to use it you need to specify the template parameter like
registry<const char*,void*, my_container2<some_type>::type > r4;
^^^^^^^^^ template type here
This is the same concept as iterators to standard types. You can't use container_type::iterator
. You have to use container_type<some_type>::iterator
.
Upvotes: 2