The following translation unit seems to show a bug exhibited by 4.4.3 and 4.5. 

    #include <type_traits> 

    template<class X, class Y> struct plus 
        : std::integral_constant< 
            decltype(X::value + Y::value), 
            X::value + Y::value 
        > { }; 

    int main(int argc, char* argv[]) { 
        return 0; 
    } 

Compiling this file (test.cpp) with 

    g++ -std=c++0x -l stdc++ test.cpp 

yields the following diagnostic: 

    test.cpp:7: error: 'decltype ((X::value + Y::value))' 
    is not a valid type for a template constant parameter 

Am I missing something? The following works as intended: 

    #include <type_traits> 
    #include <utility> 

    template<class X, class Y> struct plus 
        : std::integral_constant< 
            typename std::identity<decltype(X::value + Y::value)>::type, 
            X::value + Y::value 
        > { }; 

    int main(int argc, char* argv[]) { 
        return 0; 
    } 

(i.e. just wrapping the use of decltype with std::identity) 

Regards, 
Paul Mensonides 

Reply via email to