Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <type_traits>
- #include <cstdlib>
- namespace std
- {
- template < typename ... > using void_t = void;
- }
- struct tag
- {
- std::size_t id_;
- };
- template< typename type, typename = void >
- struct is_tagged
- : std::false_type
- {
- };
- template< typename type >
- struct is_tagged< type, std::void_t< decltype(type::tag_) > >
- : std::is_same< decltype(type::tag_), tag >
- {
- };
- struct A {};
- static_assert(!is_tagged< A >{});
- struct B { tag tag_; };
- static_assert(is_tagged< B >{});
- struct C { int tag_; };
- static_assert(!is_tagged< C >{});
- int
- main()
- {
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment