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

decltype not recognised as type specifier for base-class

Walter_D_
Beginner
426 Views

The following code compiles fine under clang and gcc but fails for icc (v14.0.2):

namespace traits_tests {
  template<typename> struct sfinae_true : true_type {};

  template<typename T> static auto value_type(int)   -> sfinae_true<typename T::value_type>;
  template<typename T> static auto value_type(void*) -> false_type;
}
template<typename C>
struct has_value_type
  : decltype(traits_tests::value_type<C>(0)) {};

with the error message

inc/traits.h(258): error: expected an identifier
      : decltype(traits_tests::value_type<C>(0)) {};
        ^

.

 

 

0 Kudos
2 Replies
MalReddy_Y_Intel
Employee
426 Views

Hi Walter,

Could you please post us the complete test code to reproduce the issue.

Reddy

 

0 Kudos
Judith_W_Intel
Employee
426 Views

 

I can reproduce this with a 14.0 compiler from 1/21/2014 but not 04/18/2014. So it should be fixed in version 14.0.3.

Please upgrade and let me know if it is still a problem for you.

thanks

Judy

sptxl15-214> cat t.cpp

struct true_type {};
struct false_type {};

namespace traits_tests {
  template<typename> struct sfinae_true : true_type {};

  template<typename T> static auto value_type(int)   -> sfinae_true<typename T::value_type>;
  template<typename T> static auto value_type(void*) -> false_type;
}

template<typename C>
struct has_value_type
  : decltype(traits_tests::value_type<C>(0)) {};

sptxl15-215> /home/cmplr/archive/SWF/deploy_14_0/x86linux/20140121_010000/build/linux_debug/bin/ia32/icpc -c -std=c++11 t.cpp
t.cpp(14): error: expected an identifier
    : decltype(traits_tests::value_type<C>(0)) {};
      ^

compilation aborted for t.cpp (code 2)
sptxl15-216> /home/cmplr/archive/SWF/deploy_14_0/x86linux/20140418_000000/build/linux_debug/bin/ia32/icpc -c -std=c++11 t.cpp
sptxl15-217>

Judy

0 Kudos
Reply