Google


   


You are here: CodeIdol.com > C++ > C++ Templates: The Complete Guide > Template Argument Deduction > Allowable Argument Conversions

SAVE
Digg
Shown on del.icio.us del.icio.us
See Whos Talking About This on Technorati Technorati
I've Reddit reddit

11.4 Allowable Argument Conversions

Normally, template deduction attempts to find a substitution of the function template parameters that make the parameterized type P identical to type A. However, when this is not possible, the following differences are tolerable:

  • If the original parameter was declared with a reference declarator, the substituted P type may be more const/volatile-qualified than the A type.

  • If the A type is a pointer or pointer-to-member type, it may be convertible to the substituted P type by a qualification conversion (in other words, a conversion that adds const and/or volatile qualifiers).

  • Unless deduction occurs for a conversion operator template, the substituted P type may be a base class type of the A type, or a pointer to a base class type of the class type for which A is a pointer type. For example:

template<typename T> 
class B<T> { 
}; 

template<typename T> 
class D : B<T> { 
}; 

template<typename T> void f(B<T>*); 

void g(D<long> dl) 
{ 
    f(&dl);  // deduction succeeds with T substituted with long 
} 

The relaxed matching requirements are considered only if an exact match was not possible. Even so, deduction succeeds only if exactly one substitution was found to fit the A type to the substituted P type with these added conversions.

    SAVE
    Digg
    Shown on del.icio.us del.icio.us
    See Whos Talking About This on Technorati Technorati
    I've Reddit reddit

    You are here: CodeIdol.com > C++ > C++ Templates: The Complete Guide > Template Argument Deduction > Allowable Argument Conversions


    ADBRITE ads links
       
    Related tags







    Popular Categories
    Unix books and guides

    AJAX popular information
    C# language guides
    Windows books and cookbooks

    .......








    Business Key Top Sites

    be number one
    rate your site





    © CodeIdol Labs, 2007 - 2009