Given next working solution:
template<typename T, typename = void>
struct has_value_t : std::false_type { };
template<typename T>
struct has_value_t<T, decltype(T::value, void())> : std::true_type { };
template<typename T>
constexpr bool has_value = has_value_t<T>::value;
Idea was taken from https://stackoverflow.com/a/14523787/3743145
I wonder if there a C++17/20 more laconic way to achieve same effect. Like
template<typename T>
constexpr bool has_value = .....;
Usage:
template<typename T>
enable_if_t<has_value<T>,
std::ostream&> operator<<(std::ostream& os, T const& arg)
{
return os << arg.value;
}