Quantcast
Channel: Intel® C++ Compiler
Viewing all articles
Browse latest Browse all 1616

icpc bug enable_if

$
0
0

Hello,

The following code doesn't compile with icpc 15.0.0.090 Build 20140723, with -std=c++11.

#include <cstdlib>
#include <typeinfo>
#include <iostream>
#include <type_traits>

struct A {
    double** m;
};

struct B {
    double* m;
};

template<class T, typename std::enable_if<std::is_pointer<T>::value>::type* = nullptr>
static inline void foo(T* const& pt) {
    std::cout << "bar 1"<< std::endl;
}
template<class T, typename std::enable_if<!std::is_pointer<T>::value>::type* = nullptr>
static inline void foo(T* const& pt) {
    std::cout << "bar 2"<< std::endl;
}

int main() {
    A a;
    foo(a.m);
    B b;
    foo(b.m);
}

On the other hand, with g++ and clang++, I get the expected output:

bar 1
bar 2

Thank you in advance for looking into this.

 


Viewing all articles
Browse latest Browse all 1616

Trending Articles



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