fork download
#include <iostream>
#include <type_traits>

template<typename T>
typename std::enable_if<!std::is_const<T>::value>::type f(T& arg)
{
    std::cout << arg << ':' << __PRETTY_FUNCTION__ << std::endl;
}


int main()
{
    int x=0;
    const int y=1;
    f(x);
    f(y); // errror. no matching function
    return 0;
}
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:16:8: error: no matching function for call to ‘f(const int&)’
     f(y); // errror. no matching function
        ^
prog.cpp:16:8: note: candidate is:
prog.cpp:5:57: note: template<class T> typename std::enable_if<(! std::is_const< <template-parameter-1-1> >::value)>::type f(T&)
 typename std::enable_if<!std::is_const<T>::value>::type f(T& arg)
                                                         ^
prog.cpp:5:57: note:   template argument deduction/substitution failed:
prog.cpp: In substitution of ‘template<class T> typename std::enable_if<(! std::is_const< <template-parameter-1-1> >::value)>::type f(T&) [with T = const int]’:
prog.cpp:16:8:   required from here
prog.cpp:5:57: error: no type named ‘type’ in ‘struct std::enable_if<false, void>’
stdout
Standard output is empty