Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template< typename from, typename to >
- struct copy_cv_reference
- {
- using type = to;
- };
- template< typename from, typename to >
- struct copy_cv_reference< from const, to >
- : copy_cv_reference< from, to const >
- {
- };
- template< typename from, typename to >
- struct copy_cv_reference< volatile from, to >
- : copy_cv_reference< from, volatile to >
- {
- };
- template< typename from, typename to >
- struct copy_cv_reference< from const, to & >
- : copy_cv_reference< from, to const & >
- {
- };
- template< typename from, typename to >
- struct copy_cv_reference< volatile from, to & >
- : copy_cv_reference< from, volatile to & >
- {
- };
- template< typename from, typename to >
- struct copy_cv_reference< from const, to && >
- : copy_cv_reference< from, to const && >
- {
- };
- template< typename from, typename to >
- struct copy_cv_reference< volatile from, to && >
- : copy_cv_reference< from, volatile to && >
- {
- };
- template< typename from, typename to >
- struct copy_cv_reference< from &, to >
- : copy_cv_reference< from, to & >
- {
- };
- template< typename from, typename to >
- struct copy_cv_reference< from &&, to >
- : copy_cv_reference< from, to && >
- {
- };
- namespace test
- {
- struct A {};
- struct B {};
- static_assert((std::is_same< copy_cv_reference< volatile const A &, B >::type, volatile const B & >{}), "");
- static_assert((std::is_same< copy_cv_reference< const A &, B >::type, const B & >{}), "");
- static_assert((std::is_same< copy_cv_reference< volatile A &, B >::type, volatile B & >{}), "");
- static_assert((std::is_same< copy_cv_reference< A &, B >::type, B & >{}), "");
- static_assert((std::is_same< copy_cv_reference< volatile const A &, B >::type, volatile const B & >{}), "");
- static_assert((std::is_same< copy_cv_reference< const A &&, B >::type, const B && >{}), "");
- static_assert((std::is_same< copy_cv_reference< volatile A &&, B >::type, volatile B && >{}), "");
- static_assert((std::is_same< copy_cv_reference< A &&, B >::type, B && >{}), "");
- static_assert((std::is_same< copy_cv_reference< volatile const A, B >::type, volatile const B >{}), "");
- static_assert((std::is_same< copy_cv_reference< const A, B >::type, const B >{}), "");
- static_assert((std::is_same< copy_cv_reference< volatile A, B >::type, volatile B >{}), "");
- static_assert((std::is_same< copy_cv_reference< A, B >::type, B >{}), "");
- }
Advertisement
Add Comment
Please, Sign In to add comment