Template<> without any content

This is a discussion on Template<> without any content within the C++ Programming forums, part of the General Programming Boards category; Hello everyone, I sometimes saw code with template<> and followed by a class definition, like, Code: template<> class { // ...

  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,893
    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, 05:23 AM
  2. Library which extract html tags content
    By Bargi in forum C++ Programming
    Replies: 0
    Last Post: 05-10-2007, 11: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, 06:09 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21