summaryrefslogtreecommitdiff
path: root/boost/utility
diff options
context:
space:
mode:
authorChanho Park <chanho61.park@samsung.com>2014-12-11 18:55:56 +0900
committerChanho Park <chanho61.park@samsung.com>2014-12-11 18:55:56 +0900
commit08c1e93fa36a49f49325a07fe91ff92c964c2b6c (patch)
tree7a7053ceb8874b28ec4b868d4c49b500008a102e /boost/utility
parentbb4dd8289b351fae6b55e303f189127a394a1edd (diff)
downloadboost-08c1e93fa36a49f49325a07fe91ff92c964c2b6c.tar.gz
boost-08c1e93fa36a49f49325a07fe91ff92c964c2b6c.tar.bz2
boost-08c1e93fa36a49f49325a07fe91ff92c964c2b6c.zip
Imported Upstream version 1.57.0upstream/1.57.0
Diffstat (limited to 'boost/utility')
-rw-r--r--boost/utility/addressof.hpp107
-rw-r--r--boost/utility/base_from_member.hpp86
-rw-r--r--boost/utility/declval.hpp41
-rw-r--r--boost/utility/detail/result_of_iterate.hpp149
-rw-r--r--boost/utility/empty_deleter.hpp43
-rw-r--r--boost/utility/enable_if.hpp122
-rw-r--r--boost/utility/explicit_operator_bool.hpp17
-rw-r--r--boost/utility/in_place_factory.hpp6
-rw-r--r--boost/utility/result_of.hpp125
-rw-r--r--boost/utility/string_ref.hpp536
-rw-r--r--boost/utility/string_ref_fwd.hpp37
-rw-r--r--boost/utility/swap.hpp58
-rw-r--r--boost/utility/value_init.hpp29
13 files changed, 1025 insertions, 331 deletions
diff --git a/boost/utility/addressof.hpp b/boost/utility/addressof.hpp
index 95cd92fca9..db4da80421 100644
--- a/boost/utility/addressof.hpp
+++ b/boost/utility/addressof.hpp
@@ -1,102 +1,17 @@
-// Copyright (C) 2002 Brad King (brad.king@kitware.com)
-// Douglas Gregor (gregod@cs.rpi.edu)
-//
-// Copyright (C) 2002, 2008 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)
-
-// For more information, see http://www.boost.org
+/*
+ * Copyright (c) 2014 Glen Fernandes
+ *
+ * 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)
+ */
#ifndef BOOST_UTILITY_ADDRESSOF_HPP
-# define BOOST_UTILITY_ADDRESSOF_HPP
-
-# include <boost/config.hpp>
-# include <boost/detail/workaround.hpp>
-
-namespace boost
-{
-
-namespace detail
-{
-
-template<class T> struct addr_impl_ref
-{
- T & v_;
-
- inline addr_impl_ref( T & v ): v_( v ) {}
- inline operator T& () const { return v_; }
-
-private:
- addr_impl_ref & operator=(const addr_impl_ref &);
-};
-
-template<class T> struct addressof_impl
-{
- static inline T * f( T & v, long )
- {
- return reinterpret_cast<T*>(
- &const_cast<char&>(reinterpret_cast<const volatile char &>(v)));
- }
-
- static inline T * f( T * v, int )
- {
- return v;
- }
-};
-
-} // namespace detail
-
-template<class T> T * addressof( T & v )
-{
-#if defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT( 0x610 ) )
-
- return boost::detail::addressof_impl<T>::f( v, 0 );
+#define BOOST_UTILITY_ADDRESSOF_HPP
-#else
+// The header file at this path is deprecated;
+// use boost/core/addressof.hpp instead.
- return boost::detail::addressof_impl<T>::f( boost::detail::addr_impl_ref<T>( v ), 0 );
+#include <boost/core/addressof.hpp>
#endif
-}
-
-#if defined( __SUNPRO_CC ) && BOOST_WORKAROUND( __SUNPRO_CC, BOOST_TESTED_AT( 0x590 ) )
-
-namespace detail
-{
-
-template<class T> struct addressof_addp
-{
- typedef T * type;
-};
-
-} // namespace detail
-
-template< class T, std::size_t N >
-typename detail::addressof_addp< T[N] >::type addressof( T (&t)[N] )
-{
- return &t;
-}
-
-#endif
-
-// Borland doesn't like casting an array reference to a char reference
-// but these overloads work around the problem.
-#if defined( __BORLANDC__ ) && BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
-template<typename T,std::size_t N>
-T (*addressof(T (&t)[N]))[N]
-{
- return reinterpret_cast<T(*)[N]>(&t);
-}
-
-template<typename T,std::size_t N>
-const T (*addressof(const T (&t)[N]))[N]
-{
- return reinterpret_cast<const T(*)[N]>(&t);
-}
-#endif
-
-} // namespace boost
-
-#endif // BOOST_UTILITY_ADDRESSOF_HPP
diff --git a/boost/utility/base_from_member.hpp b/boost/utility/base_from_member.hpp
index 04aabb59e2..fc0e13c0d7 100644
--- a/boost/utility/base_from_member.hpp
+++ b/boost/utility/base_from_member.hpp
@@ -1,6 +1,6 @@
// boost utility/base_from_member.hpp header file --------------------------//
-// Copyright 2001, 2003, 2004 Daryle Walker. Use, modification, and
+// Copyright 2001, 2003, 2004, 2012 Daryle Walker. Use, modification, and
// distribution are subject to the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or a copy at
// <http://www.boost.org/LICENSE_1_0.txt>.)
@@ -10,10 +10,15 @@
#ifndef BOOST_UTILITY_BASE_FROM_MEMBER_HPP
#define BOOST_UTILITY_BASE_FROM_MEMBER_HPP
+#include <boost/config.hpp>
#include <boost/preprocessor/arithmetic/inc.hpp>
#include <boost/preprocessor/repetition/enum_binary_params.hpp>
#include <boost/preprocessor/repetition/enum_params.hpp>
#include <boost/preprocessor/repetition/repeat_from_to.hpp>
+#include <boost/type_traits/is_same.hpp>
+#include <boost/type_traits/remove_cv.hpp>
+#include <boost/type_traits/remove_reference.hpp>
+#include <boost/utility/enable_if.hpp>
// Base-from-member arity configuration macro ------------------------------//
@@ -53,6 +58,59 @@
namespace boost
{
+namespace detail
+{
+
+// Type-unmarking class template -------------------------------------------//
+
+// Type-trait to get the raw type, i.e. the type without top-level reference nor
+// cv-qualification, from a type expression. Mainly for function arguments, any
+// reference part is stripped first.
+
+// Contributed by Daryle Walker
+
+template < typename T >
+struct remove_cv_ref
+{
+ typedef typename ::boost::remove_cv<typename
+ ::boost::remove_reference<T>::type>::type type;
+
+}; // boost::detail::remove_cv_ref
+
+// Unmarked-type comparison class template ---------------------------------//
+
+// Type-trait to check if two type expressions have the same raw type.
+
+// Contributed by Daryle Walker, based on a work-around by Luc Danton
+
+template < typename T, typename U >
+struct is_related
+ : public ::boost::is_same<
+ typename ::boost::detail::remove_cv_ref<T>::type,
+ typename ::boost::detail::remove_cv_ref<U>::type >
+{};
+
+// Enable-if-on-unidentical-unmarked-type class template -------------------//
+
+// Enable-if on the first two type expressions NOT having the same raw type.
+
+// Contributed by Daryle Walker, based on a work-around by Luc Danton
+
+#ifndef BOOST_NO_CXX11_VARIADIC_TEMPLATES
+template<typename ...T>
+struct enable_if_unrelated
+ : public ::boost::enable_if_c<true>
+{};
+
+template<typename T, typename U, typename ...U2>
+struct enable_if_unrelated<T, U, U2...>
+ : public ::boost::disable_if< ::boost::detail::is_related<T, U> >
+{};
+#endif
+
+} // namespace boost::detail
+
+
// Base-from-member class template -----------------------------------------//
// Helper to initialize a base object so a derived class can use this
@@ -68,12 +126,38 @@ class base_from_member
protected:
MemberType member;
+#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \
+ !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && \
+ !defined(BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS) && \
+ !(defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ < 4))
+ template <typename ...T, typename EnableIf = typename
+ ::boost::detail::enable_if_unrelated<base_from_member, T...>::type>
+ explicit BOOST_CONSTEXPR base_from_member( T&& ...x )
+ BOOST_NOEXCEPT_IF( BOOST_NOEXCEPT_EXPR(::new ((void*) 0) MemberType(
+ static_cast<T&&>(x)... )) ) // no std::is_nothrow_constructible...
+ : member( static_cast<T&&>(x)... ) // ...nor std::forward needed
+ {}
+#else
base_from_member()
: member()
{}
BOOST_PP_REPEAT_FROM_TO( 1, BOOST_PP_INC(BOOST_BASE_FROM_MEMBER_MAX_ARITY),
BOOST_PRIVATE_CTR_DEF, _ )
+#endif
+
+}; // boost::base_from_member
+
+template < typename MemberType, int UniqueID >
+class base_from_member<MemberType&, UniqueID>
+{
+protected:
+ MemberType& member;
+
+ explicit BOOST_CONSTEXPR base_from_member( MemberType& x )
+ BOOST_NOEXCEPT
+ : member( x )
+ {}
}; // boost::base_from_member
diff --git a/boost/utility/declval.hpp b/boost/utility/declval.hpp
index d74610c584..a4ab2c8cb4 100644
--- a/boost/utility/declval.hpp
+++ b/boost/utility/declval.hpp
@@ -1,49 +1,44 @@
-// common_type.hpp ---------------------------------------------------------//
+// declval.hpp -------------------------------------------------------------//
// Copyright 2010 Vicente J. Botet Escriba
// Distributed under the Boost Software License, Version 1.0.
// See http://www.boost.org/LICENSE_1_0.txt
-#ifndef BOOST_TYPE_TRAITS_EXT_DECLVAL__HPP
-#define BOOST_TYPE_TRAITS_EXT_DECLVAL__HPP
+#ifndef BOOST_UTILITY_DECLVAL_HPP
+#define BOOST_UTILITY_DECLVAL_HPP
#include <boost/config.hpp>
//----------------------------------------------------------------------------//
#include <boost/type_traits/add_rvalue_reference.hpp>
-//#include <boost/type_traits/add_lvalue_reference.hpp>
//----------------------------------------------------------------------------//
// //
// C++03 implementation of //
+// 20.2.4 Function template declval [declval] //
// Written by Vicente J. Botet Escriba //
-//~ 20.3.4 Function template declval [declval]
-//~ 1 The library provides the function template declval to simplify the definition of expressions which occur as
-//~ unevaluated operands.
-//~ 2 Remarks: If this function is used, the program is ill-formed.
-//~ 3 Remarks: The template parameter T of declval may be an incomplete type.
-//~ [ Example:
-
-//~ template <class To, class From>
-//~ decltype(static_cast<To>(declval<From>())) convert(From&&);
-
-//~ declares a function template convert which only participats in overloading if the type From can be
-//~ explicitly converted to type To. For another example see class template common_type (20.7.6.6). —end
-//~ example ]
// //
+// 1 The library provides the function template declval to simplify the
+// definition of expressions which occur as unevaluated operands.
+// 2 Remarks: If this function is used, the program is ill-formed.
+// 3 Remarks: The template parameter T of declval may be an incomplete type.
+// [ Example:
+//
+// template <class To, class From>
+// decltype(static_cast<To>(declval<From>())) convert(From&&);
+//
+// declares a function template convert which only participates in overloading
+// if the type From can be explicitly converted to type To. For another example
+// see class template common_type (20.9.7.6). -end example ]
//----------------------------------------------------------------------------//
namespace boost {
-//#if !defined(BOOST_NO_RVALUE_REFERENCES)
template <typename T>
typename add_rvalue_reference<T>::type declval() BOOST_NOEXCEPT; // as unevaluated operand
-//#else
-// template <typename T>
-// typename add_lvalue_reference<T>::type declval() BOOST_NOEXCEPT; // as unevaluated operand
-//#endif
+
} // namespace boost
-#endif // BOOST_TYPE_TRAITS_EXT_DECLVAL__HPP
+#endif // BOOST_UTILITY_DECLVAL_HPP
diff --git a/boost/utility/detail/result_of_iterate.hpp b/boost/utility/detail/result_of_iterate.hpp
index 1ec857a2fc..5192172cfc 100644
--- a/boost/utility/detail/result_of_iterate.hpp
+++ b/boost/utility/detail/result_of_iterate.hpp
@@ -5,6 +5,11 @@
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
+// Copyright Daniel Walker, Eric Niebler, Michel Morin 2008-2012.
+// Use, modification and distribution is 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)
+
// For more information, see http://www.boost.org/libs/utility
#if !defined(BOOST_PP_IS_ITERATING)
# error Boost result_of - do not include this file!
@@ -18,31 +23,44 @@
#endif
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551))
-template<typename F BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
- BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
+template<typename F BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(),typename T)>
struct tr1_result_of<F(BOOST_RESULT_OF_ARGS)>
: mpl::if_<
mpl::or_< is_pointer<F>, is_member_function_pointer<F> >
, boost::detail::tr1_result_of_impl<
- typename remove_cv<F>::type,
- typename remove_cv<F>::type(BOOST_RESULT_OF_ARGS),
+ typename remove_cv<F>::type,
+ typename remove_cv<F>::type(BOOST_RESULT_OF_ARGS),
(boost::detail::has_result_type<F>::value)>
, boost::detail::tr1_result_of_impl<
F,
- F(BOOST_RESULT_OF_ARGS),
+ F(BOOST_RESULT_OF_ARGS),
(boost::detail::has_result_type<F>::value)> >::type { };
#endif
-#if !defined(BOOST_NO_DECLTYPE) && defined(BOOST_RESULT_OF_USE_DECLTYPE)
+#ifdef BOOST_RESULT_OF_USE_DECLTYPE
+template<typename F BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(),typename T)>
+struct result_of<F(BOOST_RESULT_OF_ARGS)>
+ : detail::cpp0x_result_of<F(BOOST_RESULT_OF_ARGS)> { };
+#endif // BOOST_RESULT_OF_USE_DECLTYPE
+
+#ifdef BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK
+template<typename F BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(),typename T)>
+struct result_of<F(BOOST_RESULT_OF_ARGS)>
+ : mpl::if_<mpl::or_<detail::has_result_type<F>, detail::has_result<F> >,
+ tr1_result_of<F(BOOST_RESULT_OF_ARGS)>,
+ detail::cpp0x_result_of<F(BOOST_RESULT_OF_ARGS)> >::type { };
+#endif // BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK
+
+#if defined(BOOST_RESULT_OF_USE_DECLTYPE) || defined(BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK)
+
+namespace detail {
-// Uses declval following N3225 20.7.7.6 when F is not a pointer.
-template<typename F BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
- BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
-struct result_of<F(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T))>
+template<typename F BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(),typename T)>
+struct cpp0x_result_of<F(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T))>
: mpl::if_<
- mpl::or_< is_pointer<F>, is_member_function_pointer<F> >
+ is_member_function_pointer<F>
, detail::tr1_result_of_impl<
- typename remove_cv<F>::type,
+ typename remove_cv<F>::type,
typename remove_cv<F>::type(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)), false
>
, detail::cpp0x_result_of_impl<
@@ -51,55 +69,119 @@ struct result_of<F(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T))>
>::type
{};
-namespace detail {
+#ifdef BOOST_NO_SFINAE_EXPR
+
+template<typename F>
+struct BOOST_PP_CAT(result_of_callable_fun_2_, BOOST_PP_ITERATION());
+
+template<typename R BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(), typename T)>
+struct BOOST_PP_CAT(result_of_callable_fun_2_, BOOST_PP_ITERATION())<R(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T))> {
+ R operator()(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T)) const;
+ typedef result_of_private_type const &(*pfn_t)(...);
+ operator pfn_t() const volatile;
+};
-template<typename F BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
- BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
-struct cpp0x_result_of_impl<F(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T))>
+template<typename F>
+struct BOOST_PP_CAT(result_of_callable_fun_, BOOST_PP_ITERATION());
+
+template<typename F>
+struct BOOST_PP_CAT(result_of_callable_fun_, BOOST_PP_ITERATION())<F *>
+ : BOOST_PP_CAT(result_of_callable_fun_2_, BOOST_PP_ITERATION())<F>
+{};
+
+template<typename F>
+struct BOOST_PP_CAT(result_of_callable_fun_, BOOST_PP_ITERATION())<F &>
+ : BOOST_PP_CAT(result_of_callable_fun_2_, BOOST_PP_ITERATION())<F>
+{};
+
+template<typename F>
+struct BOOST_PP_CAT(result_of_select_call_wrapper_type_, BOOST_PP_ITERATION())
+ : mpl::eval_if<
+ is_class<typename remove_reference<F>::type>,
+ result_of_wrap_callable_class<F>,
+ mpl::identity<BOOST_PP_CAT(result_of_callable_fun_, BOOST_PP_ITERATION())<typename remove_cv<F>::type> >
+ >
+{};
+
+template<typename F BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(), typename T)>
+struct BOOST_PP_CAT(result_of_is_callable_, BOOST_PP_ITERATION()) {
+ typedef typename BOOST_PP_CAT(result_of_select_call_wrapper_type_, BOOST_PP_ITERATION())<F>::type wrapper_t;
+ static const bool value = (
+ sizeof(result_of_no_type) == sizeof(detail::result_of_is_private_type(
+ (boost::declval<wrapper_t>()(BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_ITERATION(), boost::declval<T, >() BOOST_PP_INTERCEPT)), result_of_weird_type())
+ ))
+ );
+ typedef mpl::bool_<value> type;
+};
+
+template<typename F BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(),typename T)>
+struct cpp0x_result_of_impl<F(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)), true>
+ : lazy_enable_if<
+ BOOST_PP_CAT(result_of_is_callable_, BOOST_PP_ITERATION())<F BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(), T)>
+ , cpp0x_result_of_impl<F(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)), false>
+ >
+{};
+
+template<typename F BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(),typename T)>
+struct cpp0x_result_of_impl<F(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)), false>
{
typedef decltype(
boost::declval<F>()(
- BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_ITERATION(), declval<T, >() BOOST_PP_INTERCEPT)
+ BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_ITERATION(), boost::declval<T, >() BOOST_PP_INTERCEPT)
)
) type;
};
-} // namespace detail
+#else // BOOST_NO_SFINAE_EXPR
+
+template<typename F BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(),typename T)>
+struct cpp0x_result_of_impl<F(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)),
+ typename result_of_always_void<decltype(
+ boost::declval<F>()(
+ BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_ITERATION(), boost::declval<T, >() BOOST_PP_INTERCEPT)
+ )
+ )>::type> {
+ typedef decltype(
+ boost::declval<F>()(
+ BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_ITERATION(), boost::declval<T, >() BOOST_PP_INTERCEPT)
+ )
+ ) type;
+};
+
+#endif // BOOST_NO_SFINAE_EXPR
+
+} // namespace detail
-#else // defined(BOOST_NO_DECLTYPE)
+#else // defined(BOOST_RESULT_OF_USE_DECLTYPE) || defined(BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK)
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551))
-template<typename F BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
- BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
+template<typename F BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(),typename T)>
struct result_of<F(BOOST_RESULT_OF_ARGS)>
: tr1_result_of<F(BOOST_RESULT_OF_ARGS)> { };
#endif
-#endif // defined(BOOST_NO_DECLTYPE)
+#endif // defined(BOOST_RESULT_OF_USE_DECLTYPE)
#undef BOOST_RESULT_OF_ARGS
-#if BOOST_PP_ITERATION() >= 1
+#if BOOST_PP_ITERATION() >= 1
namespace detail {
-template<typename R, typename FArgs BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
- BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
+template<typename R, typename FArgs BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(),typename T)>
struct tr1_result_of_impl<R (*)(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)), FArgs, false>
{
typedef R type;
};
-template<typename R, typename FArgs BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
- BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
+template<typename R, typename FArgs BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(),typename T)>
struct tr1_result_of_impl<R (&)(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)), FArgs, false>
{
typedef R type;
};
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551))
-template<typename R, typename FArgs BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
- BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
+template<typename R, typename FArgs BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(),typename T)>
struct tr1_result_of_impl<R (T0::*)
(BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_PP_ITERATION(),T)),
FArgs, false>
@@ -107,8 +189,7 @@ struct tr1_result_of_impl<R (T0::*)
typedef R type;
};
-template<typename R, typename FArgs BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
- BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
+template<typename R, typename FArgs BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(),typename T)>
struct tr1_result_of_impl<R (T0::*)
(BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_PP_ITERATION(),T))
const,
@@ -117,8 +198,7 @@ struct tr1_result_of_impl<R (T0::*)
typedef R type;
};
-template<typename R, typename FArgs BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
- BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
+template<typename R, typename FArgs BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(),typename T)>
struct tr1_result_of_impl<R (T0::*)
(BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_PP_ITERATION(),T))
volatile,
@@ -127,8 +207,7 @@ struct tr1_result_of_impl<R (T0::*)
typedef R type;
};
-template<typename R, typename FArgs BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
- BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
+template<typename R, typename FArgs BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(),typename T)>
struct tr1_result_of_impl<R (T0::*)
(BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_PP_ITERATION(),T))
const volatile,
diff --git a/boost/utility/empty_deleter.hpp b/boost/utility/empty_deleter.hpp
new file mode 100644
index 0000000000..91bc47b816
--- /dev/null
+++ b/boost/utility/empty_deleter.hpp
@@ -0,0 +1,43 @@
+/*
+ * Copyright Andrey Semashev 2007 - 2013.
+ * 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)
+ */
+
+/*!
+ * \file empty_deleter.hpp
+ * \author Andrey Semashev
+ * \date 22.04.2007
+ *
+ * This header contains an \c empty_deleter implementation. This is an empty
+ * function object that receives a pointer and does nothing with it.
+ * Such empty deletion strategy may be convenient, for example, when
+ * constructing <tt>shared_ptr</tt>s that point to some object that should not be
+ * deleted (i.e. a variable on the stack or some global singleton, like <tt>std::cout</tt>).
+ */
+
+#ifndef BOOST_UTILITY_EMPTY_DELETER_HPP
+#define BOOST_UTILITY_EMPTY_DELETER_HPP
+
+#include <boost/config.hpp>
+#include <boost/core/null_deleter.hpp>
+
+#ifdef BOOST_HAS_PRAGMA_ONCE
+#pragma once
+#endif
+
+#if defined(__GNUC__)
+#pragma message "This header is deprecated, use boost/core/null_deleter.hpp instead."
+#elif defined(_MSC_VER)
+#pragma message("This header is deprecated, use boost/core/null_deleter.hpp instead.")
+#endif
+
+namespace boost {
+
+//! A deprecated name for \c null_deleter
+typedef null_deleter empty_deleter;
+
+} // namespace boost
+
+#endif // BOOST_UTILITY_EMPTY_DELETER_HPP
diff --git a/boost/utility/enable_if.hpp b/boost/utility/enable_if.hpp
index d292c6a7b0..803bfca5e2 100644
--- a/boost/utility/enable_if.hpp
+++ b/boost/utility/enable_if.hpp
@@ -1,119 +1,17 @@
-// Boost enable_if library
-
-// Copyright 2003 (c) The Trustees of Indiana University.
-
-// Use, modification, and distribution is 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)
-
-// Authors: Jaakko Jarvi (jajarvi at osl.iu.edu)
-// Jeremiah Willcock (jewillco at osl.iu.edu)
-// Andrew Lumsdaine (lums at osl.iu.edu)
-
+/*
+ * Copyright (c) 2014 Glen Fernandes
+ *
+ * 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)
+ */
#ifndef BOOST_UTILITY_ENABLE_IF_HPP
#define BOOST_UTILITY_ENABLE_IF_HPP
-#include "boost/config.hpp"
-
-// Even the definition of enable_if causes problems on some compilers,
-// so it's macroed out for all compilers that do not support SFINAE
-
-#ifndef BOOST_NO_SFINAE
-
-namespace boost
-{
-
- template <bool B, class T = void>
- struct enable_if_c {
- typedef T type;
- };
-
- template <class T>
- struct enable_if_c<false, T> {};
-
- template <class Cond, class T = void>
- struct enable_if : public enable_if_c<Cond::value, T> {};
-
- template <bool B, class T>
- struct lazy_enable_if_c {
- typedef typename T::type type;
- };
-
- template <class T>
- struct lazy_enable_if_c<false, T> {};
-
- template <class Cond, class T>
- struct lazy_enable_if : public lazy_enable_if_c<Cond::value, T> {};
-
-
- template <bool B, class T = void>
- struct disable_if_c {
- typedef T type;
- };
-
- template <class T>
- struct disable_if_c<true, T> {};
-
- template <class Cond, class T = void>
- struct disable_if : public disable_if_c<Cond::value, T> {};
-
- template <bool B, class T>
- struct lazy_disable_if_c {
- typedef typename T::type type;
- };
-
- template <class T>
- struct lazy_disable_if_c<true, T> {};
-
- template <class Cond, class T>
- struct lazy_disable_if : public lazy_disable_if_c<Cond::value, T> {};
-
-} // namespace boost
-
-#else
-
-namespace boost {
-
- namespace detail { typedef void enable_if_default_T; }
-
- template <typename T>
- struct enable_if_does_not_work_on_this_compiler;
-
- template <bool B, class T = detail::enable_if_default_T>
- struct enable_if_c : enable_if_does_not_work_on_this_compiler<T>
- { };
-
- template <bool B, class T = detail::enable_if_default_T>
- struct disable_if_c : enable_if_does_not_work_on_this_compiler<T>
- { };
-
- template <bool B, class T = detail::enable_if_default_T>
- struct lazy_enable_if_c : enable_if_does_not_work_on_this_compiler<T>
- { };
-
- template <bool B, class T = detail::enable_if_default_T>
- struct lazy_disable_if_c : enable_if_does_not_work_on_this_compiler<T>
- { };
-
- template <class Cond, class T = detail::enable_if_default_T>
- struct enable_if : enable_if_does_not_work_on_this_compiler<T>
- { };
-
- template <class Cond, class T = detail::enable_if_default_T>
- struct disable_if : enable_if_does_not_work_on_this_compiler<T>
- { };
-
- template <class Cond, class T = detail::enable_if_default_T>
- struct lazy_enable_if : enable_if_does_not_work_on_this_compiler<T>
- { };
-
- template <class Cond, class T = detail::enable_if_default_T>
- struct lazy_disable_if : enable_if_does_not_work_on_this_compiler<T>
- { };
-
-} // namespace boost
+// The header file at this path is deprecated;
+// use boost/core/enable_if.hpp instead.
-#endif // BOOST_NO_SFINAE
+#include <boost/core/enable_if.hpp>
#endif
diff --git a/boost/utility/explicit_operator_bool.hpp b/boost/utility/explicit_operator_bool.hpp
new file mode 100644
index 0000000000..9b625cd689
--- /dev/null
+++ b/boost/utility/explicit_operator_bool.hpp
@@ -0,0 +1,17 @@
+/*
+ * Copyright (c) 2014 Glen Fernandes
+ *
+ * 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)
+ */
+
+#ifndef BOOST_UTILITY_EXPLICIT_OPERATOR_BOOL_HPP
+#define BOOST_UTILITY_EXPLICIT_OPERATOR_BOOL_HPP
+
+// The header file at this path is deprecated;
+// use boost/core/explicit_operator_bool.hpp instead.
+
+#include <boost/core/explicit_operator_bool.hpp>
+
+#endif
diff --git a/boost/utility/in_place_factory.hpp b/boost/utility/in_place_factory.hpp
index f84b003c70..1a62ace10a 100644
--- a/boost/utility/in_place_factory.hpp
+++ b/boost/utility/in_place_factory.hpp
@@ -48,15 +48,13 @@ public:
{}
template<class T>
- void* apply(void* address
- BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(T)) const
+ void* apply(void* address) const
{
return new(address) T( BOOST_PP_ENUM_PARAMS(N, m_a) );
}
template<class T>
- void* apply(void* address, std::size_t n
- BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(T)) const
+ void* apply(void* address, std::size_t n) const
{
for(char* next = address = this->BOOST_NESTED_TEMPLATE apply<T>(address);
!! --n;)
diff --git a/boost/utility/result_of.hpp b/boost/utility/result_of.hpp
index 41cc176101..206ae3088a 100644
--- a/boost/utility/result_of.hpp
+++ b/boost/utility/result_of.hpp
@@ -10,24 +10,57 @@
#define BOOST_RESULT_OF_HPP
#include <boost/config.hpp>
-#include <boost/preprocessor/iteration/iterate.hpp>
-#include <boost/preprocessor/punctuation/comma_if.hpp>
-#include <boost/preprocessor/repetition/enum_params.hpp>
-#include <boost/preprocessor/repetition/enum_binary_params.hpp>
-#include <boost/preprocessor/repetition/enum_shifted_params.hpp>
-#include <boost/preprocessor/facilities/intercept.hpp>
+#include <boost/preprocessor/cat.hpp>
+#include <boost/preprocessor/iteration/iterate.hpp>
+#include <boost/preprocessor/repetition/enum_params.hpp>
+#include <boost/preprocessor/repetition/enum_trailing_params.hpp>
+#include <boost/preprocessor/repetition/enum_binary_params.hpp>
+#include <boost/preprocessor/repetition/enum_shifted_params.hpp>
+#include <boost/preprocessor/facilities/intercept.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/mpl/has_xxx.hpp>
#include <boost/mpl/if.hpp>
+#include <boost/mpl/eval_if.hpp>
#include <boost/mpl/bool.hpp>
+#include <boost/mpl/identity.hpp>
#include <boost/mpl/or.hpp>
+#include <boost/type_traits/is_class.hpp>
#include <boost/type_traits/is_pointer.hpp>
#include <boost/type_traits/is_member_function_pointer.hpp>
#include <boost/type_traits/remove_cv.hpp>
+#include <boost/type_traits/remove_reference.hpp>
#include <boost/utility/declval.hpp>
+#include <boost/utility/enable_if.hpp>
#ifndef BOOST_RESULT_OF_NUM_ARGS
-# define BOOST_RESULT_OF_NUM_ARGS 10
+# define BOOST_RESULT_OF_NUM_ARGS 16
+#endif
+
+// Use the decltype-based version of result_of by default if the compiler
+// supports N3276 <http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2011/n3276.pdf>.
+// The user can force the choice by defining BOOST_RESULT_OF_USE_DECLTYPE,
+// BOOST_RESULT_OF_USE_TR1, or BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK but not more than one!
+#if (defined(BOOST_RESULT_OF_USE_DECLTYPE) && defined(BOOST_RESULT_OF_USE_TR1)) || \
+ (defined(BOOST_RESULT_OF_USE_DECLTYPE) && defined(BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK)) || \
+ (defined(BOOST_RESULT_OF_USE_TR1) && defined(BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK))
+# error More than one of BOOST_RESULT_OF_USE_DECLTYPE, BOOST_RESULT_OF_USE_TR1 and \
+ BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK cannot be defined at the same time.
+#endif
+
+#if defined(BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK) && defined(BOOST_MPL_CFG_NO_HAS_XXX_TEMPLATE)
+# error Cannot fallback to decltype if BOOST_MPL_CFG_NO_HAS_XXX_TEMPLATE is not defined.
+#endif
+
+#ifndef BOOST_RESULT_OF_USE_TR1
+# ifndef BOOST_RESULT_OF_USE_DECLTYPE
+# ifndef BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK
+# ifndef BOOST_NO_CXX11_DECLTYPE_N3276 // this implies !defined(BOOST_NO_CXX11_DECLTYPE)
+# define BOOST_RESULT_OF_USE_DECLTYPE
+# else
+# define BOOST_RESULT_OF_USE_TR1
+# endif
+# endif
+# endif
#endif
namespace boost {
@@ -35,13 +68,87 @@ namespace boost {
template<typename F> struct result_of;
template<typename F> struct tr1_result_of; // a TR1-style implementation of result_of
-#if !defined(BOOST_NO_SFINAE) && !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
+#if !defined(BOOST_NO_SFINAE)
namespace detail {
BOOST_MPL_HAS_XXX_TRAIT_DEF(result_type)
+// Work around a nvcc bug by only defining has_result when it's needed.
+#ifdef BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK
+BOOST_MPL_HAS_XXX_TEMPLATE_DEF(result)
+#endif
+
template<typename F, typename FArgs, bool HasResultType> struct tr1_result_of_impl;
-template<typename F> struct cpp0x_result_of_impl;
+
+template<typename F> struct cpp0x_result_of;
+
+#ifdef BOOST_NO_SFINAE_EXPR
+
+// There doesn't seem to be any other way to turn this off such that the presence of
+// the user-defined operator,() below doesn't cause spurious warning all over the place,
+// so unconditionally turn it off.
+#if BOOST_MSVC
+# pragma warning(disable: 4913) // user defined binary operator ',' exists but no overload could convert all operands, default built-in binary operator ',' used
+#endif
+
+struct result_of_private_type {};
+
+struct result_of_weird_type {
+ friend result_of_private_type operator,(result_of_private_type, result_of_weird_type);
+};
+
+typedef char result_of_yes_type; // sizeof(result_of_yes_type) == 1
+typedef char (&result_of_no_type)[2]; // sizeof(result_of_no_type) == 2
+
+template<typename T>
+result_of_no_type result_of_is_private_type(T const &);
+result_of_yes_type result_of_is_private_type(result_of_private_type);
+
+template<typename C>
+struct result_of_callable_class : C {
+ result_of_callable_class();
+ typedef result_of_private_type const &(*pfn_t)(...);
+ operator pfn_t() const volatile;
+};
+
+template<typename C>
+struct result_of_wrap_callable_class {
+ typedef result_of_callable_class<C> type;
+};
+
+template<typename C>
+struct result_of_wrap_callable_class<C const> {
+ typedef result_of_callable_class<C> const type;
+};
+
+template<typename C>
+struct result_of_wrap_callable_class<C volatile> {
+ typedef result_of_callable_class<C> volatile type;
+};
+
+template<typename C>
+struct result_of_wrap_callable_class<C const volatile> {
+ typedef result_of_callable_class<C> const volatile type;
+};
+
+template<typename C>
+struct result_of_wrap_callable_class<C &> {
+ typedef typename result_of_wrap_callable_class<C>::type &type;
+};
+
+template<typename F, bool TestCallability = true> struct cpp0x_result_of_impl;
+
+#else // BOOST_NO_SFINAE_EXPR
+
+template<typename T>
+struct result_of_always_void
+{
+ typedef void type;
+};
+
+template<typename F, typename Enable = void> struct cpp0x_result_of_impl {};
+
+#endif // BOOST_NO_SFINAE_EXPR
template<typename F>
struct result_of_void_impl
diff --git a/boost/utility/string_ref.hpp b/boost/utility/string_ref.hpp
new file mode 100644
index 0000000000..90185135a8
--- /dev/null
+++ b/boost/utility/string_ref.hpp
@@ -0,0 +1,536 @@
+/*
+ Copyright (c) Marshall Clow 2012-2012.
+
+ 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)
+
+ For more information, see http://www.boost.org
+
+ Based on the StringRef implementation in LLVM (http://llvm.org) and
+ N3422 by Jeffrey Yasskin
+ http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3442.html
+
+*/
+
+#ifndef BOOST_STRING_REF_HPP
+#define BOOST_STRING_REF_HPP
+
+#include <boost/config.hpp>
+#include <boost/detail/workaround.hpp>
+#include <boost/utility/string_ref_fwd.hpp>
+#include <boost/throw_exception.hpp>
+
+#include <cstddef>
+#include <stdexcept>
+#include <algorithm>
+#include <iterator>
+#include <string>
+#include <iosfwd>
+
+namespace boost {
+
+ namespace detail {
+ // A helper functor because sometimes we don't have lambdas
+ template <typename charT, typename traits>
+ class string_ref_traits_eq {
+ public:
+ string_ref_traits_eq ( charT ch ) : ch_(ch) {}
+ bool operator () ( charT val ) const { return traits::eq ( ch_, val ); }
+ charT ch_;
+ };
+ }
+
+ template<typename charT, typename traits>
+ class basic_string_ref {
+ public:
+ // types
+ typedef charT value_type;
+ typedef const charT* pointer;
+ typedef const charT& reference;
+ typedef const charT& const_reference;
+ typedef pointer const_iterator; // impl-defined
+ typedef const_iterator iterator;
+ typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
+ typedef const_reverse_iterator reverse_iterator;
+ typedef std::size_t size_type;
+ typedef std::ptrdiff_t difference_type;
+ static BOOST_CONSTEXPR_OR_CONST size_type npos = size_type(-1);
+
+ // construct/copy
+ BOOST_CONSTEXPR basic_string_ref ()
+ : ptr_(NULL), len_(0) {}
+
+ BOOST_CONSTEXPR basic_string_ref (const basic_string_ref &rhs)
+ : ptr_(rhs.ptr_), len_(rhs.len_) {}
+
+ basic_string_ref& operator=(const basic_string_ref &rhs) {
+ ptr_ = rhs.ptr_;
+ len_ = rhs.len_;
+ return *this;
+ }
+
+ basic_string_ref(const charT* str)
+ : ptr_(str), len_(traits::length(str)) {}
+
+ template<typename Allocator>
+ basic_string_ref(const std::basic_string<charT, traits, Allocator>& str)
+ : ptr_(str.data()), len_(str.length()) {}
+
+ BOOST_CONSTEXPR basic_string_ref(const charT* str, size_type len)
+ : ptr_(str), len_(len) {}
+
+#ifndef BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS
+ template<typename Allocator>
+ explicit operator std::basic_string<charT, traits, Allocator>() const {
+ return std::basic_string<charT, traits, Allocator> ( ptr_, len_ );
+ }
+#endif
+
+ std::basic_string<charT, traits> to_string () const {
+ return std::basic_string<charT, traits> ( ptr_, len_ );
+ }
+
+ // iterators
+ BOOST_CONSTEXPR const_iterator begin() const { return ptr_; }
+ BOOST_CONSTEXPR const_iterator cbegin() const { return ptr_; }
+ BOOST_CONSTEXPR const_iterator end() const { return ptr_ + len_; }
+ BOOST_CONSTEXPR const_iterator cend() const { return ptr_ + len_; }
+ const_reverse_iterator rbegin() const { return const_reverse_iterator (end()); }
+ const_reverse_iterator crbegin() const { return const_reverse_iterator (end()); }
+ const_reverse_iterator rend() const { return const_reverse_iterator (begin()); }
+ const_reverse_iterator crend() const { return const_reverse_iterator (begin()); }
+
+ // capacity
+ BOOST_CONSTEXPR size_type size() const { return len_; }
+ BOOST_CONSTEXPR size_type length() const { return len_; }
+ BOOST_CONSTEXPR size_type max_size() const { return len_; }
+ BOOST_CONSTEXPR bool empty() const { return len_ == 0; }
+
+ // element access
+ BOOST_CONSTEXPR const charT& operator[](size_type pos) const { return ptr_[pos]; }
+
+ const charT& at(size_t pos) const {
+ if ( pos >= len_ )
+ BOOST_THROW_EXCEPTION( std::out_of_range ( "boost::string_ref::at" ) );
+ return ptr_[pos];
+ }
+
+ BOOST_CONSTEXPR const charT& front() const { return ptr_[0]; }
+ BOOST_CONSTEXPR const charT& back() const { return ptr_[len_-1]; }
+ BOOST_CONSTEXPR const charT* data() const { return ptr_; }
+
+ // modifiers
+ void clear() { len_ = 0; }
+ void remove_prefix(size_type n) {
+ if ( n > len_ )
+ n = len_;
+ ptr_ += n;
+ len_ -= n;
+ }
+
+ void remove_suffix(size_type n) {
+ if ( n > len_ )
+ n = len_;
+ len_ -= n;
+ }
+
+
+ // basic_string_ref string operations
+ basic_string_ref substr(size_type pos, size_type n=npos) const {
+ if ( pos > size())
+ BOOST_THROW_EXCEPTION( std::out_of_range ( "string_ref::substr" ) );
+ if ( n == npos || pos + n > size())
+ n = size () - pos;
+ return basic_string_ref ( data() + pos, n );
+ }
+
+ int compare(basic_string_ref x) const {
+ const int cmp = traits::compare ( ptr_, x.ptr_, (std::min)(len_, x.len_));
+ return cmp != 0 ? cmp : ( len_ == x.len_ ? 0 : len_ < x.len_ ? -1 : 1 );
+ }
+
+ bool starts_with(charT c) const { return !empty() && traits::eq ( c, front()); }
+ bool starts_with(basic_string_ref x) const {
+ return len_ >= x.len_ && traits::compare ( ptr_, x.ptr_, x.len_ ) == 0;
+ }
+
+ bool ends_with(charT c) const { return !empty() && traits::eq ( c, back()); }
+ bool ends_with(basic_string_ref x) const {
+ return len_ >= x.len_ && traits::compare ( ptr_ + len_ - x.len_, x.ptr_, x.len_ ) == 0;
+ }
+
+ size_type find(basic_string_ref s) const {
+ const_iterator iter = std::search ( this->cbegin (), this->cend (),
+ s.cbegin (), s.cend (), traits::eq );
+ return iter == this->cend () ? npos : std::distance ( this->cbegin (), iter );
+ }
+
+ size_type find(charT c) const {
+ const_iterator iter = std::find_if ( this->cbegin (), this->cend (),
+ detail::string_ref_traits_eq<charT, traits> ( c ));
+ return iter == this->cend () ? npos : std::distance ( this->cbegin (), iter );
+ }
+
+ size_type rfind(basic_string_ref s) const {
+ const_reverse_iterator iter = std::search ( this->crbegin (), this->crend (),
+ s.crbegin (), s.crend (), traits::eq );
+ return iter == this->crend () ? npos : reverse_distance ( this->crbegin (), iter );
+ }
+
+ size_type rfind(charT c) const {
+ const_reverse_iterator iter = std::find_if ( this->crbegin (), this->crend (),
+ detail::string_ref_traits_eq<charT, traits> ( c ));
+ return iter == this->crend () ? npos : reverse_distance ( this->crbegin (), iter );
+ }
+
+ size_type find_first_of(charT c) const { return find (c); }
+ size_type find_last_of (charT c) const { return rfind (c); }
+
+ size_type find_first_of(basic_string_ref s) const {
+ const_iterator iter = std::find_first_of
+ ( this->cbegin (), this->cend (), s.cbegin (), s.cend (), traits::eq );
+ return iter == this->cend () ? npos : std::distance ( this->cbegin (), iter );
+ }
+
+ size_type find_last_of(basic_string_ref s) const {
+ const_reverse_iterator iter = std::find_first_of
+ ( this->crbegin (), this->crend (), s.cbegin (), s.cend (), traits::eq );
+ return iter == this->crend () ? npos : reverse_distance ( this->crbegin (), iter);
+ }
+
+ size_type find_first_not_of(basic_string_ref s) const {
+ const_iterator iter = find_not_of ( this->cbegin (), this->cend (), s );
+ return iter == this->cend () ? npos : std::distance ( this->cbegin (), iter );
+ }
+
+ size_type find_first_not_of(charT c) const {
+ for ( const_iterator iter = this->cbegin (); iter != this->cend (); ++iter )
+ if ( !traits::eq ( c, *iter ))
+ return std::distance ( this->cbegin (), iter );
+ return npos;
+ }
+
+ size_type find_last_not_of(basic_string_ref s) const {
+ const_reverse_iterator iter = find_not_of ( this->crbegin (), this->crend (), s );
+ return iter == this->crend () ? npos : reverse_distance ( this->crbegin (), iter );
+ }
+
+ size_type find_last_not_of(charT c) const {
+ for ( const_reverse_iterator iter = this->crbegin (); iter != this->crend (); ++iter )
+ if ( !traits::eq ( c, *iter ))
+ return reverse_distance ( this->crbegin (), iter );
+ return npos;
+ }
+
+ private:
+ template <typename r_iter>
+ size_type reverse_distance ( r_iter first, r_iter last ) const {
+ return len_ - 1 - std::distance ( first, last );
+ }
+
+ template <typename Iterator>
+ Iterator find_not_of ( Iterator first, Iterator last, basic_string_ref s ) const {
+ for ( ; first != last ; ++first )
+ if ( 0 == traits::find ( s.ptr_, s.len_, *first ))
+ return first;
+ return last;
+ }
+
+
+
+ const charT *ptr_;
+ std::size_t len_;
+ };
+
+
+// Comparison operators
+// Equality
+ template<typename charT, typename traits>
+ inline bool operator==(basic_string_ref<charT, traits> x, basic_string_ref<charT, traits> y) {
+ if ( x.size () != y.size ()) return false;
+ return x.compare(y) == 0;
+ }
+
+ template<typename charT, typename traits, typename Allocator>
+ inline bool operator==(basic_string_ref<charT, traits> x, const std::basic_string<charT, traits, Allocator> & y) {
+ return x == basic_string_ref<charT, traits>(y);
+ }
+
+ template<typename charT, typename traits, typename Allocator>
+ inline bool operator==(const std::basic_string<charT, traits, Allocator> & x, basic_string_ref<charT, traits> y) {
+ return basic_string_ref<charT, traits>(x) == y;
+ }
+
+ template<typename charT, typename traits>
+ inline bool operator==(basic_string_ref<charT, traits> x, const charT * y) {
+ return x == basic_string_ref<charT, traits>(y);
+ }
+
+ template<typename charT, typename traits>
+ inline bool operator==(const charT * x, basic_string_ref<charT, traits> y) {
+ return basic_string_ref<charT, traits>(x) == y;
+ }
+
+// Inequality
+ template<typename charT, typename traits>
+ inline bool operator!=(basic_string_ref<charT, traits> x, basic_string_ref<charT, traits> y) {
+ if ( x.size () != y.size ()) return true;
+ return x.compare(y) != 0;
+ }
+
+ template<typename charT, typename traits, typename Allocator>
+ inline bool operator!=(basic_string_ref<charT, traits> x, const std::basic_string<charT, traits, Allocator> & y) {
+ return x != basic_string_ref<charT, traits>(y);
+ }
+
+ template<typename charT, typename traits, typename Allocator>
+ inline bool operator!=(const std::basic_string<charT, traits, Allocator> & x, basic_string_ref<charT, traits> y) {
+ return basic_string_ref<charT, traits>(x) != y;
+ }
+
+ template<typename charT, typename traits>
+ inline bool operator!=(basic_string_ref<charT, traits> x, const charT * y) {
+ return x != basic_string_ref<charT, traits>(y);
+ }
+
+ template<typename charT, typename traits>
+ inline bool operator!=(const charT * x, basic_string_ref<charT, traits> y) {
+ return basic_string_ref<charT, traits>(x) != y;
+ }
+
+// Less than
+ template<typename charT, typename traits>
+ inline bool operator<(basic_string_ref<charT, traits> x, basic_string_ref<charT, traits> y) {
+ return x.compare(y) < 0;
+ }
+
+ template<typename charT, typename traits, typename Allocator>
+ inline bool operator<(basic_string_ref<charT, traits> x, const std::basic_string<charT, traits, Allocator> & y) {
+ return x < basic_string_ref<charT, traits>(y);
+ }
+
+ template<typename charT, typename traits, typename Allocator>
+ inline bool operator<(const std::basic_string<charT, traits, Allocator> & x, basic_string_ref<charT, traits> y) {
+ return basic_string_ref<charT, traits>(x) < y;
+ }
+
+ template<typename charT, typename traits>
+ inline bool operator<(basic_string_ref<charT, traits> x, const charT * y) {
+ return x < basic_string_ref<charT, traits>(y);
+ }
+
+ template<typename charT, typename traits>
+ inline bool operator<(const charT * x, basic_string_ref<charT, traits> y) {
+ return basic_string_ref<charT, traits>(x) < y;
+ }
+
+// Greater than
+ template<typename charT, typename traits>
+ inline bool operator>(basic_string_ref<charT, traits> x, basic_string_ref<charT, traits> y) {
+ return x.compare(y) > 0;
+ }
+
+ template<typename charT, typename traits, typename Allocator>
+ inline bool operator>(basic_string_ref<charT, traits> x, const std::basic_string<charT, traits, Allocator> & y) {
+ return x > basic_string_ref<charT, traits>(y);
+ }
+
+ template<typename charT, typename traits, typename Allocator>
+ inline bool operator>(const std::basic_string<charT, traits, Allocator> & x, basic_string_ref<charT, traits> y) {
+ return basic_string_ref<charT, traits>(x) > y;
+ }
+
+ template<typename charT, typename traits>
+ inline bool operator>(basic_string_ref<charT, traits> x, const charT * y) {
+ return x > basic_string_ref<charT, traits>(y);
+ }
+
+ template<typename charT, typename traits>
+ inline bool operator>(const charT * x, basic_string_ref<charT, traits> y) {
+ return basic_string_ref<charT, traits>(x) > y;
+ }
+
+// Less than or equal to
+ template<typename charT, typename traits>
+ inline bool operator<=(basic_string_ref<charT, traits> x, basic_string_ref<charT, traits> y) {
+ return x.compare(y) <= 0;
+ }
+
+ template<typename charT, typename traits, typename Allocator>
+ inline bool operator<=(basic_string_ref<charT, traits> x, const std::basic_string<charT, traits, Allocator> & y) {
+ return x <= basic_string_ref<charT, traits>(y);
+ }
+
+ template<typename charT, typename traits, typename Allocator>
+ inline bool operator<=(const std::basic_string<charT, traits, Allocator> & x, basic_string_ref<charT, traits> y) {
+ return basic_string_ref<charT, traits>(x) <= y;
+ }
+
+ template<typename charT, typename traits>
+ inline bool operator<=(basic_string_ref<charT, traits> x, const charT * y) {
+ return x <= basic_string_ref<charT, traits>(y);
+ }
+
+ template<typename charT, typename traits>
+ inline bool operator<=(const charT * x, basic_string_ref<charT, traits> y) {
+ return basic_string_ref<charT, traits>(x) <= y;
+ }
+
+// Greater than or equal to
+ template<typename charT, typename traits>
+ inline bool operator>=(basic_string_ref<charT, traits> x, basic_string_ref<charT, traits> y) {
+ return x.compare(y) >= 0;
+ }
+
+ template<typename charT, typename traits, typename Allocator>
+ inline bool operator>=(basic_string_ref<charT, traits> x, const std::basic_string<charT, traits, Allocator> & y) {
+ return x >= basic_string_ref<charT, traits>(y);
+ }
+
+ template<typename charT, typename traits, typename Allocator>
+ inline bool operator>=(const std::basic_string<charT, traits, Allocator> & x, basic_string_ref<charT, traits> y) {
+ return basic_string_ref<charT, traits>(x) >= y;
+ }
+
+ template<typename charT, typename traits>
+ inline bool operator>=(basic_string_ref<charT, traits> x, const charT * y) {
+ return x >= basic_string_ref<charT, traits>(y);
+ }
+
+ template<typename charT, typename traits>
+ inline bool operator>=(const charT * x, basic_string_ref<charT, traits> y) {
+ return basic_string_ref<charT, traits>(x) >= y;
+ }
+
+ namespace detail {
+
+ template<class charT, class traits>
+ inline void insert_fill_chars(std::basic_ostream<charT, traits>& os, std::size_t n) {
+ enum { chunk_size = 8 };
+ charT fill_chars[chunk_size];
+ std::fill_n(fill_chars, static_cast< std::size_t >(chunk_size), os.fill());
+ for (; n >= chunk_size && os.good(); n -= chunk_size)
+ os.write(fill_chars, static_cast< std::size_t >(chunk_size));
+ if (n > 0 && os.good())
+ os.write(fill_chars, n);
+ }
+
+ template<class charT, class traits>
+ void insert_aligned(std::basic_ostream<charT, traits>& os, const basic_string_ref<charT,traits>& str) {
+ const std::size_t size = str.size();
+ const std::size_t alignment_size = static_cast< std::size_t >(os.width()) - size;
+ const bool align_left = (os.flags() & std::basic_ostream<charT, traits>::adjustfield) == std::basic_ostream<charT, traits>::left;
+ if (!align_left) {
+ detail::insert_fill_chars(os, alignment_size);
+ if (os.good())
+ os.write(str.data(), size);
+ }
+ else {
+ os.write(str.data(), size);
+ if (os.good())
+ detail::insert_fill_chars(os, alignment_size);
+ }
+ }
+
+ } // namespace detail
+
+ // Inserter
+ template<class charT, class traits>
+ inline std::basic_ostream<charT, traits>&
+ operator<<(std::basic_ostream<charT, traits>& os, const basic_string_ref<charT,traits>& str) {
+ if (os.good()) {
+ const std::size_t size = str.size();
+ const std::size_t w = static_cast< std::size_t >(os.width());
+ if (w <= size)
+ os.write(str.data(), size);
+ else
+ detail::insert_aligned(os, str);
+ os.width(0);
+ }
+ return os;
+ }
+
+#if 0
+ // numeric conversions
+ //
+ // These are short-term implementations.
+ // In a production environment, I would rather avoid the copying.
+ //
+ inline int stoi (string_ref str, size_t* idx=0, int base=10) {
+ return std::stoi ( std::string(str), idx, base );
+ }
+
+ inline long stol (string_ref str, size_t* idx=0, int base=10) {
+ return std::stol ( std::string(str), idx, base );
+ }
+
+ inline unsigned long stoul (string_ref str, size_t* idx=0, int base=10) {
+ return std::stoul ( std::string(str), idx, base );
+ }
+
+ inline long long stoll (string_ref str, size_t* idx=0, int base=10) {
+ return std::stoll ( std::string(str), idx, base );
+ }
+
+ inline unsigned long long stoull (string_ref str, size_t* idx=0, int base=10) {
+ return std::stoull ( std::string(str), idx, base );
+ }
+
+ inline float stof (string_ref str, size_t* idx=0) {
+ return std::stof ( std::string(str), idx );
+ }
+
+ inline double stod (string_ref str, size_t* idx=0) {
+ return std::stod ( std::string(str), idx );
+ }
+
+ inline long double stold (string_ref str, size_t* idx=0) {
+ return std::stold ( std::string(str), idx );
+ }
+
+ inline int stoi (wstring_ref str, size_t* idx=0, int base=10) {
+ return std::stoi ( std::wstring(str), idx, base );
+ }
+
+ inline long stol (wstring_ref str, size_t* idx=0, int base=10) {
+ return std::stol ( std::wstring(str), idx, base );
+ }
+
+ inline unsigned long stoul (wstring_ref str, size_t* idx=0, int base=10) {
+ return std::stoul ( std::wstring(str), idx, base );
+ }
+
+ inline long long stoll (wstring_ref str, size_t* idx=0, int base=10) {
+ return std::stoll ( std::wstring(str), idx, base );
+ }
+
+ inline unsigned long long stoull (wstring_ref str, size_t* idx=0, int base=10) {
+ return std::stoull ( std::wstring(str), idx, base );
+ }
+
+ inline float stof (wstring_ref str, size_t* idx=0) {
+ return std::stof ( std::wstring(str), idx );
+ }
+
+ inline double stod (wstring_ref str, size_t* idx=0) {
+ return std::stod ( std::wstring(str), idx );
+ }
+
+ inline long double stold (wstring_ref str, size_t* idx=0) {
+ return std::stold ( std::wstring(str), idx );
+ }
+#endif
+
+}
+
+#if 0
+namespace std {
+ // Hashing
+ template<> struct hash<boost::string_ref>;
+ template<> struct hash<boost::u16string_ref>;
+ template<> struct hash<boost::u32string_ref>;
+ template<> struct hash<boost::wstring_ref>;
+}
+#endif
+
+#endif
diff --git a/boost/utility/string_ref_fwd.hpp b/boost/utility/string_ref_fwd.hpp
new file mode 100644
index 0000000000..f58b98c1fb
--- /dev/null
+++ b/boost/utility/string_ref_fwd.hpp
@@ -0,0 +1,37 @@
+/*
+ Copyright (c) Marshall Clow 2012-2012.
+
+ 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)
+
+ For more information, see http://www.boost.org
+
+ Based on the StringRef implementation in LLVM (http://llvm.org) and
+ N3422 by Jeffrey Yasskin
+ http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3442.html
+
+*/
+
+#ifndef BOOST_STRING_REF_FWD_HPP
+#define BOOST_STRING_REF_FWD_HPP
+
+#include <boost/config.hpp>
+#include <string>
+
+namespace boost {
+
+ template<typename charT, typename traits = std::char_traits<charT> > class basic_string_ref;
+ typedef basic_string_ref<char, std::char_traits<char> > string_ref;
+ typedef basic_string_ref<wchar_t, std::char_traits<wchar_t> > wstring_ref;
+
+#ifndef BOOST_NO_CXX11_CHAR16_T
+ typedef basic_string_ref<char16_t, std::char_traits<char16_t> > u16string_ref;
+#endif
+
+#ifndef BOOST_NO_CXX11_CHAR32_T
+ typedef basic_string_ref<char32_t, std::char_traits<char32_t> > u32string_ref;
+#endif
+
+}
+
+#endif
diff --git a/boost/utility/swap.hpp b/boost/utility/swap.hpp
index 6845e7965b..dd9ecd9070 100644
--- a/boost/utility/swap.hpp
+++ b/boost/utility/swap.hpp
@@ -1,55 +1,17 @@
-// Copyright (C) 2007, 2008 Steven Watanabe, Joseph Gauterin, Niels Dekker
-//
-// 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)
-// For more information, see http://www.boost.org
-
+/*
+ * Copyright (c) 2014 Glen Fernandes
+ *
+ * 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)
+ */
#ifndef BOOST_UTILITY_SWAP_HPP
#define BOOST_UTILITY_SWAP_HPP
-// Note: the implementation of this utility contains various workarounds:
-// - swap_impl is put outside the boost namespace, to avoid infinite
-// recursion (causing stack overflow) when swapping objects of a primitive
-// type.
-// - swap_impl has a using-directive, rather than a using-declaration,
-// because some compilers (including MSVC 7.1, Borland 5.9.3, and
-// Intel 8.1) don't do argument-dependent lookup when it has a
-// using-declaration instead.
-// - boost::swap has two template arguments, instead of one, to
-// avoid ambiguity when swapping objects of a Boost type that does
-// not have its own boost::swap overload.
-
-#include <algorithm> //for std::swap
-#include <cstddef> //for std::size_t
-
-namespace boost_swap_impl
-{
- template<class T>
- void swap_impl(T& left, T& right)
- {
- using namespace std;//use std::swap if argument dependent lookup fails
- swap(left,right);
- }
-
- template<class T, std::size_t N>
- void swap_impl(T (& left)[N], T (& right)[N])
- {
- for (std::size_t i = 0; i < N; ++i)
- {
- ::boost_swap_impl::swap_impl(left[i], right[i]);
- }
- }
-}
+// The header file at this path is deprecated;
+// use boost/core/swap.hpp instead.
-namespace boost
-{
- template<class T1, class T2>
- void swap(T1& left, T2& right)
- {
- ::boost_swap_impl::swap_impl(left, right);
- }
-}
+#include <boost/core/swap.hpp>
#endif
diff --git a/boost/utility/value_init.hpp b/boost/utility/value_init.hpp
index 5de958575e..9d8de70733 100644
--- a/boost/utility/value_init.hpp
+++ b/boost/utility/value_init.hpp
@@ -33,7 +33,6 @@
#ifdef BOOST_MSVC
#pragma warning(push)
-#if _MSC_VER >= 1310
// It is safe to ignore the following warning from MSVC 7.1 or higher:
// "warning C4351: new behavior: elements of array will be default initialized"
#pragma warning(disable: 4351)
@@ -41,7 +40,6 @@
// a const type: "warning C4512: assignment operator could not be generated".
#pragma warning(disable: 4512)
#endif
-#endif
#ifdef BOOST_NO_COMPLETE_VALUE_INITIALIZATION
// Implementation detail: The macro BOOST_DETAIL_VALUE_INIT_WORKAROUND_SUGGESTED
@@ -73,12 +71,14 @@ class initialized
#endif
remove_const<T>::type data;
+ BOOST_GPU_ENABLED
wrapper()
:
data()
{
}
+ BOOST_GPU_ENABLED
wrapper(T const & arg)
:
data(arg)
@@ -92,6 +92,7 @@ class initialized
#endif
aligned_storage<sizeof(wrapper), alignment_of<wrapper>::value>::type x;
+ BOOST_GPU_ENABLED
wrapper * wrapper_address() const
{
return static_cast<wrapper *>( static_cast<void*>(&x));
@@ -99,6 +100,7 @@ class initialized
public :
+ BOOST_GPU_ENABLED
initialized()
{
#if BOOST_DETAIL_VALUE_INIT_WORKAROUND
@@ -107,16 +109,19 @@ class initialized
new (wrapper_address()) wrapper();
}
+ BOOST_GPU_ENABLED
initialized(initialized const & arg)
{
new (wrapper_address()) wrapper( static_cast<wrapper const &>(*(arg.wrapper_address())));
}
+ BOOST_GPU_ENABLED
explicit initialized(T const & arg)
{
new (wrapper_address()) wrapper(arg);
}
+ BOOST_GPU_ENABLED
initialized & operator=(initialized const & arg)
{
// Assignment is only allowed when T is non-const.
@@ -125,31 +130,37 @@ class initialized
return *this;
}
+ BOOST_GPU_ENABLED
~initialized()
{
wrapper_address()->wrapper::~wrapper();
}
+ BOOST_GPU_ENABLED
T const & data() const
{
return wrapper_address()->data;
}
+ BOOST_GPU_ENABLED
T& data()
{
return wrapper_address()->data;
}
+ BOOST_GPU_ENABLED
void swap(initialized & arg)
{
::boost::swap( this->data(), arg.data() );
}
+ BOOST_GPU_ENABLED
operator T const &() const
{
return wrapper_address()->data;
}
+ BOOST_GPU_ENABLED
operator T&()
{
return wrapper_address()->data;
@@ -158,18 +169,21 @@ class initialized
} ;
template<class T>
+BOOST_GPU_ENABLED
T const& get ( initialized<T> const& x )
{
return x.data() ;
}
template<class T>
+BOOST_GPU_ENABLED
T& get ( initialized<T>& x )
{
return x.data() ;
}
template<class T>
+BOOST_GPU_ENABLED
void swap ( initialized<T> & lhs, initialized<T> & rhs )
{
lhs.swap(rhs) ;
@@ -185,31 +199,37 @@ class value_initialized
public :
+ BOOST_GPU_ENABLED
value_initialized()
:
m_data()
{ }
+ BOOST_GPU_ENABLED
T const & data() const
{
return m_data.data();
}
+ BOOST_GPU_ENABLED
T& data()
{
return m_data.data();
}
+ BOOST_GPU_ENABLED
void swap(value_initialized & arg)
{
m_data.swap(arg.m_data);
}
+ BOOST_GPU_ENABLED
operator T const &() const
{
return m_data;
}
+ BOOST_GPU_ENABLED
operator T&()
{
return m_data;
@@ -218,18 +238,21 @@ class value_initialized
template<class T>
+BOOST_GPU_ENABLED
T const& get ( value_initialized<T> const& x )
{
return x.data() ;
}
template<class T>
+BOOST_GPU_ENABLED
T& get ( value_initialized<T>& x )
{
return x.data() ;
}
template<class T>
+BOOST_GPU_ENABLED
void swap ( value_initialized<T> & lhs, value_initialized<T> & rhs )
{
lhs.swap(rhs) ;
@@ -240,7 +263,7 @@ class initialized_value_t
{
public :
- template <class T> operator T() const
+ template <class T> BOOST_GPU_ENABLED operator T() const
{
return initialized<T>().data();
}