c++ - C++11: template parameter redefines default argument -


when compiling following source code gcc there no errors / warnings:

template< typename t = int > t func( ); template< typename t = int > t func( ); 

when compile same source code clang++, got following error:

redeftempparam.cc:2:24: error: template parameter redefines default argument template< typename t = int > t func( );                        ^ redeftempparam.cc:1:24: note: previous default template argument defined here template< typename t = int > t func( );                        ^ 1 error generated. 

command compile

[clang++|g++] -wall -werror -std=c++11 redeftempparam.cc 

(version information: gcc 4.7.2, clang version 3.3 (trunk 171722))

my question:

is type of redefinition allowed? if not: can please point me appropriate point in c++ standard?

§14.1.12:

a template-parameter shall not given default arguments 2 different declarations in same scope.

[example:

template<class t = int> class x; template<class t = int> class x { /∗... ∗/ }; // error 

— end example ]


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -