Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7944 Discussions

[iso-c++] compatible template check as template template parameter

charlls
Beginner
291 Views

Hi everyone.
I have the following testcase:
$ cat templatetemplate.cc
template
struct LabelTypeMap { typedef int type_t; };
template
struct Hold { typedef int type; };
template class typeMap>
struct Whatever { };
template
struct Now { typedef Whatever, LabelTypeMap> concrete_t; };
Now::concrete_t obj;
After trying to build i got this error:
$icpc -DENABLE=Enable ttemplatetemplate.cc -o ./x2test
templatetemplate.cc(12): error: class template "LabelTypeMap" is not compatible with template template parameter "typeMap"
struct Now { typedef Whatever, LabelTypeMap> concrete_t; };
^
compilation aborted for templatetemplate.cc (code 2)
$ icpc --version
icpc (ICC) 12.0.0 20101116
Copyright (C) 1985-2010 Intel Corporation. All rights reserved.
With g++ i get the following error:
(notably both compilers build the sample successfully if the ENABLE is set to true)
$ g++ templatetemplate.cc -o ./x2test
templatetemplate.cc:12: error: type/value mismatch at argument 2 in template parameter list for template > class typeMap> struct Whatever
templatetemplate.cc:12: error: expected a template of type template > class typeMap, got template struct LabelTypeMap
$ g++ DENABLE=Enable templatetemplate.cc -o ./x2test templatetemplate.cc:12: error: type/value mismatch at argument 2 in template parameter list for template > class typeMap> struct Whatevertemplatetemplate.cc:12: error: expected a template of type template > class typeMap, got template struct LabelTypeMap
$ g++ --version g++ (Ubuntu/Linaro 4.4.4-14ubuntu5) 4.4.5 Copyright (C) 2010 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
So, my question is, what is the reason this code is being rejected?
0 Kudos
0 Replies
Reply