I'm trying to add support for icc on one of my projects, but I have some issues with SFINAE, when there are more than two methods. Here is a bare simple example of the problem:
#include <iostream>
template<std::size_t Selector>
struct impl {
template<bool Enable = true, typename std::enable_if<Selector == 1 && Enable, int>::type = 0>
static void apply(){
std::cout << "First selector" << std::endl;
}
template<bool Enable = true, typename std::enable_if<Selector == 2 && Enable, int>::type = 0>
static void apply(){
std::cout << "Second selector" << std::endl;
}
template<bool Enable = true, typename std::enable_if<Selector == 3 && Enable, int>::type = 0>
static void apply(){
std::cout << "Big selector" << std::endl;
}
};
int main(){
impl<1>::apply();
impl<2>::apply();
impl<3>::apply();
return 0;
}
This works like a charm with g++ and clang++, but fails to compile with icc:
test.cpp(16): error: invalid redeclaration of member function template "void impl<Selector>::apply() [with Selector=1UL]" (declared at line 11)
static void apply(){
^
detected during instantiation of class "impl<Selector> [with Selector=1UL]" at line 22
test.cpp(11): error: invalid redeclaration of member function template "void impl<Selector>::apply() [with Selector=3UL]" (declared at line 6)
static void apply(){
^
detected during instantiation of class "impl<Selector> [with Selector=3UL]" at line 24
compilation aborted for test.cpp (code 2)
Is there a workaround for this with icc ?
Thanks
Aucun commentaire:
Enregistrer un commentaire