mirror of
https://github.com/boostorg/fusion.git
synced 2025-07-23 17:17:23 +02:00
Add DISABLE_VARIADIC_VECTOR and SFINAE for c++11 tuple element construction
This commit is contained in:
@ -15,6 +15,7 @@
|
||||
|| defined(BOOST_NO_CXX11_RVALUE_REFERENCES) \
|
||||
|| defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) \
|
||||
|| defined(BOOST_NO_CXX11_DECLTYPE)) \
|
||||
|| defined(BOOST_FUSION_DISABLE_VARIADIC_VECTOR) \
|
||||
|| (defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES))
|
||||
# if defined(BOOST_FUSION_HAS_VARIADIC_VECTOR)
|
||||
# undef BOOST_FUSION_HAS_VARIADIC_VECTOR
|
||||
|
35
include/boost/fusion/support/detail/and.hpp
Normal file
35
include/boost/fusion/support/detail/and.hpp
Normal file
@ -0,0 +1,35 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2016 Lee Clagett
|
||||
|
||||
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 FUSION_AND_07152016_1625
|
||||
#define FUSION_AND_07152016_1625
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/type_traits/integral_constant.hpp>
|
||||
|
||||
#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
#error fusion::detail::and_ requires variadic templates
|
||||
#endif
|
||||
|
||||
namespace boost { namespace fusion { namespace detail {
|
||||
template<typename ...Cond>
|
||||
struct and_impl : false_type {};
|
||||
|
||||
template<typename ...T>
|
||||
struct and_impl<integral_constant<T, true>...> : true_type {};
|
||||
|
||||
/* fusion::detail::and_ differs from mpl::and_ in the following ways:
|
||||
- The empty set is valid and returns true
|
||||
- A single element set is valid and returns the identity
|
||||
- There is no upper bound on the set size
|
||||
- The conditions are evaluated at once, and are not short-circuited. This
|
||||
reduces instantations when returning true; the implementation is not
|
||||
recursive. */
|
||||
template<typename ...Cond>
|
||||
struct and_ : and_impl<integral_constant<bool, Cond::value>...> {};
|
||||
}}}
|
||||
|
||||
#endif // FUSION_AND_07152016_1625
|
@ -20,12 +20,15 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// C++11 interface
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#include <boost/core/enable_if.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/size.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/value_at.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/at.hpp>
|
||||
#include <boost/fusion/sequence/comparison.hpp>
|
||||
#include <boost/fusion/sequence/io.hpp>
|
||||
#include <boost/fusion/support/detail/and.hpp>
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
#include <utility>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
@ -49,13 +52,29 @@ namespace boost { namespace fusion
|
||||
tuple(tuple<U...>&& other)
|
||||
: base_type(std::move(other)) {}
|
||||
|
||||
template <typename ...U>
|
||||
template <
|
||||
typename ...U
|
||||
, typename = typename boost::enable_if_c<(
|
||||
fusion::detail::and_<is_convertible<U, T>...>::value &&
|
||||
sizeof...(U) >= 1
|
||||
)>::type
|
||||
>
|
||||
/*BOOST_CONSTEXPR*/ BOOST_FUSION_GPU_ENABLED
|
||||
explicit
|
||||
tuple(U&&... args)
|
||||
: base_type(std::forward<U>(args)...) {}
|
||||
|
||||
template <typename U>
|
||||
template<typename U1, typename U2>
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
tuple(std::pair<U1, U2> const& other)
|
||||
: base_type(other.first, other.second) {}
|
||||
|
||||
template<typename U1, typename U2>
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
tuple(std::pair<U1, U2>&& other)
|
||||
: base_type(std::move(other.first), std::move(other.second)) {}
|
||||
|
||||
template<typename U>
|
||||
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
tuple& operator=(U&& rhs)
|
||||
{
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include <boost/fusion/container/vector/detail/config.hpp>
|
||||
|
||||
#if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) \
|
||||
|| defined(BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS) \
|
||||
|| (defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES))
|
||||
# if defined(BOOST_FUSION_HAS_VARIADIC_TUPLE)
|
||||
# undef BOOST_FUSION_HAS_VARIADIC_TUPLE
|
||||
|
Reference in New Issue
Block a user