Community
cancel
Showing results for 
Search instead for 
Did you mean: 
John_S_20
Beginner
89 Views

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).

[cpp]

#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);
//   ^


[/cpp]

0 Kudos
1 Reply
Judith_W_Intel
Employee
89 Views

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
Reply