summaryrefslogtreecommitdiff
path: root/boost/core
diff options
context:
space:
mode:
Diffstat (limited to 'boost/core')
-rw-r--r--boost/core/addressof.hpp15
-rw-r--r--boost/core/lightweight_test.hpp82
-rw-r--r--boost/core/no_exceptions_support.hpp2
-rw-r--r--boost/core/pointer_traits.hpp258
-rw-r--r--boost/core/ref.hpp4
5 files changed, 353 insertions, 8 deletions
diff --git a/boost/core/addressof.hpp b/boost/core/addressof.hpp
index 0a2b46be77..8ddda8be4a 100644
--- a/boost/core/addressof.hpp
+++ b/boost/core/addressof.hpp
@@ -42,7 +42,7 @@ addressof(T& o) BOOST_NOEXCEPT
} /* boost */
#else
-#include <boost/detail/workaround.hpp>
+#include <boost/config/workaround.hpp>
#include <cstddef>
namespace boost {
@@ -117,7 +117,6 @@ struct address_of<const volatile addressof_null_t> {
} /* detail */
#if defined(BOOST_NO_CXX11_SFINAE_EXPR) || \
- defined(BOOST_NO_CXX11_RVALUE_REFERENCES) || \
defined(BOOST_NO_CXX11_CONSTEXPR) || \
defined(BOOST_NO_CXX11_DECLTYPE)
#define BOOST_CORE_NO_CONSTEXPR_ADDRESSOF
@@ -171,7 +170,7 @@ const T (*addressof(const T (&o)[N]) BOOST_NOEXCEPT)[N]
namespace detail {
template<class T>
-T&& addressof_declval() BOOST_NOEXCEPT;
+T addressof_declval() BOOST_NOEXCEPT;
template<class>
struct addressof_void {
@@ -262,4 +261,14 @@ addressof(T& o) BOOST_NOEXCEPT
} /* boost */
#endif
+#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \
+ !defined(BOOST_NO_CXX11_DELETED_FUNCTIONS)
+namespace boost {
+
+template<class T>
+const T* addressof(const T&&) = delete;
+
+} /* boost */
+#endif
+
#endif
diff --git a/boost/core/lightweight_test.hpp b/boost/core/lightweight_test.hpp
index b580dd2fa6..603e905bb5 100644
--- a/boost/core/lightweight_test.hpp
+++ b/boost/core/lightweight_test.hpp
@@ -19,12 +19,13 @@
// http://www.boost.org/LICENSE_1_0.txt
//
-#include <iterator>
+#include <boost/core/no_exceptions_support.hpp>
#include <boost/assert.hpp>
#include <boost/current_function.hpp>
-#include <boost/core/no_exceptions_support.hpp>
#include <iostream>
+#include <iterator>
#include <cstring>
+#include <cstddef>
// IDE's like Visual Studio perform better if output goes to std::cout or
// some other stream, so allow user to configure output stream:
@@ -113,6 +114,10 @@ inline const void* test_output_impl(unsigned char* v) { return v; }
inline const void* test_output_impl(signed char* v) { return v; }
template<class T> inline const void* test_output_impl(T volatile* v) { return const_cast<T*>(v); }
+#if !defined( BOOST_NO_CXX11_NULLPTR )
+inline const void* test_output_impl(std::nullptr_t v) { return v; }
+#endif
+
template<class T, class U> inline void test_eq_impl( char const * expr1, char const * expr2,
char const * file, int line, char const * function, T const & t, U const & u )
{
@@ -147,6 +152,74 @@ template<class T, class U> inline void test_ne_impl( char const * expr1, char co
}
}
+template<class T, class U> inline void test_lt_impl( char const * expr1, char const * expr2,
+ char const * file, int line, char const * function, T const & t, U const & u )
+{
+ if( t < u )
+ {
+ report_errors_remind();
+ }
+ else
+ {
+ BOOST_LIGHTWEIGHT_TEST_OSTREAM
+ << file << "(" << line << "): test '" << expr1 << " < " << expr2
+ << "' failed in function '" << function << "': "
+ << "'" << test_output_impl(t) << "' >= '" << test_output_impl(u) << "'" << std::endl;
+ ++test_errors();
+ }
+}
+
+template<class T, class U> inline void test_le_impl( char const * expr1, char const * expr2,
+ char const * file, int line, char const * function, T const & t, U const & u )
+{
+ if( t <= u )
+ {
+ report_errors_remind();
+ }
+ else
+ {
+ BOOST_LIGHTWEIGHT_TEST_OSTREAM
+ << file << "(" << line << "): test '" << expr1 << " <= " << expr2
+ << "' failed in function '" << function << "': "
+ << "'" << test_output_impl(t) << "' > '" << test_output_impl(u) << "'" << std::endl;
+ ++test_errors();
+ }
+}
+
+template<class T, class U> inline void test_gt_impl( char const * expr1, char const * expr2,
+ char const * file, int line, char const * function, T const & t, U const & u )
+{
+ if( t > u )
+ {
+ report_errors_remind();
+ }
+ else
+ {
+ BOOST_LIGHTWEIGHT_TEST_OSTREAM
+ << file << "(" << line << "): test '" << expr1 << " > " << expr2
+ << "' failed in function '" << function << "': "
+ << "'" << test_output_impl(t) << "' <= '" << test_output_impl(u) << "'" << std::endl;
+ ++test_errors();
+ }
+}
+
+template<class T, class U> inline void test_ge_impl( char const * expr1, char const * expr2,
+ char const * file, int line, char const * function, T const & t, U const & u )
+{
+ if( t >= u )
+ {
+ report_errors_remind();
+ }
+ else
+ {
+ BOOST_LIGHTWEIGHT_TEST_OSTREAM
+ << file << "(" << line << "): test '" << expr1 << " >= " << expr2
+ << "' failed in function '" << function << "': "
+ << "'" << test_output_impl(t) << "' < '" << test_output_impl(u) << "'" << std::endl;
+ ++test_errors();
+ }
+}
+
inline void test_cstr_eq_impl( char const * expr1, char const * expr2,
char const * file, int line, char const * function, char const * const t, char const * const u )
{
@@ -360,6 +433,11 @@ inline int report_errors()
#define BOOST_TEST_EQ(expr1,expr2) ( ::boost::detail::test_eq_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
#define BOOST_TEST_NE(expr1,expr2) ( ::boost::detail::test_ne_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
+#define BOOST_TEST_LT(expr1,expr2) ( ::boost::detail::test_lt_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
+#define BOOST_TEST_LE(expr1,expr2) ( ::boost::detail::test_le_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
+#define BOOST_TEST_GT(expr1,expr2) ( ::boost::detail::test_gt_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
+#define BOOST_TEST_GE(expr1,expr2) ( ::boost::detail::test_ge_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
+
#define BOOST_TEST_CSTR_EQ(expr1,expr2) ( ::boost::detail::test_cstr_eq_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
#define BOOST_TEST_CSTR_NE(expr1,expr2) ( ::boost::detail::test_cstr_ne_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
diff --git a/boost/core/no_exceptions_support.hpp b/boost/core/no_exceptions_support.hpp
index a697f01a52..e2453d084b 100644
--- a/boost/core/no_exceptions_support.hpp
+++ b/boost/core/no_exceptions_support.hpp
@@ -21,7 +21,7 @@
//----------------------------------------------------------------------
#include <boost/config.hpp>
-#include <boost/detail/workaround.hpp>
+#include <boost/config/workaround.hpp>
#if !(defined BOOST_NO_EXCEPTIONS)
# define BOOST_TRY { try
diff --git a/boost/core/pointer_traits.hpp b/boost/core/pointer_traits.hpp
new file mode 100644
index 0000000000..ff1a5321db
--- /dev/null
+++ b/boost/core/pointer_traits.hpp
@@ -0,0 +1,258 @@
+/*
+Copyright 2017 Glen Joseph Fernandes
+(glenjofe@gmail.com)
+
+Distributed under the Boost Software License, Version 1.0.
+(http://www.boost.org/LICENSE_1_0.txt)
+*/
+#ifndef BOOST_CORE_POINTER_TRAITS_HPP
+#define BOOST_CORE_POINTER_TRAITS_HPP
+
+#include <boost/config.hpp>
+#if !defined(BOOST_NO_CXX11_POINTER_TRAITS)
+#include <memory>
+#else
+#include <boost/core/addressof.hpp>
+#endif
+
+namespace boost {
+
+template<class T>
+struct pointer_traits;
+
+namespace detail {
+
+template<class U>
+inline typename boost::pointer_traits<U>::element_type*
+ptr_traits_address(const U& v) BOOST_NOEXCEPT
+{
+ return boost::pointer_traits<U>::to_address(v);
+}
+
+} /* detail */
+
+#if !defined(BOOST_NO_CXX11_POINTER_TRAITS)
+template<class T>
+struct pointer_traits
+ : std::pointer_traits<T> {
+ template<class U>
+ struct rebind_to {
+ typedef typename std::pointer_traits<T>::template rebind<U> type;
+ };
+ static typename std::pointer_traits<T>::element_type*
+ to_address(const T& v) BOOST_NOEXCEPT {
+ return detail::ptr_traits_address(v.operator->());
+ }
+};
+
+template<class T>
+struct pointer_traits<T*>
+ : std::pointer_traits<T*> {
+ template<class U>
+ struct rebind_to {
+ typedef U* type;
+ };
+ static T* to_address(T* v) BOOST_NOEXCEPT {
+ return v;
+ }
+};
+#else
+namespace detail {
+
+struct ptr_traits_none { char first, second; };
+
+template<class T>
+struct ptr_traits_has_element {
+private:
+ template<class U>
+ static ptr_traits_none call(...);
+ template<class U>
+ static char call(typename U::element_type* = 0);
+public:
+ static const bool value = sizeof(call<T>(0)) == 1;
+};
+
+template<class T>
+struct ptr_traits_first;
+
+#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
+template<template<class, class...> class T, class U, class... Args>
+struct ptr_traits_first<T<U, Args...> > {
+ typedef U type;
+};
+#else
+template<template<class> class T, class U>
+struct ptr_traits_first<T<U> > {
+ typedef U type;
+};
+
+template<template<class, class> class T, class U1, class U2>
+struct ptr_traits_first<T<U1, U2> > {
+ typedef U1 type;
+};
+
+template<template<class, class, class> class T, class U1, class U2, class U3>
+struct ptr_traits_first<T<U1, U2, U3> > {
+ typedef U1 type;
+};
+#endif
+
+template<class T, bool = ptr_traits_has_element<T>::value>
+struct ptr_traits_element {
+ typedef typename T::element_type type;
+};
+
+template<class T>
+struct ptr_traits_element<T, false> {
+ typedef typename ptr_traits_first<T>::type type;
+};
+
+template<class T>
+struct ptr_traits_has_difference {
+private:
+ template<class U>
+ static ptr_traits_none call(...);
+ template<class U>
+ static char call(typename U::difference_type* = 0);
+public:
+ static const bool value = sizeof(call<T>(0)) == 1;
+};
+
+template<class T, bool = ptr_traits_has_difference<T>::value>
+struct ptr_traits_difference {
+ typedef typename T::difference_type type;
+};
+
+template<class T>
+struct ptr_traits_difference<T, false> {
+ typedef std::ptrdiff_t type;
+};
+
+template<class T, class V>
+struct ptr_traits_has_rebind {
+private:
+ template<class U>
+ static ptr_traits_none call(...);
+ template<class U>
+ static char call(typename U::template rebind<V>* = 0);
+public:
+ static const bool value = sizeof(call<T>(0)) == 1;
+};
+
+template<class T, class V>
+struct ptr_traits_rebind_to;
+
+#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
+template<template<class, class...> class T, class U, class... Args, class V>
+struct ptr_traits_rebind_to<T<U, Args...>, V> {
+ typedef T<V, Args...> type;
+};
+#else
+template<template<class> class T, class U, class V>
+struct ptr_traits_rebind_to<T<U>, V> {
+ typedef T<V> type;
+};
+
+template<template<class, class> class T, class U1, class U2, class V>
+struct ptr_traits_rebind_to<T<U1, U2>, V> {
+ typedef T<V, U2> type;
+};
+
+template<template<class, class, class> class T,
+ class U1, class U2, class U3, class V>
+struct ptr_traits_rebind_to<T<U1, U2, U3>, V> {
+ typedef T<V, U2, U3> type;
+};
+#endif
+
+#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
+template<class T, class U, bool = ptr_traits_has_rebind<T, U>::value>
+struct ptr_traits_rebind {
+ typedef typename T::template rebind<U> type;
+};
+
+template<class T, class U>
+struct ptr_traits_rebind<T, U, false> {
+ typedef typename ptr_traits_rebind_to<T, U>::type type;
+};
+#else
+template<class T, class U>
+struct ptr_traits_rebind {
+ typedef typename ptr_traits_rebind_to<T, U>::type type;
+};
+#endif
+
+template<class T>
+struct ptr_traits_value {
+ typedef T type;
+};
+
+template<>
+struct ptr_traits_value<void> {
+ typedef struct { } type;
+};
+
+} /* detail */
+
+template<class T>
+struct pointer_traits {
+ typedef T pointer;
+ typedef typename detail::ptr_traits_element<T>::type element_type;
+ typedef typename detail::ptr_traits_difference<T>::type difference_type;
+ template<class U>
+ struct rebind_to {
+ typedef typename detail::ptr_traits_rebind<T, U>::type type;
+ };
+#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
+ template<class U>
+ using rebind = typename detail::ptr_traits_rebind<T, U>::type;
+#endif
+ static pointer
+ pointer_to(typename detail::ptr_traits_value<element_type>::type& v) {
+ return pointer::pointer_to(v);
+ }
+ static element_type* to_address(const pointer& v) BOOST_NOEXCEPT {
+ return detail::ptr_traits_address(v.operator->());
+ }
+};
+
+template<class T>
+struct pointer_traits<T*> {
+ typedef T* pointer;
+ typedef T element_type;
+ typedef std::ptrdiff_t difference_type;
+ template<class U>
+ struct rebind_to {
+ typedef U* type;
+ };
+#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
+ template<class U>
+ using rebind = U*;
+#endif
+ static T*
+ pointer_to(typename detail::ptr_traits_value<T>::type& v) BOOST_NOEXCEPT {
+ return addressof(v);
+ }
+ static T* to_address(T* v) BOOST_NOEXCEPT {
+ return v;
+ }
+};
+#endif
+
+template<class T>
+inline typename pointer_traits<T>::element_type*
+to_address(const T& v) BOOST_NOEXCEPT
+{
+ return pointer_traits<T>::to_address(v);
+}
+
+template<class T>
+inline T*
+to_address(T* v) BOOST_NOEXCEPT
+{
+ return v;
+}
+
+} /* boost */
+
+#endif
diff --git a/boost/core/ref.hpp b/boost/core/ref.hpp
index 47dc858007..7d768ffc75 100644
--- a/boost/core/ref.hpp
+++ b/boost/core/ref.hpp
@@ -8,8 +8,8 @@
#endif
#include <boost/config.hpp>
-#include <boost/utility/addressof.hpp>
-#include <boost/detail/workaround.hpp>
+#include <boost/config/workaround.hpp>
+#include <boost/core/addressof.hpp>
//
// ref.hpp - ref/cref, useful helper functions