Thread: storing datatypes (typedefs) inside template class

  1. #1
    Registered User
    Join Date
    May 2006

    storing datatypes (typedefs) inside template class


    Is it possible to do the following (without template argument list):

    Registry::Inside::Type some_type;
    with this code:

    template<class T>
    struct Registry {
    	typedef std::map<std::string, T> Type;
    	struct Inside {
    		typedef std::string Type;
    Ive been wondering if this is possible because I want to keep datatypes nicely organized in same classes so that I could do:

    Registry::Inside::Type some_type;
    Registry<std::string>::Type some_other_type;
    Many thanks in advance!

  2. #2
    Registered User
    Join Date
    Jan 2005
    Yes... that should work fine (although you probably need a typename for the first one). Are you having problems?

  3. #3
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    You cannot omit the template parameters of a template in naming a nested element unless you're within the implementation scope of the template.
    All the buzzt!

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 8
    Last Post: 07-24-2006, 08:14 AM
  2. Class Template Trouble
    By pliang in forum C++ Programming
    Replies: 4
    Last Post: 04-21-2005, 04:15 AM
  3. Instantiating a template class
    By NullS in forum C++ Programming
    Replies: 11
    Last Post: 02-23-2005, 10:04 AM
  4. template functions inside a class
    By Trauts in forum C++ Programming
    Replies: 8
    Last Post: 03-12-2004, 10:05 PM
  5. oh me oh my hash maps up the wazoo
    By DarkDays in forum C++ Programming
    Replies: 5
    Last Post: 11-30-2001, 12:54 PM