adding working converting ctors for zero length sequences

[SVN r38155]
This commit is contained in:
Dan Marsden
2007-07-06 20:47:11 +00:00
parent d20847afd7
commit 3612acb0ef
4 changed files with 41 additions and 1 deletions

View File

@ -20,20 +20,23 @@
#include <boost/preprocessor/repetition/enum_params_with_a_default.hpp>
#include <boost/type_traits/add_reference.hpp>
#include <boost/type_traits/add_const.hpp>
#include <boost/type_traits/is_convertible.hpp>
#include <boost/fusion/sequence/container/deque/deque_fwd.hpp>
#include <boost/fusion/sequence/container/deque/detail/value_at_impl.hpp>
#include <boost/fusion/sequence/container/deque/detail/at_impl.hpp>
#include <boost/fusion/sequence/container/deque/detail/begin_impl.hpp>
#include <boost/fusion/sequence/container/deque/detail/end_impl.hpp>
#include <boost/fusion/sequence/intrinsic/begin.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/fusion/support/sequence_base.hpp>
#include <boost/fusion/support/void.hpp>
#include <boost/utility/enable_if.hpp>
namespace boost { namespace fusion {
struct deque_tag;
struct void_;
template<BOOST_PP_ENUM_PARAMS(FUSION_MAX_DEQUE_SIZE, typename T)>
struct deque
@ -63,6 +66,11 @@ namespace boost { namespace fusion {
: base(seq)
{}
template<typename Sequence>
deque(Sequence const& seq, typename disable_if<is_convertible<Sequence, T0> >::type* dummy = 0)
: base(base::from_iterator(fusion::begin(seq)))
{}
template <BOOST_PP_ENUM_PARAMS(FUSION_MAX_DEQUE_SIZE, typename U)>
deque&
operator=(deque<BOOST_PP_ENUM_PARAMS(FUSION_MAX_DEQUE_SIZE, U)> const& rhs)

View File

@ -11,6 +11,9 @@
#include <boost/type_traits/add_reference.hpp>
#include <boost/type_traits/add_const.hpp>
#include <boost/fusion/iterator/deref.hpp>
#include <boost/fusion/iterator/next.hpp>
namespace boost { namespace fusion {
struct fusion_sequence_tag;
@ -21,6 +24,13 @@ namespace detail {
{
typedef fusion_sequence_tag tag;
void get();
template<typename It>
static nil_keyed_element
from_iterator(It const&)
{
return nil_keyed_element();
}
};
template<typename Key, typename Value, typename Rest>
@ -31,6 +41,14 @@ namespace detail {
typedef fusion_sequence_tag tag;
using Rest::get;
template<typename It>
static keyed_element
from_iterator(It const& it)
{
return keyed_element(
*it, base::from_iterator(fusion::next(it)));
}
template<typename U, typename Rst>
keyed_element(keyed_element<Key, U, Rst> const& rhs)
: Rest(rhs.get_base()), value_(rhs.value_)

View File

@ -47,6 +47,12 @@ namespace boost { namespace fusion
typedef mpl::false_ is_view;
typedef random_access_traversal_tag category;
typedef mpl::int_<0> size;
vector0() {}
template<typename Sequence>
vector0(Sequence const& seq)
{}
};
// expand vector1 to vector10

View File

@ -0,0 +1,8 @@
#if !defined(BOOST_FUSION_SUPPORT_VOID_20070706_2125)
#define BOOST_FUSION_SUPPORT_VOID_20070706_2125
namespace boost { namespace fusion {
struct void_ {};
}}
#endif