Thread: Template<> without any content

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    1,579

    Template<> without any content

    Hello everyone,


    I sometimes saw code with template<> and followed by a class definition, like,

    Code:
    template<> class {
    
            // class definition
    }
    I am wondering the practical usage of this trick. Why declar a template but leaving the content to nothing? If there is no type parameters, I do not think there is a need to put template<> statement.


    thanks in advance,
    George

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    I don't think this is legal. Are you sure it wasn't of the form
    Code:
    template <> class<a_type> {
    };
    ?
    That would be a full specialization.


    Edit: Definitely not legal. The production for a template declaration is
    Code:
              template-declaration:
                      exportopt template < template-parameter-list > declaration
              template-parameter-list:
                      template-parameter
                      template-parameter-list , template-parameter
    This production requires at least one actual parameter.
    Last edited by CornedBee; 11-19-2007 at 05:52 AM.
    All the buzzt!
    CornedBee

    "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. Simple Memory Content Question
    By azzuwan in forum C Programming
    Replies: 7
    Last Post: 09-18-2008, 04:23 AM
  2. Library which extract html tags content
    By Bargi in forum C++ Programming
    Replies: 0
    Last Post: 05-10-2007, 10:17 PM
  3. Messy Content: Avoidable?
    By loopshot in forum Game Programming
    Replies: 4
    Last Post: 12-16-2005, 11:26 AM
  4. How do I delete the content of a char && string ??
    By client in forum C Programming
    Replies: 2
    Last Post: 06-01-2002, 05:09 AM