Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7939 Discussions

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

John_S_20
Beginner
401 Views

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
401 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
0 Kudos
Reply