std::underlying_type fails in SFINAE situation when it shouldn't

std::underlying_type fails in SFINAE situation when it shouldn't

I can't login to Premier Support, so... Could someone file a bug report about this for me? The following code works when compiled with Visual Studio 2012 (v.11.0), but it fails with Intel C++ Composer XE 2013 (v.13.0.089).

#include <type_traits>

enum Fruit { apple, orange };

template <typename T>
    typename std::enable_if< std::is_enum<T>::value,
typename std::underlying_type<T>::type& >::type underlying(T& enumValue)
{
    return reinterpret_cast< std::underlying_type<T>::type& >(enumValue);
}

int main()
{
    static_assert(std::is_enum<Fruit>::value, "");
    
    Fruit fruit;
    ++underlying(fruit);
    
    return 0;
}

// error : no instance of function template "underlying" matches the argument list
// argument types are: (Fruit)
// ++underlying(fruit);
//   ^

2 post / 0 nuovi
Ultimo contenuto
Per informazioni complete sulle ottimizzazioni del compilatore, consultare l'Avviso sull'ottimizzazione

Thank you for the small example. I have entered DPD200236148 in our internal bug database for this defect.
It seems to be a problem when using the underlying_type type trait with a dependent type.

We will fix this as soon as possible.

Judy

Accedere per lasciare un commento.