Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. #include <type_traits>
  2.  
  3. template<typename T, typename U = void>
  4. struct is_defined {
  5. static constexpr const bool value = false;
  6. };
  7.  
  8. template<typename T>
  9. struct is_defined<T, std::enable_if_t<sizeof(T)>>{
  10. static constexpr const bool value = true;
  11. };
  12.  
  13. template<typename T, typename U>
  14. using choose = std::conditional<is_defined<T>::value, T, U>;
  15.  
  16. int main(){
  17. choose<char*, void*>::type i;
  18. i = 9;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement