Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
is_convertible
//clang 3.8.0 #include <iostream> #include <type_traits> #include <utility> template<typename...> struct or_; template<> struct or_<> : public std::false_type { }; template<typename _B1> struct or_<_B1> : public _B1 { }; template<typename _B1, typename _B2> struct or_<_B1, _B2> : public std::conditional<_B1::value, _B1, _B2>::type { }; template<typename _B1, typename _B2, typename _B3> struct or_<_B1, _B2, _B3> : public std::conditional<_B1::value, _B1, or_<_B2, _B3>>::type { }; typedef char (& yes_type)[2]; typedef char (& no_type )[1]; template <typename U> U& declval(); namespace detail { template <typename Tp1, typename Tp2> struct is_convertible_helper { private: template <typename U> static yes_type is_convertible_check(U const &); template <typename U> static no_type is_convertible_check(...); public: enum { value = sizeof( is_convertible_check<Tp2>(declval<Tp1>()) ) - 1 }; }; template <typename Tp> struct is_convertible_helper<Tp, Tp> { public: enum { value = 1 }; }; } // detail template <typename Tp1, typename Tp2> struct is_convertible : std::integral_constant<bool, detail::is_convertible_helper<Tp1, Tp2>::value> { }; class C { C() = default; }; int main() { std::cout << is_convertible<C, C>::value; }
run
|
edit
|
history
|
help
0
LOOL
non-template template parameters for container stream insertion: SFINAE
Variable declarations in while loop conditions are also C++-only.
Initialise arrays with N number
Access namespace by unqualified manner
Throttle Example (Send two requests every two seconds)
C++ Register
Optional conversions
test
test C++ register