Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make type_traits usable as a module. #169

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions include/boost/type_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@
#include <boost/type_traits/is_assignable.hpp>
#include <boost/type_traits/is_base_and_derived.hpp>
#include <boost/type_traits/is_base_of.hpp>
#include <boost/type_traits/is_bounded_array.hpp>
#include <boost/type_traits/is_unbounded_array.hpp>
#include <boost/type_traits/is_class.hpp>
#include <boost/type_traits/is_complex.hpp>
#include <boost/type_traits/is_compound.hpp>
Expand Down Expand Up @@ -160,4 +162,12 @@
#include <boost/type_traits/promote.hpp>
#endif

#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_SFINAE_EXPR)
#include <boost/type_traits/detected.hpp>
#include <boost/type_traits/is_detected.hpp>
#include <boost/type_traits/is_detected_convertible.hpp>
#include <boost/type_traits/is_detected_exact.hpp>
#include <boost/type_traits/detected_or.hpp>
#endif

#endif // BOOST_TYPE_TRAITS_HPP
6 changes: 3 additions & 3 deletions include/boost/type_traits/add_const.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace boost {
# pragma warning(disable:4181) // warning C4181: qualifier applied to reference type ignored
#endif

template <class T> struct add_const
BOOST_TYPE_TRAITS_MODULE_EXPORT template <class T> struct add_const
{
typedef T const type;
};
Expand All @@ -36,14 +36,14 @@ namespace boost {
# pragma warning(pop)
#endif

template <class T> struct add_const<T&>
BOOST_TYPE_TRAITS_MODULE_EXPORT template <class T> struct add_const<T&>
{
typedef T& type;
};

#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)

template <class T> using add_const_t = typename add_const<T>::type;
BOOST_TYPE_TRAITS_MODULE_EXPORT template <class T> using add_const_t = typename add_const<T>::type;

#endif

Expand Down
8 changes: 4 additions & 4 deletions include/boost/type_traits/add_cv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#ifndef BOOST_TT_ADD_CV_HPP_INCLUDED
#define BOOST_TT_ADD_CV_HPP_INCLUDED

#include <boost/config.hpp>
#include <boost/type_traits/detail/config.hpp>

namespace boost {

Expand All @@ -28,17 +28,17 @@ namespace boost {
# pragma warning(disable:4181) // warning C4181: qualifier applied to reference type ignored
#endif

template <class T> struct add_cv{ typedef T const volatile type; };
BOOST_TYPE_TRAITS_MODULE_EXPORT template <class T> struct add_cv{ typedef T const volatile type; };

#if defined(BOOST_MSVC)
# pragma warning(pop)
#endif

template <class T> struct add_cv<T&>{ typedef T& type; };
BOOST_TYPE_TRAITS_MODULE_EXPORT template <class T> struct add_cv<T&>{ typedef T& type; };

#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)

template <class T> using add_cv_t = typename add_cv<T>::type;
BOOST_TYPE_TRAITS_MODULE_EXPORT template <class T> using add_cv_t = typename add_cv<T>::type;

#endif

Expand Down
6 changes: 3 additions & 3 deletions include/boost/type_traits/add_lvalue_reference.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@

namespace boost{

template <class T> struct add_lvalue_reference
BOOST_TYPE_TRAITS_MODULE_EXPORT template <class T> struct add_lvalue_reference
{
typedef typename boost::add_reference<T>::type type;
};

#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
template <class T> struct add_lvalue_reference<T&&>
BOOST_TYPE_TRAITS_MODULE_EXPORT template <class T> struct add_lvalue_reference<T&&>
{
typedef T& type;
};
#endif

#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)

template <class T> using add_lvalue_reference_t = typename add_lvalue_reference<T>::type;
BOOST_TYPE_TRAITS_MODULE_EXPORT template <class T> using add_lvalue_reference_t = typename add_lvalue_reference<T>::type;

#endif

Expand Down
4 changes: 2 additions & 2 deletions include/boost/type_traits/add_pointer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ struct add_pointer<T&const volatile>

#else

template <typename T>
BOOST_TYPE_TRAITS_MODULE_EXPORT template <typename T>
struct add_pointer
{
typedef typename remove_reference<T>::type no_ref_type;
Expand All @@ -58,7 +58,7 @@ struct add_pointer

#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)

template <class T> using add_pointer_t = typename add_pointer<T>::type;
BOOST_TYPE_TRAITS_MODULE_EXPORT template <class T> using add_pointer_t = typename add_pointer<T>::type;

#endif

Expand Down
21 changes: 10 additions & 11 deletions include/boost/type_traits/add_reference.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
#ifndef BOOST_TT_ADD_REFERENCE_HPP_INCLUDED
#define BOOST_TT_ADD_REFERENCE_HPP_INCLUDED

#include <boost/detail/workaround.hpp>
#include <boost/config.hpp>
#include <boost/type_traits/detail/config.hpp>

namespace boost {

Expand All @@ -21,14 +20,14 @@ namespace detail {
// references or we get ambiguities from msvc:
//

template <typename T>
BOOST_TYPE_TRAITS_MODULE_EXPORT template <typename T>
struct add_reference_impl
{
typedef T& type;
};

#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
template <typename T>
BOOST_TYPE_TRAITS_MODULE_EXPORT template <typename T>
struct add_reference_impl<T&&>
{
typedef T&& type;
Expand All @@ -37,26 +36,26 @@ struct add_reference_impl<T&&>

} // namespace detail

template <class T> struct add_reference
BOOST_TYPE_TRAITS_MODULE_EXPORT template <class T> struct add_reference
{
typedef typename boost::detail::add_reference_impl<T>::type type;
};
template <class T> struct add_reference<T&>
BOOST_TYPE_TRAITS_MODULE_EXPORT template <class T> struct add_reference<T&>
{
typedef T& type;
};

// these full specialisations are always required:
template <> struct add_reference<void> { typedef void type; };
BOOST_TYPE_TRAITS_MODULE_EXPORT template <> struct add_reference<void> { typedef void type; };
#ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS
template <> struct add_reference<const void> { typedef const void type; };
template <> struct add_reference<const volatile void> { typedef const volatile void type; };
template <> struct add_reference<volatile void> { typedef volatile void type; };
BOOST_TYPE_TRAITS_MODULE_EXPORT template <> struct add_reference<const void> { typedef const void type; };
BOOST_TYPE_TRAITS_MODULE_EXPORT template <> struct add_reference<const volatile void> { typedef const volatile void type; };
BOOST_TYPE_TRAITS_MODULE_EXPORT template <> struct add_reference<volatile void> { typedef volatile void type; };
#endif

#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)

template <class T> using add_reference_t = typename add_reference<T>::type;
BOOST_TYPE_TRAITS_MODULE_EXPORT template <class T> using add_reference_t = typename add_reference<T>::type;

#endif

Expand Down
6 changes: 3 additions & 3 deletions include/boost/type_traits/add_rvalue_reference.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#ifndef BOOST_TYPE_TRAITS_EXT_ADD_RVALUE_REFERENCE__HPP
#define BOOST_TYPE_TRAITS_EXT_ADD_RVALUE_REFERENCE__HPP

#include <boost/config.hpp>
#include <boost/type_traits/detail/config.hpp>

//----------------------------------------------------------------------------//

Expand Down Expand Up @@ -53,14 +53,14 @@ namespace type_traits_detail {

}

template <class T> struct add_rvalue_reference
BOOST_TYPE_TRAITS_MODULE_EXPORT template <class T> struct add_rvalue_reference
{
typedef typename boost::type_traits_detail::add_rvalue_reference_imp<T>::type type;
};

#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)

template <class T> using add_rvalue_reference_t = typename add_rvalue_reference<T>::type;
BOOST_TYPE_TRAITS_MODULE_EXPORT template <class T> using add_rvalue_reference_t = typename add_rvalue_reference<T>::type;

#endif

Expand Down
8 changes: 4 additions & 4 deletions include/boost/type_traits/add_volatile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#ifndef BOOST_TT_ADD_VOLATILE_HPP_INCLUDED
#define BOOST_TT_ADD_VOLATILE_HPP_INCLUDED

#include <boost/config.hpp>
#include <boost/type_traits/detail/config.hpp>

namespace boost {

Expand All @@ -27,17 +27,17 @@ namespace boost {
# pragma warning(disable:4181) // warning C4181: qualifier applied to reference type ignored
#endif

template <class T> struct add_volatile{ typedef T volatile type; };
BOOST_TYPE_TRAITS_MODULE_EXPORT template <class T> struct add_volatile{ typedef T volatile type; };

#if defined(BOOST_MSVC)
# pragma warning(pop)
#endif

template <class T> struct add_volatile<T&>{ typedef T& type; };
BOOST_TYPE_TRAITS_MODULE_EXPORT template <class T> struct add_volatile<T&>{ typedef T& type; };

#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)

template <class T> using add_volatile_t = typename add_volatile<T>::type;
BOOST_TYPE_TRAITS_MODULE_EXPORT template <class T> using add_volatile_t = typename add_volatile<T>::type;

#endif

Expand Down
16 changes: 6 additions & 10 deletions include/boost/type_traits/aligned_storage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
#ifndef BOOST_TT_ALIGNED_STORAGE_HPP
#define BOOST_TT_ALIGNED_STORAGE_HPP

#ifndef BOOST_TYPE_TRAITS_AS_MODULE
#include <cstddef> // for std::size_t
#endif

#include <boost/config.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/type_traits/detail/config.hpp>
#include <boost/type_traits/alignment_of.hpp>
#include <boost/type_traits/type_with_alignment.hpp>
#include <boost/type_traits/is_pod.hpp>
Expand All @@ -26,11 +27,6 @@ namespace boost {

namespace detail { namespace aligned_storage {

BOOST_STATIC_CONSTANT(
std::size_t
, alignment_of_max_align = ::boost::alignment_of<boost::detail::max_align>::value
);

//
// To be TR1 conforming this must be a POD type:
//
Expand Down Expand Up @@ -68,7 +64,7 @@ struct aligned_storage_imp<0u,alignment_>

}} // namespace detail::aligned_storage

template <
BOOST_TYPE_TRAITS_MODULE_EXPORT template <
std::size_t size_
, std::size_t alignment_ = std::size_t(-1)
>
Expand All @@ -93,7 +89,7 @@ class aligned_storage :
std::size_t
, alignment = (
alignment_ == std::size_t(-1)
? ::boost::detail::aligned_storage::alignment_of_max_align
? ::boost::alignment_of<boost::detail::max_align>::value
: alignment_
)
);
Expand Down Expand Up @@ -130,7 +126,7 @@ class aligned_storage :
// Make sure that is_pod recognises aligned_storage<>::type
// as a POD (Note that aligned_storage<> itself is not a POD):
//
template <std::size_t size_, std::size_t alignment_>
BOOST_TYPE_TRAITS_MODULE_EXPORT template <std::size_t size_, std::size_t alignment_>
struct is_pod< ::boost::detail::aligned_storage::aligned_storage_imp<size_, alignment_> > : public true_type{};

} // namespace boost
Expand Down
20 changes: 11 additions & 9 deletions include/boost/type_traits/alignment_of.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
#ifndef BOOST_TT_ALIGNMENT_OF_HPP_INCLUDED
#define BOOST_TT_ALIGNMENT_OF_HPP_INCLUDED

#include <boost/config.hpp>
#ifndef BOOST_TYPE_TRAITS_AS_MODULE
#include <cstddef>
#endif

#include <boost/type_traits/detail/config.hpp>
#include <boost/type_traits/intrinsics.hpp>
#include <boost/type_traits/integral_constant.hpp>

Expand All @@ -25,7 +27,7 @@

namespace boost {

template <typename T> struct alignment_of;
BOOST_TYPE_TRAITS_MODULE_EXPORT template <typename T> struct alignment_of;

// get the alignment of some arbitrary type:
namespace detail {
Expand Down Expand Up @@ -85,25 +87,25 @@ struct alignment_of_impl

} // namespace detail

template <class T> struct alignment_of : public integral_constant<std::size_t, ::boost::detail::alignment_of_impl<T>::value>{};
BOOST_TYPE_TRAITS_MODULE_EXPORT template <class T> struct alignment_of : public integral_constant<std::size_t, ::boost::detail::alignment_of_impl<T>::value>{};

// references have to be treated specially, assume
// that a reference is just a special pointer:
template <typename T> struct alignment_of<T&> : public alignment_of<T*>{};
BOOST_TYPE_TRAITS_MODULE_EXPORT template <typename T> struct alignment_of<T&> : public alignment_of<T*>{};

#ifdef BOOST_BORLANDC
// long double gives an incorrect value of 10 (!)
// unless we do this...
struct long_double_wrapper{ long double ld; };
template<> struct alignment_of<long double> : public alignment_of<long_double_wrapper>{};
BOOST_TYPE_TRAITS_MODULE_EXPORT template<> struct alignment_of<long double> : public alignment_of<long_double_wrapper>{};
#endif

// void has to be treated specially:
template<> struct alignment_of<void> : integral_constant<std::size_t, 0>{};
BOOST_TYPE_TRAITS_MODULE_EXPORT template<> struct alignment_of<void> : integral_constant<std::size_t, 0>{};
#ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS
template<> struct alignment_of<void const> : integral_constant<std::size_t, 0>{};
template<> struct alignment_of<void const volatile> : integral_constant<std::size_t, 0>{};
template<> struct alignment_of<void volatile> : integral_constant<std::size_t, 0>{};
BOOST_TYPE_TRAITS_MODULE_EXPORT template<> struct alignment_of<void const> : integral_constant<std::size_t, 0>{};
BOOST_TYPE_TRAITS_MODULE_EXPORT template<> struct alignment_of<void const volatile> : integral_constant<std::size_t, 0>{};
BOOST_TYPE_TRAITS_MODULE_EXPORT template<> struct alignment_of<void volatile> : integral_constant<std::size_t, 0>{};
#endif

} // namespace boost
Expand Down
Loading