MCPcopy Create free account
hub / github.com/boostorg/hana / optionalToString

Function optionalToString

example/tutorial/introspection.sfinae.cpp:17–23  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15//! [optionalToString.sfinae]
16template <typename T>
17std::string optionalToString(T const& obj) {
18 auto maybe_toString = hana::sfinae([](auto&& x) -> decltype(x.toString()) {
19 return x.toString();
20 });
21
22 return maybe_toString(obj).value_or("toString not defined");
23}
24//! [optionalToString.sfinae]
25
26int main() {

Callers 1

mainFunction · 0.70

Calls 1

toStringMethod · 0.45

Tested by

no test coverage detected