#include <iostream>
#include <type_traits>
int main()
{
enum { X = 78 }; // X has a distinct (unnamed) type
enum { Y = 79 }; // Y has a distinct (unnamed) type
// X and Y are of two different types
std::cout << "X and Y are of the same type? " << std::boolalpha
<< std::is_same< decltype(X), decltype(Y) >::value << '\n' ; // false
constauto ex = X ;
auto ey = Y ;
// ey = ex ; // *** error: ex and ey are of different types with no implicit conversion between them
// ey = int(ex) ; // *** error: no implicit conversion from int to type of ey
// ey = 7 ; // *** error: no implicit conversion from int to type of ey
using type_of_y = decltype(Y) ;
ey = type_of_y(ex) ; // fine: explicit conversion with a cast
ey = type_of_y(7) ; // fine: explicit conversion with a cast
std::cout << ey << ' ' << (X==Y) << '\n' ; // fine: implicit conversion to the underlying type 'int'
// g++: ** warning: (X==Y) comparison between unrelated enum types
}