Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template<class T>
- constexpr auto supportsAPI(T x) -> decltype(x.Method1(), x.Method2(), true_type{}) {
- return {};
- }
- constexpr auto supportsAPI(...) -> false_type {
- return {};
- }
- template<class T>
- auto compute(T x) -> decltype( enable_if_t< supportsAPI(T{}), int>{}) {
- return x.Method();
- }
- template<class T>
- auto compute(T x) -> decltype( enable_if_t<!supportsAPI(T{}), int>{}) {
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement