samedi 1 juillet 2017

why this doesn't work

i wrote simple code.

#include <iostream>
#include <string>
#include <type_traits>

template<typename, typename = void>
struct is_incrementable : std::false_type {};

template<typename T>
struct is_incrementable<T, decltype( ++std::declval<T&>() )> : std::true_type {};

int main()
{
    std::cout << is_incrementable<std::string>::value << std::endl;
    std::cout << is_incrementable<int>::value << std::endl;
}

main output is: 0 0 while i expect: 0 1 what is wrong here?

Aucun commentaire:

Enregistrer un commentaire