go to start Sol W9
|home |print view |recent changes |changed April 19, 2017 |
exact
|You are 54.81.59.211 <- set your identity!

Sections: SFINAE for Feature Detection |

SFINAE for Feature Detection ^

Alias Template has_ostream_shift_t:

template<typename T>
using has_ostream_shift_t = decltype(std::declval<std::ostream&>() << std::declval<T>());

Alias Template is_outputtable:

template<typename T>
using is_outputtable = detect<T, has_ostream_shift_t>;

Function Template printer:

template<typename T, typename = std::enable_if_t<is_outputtable<T>{}>>
void printer(std::ostream & out, T const &t) {
	out << t << '\n';
}

template<typename T, typename = std::enable_if_t<not is_outputtable<T>{}>>
void printer(std::ostream & out, T const &t, std::enable_if_t<not is_outputtable<T>::value>* = nullptr) {
	out << "cannot print " << boost::typeindex::type_id<T>().pretty_name() << '\n';
}


|home |print view |recent changes |changed April 19, 2017 |
exact
|You are 54.81.59.211 <- set your identity!

Sol W9
go to start