Skip to content

Instantly share code, notes, and snippets.

@stryku
Last active July 12, 2017 20:58
Show Gist options
  • Select an option

  • Save stryku/8216cf23bfaa67beaffadff0f1dd4923 to your computer and use it in GitHub Desktop.

Select an option

Save stryku/8216cf23bfaa67beaffadff0f1dd4923 to your computer and use it in GitHub Desktop.
//big credits to this guy, for a hints: https://stackoverflow.com/a/16824239/4175394
template <typename Type>
struct HasToString {
private:
template<typename T>
static constexpr auto check(T*) -> typename std::is_same<
decltype(std::declval<T>().toString()),
std::string
>::type;
template<typename>
static constexpr std::false_type check(...);
using type = decltype(check<Type>(nullptr));
public:
static constexpr bool value = type::value;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment