mirror of
https://github.com/boostorg/fusion.git
synced 2025-07-24 01:27:37 +02:00
Implement variadic templates based fusion::vector.
Thanks to Lee Clagett.
This commit is contained in:
@ -27,16 +27,38 @@ namespace boost { namespace fusion
|
||||
template <typename ...T>
|
||||
struct make_vector
|
||||
{
|
||||
typedef vector<typename detail::as_fusion_element<T>::type...> type;
|
||||
// make `make_vector<T..., void_...>' into `make_vector<T...>'
|
||||
template <typename, typename...> struct trim_void;
|
||||
|
||||
template <typename... U>
|
||||
struct trim_void<vector<U...> >
|
||||
{
|
||||
typedef vector<numbered_vector_tag<sizeof...(U)>, U...> type;
|
||||
};
|
||||
|
||||
template <typename... U, typename... Tail>
|
||||
struct trim_void<vector<U...>, void_, Tail...>
|
||||
: trim_void<vector<U...> > { };
|
||||
|
||||
template <typename... U, typename Head, typename... Tail>
|
||||
struct trim_void<vector<U...>, Head, Tail...>
|
||||
: trim_void<vector<U..., Head>, Tail...> { };
|
||||
|
||||
typedef
|
||||
typename trim_void<
|
||||
vector<>
|
||||
, typename detail::as_fusion_element<T>::type...
|
||||
>::type
|
||||
type;
|
||||
};
|
||||
}
|
||||
|
||||
template <typename ...T>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
inline vector<typename detail::as_fusion_element<T>::type...>
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
inline typename result_of::make_vector<T...>::type
|
||||
make_vector(T const&... arg)
|
||||
{
|
||||
return vector<typename detail::as_fusion_element<T>::type...>(arg...);
|
||||
return typename result_of::make_vector<T...>::type(arg...);
|
||||
}
|
||||
}}
|
||||
|
||||
|
@ -30,7 +30,7 @@ namespace boost { namespace fusion
|
||||
}
|
||||
|
||||
template <typename ...T>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
inline vector<T&...>
|
||||
vector_tie(T&... arg)
|
||||
{
|
||||
|
@ -20,6 +20,50 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// C++11 interface
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#include <boost/fusion/support/detail/index_sequence.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
#include <boost/fusion/iterator/value_of.hpp>
|
||||
#include <boost/fusion/iterator/deref.hpp>
|
||||
#include <boost/fusion/iterator/advance.hpp>
|
||||
#include <cstddef>
|
||||
|
||||
namespace boost { namespace fusion { namespace detail
|
||||
{
|
||||
BOOST_FUSION_BARRIER_BEGIN
|
||||
|
||||
template <typename Indices>
|
||||
struct as_vector_impl;
|
||||
|
||||
template <std::size_t ...Indices>
|
||||
struct as_vector_impl<index_sequence<Indices...> >
|
||||
{
|
||||
template <typename Iterator>
|
||||
struct apply
|
||||
{
|
||||
typedef vector<
|
||||
numbered_vector_tag<sizeof...(Indices)>
|
||||
, typename result_of::value_of<
|
||||
typename result_of::advance_c<Iterator, Indices>::type
|
||||
>::type...
|
||||
> type;
|
||||
};
|
||||
|
||||
template <typename Iterator>
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
static typename apply<Iterator>::type
|
||||
call(Iterator i)
|
||||
{
|
||||
typedef typename apply<Iterator>::type result;
|
||||
return result(*advance_c<Indices>(i)...);
|
||||
}
|
||||
};
|
||||
|
||||
template <int size>
|
||||
struct as_vector
|
||||
: as_vector_impl<typename make_index_sequence<size>::type> {};
|
||||
|
||||
BOOST_FUSION_BARRIER_END
|
||||
}}}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
@ -9,9 +9,8 @@
|
||||
|
||||
#include <boost/fusion/support/config.hpp>
|
||||
#include <boost/fusion/support/detail/access.hpp>
|
||||
#include <boost/type_traits/is_const.hpp>
|
||||
#include <boost/mpl/at.hpp>
|
||||
#include <boost/mpl/int.hpp>
|
||||
#include <boost/fusion/container/vector/detail/value_at_impl.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
@ -28,7 +27,7 @@ namespace boost { namespace fusion
|
||||
template <typename Sequence, typename N>
|
||||
struct apply
|
||||
{
|
||||
typedef typename mpl::at<typename Sequence::types, N>::type element;
|
||||
typedef typename value_at_impl<vector_tag>::template apply<Sequence, N>::type element;
|
||||
typedef typename detail::ref_result<element>::type type;
|
||||
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
@ -43,7 +42,7 @@ namespace boost { namespace fusion
|
||||
template <typename Sequence, typename N>
|
||||
struct apply <Sequence const, N>
|
||||
{
|
||||
typedef typename mpl::at<typename Sequence::types, N>::type element;
|
||||
typedef typename value_at_impl<vector_tag>::template apply<Sequence, N>::type element;
|
||||
typedef typename detail::cref_result<element>::type type;
|
||||
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2014 Kohei Takahashi
|
||||
Copyright (c) 2014-2015 Kohei Takahashi
|
||||
|
||||
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)
|
||||
@ -8,10 +8,11 @@
|
||||
#define FUSION_VECTOR_CONFIG_11052014_1720
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <boost/fusion/support/config.hpp>
|
||||
|
||||
/*
|
||||
#if (defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) \
|
||||
|| defined(BOOST_NO_CXX11_RVALUE_REFERENCES) \
|
||||
|| defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)) \
|
||||
|| (defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES))
|
||||
# if defined(BOOST_FUSION_HAS_VARIADIC_VECTOR)
|
||||
@ -22,7 +23,13 @@
|
||||
# define BOOST_FUSION_HAS_VARIADIC_VECTOR
|
||||
# endif
|
||||
#endif
|
||||
*/
|
||||
|
||||
// Sometimes, MSVC 12 shows compile error with std::size_t of template parameter.
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1800))
|
||||
# if defined(BOOST_FUSION_HAS_VARIADIC_VECTOR)
|
||||
# undef BOOST_FUSION_HAS_VARIADIC_VECTOR
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -8,8 +8,8 @@
|
||||
#define FUSION_DEREF_IMPL_05042005_1037
|
||||
|
||||
#include <boost/fusion/support/config.hpp>
|
||||
#include <boost/mpl/at.hpp>
|
||||
#include <boost/fusion/support/detail/access.hpp>
|
||||
#include <boost/fusion/container/vector/detail/value_at_impl.hpp>
|
||||
#include <boost/type_traits/is_const.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
|
||||
@ -30,9 +30,7 @@ namespace boost { namespace fusion
|
||||
{
|
||||
typedef typename Iterator::vector vector;
|
||||
typedef typename Iterator::index index;
|
||||
typedef typename mpl::at<
|
||||
typename vector::types, index>::type
|
||||
element;
|
||||
typedef typename value_at_impl<vector_tag>::template apply<vector, index>::type element;
|
||||
|
||||
typedef typename
|
||||
mpl::if_<
|
||||
|
@ -9,11 +9,60 @@
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/fusion/support/config.hpp>
|
||||
#include <boost/fusion/container/vector/detail/config.hpp>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Without variadics, we will use the PP version
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR)
|
||||
# include <boost/fusion/container/vector/detail/cpp03/value_at_impl.hpp>
|
||||
#else
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// C++11 interface
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#include <cstddef>
|
||||
#include <boost/fusion/container/vector/vector_fwd.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct vector_tag;
|
||||
|
||||
namespace vector_detail
|
||||
{
|
||||
template <typename I, typename ...T>
|
||||
struct vector_data;
|
||||
}
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template <typename Tag>
|
||||
struct value_at_impl;
|
||||
|
||||
template <>
|
||||
struct value_at_impl<vector_tag>
|
||||
{
|
||||
template <typename V, std::size_t N>
|
||||
struct apply_impl;
|
||||
|
||||
template <typename H, typename ...T>
|
||||
struct apply_impl<vector<H, T...>, 0>
|
||||
{
|
||||
typedef H type;
|
||||
};
|
||||
|
||||
template <typename H, typename ...T, std::size_t N>
|
||||
struct apply_impl<vector<H, T...>, N>
|
||||
: apply_impl<vector<T...>, N - 1>
|
||||
{};
|
||||
|
||||
template <typename Sequence, typename N>
|
||||
struct apply : apply_impl<typename Sequence::type_sequence, N::value>
|
||||
{};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
#define FUSION_VALUE_OF_IMPL_05052005_1128
|
||||
|
||||
#include <boost/fusion/support/config.hpp>
|
||||
#include <boost/mpl/at.hpp>
|
||||
#include <boost/fusion/container/vector/detail/value_at_impl.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
@ -27,9 +27,7 @@ namespace boost { namespace fusion
|
||||
{
|
||||
typedef typename Iterator::vector vector;
|
||||
typedef typename Iterator::index index;
|
||||
typedef typename mpl::at<
|
||||
typename vector::types, index>::type
|
||||
type;
|
||||
typedef typename value_at_impl<vector_tag>::template apply<vector, index>::type type;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2014 Kohei Takahashi
|
||||
Copyright (c) 2014-2015 Kohei Takahashi
|
||||
|
||||
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)
|
||||
@ -7,6 +7,7 @@
|
||||
#ifndef FUSION_VECTOR_11052014_1625
|
||||
#define FUSION_VECTOR_11052014_1625
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/fusion/support/config.hpp>
|
||||
#include <boost/fusion/container/vector/detail/config.hpp>
|
||||
#include <boost/fusion/container/vector/vector_fwd.hpp>
|
||||
@ -21,6 +22,334 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// C++11 interface
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#include <boost/fusion/support/sequence_base.hpp>
|
||||
#include <boost/fusion/support/is_sequence.hpp>
|
||||
#include <boost/fusion/support/detail/index_sequence.hpp>
|
||||
#include <boost/fusion/container/vector/detail/at_impl.hpp>
|
||||
#include <boost/fusion/container/vector/detail/value_at_impl.hpp>
|
||||
#include <boost/fusion/container/vector/detail/begin_impl.hpp>
|
||||
#include <boost/fusion/container/vector/detail/end_impl.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/size.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/begin.hpp>
|
||||
#include <boost/fusion/iterator/advance.hpp>
|
||||
#include <boost/fusion/iterator/deref.hpp>
|
||||
#include <boost/core/enable_if.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/mpl/int.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/type_traits/remove_cv.hpp>
|
||||
#include <boost/type_traits/remove_reference.hpp>
|
||||
#include <cstddef>
|
||||
#include <utility>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct vector_tag;
|
||||
struct random_access_traversal_tag;
|
||||
|
||||
namespace vector_detail
|
||||
{
|
||||
struct each_elem {};
|
||||
struct copy_or_move {};
|
||||
template <typename I> struct from_sequence {};
|
||||
|
||||
template <typename Sequence>
|
||||
struct make_indices_from_seq
|
||||
: detail::make_index_sequence<
|
||||
fusion::result_of::size<typename remove_reference<Sequence>::type>::value
|
||||
>
|
||||
{};
|
||||
|
||||
template <typename T>
|
||||
struct pure : remove_cv<typename remove_reference<T>::type> {};
|
||||
|
||||
template <typename This, typename ...T>
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
inline each_elem
|
||||
dispatch( T const&... ) BOOST_NOEXCEPT { return each_elem(); }
|
||||
|
||||
template <typename This>
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
inline copy_or_move
|
||||
dispatch( This const& ) BOOST_NOEXCEPT { return copy_or_move(); }
|
||||
|
||||
template <typename This, typename Sequence>
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
inline from_sequence<
|
||||
typename lazy_enable_if_c<
|
||||
(traits::is_sequence<Sequence>::value &&
|
||||
!is_same<This, Sequence>::value)
|
||||
, make_indices_from_seq<Sequence>
|
||||
>::type
|
||||
>
|
||||
dispatch( Sequence const& ) BOOST_NOEXCEPT
|
||||
{ return from_sequence<typename make_indices_from_seq<Sequence>::type>(); }
|
||||
|
||||
|
||||
// forward_at_c allows to access Nth element even if ForwardSequence
|
||||
// since fusion::at_c requires RandomAccessSequence.
|
||||
namespace result_of
|
||||
{
|
||||
template <typename Sequence, int N>
|
||||
struct forward_at_c
|
||||
: fusion::result_of::deref<
|
||||
typename fusion::result_of::advance_c<
|
||||
typename fusion::result_of::begin<
|
||||
typename remove_reference<Sequence>::type
|
||||
>::type
|
||||
, N
|
||||
>::type
|
||||
>
|
||||
{};
|
||||
}
|
||||
|
||||
template <int N, typename Sequence>
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
inline typename result_of::forward_at_c<Sequence, N>::type
|
||||
forward_at_c(Sequence&& seq)
|
||||
{
|
||||
typedef typename
|
||||
result_of::forward_at_c<Sequence, N>::type
|
||||
result;
|
||||
return std::forward<result>(*advance_c<N>(begin(seq)));
|
||||
}
|
||||
|
||||
// Object proxy since preserve object order
|
||||
template <std::size_t, typename T>
|
||||
struct store
|
||||
{
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
store()
|
||||
: elem() // value-initialized explicitly
|
||||
{}
|
||||
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
store(store const& rhs)
|
||||
: elem(rhs.get())
|
||||
{}
|
||||
|
||||
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
store&
|
||||
operator=(store const& rhs)
|
||||
{
|
||||
elem = rhs.get();
|
||||
return *this;
|
||||
}
|
||||
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
store(store&& rhs)
|
||||
: elem(static_cast<T&&>(rhs.get()))
|
||||
{}
|
||||
|
||||
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
store&
|
||||
operator=(store&& rhs)
|
||||
{
|
||||
elem = static_cast<T&&>(rhs.get());
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename U>
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
store(U&& rhs
|
||||
, typename disable_if<is_same<typename pure<U>::type, store> >::type* = 0)
|
||||
: elem(std::forward<U>(rhs))
|
||||
{}
|
||||
|
||||
template <typename U>
|
||||
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
typename disable_if<is_same<typename pure<U>::type, store>, store&>::type
|
||||
operator=(U&& rhs)
|
||||
{
|
||||
elem = std::forward<U>(rhs);
|
||||
return *this;
|
||||
}
|
||||
|
||||
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
T & get() { return elem; }
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
T const& get() const { return elem; }
|
||||
|
||||
T elem;
|
||||
};
|
||||
|
||||
template <typename I, typename ...T>
|
||||
struct vector_data;
|
||||
|
||||
template <std::size_t ...I, typename ...T>
|
||||
struct vector_data<detail::index_sequence<I...>, T...>
|
||||
: store<I, T>...
|
||||
, sequence_base<vector_data<detail::index_sequence<I...>, T...> >
|
||||
{
|
||||
typedef vector_tag fusion_tag;
|
||||
typedef fusion_sequence_tag tag; // this gets picked up by MPL
|
||||
typedef mpl::false_ is_view;
|
||||
typedef random_access_traversal_tag category;
|
||||
typedef mpl::int_<sizeof...(T)> size;
|
||||
typedef vector<T...> type_sequence;
|
||||
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
vector_data()
|
||||
{}
|
||||
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
vector_data(copy_or_move, vector_data const& rhs)
|
||||
: store<I, T>(static_cast<store<I, T> const&>(rhs))...
|
||||
{}
|
||||
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
vector_data(copy_or_move, vector_data&& rhs)
|
||||
: store<I, T>(std::forward<store<I, T> >(rhs))...
|
||||
{}
|
||||
|
||||
template <typename Sequence>
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
explicit
|
||||
vector_data(from_sequence<detail::index_sequence<I...> >, Sequence&& rhs)
|
||||
: store<I, T>(forward_at_c<I>(rhs))...
|
||||
{}
|
||||
|
||||
template <typename ...U>
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
explicit
|
||||
vector_data(each_elem, U&&... var)
|
||||
: store<I, T>(std::forward<U>(var))...
|
||||
{}
|
||||
|
||||
template <typename Sequence>
|
||||
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
void
|
||||
assign(Sequence&&, detail::index_sequence<>) {}
|
||||
|
||||
template <typename Sequence, std::size_t N, std::size_t ...M>
|
||||
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
void
|
||||
assign(Sequence&& seq, detail::index_sequence<N, M...>)
|
||||
{
|
||||
at_impl(mpl::int_<N>()) = vector_detail::forward_at_c<N>(seq);
|
||||
assign(std::forward<Sequence>(seq), detail::index_sequence<M...>());
|
||||
}
|
||||
|
||||
typedef extension::value_at_impl<vector_tag> value_at_impl;
|
||||
|
||||
template <typename J>
|
||||
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
typename value_at_impl::template apply<vector_data, J>::type&
|
||||
at_impl(J)
|
||||
{
|
||||
typedef typename value_at_impl::template apply<vector_data, J>::type U;
|
||||
typedef store<J::value, U> S;
|
||||
return static_cast<S*>(this)->get();
|
||||
}
|
||||
|
||||
template <typename J>
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
typename value_at_impl::template apply<vector_data, J>::type const&
|
||||
at_impl(J) const
|
||||
{
|
||||
typedef typename value_at_impl::template apply<vector_data, J>::type U;
|
||||
typedef store<J::value, U> S;
|
||||
return static_cast<S const*>(this)->get();
|
||||
}
|
||||
};
|
||||
|
||||
// Internal use only specialization for implementing vectorN.
|
||||
// Simple aliasing (like a using vectorN = vector<T...>) will cause specialization confliction
|
||||
// like following.
|
||||
//
|
||||
// template <typename> struct SomeClass;
|
||||
// template <typename T> struct SomeClass<vector<T>> { ... };
|
||||
// template <typename T>
|
||||
// struct SomeClass<vector1<T>> // Error, since vector<T> and vector1<T> are exact same type.
|
||||
// { ... };
|
||||
//
|
||||
// Introducing `numbered_vector_tag` will resolve such specialization error.
|
||||
//
|
||||
// template <typename T>
|
||||
// struct SomeClass<vector<T>> { ... };
|
||||
// template <typename T>
|
||||
// struct SomeClass<vector1<T>> // OK
|
||||
// { ... };
|
||||
//
|
||||
// // Same meaning as above specialization.
|
||||
// template <typename T>
|
||||
// struct SomeClass<vector<numbered_vector_tag<1>, T>>
|
||||
// { ... };
|
||||
template <std::size_t ...I, std::size_t N, typename ...T>
|
||||
struct vector_data<detail::index_sequence<I...>, numbered_vector_tag<N>, T...>
|
||||
: vector_data<typename detail::make_index_sequence<sizeof...(T)>::type, T...>
|
||||
{
|
||||
typedef vector_data<typename detail::make_index_sequence<sizeof...(T)>::type, T...> base;
|
||||
|
||||
BOOST_STATIC_ASSERT((base::size::value == N));
|
||||
|
||||
template <typename ...U>
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
vector_data(U&&... var)
|
||||
: base(std::forward<U>(var)...)
|
||||
{}
|
||||
};
|
||||
|
||||
template <typename V, typename... T>
|
||||
struct construct_vector_;
|
||||
|
||||
template <typename... T>
|
||||
struct construct_vector_<vector<T...> >
|
||||
{
|
||||
typedef vector_data<
|
||||
typename detail::make_index_sequence<sizeof...(T)>::type
|
||||
, T...
|
||||
> type;
|
||||
};
|
||||
|
||||
template <typename... U, typename... Tail>
|
||||
struct construct_vector_<vector<U...>, void_, Tail...>
|
||||
: construct_vector_<vector<U...> > {};
|
||||
|
||||
template <typename... U, typename Head, typename... Tail>
|
||||
struct construct_vector_<vector<U...>, Head, Tail...>
|
||||
: construct_vector_<vector<U..., Head>, Tail...> {};
|
||||
|
||||
template <typename... T>
|
||||
struct construct_vector : construct_vector_<vector<>, T...> {};
|
||||
} // namespace boost::fusion::vector_detail
|
||||
|
||||
// This class provides backward compatibility: vector<T, ..., void_, void_, ...>.
|
||||
template <typename... T>
|
||||
struct vector
|
||||
: vector_detail::construct_vector<T...>::type
|
||||
{
|
||||
typedef typename vector_detail::construct_vector<T...>::type base;
|
||||
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
vector()
|
||||
{}
|
||||
|
||||
// rvalue-references is required here in order to forward any arguments to
|
||||
// base: vector(T const&...) doesn't work with trailing void_ and
|
||||
// vector(U const&...) cannot forward any arguments to base.
|
||||
template <typename... U>
|
||||
// XXX: constexpr become error due to pull-request #79, booooo!!
|
||||
// In the (near) future release, should be fixed.
|
||||
/* BOOST_CONSTEXPR */ BOOST_FUSION_GPU_ENABLED
|
||||
vector(U&&... u)
|
||||
: base(vector_detail::dispatch<vector>(u...), std::forward<U>(u)...)
|
||||
{}
|
||||
|
||||
template <typename Sequence>
|
||||
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
vector&
|
||||
operator=(Sequence&& rhs)
|
||||
{
|
||||
typedef typename
|
||||
vector_detail::make_indices_from_seq<Sequence>::type
|
||||
indices;
|
||||
base::assign(std::forward<Sequence>(rhs), indices());
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
}}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
@ -21,6 +21,8 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// C++11 interface
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#include <boost/fusion/container/vector/vector_fwd.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
@ -21,6 +21,8 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// C++11 interface
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#include <boost/fusion/container/vector/vector_fwd.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
@ -21,6 +21,8 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// C++11 interface
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#include <boost/fusion/container/vector/vector_fwd.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
@ -21,6 +21,8 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// C++11 interface
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#include <boost/fusion/container/vector/vector_fwd.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
@ -21,6 +21,8 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// C++11 interface
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#include <boost/fusion/container/vector/vector_fwd.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
@ -21,10 +21,25 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// C++11 interface
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#include <boost/preprocessor/cat.hpp>
|
||||
#include <boost/preprocessor/repetition/repeat.hpp>
|
||||
#include <cstddef>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
template <typename ...T>
|
||||
struct vector;
|
||||
|
||||
template <std::size_t N>
|
||||
struct numbered_vector_tag;
|
||||
|
||||
#define FUSION_VECTOR_N_ALIASES(z, N, d) \
|
||||
template <typename ...T> \
|
||||
using BOOST_PP_CAT(vector, N) = vector<numbered_vector_tag<N>, T...>;
|
||||
|
||||
BOOST_PP_REPEAT(51, FUSION_VECTOR_N_ALIASES, ~)
|
||||
|
||||
#undef FUSION_VECTOR_N_ALIASES
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user