Quantcast
Channel: Intel® Software - Intel® C++ Compiler
Viewing all articles
Browse latest Browse all 2797

Intel C++ Compiler rejects presumably valid code with out-of-line template member function definition

$
0
0

Intel C++ Compiler (EDG-based frontend) rejects the following code:

template <typename Descriptor>
class hash_table
{
public:
  typedef int value_type;

  template <typename Argument, int Callback (value_type *, Argument)>
  void traverse (Argument);
};

template <typename Descriptor>
template <typename Argument, int Callback (typename hash_table <Descriptor>::value_type *, Argument)>
void hash_table <Descriptor>::traverse (Argument) {}

with the following error message:

$ /opt/intel/bin/icpc -v
icpc version 16.0.0 (gcc version 4.9.0 compatibility)
$ /opt/intel/bin/icpc -c test.cc
test.cc(13): error: declaration is incompatible with function template "void hash_table<Descriptor>::traverse<Argument,Callback>(Argument)" (declared at line 8)
  void hash_table <Descriptor>::traverse (Argument) {}
                                ^

compilation aborted for test.cc (code 2)

Both GCC 4.9.x and later and Clang 3.7 accept this code. See also: question on Stack Overflow.


Viewing all articles
Browse latest Browse all 2797


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>