Merge pull request #34 from boostorg/feature/remove_cv_ref

Add remove_cv_ref
This commit is contained in:
jzmaddock
2017-05-21 10:52:29 +01:00
committed by GitHub
5 changed files with 221 additions and 0 deletions

44
doc/remove_cv_ref.qbk Normal file
View File

@ -0,0 +1,44 @@
[/
Copyright 2007 John Maddock.
Copyright 2017 Peter Dimov.
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt).
]
[section:remove_cv_ref remove_cv_ref]
template <class T>
struct remove_cv_ref
{
typedef __below type;
};
template <class T> using remove_cv_ref_t = typename remove_cv_ref<T>::type; // C++11 and above
__type The same type as `T`, but with any reference modifiers and /top level/ cv-qualifiers removed.
__std_ref 3.9.3, 8.3.2.
[all_compilers]
__header ` #include <boost/type_traits/remove_cv_ref.hpp>` or ` #include <boost/type_traits.hpp>`
[table Examples
[ [Expression] [Result Type]]
[[`remove_cv_ref<int>::type`][`int`]]
[[`remove_cv_ref<int const>::type`] [`int`]]
[[`remove_cv_ref<int const volatile>::type`] [`int`]]
[[`remove_cv_ref<int const&>::type`] [`int`]]
[[`remove_cv_ref<int const*>::type`] [`int const*`]]
]
[endsect]

View File

@ -109,6 +109,7 @@
[def __remove_const [link boost_typetraits.reference.remove_const remove_const]]
[def __remove_volatile [link boost_typetraits.reference.remove_volatile remove_volatile]]
[def __remove_cv [link boost_typetraits.reference.remove_cv remove_cv]]
[def __remove_cv_ref [link boost_typetraits.reference.remove_cv_ref remove_cv_ref]]
[def __remove_reference [link boost_typetraits.reference.remove_reference remove_reference]]
[def __remove_extent [link boost_typetraits.reference.remove_extent remove_extent]]
[def __remove_all_extents [link boost_typetraits.reference.remove_all_extents remove_all_extents]]
@ -325,6 +326,7 @@ See __has_trivial_constructor.
[include remove_all_extents.qbk]
[include remove_const.qbk]
[include remove_cv.qbk]
[include remove_cv_ref.qbk]
[include remove_extent.qbk]
[include remove_pointer.qbk]
[include remove_reference.qbk]

View File

@ -136,6 +136,7 @@
#include <boost/type_traits/remove_bounds.hpp>
#include <boost/type_traits/remove_const.hpp>
#include <boost/type_traits/remove_cv.hpp>
#include <boost/type_traits/remove_cv_ref.hpp>
#include <boost/type_traits/remove_extent.hpp>
#include <boost/type_traits/remove_pointer.hpp>
#include <boost/type_traits/remove_reference.hpp>

View File

@ -0,0 +1,30 @@
// (C) Copyright Peter Dimov 2017.
// Use, modification and distribution are subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt).
//
// See http://www.boost.org/libs/type_traits for most recent version including documentation.
#ifndef BOOST_TT_REMOVE_CV_REF_HPP_INCLUDED
#define BOOST_TT_REMOVE_CV_REF_HPP_INCLUDED
#include <boost/config.hpp>
#include <boost/type_traits/remove_cv.hpp>
#include <boost/type_traits/remove_reference.hpp>
namespace boost {
template <class T> struct remove_cv_ref: remove_cv<typename remove_reference<T>::type> {};
#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
template <class T> using remove_cv_ref_t = typename remove_cv_ref<T>::type;
#endif
} // namespace boost
#endif // BOOST_TT_REMOVE_CV_REF_HPP_INCLUDED

144
test/remove_cv_ref_test.cpp Normal file
View File

@ -0,0 +1,144 @@
// (C) Copyright John Maddock 2000.
// (C) Copyright Peter Dimov 2017.
// Use, modification and distribution are subject to the
// Boost Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.tt.org/LICENSE_1_0.txt)
#include "test.hpp"
#include "check_type.hpp"
#ifdef TEST_STD
# include <type_traits>
#else
# include <boost/type_traits/remove_cv_ref.hpp>
#endif
BOOST_DECL_TRANSFORM_TEST3(remove_cv_ref_test_1, ::tt::remove_cv_ref, const)
BOOST_DECL_TRANSFORM_TEST3(remove_cv_ref_test_2, ::tt::remove_cv_ref, volatile)
BOOST_DECL_TRANSFORM_TEST3(remove_cv_ref_test_3, ::tt::remove_cv_ref, const volatile)
BOOST_DECL_TRANSFORM_TEST0(remove_cv_ref_test_4, ::tt::remove_cv_ref)
BOOST_DECL_TRANSFORM_TEST3(remove_cv_ref_test_5, ::tt::remove_cv_ref, const &)
BOOST_DECL_TRANSFORM_TEST3(remove_cv_ref_test_6, ::tt::remove_cv_ref, volatile &)
BOOST_DECL_TRANSFORM_TEST3(remove_cv_ref_test_7, ::tt::remove_cv_ref, const volatile &)
BOOST_DECL_TRANSFORM_TEST3(remove_cv_ref_test_8, ::tt::remove_cv_ref, &)
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
BOOST_DECL_TRANSFORM_TEST3(remove_cv_ref_test_9, ::tt::remove_cv_ref, const &&)
BOOST_DECL_TRANSFORM_TEST3(remove_cv_ref_test_10, ::tt::remove_cv_ref, volatile &&)
BOOST_DECL_TRANSFORM_TEST3(remove_cv_ref_test_11, ::tt::remove_cv_ref, const volatile &&)
BOOST_DECL_TRANSFORM_TEST3(remove_cv_ref_test_12, ::tt::remove_cv_ref, &&)
#endif
BOOST_DECL_TRANSFORM_TEST(remove_cv_ref_test_13, ::tt::remove_cv_ref, *const, *)
BOOST_DECL_TRANSFORM_TEST(remove_cv_ref_test_14, ::tt::remove_cv_ref, *volatile, *)
BOOST_DECL_TRANSFORM_TEST(remove_cv_ref_test_15, ::tt::remove_cv_ref, *const volatile, *)
BOOST_DECL_TRANSFORM_TEST(remove_cv_ref_test_16, ::tt::remove_cv_ref, *, *)
BOOST_DECL_TRANSFORM_TEST(remove_cv_ref_test_17, ::tt::remove_cv_ref, *const &, *)
BOOST_DECL_TRANSFORM_TEST(remove_cv_ref_test_18, ::tt::remove_cv_ref, *volatile &, *)
BOOST_DECL_TRANSFORM_TEST(remove_cv_ref_test_19, ::tt::remove_cv_ref, *const volatile &, *)
BOOST_DECL_TRANSFORM_TEST(remove_cv_ref_test_20, ::tt::remove_cv_ref, * &, *)
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
BOOST_DECL_TRANSFORM_TEST(remove_cv_ref_test_21, ::tt::remove_cv_ref, *const &&, *)
BOOST_DECL_TRANSFORM_TEST(remove_cv_ref_test_22, ::tt::remove_cv_ref, *volatile &&, *)
BOOST_DECL_TRANSFORM_TEST(remove_cv_ref_test_23, ::tt::remove_cv_ref, *const volatile &&, *)
BOOST_DECL_TRANSFORM_TEST(remove_cv_ref_test_24, ::tt::remove_cv_ref, * &&, *)
#endif
BOOST_DECL_TRANSFORM_TEST(remove_cv_ref_test_25, ::tt::remove_cv_ref, const*, const*)
BOOST_DECL_TRANSFORM_TEST(remove_cv_ref_test_26, ::tt::remove_cv_ref, volatile*, volatile*)
BOOST_DECL_TRANSFORM_TEST(remove_cv_ref_test_27, ::tt::remove_cv_ref, const*const, const*)
BOOST_DECL_TRANSFORM_TEST(remove_cv_ref_test_28, ::tt::remove_cv_ref, const*volatile, const*)
BOOST_DECL_TRANSFORM_TEST(remove_cv_ref_test_29, ::tt::remove_cv_ref, const* &, const*)
BOOST_DECL_TRANSFORM_TEST(remove_cv_ref_test_30, ::tt::remove_cv_ref, volatile* &, volatile*)
BOOST_DECL_TRANSFORM_TEST(remove_cv_ref_test_31, ::tt::remove_cv_ref, const*const &, const*)
BOOST_DECL_TRANSFORM_TEST(remove_cv_ref_test_32, ::tt::remove_cv_ref, const*volatile &, const*)
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
BOOST_DECL_TRANSFORM_TEST(remove_cv_ref_test_33, ::tt::remove_cv_ref, const* &&, const*)
BOOST_DECL_TRANSFORM_TEST(remove_cv_ref_test_34, ::tt::remove_cv_ref, volatile* &&, volatile*)
BOOST_DECL_TRANSFORM_TEST(remove_cv_ref_test_35, ::tt::remove_cv_ref, const*const &&, const*)
BOOST_DECL_TRANSFORM_TEST(remove_cv_ref_test_36, ::tt::remove_cv_ref, const*volatile &&, const*)
#endif
BOOST_DECL_TRANSFORM_TEST(remove_cv_ref_test_37, ::tt::remove_cv_ref, const[2], [2])
BOOST_DECL_TRANSFORM_TEST(remove_cv_ref_test_38, ::tt::remove_cv_ref, volatile[2], [2])
BOOST_DECL_TRANSFORM_TEST(remove_cv_ref_test_39, ::tt::remove_cv_ref, const volatile[2], [2])
BOOST_DECL_TRANSFORM_TEST(remove_cv_ref_test_40, ::tt::remove_cv_ref, [2], [2])
BOOST_DECL_TRANSFORM_TEST(remove_cv_ref_test_41, ::tt::remove_cv_ref, const(&)[2], [2])
BOOST_DECL_TRANSFORM_TEST(remove_cv_ref_test_42, ::tt::remove_cv_ref, volatile(&)[2], [2])
BOOST_DECL_TRANSFORM_TEST(remove_cv_ref_test_43, ::tt::remove_cv_ref, const volatile(&)[2], [2])
BOOST_DECL_TRANSFORM_TEST(remove_cv_ref_test_44, ::tt::remove_cv_ref, (&)[2], [2])
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
BOOST_DECL_TRANSFORM_TEST(remove_cv_ref_test_45, ::tt::remove_cv_ref, const(&&)[2], [2])
BOOST_DECL_TRANSFORM_TEST(remove_cv_ref_test_46, ::tt::remove_cv_ref, volatile(&&)[2], [2])
BOOST_DECL_TRANSFORM_TEST(remove_cv_ref_test_47, ::tt::remove_cv_ref, const volatile(&&)[2], [2])
BOOST_DECL_TRANSFORM_TEST(remove_cv_ref_test_48, ::tt::remove_cv_ref, (&&)[2], [2])
#endif
TT_TEST_BEGIN(remove_cv_ref)
remove_cv_ref_test_1();
remove_cv_ref_test_2();
remove_cv_ref_test_3();
remove_cv_ref_test_4();
remove_cv_ref_test_5();
remove_cv_ref_test_6();
remove_cv_ref_test_7();
remove_cv_ref_test_8();
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
remove_cv_ref_test_9();
remove_cv_ref_test_10();
remove_cv_ref_test_11();
remove_cv_ref_test_12();
#endif
remove_cv_ref_test_13();
remove_cv_ref_test_14();
remove_cv_ref_test_15();
remove_cv_ref_test_16();
remove_cv_ref_test_17();
remove_cv_ref_test_18();
remove_cv_ref_test_19();
remove_cv_ref_test_20();
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
remove_cv_ref_test_21();
remove_cv_ref_test_22();
remove_cv_ref_test_23();
remove_cv_ref_test_24();
#endif
remove_cv_ref_test_25();
remove_cv_ref_test_26();
remove_cv_ref_test_27();
remove_cv_ref_test_28();
remove_cv_ref_test_29();
remove_cv_ref_test_30();
remove_cv_ref_test_31();
remove_cv_ref_test_32();
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
remove_cv_ref_test_33();
remove_cv_ref_test_34();
remove_cv_ref_test_35();
remove_cv_ref_test_36();
#endif
remove_cv_ref_test_37();
remove_cv_ref_test_38();
remove_cv_ref_test_39();
remove_cv_ref_test_40();
remove_cv_ref_test_41();
remove_cv_ref_test_42();
remove_cv_ref_test_43();
remove_cv_ref_test_44();
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
remove_cv_ref_test_45();
remove_cv_ref_test_46();
remove_cv_ref_test_47();
remove_cv_ref_test_48();
#endif
TT_TEST_END