Thread: Unfamiliar from of template

  1. #1
    Guest
    Guest

    Unfamiliar from of template

    I recently looked up std::remove_reference and found the following "possible implementation":
    Code:
    template<class T> struct remove_reference { typedef T type; };
    template<class T> struct remove_reference<T&> { typedef T type; };
    template<class T> struct remove_reference<T&&> { typedef T type; };
    I'm familiar with:
    Code:
    template<class T> struct S { T member; }; // regular template
    template<> struct S<int> { int members[5]; }; // specialization thereof
    So what is this trailing type syntax called and by what rule is it able to determine what (reference-)type it has been passed?

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    It's called partial specialization. What you showed is explicit specialization. Type deduction is done much the same as overload resolution.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Unfamiliar debugger problems
    By ashinms in forum C++ Programming
    Replies: 1
    Last Post: 02-24-2012, 09:14 PM
  2. Errors in Code i am unfamiliar with, Please Help
    By msween21 in forum C Programming
    Replies: 6
    Last Post: 10-03-2009, 12:06 AM
  3. unfamiliar syntax
    By bean66 in forum C++ Programming
    Replies: 11
    Last Post: 04-02-2009, 12:36 PM
  4. little sign convention i'm unfamiliar with
    By trickae2 in forum C Programming
    Replies: 8
    Last Post: 08-25-2006, 08:32 PM
  5. unfamiliar with linux
    By macronin in forum C++ Programming
    Replies: 0
    Last Post: 03-25-2002, 09:17 AM

Tags for this Thread