Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <type_traits>
- template<typename T, typename U = void>
- struct is_defined {
- static constexpr const bool value = false;
- };
- template<typename T>
- struct is_defined<T, std::enable_if_t<sizeof(T)>>{
- static constexpr const bool value = true;
- };
- template<typename T, typename U>
- using choose = std::conditional<is_defined<T>::value, T, U>;
- int main(){
- choose<char*, void*>::type i;
- i = 9;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement