forked from boostorg/fusion
adding fusion docs and tests
[SVN r34920]
This commit is contained in:
18
example/extension/Jamfile.v2
Normal file
18
example/extension/Jamfile.v2
Normal file
@ -0,0 +1,18 @@
|
||||
#==============================================================================
|
||||
# Copyright (c) 2003-2006 Joel de Guzman
|
||||
# Copyright (c) 2006 Dan Marsden
|
||||
#
|
||||
# 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)
|
||||
#==============================================================================
|
||||
|
||||
# bring in rules for testing
|
||||
import testing ;
|
||||
|
||||
{
|
||||
test-suite example :
|
||||
|
||||
[ run test_example.cpp : : : : ] ;
|
||||
}
|
||||
|
45
example/extension/detail/advance_impl.hpp
Normal file
45
example/extension/detail/advance_impl.hpp
Normal file
@ -0,0 +1,45 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2006 Dan Marsden
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(BOOST_FUSION_ADVANCE_IMPL_20060222_2150)
|
||||
#define BOOST_FUSION_ADVANCE_IMPL_20060222_2150
|
||||
|
||||
namespace boost { namespace fusion {
|
||||
|
||||
struct example_struct_iterator_tag;
|
||||
|
||||
template<typename Struct, int Pos>
|
||||
struct example_struct_iterator;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template<typename Tag>
|
||||
struct advance_impl;
|
||||
|
||||
template<>
|
||||
struct advance_impl<example_struct_iterator_tag>
|
||||
{
|
||||
template<typename Iterator, typename N>
|
||||
struct apply
|
||||
{
|
||||
typedef typename Iterator::struct_type struct_type;
|
||||
typedef typename Iterator::index index;
|
||||
typedef example_struct_iterator<
|
||||
struct_type, index::value + N::value> type;
|
||||
|
||||
static type
|
||||
call(Iterator const& it)
|
||||
{
|
||||
return type(it.struct_);
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
65
example/extension/detail/at_impl.hpp
Normal file
65
example/extension/detail/at_impl.hpp
Normal file
@ -0,0 +1,65 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2005-2006 Dan Marsden
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(BOOST_FUSION_AT_IMPL_20060223_2017)
|
||||
#define BOOST_FUSION_AT_IMPL_20060223_2017
|
||||
|
||||
#include <string>
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/mpl/int.hpp>
|
||||
#include <boost/type_traits/is_const.hpp>
|
||||
|
||||
namespace boost { namespace fusion {
|
||||
|
||||
struct example_sequence_tag;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template<typename Tag>
|
||||
struct at_impl;
|
||||
|
||||
template<>
|
||||
struct at_impl<example_sequence_tag>
|
||||
{
|
||||
template<typename Sequence, typename Key>
|
||||
struct apply;
|
||||
|
||||
template<typename Sequence>
|
||||
struct apply<Sequence, mpl::int_<0> >
|
||||
{
|
||||
typedef typename mpl::if_<
|
||||
is_const<Sequence>,
|
||||
std::string const&,
|
||||
std::string&>::type type;
|
||||
|
||||
static type
|
||||
call(Sequence& seq)
|
||||
{
|
||||
return seq.name;
|
||||
};
|
||||
};
|
||||
|
||||
template<typename Sequence>
|
||||
struct apply<Sequence, mpl::int_<1> >
|
||||
{
|
||||
typedef typename mpl::if_<
|
||||
is_const<Sequence>,
|
||||
int const&,
|
||||
int&>::type type;
|
||||
|
||||
static type
|
||||
call(Sequence& seq)
|
||||
{
|
||||
return seq.age;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
70
example/extension/detail/at_key_impl.hpp
Normal file
70
example/extension/detail/at_key_impl.hpp
Normal file
@ -0,0 +1,70 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2005-2006 Dan Marsden
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(BOOST_FUSION_AT_KEY_IMPL_20060223_2017)
|
||||
#define BOOST_FUSION_AT_KEY_IMPL_20060223_2017
|
||||
|
||||
#include <string>
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/type_traits/is_const.hpp>
|
||||
|
||||
namespace fields
|
||||
{
|
||||
struct name;
|
||||
struct age;
|
||||
}
|
||||
|
||||
namespace boost { namespace fusion {
|
||||
|
||||
struct example_sequence_tag;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template<typename Tag>
|
||||
struct at_key_impl;
|
||||
|
||||
template<>
|
||||
struct at_key_impl<example_sequence_tag>
|
||||
{
|
||||
template<typename Sequence, typename Key>
|
||||
struct apply;
|
||||
|
||||
template<typename Sequence>
|
||||
struct apply<Sequence, fields::name>
|
||||
{
|
||||
typedef typename mpl::if_<
|
||||
is_const<Sequence>,
|
||||
std::string const&,
|
||||
std::string&>::type type;
|
||||
|
||||
static type
|
||||
call(Sequence& seq)
|
||||
{
|
||||
return seq.name;
|
||||
};
|
||||
};
|
||||
|
||||
template<typename Sequence>
|
||||
struct apply<Sequence, fields::age>
|
||||
{
|
||||
typedef typename mpl::if_<
|
||||
is_const<Sequence>,
|
||||
int const&,
|
||||
int&>::type type;
|
||||
|
||||
static type
|
||||
call(Sequence& seq)
|
||||
{
|
||||
return seq.age;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
41
example/extension/detail/begin_impl.hpp
Normal file
41
example/extension/detail/begin_impl.hpp
Normal file
@ -0,0 +1,41 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2005-2006 Dan Marsden
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(BOOST_FUSION_BEGIN_IMPL_20060222_2042)
|
||||
#define BOOST_FUSION_BEGIN_IMPL_20060222_2042
|
||||
|
||||
#include "../example_struct_iterator.hpp"
|
||||
|
||||
namespace boost { namespace fusion {
|
||||
|
||||
struct example_sequence_tag;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template<typename Tag>
|
||||
struct begin_impl;
|
||||
|
||||
template<>
|
||||
struct begin_impl<example_sequence_tag>
|
||||
{
|
||||
template<typename Sequence>
|
||||
struct apply
|
||||
{
|
||||
typedef example_struct_iterator<Sequence, 0> type;
|
||||
|
||||
static type
|
||||
call(Sequence& seq)
|
||||
{
|
||||
return type(seq);
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
33
example/extension/detail/category_of_impl.hpp
Normal file
33
example/extension/detail/category_of_impl.hpp
Normal file
@ -0,0 +1,33 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2005-2006 Dan Marsden
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(BOOST_FUSION_CATEGORY_OF_IMPL_20060223_2037)
|
||||
#define BOOST_FUSION_CATEGORY_OF_IMPL_20060223_2037
|
||||
|
||||
namespace boost { namespace fusion {
|
||||
|
||||
struct random_access_traversal_tag;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template<typename Tag>
|
||||
struct category_of_impl;
|
||||
|
||||
template<>
|
||||
struct category_of_impl<example_sequence_tag>
|
||||
{
|
||||
template<typename Sequence>
|
||||
struct apply
|
||||
{
|
||||
typedef random_access_traversal_tag type;
|
||||
};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
65
example/extension/detail/deref_impl.hpp
Normal file
65
example/extension/detail/deref_impl.hpp
Normal file
@ -0,0 +1,65 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2006 Dan Marsden
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(BOOST_FUSION_DEREF_IMPL_20060222_1952)
|
||||
#define BOOST_FUSION_DEREF_IMPL_20060222_1952
|
||||
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/type_traits/is_const.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace boost { namespace fusion {
|
||||
|
||||
struct example_struct_iterator_tag;
|
||||
|
||||
template<typename Struct, int Pos>
|
||||
struct example_struct_iterator;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template<typename Tag>
|
||||
struct deref_impl;
|
||||
|
||||
template<>
|
||||
struct deref_impl<example_struct_iterator_tag>
|
||||
{
|
||||
template<typename Iterator>
|
||||
struct apply;
|
||||
|
||||
template<typename Struct>
|
||||
struct apply<example_struct_iterator<Struct, 0> >
|
||||
{
|
||||
typedef typename mpl::if_<
|
||||
is_const<Struct>, std::string const&, std::string&>::type type;
|
||||
|
||||
static type
|
||||
call(example_struct_iterator<Struct, 0> const& it)
|
||||
{
|
||||
return it.struct_.name;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Struct>
|
||||
struct apply<example_struct_iterator<Struct, 1> >
|
||||
{
|
||||
typedef typename mpl::if_<
|
||||
is_const<Struct>, int const&, int&>::type type;
|
||||
|
||||
static type
|
||||
call(example_struct_iterator<Struct, 1> const& it)
|
||||
{
|
||||
return it.struct_.age;
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
42
example/extension/detail/distance_impl.hpp
Normal file
42
example/extension/detail/distance_impl.hpp
Normal file
@ -0,0 +1,42 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2006 Dan Marsden
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(BOOST_FUSION_DISTANCE_IMPL_20060223_0814)
|
||||
#define BOOST_FUSION_DISTANCE_IMPL_20060223_0814
|
||||
|
||||
#include <boost/mpl/minus.hpp>
|
||||
|
||||
namespace boost { namespace fusion {
|
||||
|
||||
struct example_struct_iterator_tag;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template<typename Tag>
|
||||
struct distance_impl;
|
||||
|
||||
template<>
|
||||
struct distance_impl<example_struct_iterator_tag>
|
||||
{
|
||||
template<typename First, typename Last>
|
||||
struct apply
|
||||
: mpl::minus<typename Last::index, typename First::index>
|
||||
{
|
||||
typedef apply<First, Last> self;
|
||||
|
||||
static typename self::type
|
||||
call(First const& first, Last const& last)
|
||||
{
|
||||
return typename self::type();
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
41
example/extension/detail/end_impl.hpp
Normal file
41
example/extension/detail/end_impl.hpp
Normal file
@ -0,0 +1,41 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2005-2006 Dan Marsden
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(BOOST_FUSION_END_IMPL_20060222_2042)
|
||||
#define BOOST_FUSION_END_IMPL_20060222_2042
|
||||
|
||||
#include "../example_struct_iterator.hpp"
|
||||
|
||||
namespace boost { namespace fusion {
|
||||
|
||||
struct example_sequence_tag;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template<typename Tag>
|
||||
struct end_impl;
|
||||
|
||||
template<>
|
||||
struct end_impl<example_sequence_tag>
|
||||
{
|
||||
template<typename Sequence>
|
||||
struct apply
|
||||
{
|
||||
typedef example_struct_iterator<Sequence, 2> type;
|
||||
|
||||
static type
|
||||
call(Sequence& seq)
|
||||
{
|
||||
return type(seq);
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
36
example/extension/detail/equal_to_impl.hpp
Normal file
36
example/extension/detail/equal_to_impl.hpp
Normal file
@ -0,0 +1,36 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2006 Dan Marsden
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(BOOST_FUSION_EQUAL_TO_IMPL_20060223_1941)
|
||||
#define BOOST_FUSION_EQUAL_TO_IMPL_20060223_1941
|
||||
|
||||
#include <boost/mpl/equal_to.hpp>
|
||||
|
||||
namespace boost { namespace fusion {
|
||||
|
||||
struct example_struct_iterator_tag;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template<typename Tag>
|
||||
struct equal_to_impl;
|
||||
|
||||
template<>
|
||||
struct equal_to_impl<example_struct_iterator_tag>
|
||||
{
|
||||
template<typename It1, typename It2>
|
||||
struct apply
|
||||
: mpl::equal_to<
|
||||
typename It1::index,
|
||||
typename It2::index>
|
||||
{};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
43
example/extension/detail/has_key_impl.hpp
Normal file
43
example/extension/detail/has_key_impl.hpp
Normal file
@ -0,0 +1,43 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2005-2006 Dan Marsden
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(BOOST_FUSION_HAS_KEY_IMPL_20060223_2156)
|
||||
#define BOOST_FUSION_HAS_KEY_IMPL_20060223_2156
|
||||
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/mpl/or.hpp>
|
||||
|
||||
namespace fields
|
||||
{
|
||||
struct name;
|
||||
struct age;
|
||||
}
|
||||
|
||||
namespace boost { namespace fusion {
|
||||
|
||||
struct example_sequence_tag;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template<typename Tag>
|
||||
struct has_key_impl;
|
||||
|
||||
template<>
|
||||
struct has_key_impl<example_sequence_tag>
|
||||
{
|
||||
template<typename Sequence, typename Key>
|
||||
struct apply
|
||||
: mpl::or_<
|
||||
is_same<Key, fields::name>,
|
||||
is_same<Key, fields::age> >
|
||||
{};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
34
example/extension/detail/is_associative_impl.hpp
Normal file
34
example/extension/detail/is_associative_impl.hpp
Normal file
@ -0,0 +1,34 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2006 Dan Marsden
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(BOOST_FUSION_IS_ASSOCIATIVE_IMPL_20060304_2324)
|
||||
#define BOOST_FUSION_IS_ASSOCIATIVE_IMPL_20060304_2324
|
||||
|
||||
#include <boost/mpl/bool.hpp>
|
||||
|
||||
namespace boost { namespace fusion {
|
||||
|
||||
struct example_sequence_tag;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template<typename Tag>
|
||||
struct is_associative_impl;
|
||||
|
||||
template<>
|
||||
struct is_associative_impl<example_sequence_tag>
|
||||
{
|
||||
template<typename Seq>
|
||||
struct apply
|
||||
: mpl::true_
|
||||
{};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
32
example/extension/detail/is_sequence_impl.hpp
Normal file
32
example/extension/detail/is_sequence_impl.hpp
Normal file
@ -0,0 +1,32 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2005-2006 Dan Marsden
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(BOOST_FUSION_IS_SEQUENCE_IMPL_20060228_1946)
|
||||
#define BOOST_FUSION_IS_SEQUENCE_IMPL_20060228_1946
|
||||
|
||||
#include <boost/mpl/bool.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct example_sequence_tag;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template<typename Tag>
|
||||
struct is_sequence_impl;
|
||||
|
||||
template<>
|
||||
struct is_sequence_impl<example_sequence_tag>
|
||||
{
|
||||
template<typename T>
|
||||
struct apply : mpl::true_ {};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
30
example/extension/detail/is_view_impl.hpp
Normal file
30
example/extension/detail/is_view_impl.hpp
Normal file
@ -0,0 +1,30 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2005-2006 Dan Marsden
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(BOOST_FUSION_IS_VIEW_IMPL_200604227_2150)
|
||||
#define BOOST_FUSION_IS_VIEW_IMPL_200604227_2150
|
||||
|
||||
#include <boost/mpl/bool.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct example_sequence_tag;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template<typename Tag>
|
||||
struct is_view_impl;
|
||||
|
||||
template<>
|
||||
struct is_view_impl<example_sequence_tag>
|
||||
: boost::mpl::false_
|
||||
{};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
44
example/extension/detail/next_impl.hpp
Normal file
44
example/extension/detail/next_impl.hpp
Normal file
@ -0,0 +1,44 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2006 Dan Marsden
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(BOOST_FUSION_NEXT_IMPL_20060222_1859)
|
||||
#define BOOST_FUSION_NEXT_IMPL_20060222_1859
|
||||
|
||||
namespace boost { namespace fusion {
|
||||
|
||||
struct example_struct_iterator_tag;
|
||||
|
||||
template<typename Struct, int Pos>
|
||||
struct example_struct_iterator;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template<typename Tag>
|
||||
struct next_impl;
|
||||
|
||||
template<>
|
||||
struct next_impl<example_struct_iterator_tag>
|
||||
{
|
||||
template<typename Iterator>
|
||||
struct apply
|
||||
{
|
||||
typedef typename Iterator::struct_type struct_type;
|
||||
typedef typename Iterator::index index;
|
||||
typedef example_struct_iterator<struct_type, index::value + 1> type;
|
||||
|
||||
static type
|
||||
call(Iterator const& i)
|
||||
{
|
||||
return type(i.struct_);
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
44
example/extension/detail/prior_impl.hpp
Normal file
44
example/extension/detail/prior_impl.hpp
Normal file
@ -0,0 +1,44 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2006 Dan Marsden
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(BOOST_FUSION_PRIOR_IMPL_20060222_1944)
|
||||
#define BOOST_FUSION_PRIOR_IMPL_20060222_1944
|
||||
|
||||
namespace boost { namespace fusion {
|
||||
|
||||
struct example_struct_iterator_tag;
|
||||
|
||||
template<typename Struct, int Pos>
|
||||
struct example_struct_iterator;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template<typename Tag>
|
||||
struct prior_impl;
|
||||
|
||||
template<>
|
||||
struct prior_impl<example_struct_iterator_tag>
|
||||
{
|
||||
template<typename Iterator>
|
||||
struct apply
|
||||
{
|
||||
typedef typename Iterator::struct_type struct_type;
|
||||
typedef typename Iterator::index index;
|
||||
typedef example_struct_iterator<struct_type, index::value - 1> type;
|
||||
|
||||
static type
|
||||
call(Iterator const& i)
|
||||
{
|
||||
return type(i.struct_);
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
34
example/extension/detail/size_impl.hpp
Normal file
34
example/extension/detail/size_impl.hpp
Normal file
@ -0,0 +1,34 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2005-2006 Dan Marsden
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(BOOST_FUSION_SIZE_IMPL_20060223_2033)
|
||||
#define BOOST_FUSION_SIZE_IMPL_20060223_2033
|
||||
|
||||
#include <boost/mpl/int.hpp>
|
||||
|
||||
namespace boost { namespace fusion {
|
||||
|
||||
struct example_sequence_tag;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template<typename Tag>
|
||||
struct size_impl;
|
||||
|
||||
template<>
|
||||
struct size_impl<example_sequence_tag>
|
||||
{
|
||||
template<typename Sequence>
|
||||
struct apply
|
||||
: mpl::int_<2>
|
||||
{};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
42
example/extension/detail/value_at_impl.hpp
Normal file
42
example/extension/detail/value_at_impl.hpp
Normal file
@ -0,0 +1,42 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2005-2006 Dan Marsden
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(BOOST_FUSION_VALUE_AT_IMPL_20060223_2025)
|
||||
#define BOOST_FUSION_VALUE_AT_IMPL_20060223_2025
|
||||
|
||||
namespace boost { namespace fusion {
|
||||
|
||||
struct example_sequence_tag;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template<typename Tag>
|
||||
struct value_at_impl;
|
||||
|
||||
template<>
|
||||
struct value_at_impl<example_sequence_tag>
|
||||
{
|
||||
template<typename Sequence, typename N>
|
||||
struct apply;
|
||||
|
||||
template<typename Sequence>
|
||||
struct apply<Sequence, mpl::int_<0> >
|
||||
{
|
||||
typedef std::string type;
|
||||
};
|
||||
|
||||
template<typename Sequence>
|
||||
struct apply<Sequence, mpl::int_<1> >
|
||||
{
|
||||
typedef int type;
|
||||
};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
48
example/extension/detail/value_at_key_impl.hpp
Normal file
48
example/extension/detail/value_at_key_impl.hpp
Normal file
@ -0,0 +1,48 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2005-2006 Dan Marsden
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(BOOST_FUSION_VALUE_AT_KEY_IMPL_20060223_2025)
|
||||
#define BOOST_FUSION_VALUE_AT_KEY_IMPL_20060223_2025
|
||||
|
||||
namespace fields
|
||||
{
|
||||
struct name;
|
||||
struct age;
|
||||
}
|
||||
|
||||
namespace boost { namespace fusion {
|
||||
|
||||
struct example_sequence_tag;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template<typename Tag>
|
||||
struct value_at_key_impl;
|
||||
|
||||
template<>
|
||||
struct value_at_key_impl<example_sequence_tag>
|
||||
{
|
||||
template<typename Sequence, typename N>
|
||||
struct apply;
|
||||
|
||||
template<typename Sequence>
|
||||
struct apply<Sequence, fields::name>
|
||||
{
|
||||
typedef std::string type;
|
||||
};
|
||||
|
||||
template<typename Sequence>
|
||||
struct apply<Sequence, fields::age>
|
||||
{
|
||||
typedef int type;
|
||||
};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
48
example/extension/detail/value_of_impl.hpp
Normal file
48
example/extension/detail/value_of_impl.hpp
Normal file
@ -0,0 +1,48 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2006 Dan Marsden
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(BOOST_FUSION_VALUE_OF_IMPL_20060223_1905)
|
||||
#define BOOST_FUSION_VALUE_OF_IMPL_20060223_1905
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace boost { namespace fusion {
|
||||
|
||||
struct example_struct_iterator_tag;
|
||||
|
||||
template<typename Struct, int Pos>
|
||||
struct example_struct_iterator;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template<typename Tag>
|
||||
struct value_of_impl;
|
||||
|
||||
template<>
|
||||
struct value_of_impl<example_struct_iterator_tag>
|
||||
{
|
||||
template<typename Iterator>
|
||||
struct apply;
|
||||
|
||||
template<typename Struct>
|
||||
struct apply<example_struct_iterator<Struct, 0> >
|
||||
{
|
||||
typedef std::string type;
|
||||
};
|
||||
|
||||
template<typename Struct>
|
||||
struct apply<example_struct_iterator<Struct, 1> >
|
||||
{
|
||||
typedef int type;
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
27
example/extension/example_struct.hpp
Normal file
27
example/extension/example_struct.hpp
Normal file
@ -0,0 +1,27 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2005-2006 Dan Marsden
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(BOOST_FUSION_EXAMPLE_STRUCT)
|
||||
#define BOOST_FUSION_EXAMPLE_STRUCT
|
||||
|
||||
#include "./tag_of.hpp"
|
||||
#include "./example_struct_iterator.hpp"
|
||||
#include "./detail/begin_impl.hpp"
|
||||
#include "./detail/end_impl.hpp"
|
||||
#include "./detail/at_impl.hpp"
|
||||
#include "./detail/value_at_impl.hpp"
|
||||
#include "./detail/size_impl.hpp"
|
||||
#include "./detail/category_of_impl.hpp"
|
||||
#include "./detail/at_key_impl.hpp"
|
||||
#include "./detail/value_at_key_impl.hpp"
|
||||
#include "./detail/has_key_impl.hpp"
|
||||
#include "./detail/is_sequence_impl.hpp"
|
||||
#include "./detail/is_associative_impl.hpp"
|
||||
#include "./detail/is_view_impl.hpp"
|
||||
|
||||
#endif
|
47
example/extension/example_struct_iterator.hpp
Normal file
47
example/extension/example_struct_iterator.hpp
Normal file
@ -0,0 +1,47 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2005-2006 Dan Marsden
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(BOOST_FUSION_EXAMPLE_STRUCT_ITERATOR)
|
||||
#define BOOST_FUSION_EXAMPLE_STRUCT_ITERATOR
|
||||
|
||||
#include <boost/fusion/support/iterator_base.hpp>
|
||||
#include <boost/mpl/int.hpp>
|
||||
#include <boost/type_traits/add_const.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
|
||||
#include "./detail/next_impl.hpp"
|
||||
#include "./detail/prior_impl.hpp"
|
||||
#include "./detail/deref_impl.hpp"
|
||||
#include "./detail/advance_impl.hpp"
|
||||
#include "./detail/distance_impl.hpp"
|
||||
#include "./detail/value_of_impl.hpp"
|
||||
#include "./detail/equal_to_impl.hpp"
|
||||
|
||||
namespace boost { namespace fusion {
|
||||
|
||||
struct example_struct_iterator_tag;
|
||||
struct random_access_traversal_tag;
|
||||
|
||||
template<typename Struct, int Pos>
|
||||
struct example_struct_iterator
|
||||
: iterator_base<example_struct_iterator<Struct, Pos> >
|
||||
{
|
||||
BOOST_STATIC_ASSERT(Pos >=0 && Pos < 3);
|
||||
typedef Struct struct_type;
|
||||
typedef mpl::int_<Pos> index;
|
||||
typedef example_struct_iterator_tag ftag;
|
||||
typedef random_access_traversal_tag category;
|
||||
|
||||
example_struct_iterator(Struct& str)
|
||||
: struct_(str) {}
|
||||
|
||||
Struct& struct_;
|
||||
};
|
||||
}}
|
||||
|
||||
#endif
|
28
example/extension/example_struct_type.hpp
Normal file
28
example/extension/example_struct_type.hpp
Normal file
@ -0,0 +1,28 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2006 Dan Marsden
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(BOOST_FUSION_EXAMPLE_STRUCT_TYPE)
|
||||
#define BOOST_FUSION_EXAMPLE_STRUCT_TYPE
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace example
|
||||
{
|
||||
struct example_struct
|
||||
{
|
||||
std::string name;
|
||||
int age;
|
||||
example_struct(
|
||||
const std::string& n,
|
||||
int a)
|
||||
: name(n), age(a)
|
||||
{}
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
28
example/extension/tag_of.hpp
Normal file
28
example/extension/tag_of.hpp
Normal file
@ -0,0 +1,28 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2005-2006 Dan Marsden
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(BOOST_FUSION_TAG_OF_20060222_2052)
|
||||
#define BOOST_FUSION_TAG_OF_20060222_2052
|
||||
|
||||
#include <boost/fusion/support/tag_of_fwd.hpp>
|
||||
#include "./example_struct_type.hpp"
|
||||
|
||||
namespace boost { namespace fusion {
|
||||
|
||||
struct example_sequence_tag;
|
||||
|
||||
namespace traits {
|
||||
|
||||
template<>
|
||||
struct tag_of<example::example_struct>
|
||||
{
|
||||
typedef example_sequence_tag type;
|
||||
};
|
||||
}}}
|
||||
|
||||
#endif
|
63
example/extension/test_example.cpp
Normal file
63
example/extension/test_example.cpp
Normal file
@ -0,0 +1,63 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2006 Dan Marsden
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#include "./example_struct.hpp"
|
||||
#include "./example_struct_type.hpp"
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
#include <boost/fusion/sequence/intrinsic.hpp>
|
||||
#include <boost/fusion/support/is_sequence.hpp>
|
||||
#include <boost/fusion/iterator.hpp>
|
||||
#include <boost/fusion/support/is_associative.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/mpl/assert.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
example::example_struct bert("bert", 99);
|
||||
using namespace boost::fusion;
|
||||
BOOST_MPL_ASSERT((traits::is_associative<example::example_struct>));
|
||||
BOOST_TEST(*begin(bert) == "bert");
|
||||
BOOST_TEST(*next(begin(bert)) == 99);
|
||||
BOOST_TEST(*prior(end(bert)) == 99);
|
||||
BOOST_TEST(*advance_c<1>(begin(bert)) == 99);
|
||||
BOOST_TEST(*advance_c<-1>(end(bert)) == 99);
|
||||
BOOST_TEST(distance(begin(bert), end(bert)) == 2);
|
||||
|
||||
typedef result_of::begin<example::example_struct>::type first;
|
||||
typedef result_of::next<first>::type second;
|
||||
BOOST_MPL_ASSERT((boost::is_same<result_of::value_of<first>::type, std::string>));
|
||||
BOOST_MPL_ASSERT((boost::is_same<result_of::value_of<second>::type, int>));
|
||||
|
||||
BOOST_TEST(begin(bert) != end(bert));
|
||||
BOOST_TEST(advance_c<2>(begin(bert)) == end(const_cast<const example::example_struct&>(bert)));
|
||||
|
||||
BOOST_TEST(at_c<0>(bert) == "bert");
|
||||
BOOST_TEST(at_c<1>(bert) == 99);
|
||||
|
||||
BOOST_TEST(at_key<fields::name>(bert) == "bert");
|
||||
BOOST_TEST(at_key<fields::age>(bert) == 99);
|
||||
|
||||
BOOST_TEST(has_key<fields::name>(bert));
|
||||
BOOST_TEST(has_key<fields::age>(bert));
|
||||
BOOST_TEST(!has_key<int>(bert));
|
||||
|
||||
BOOST_MPL_ASSERT((boost::is_same<result_of::value_at_c<example::example_struct, 0>::type, std::string>));
|
||||
BOOST_MPL_ASSERT((boost::is_same<result_of::value_at_c<example::example_struct, 1>::type, int>));
|
||||
|
||||
BOOST_MPL_ASSERT((boost::is_same<result_of::value_at_key<example::example_struct, fields::name>::type, std::string>));
|
||||
BOOST_MPL_ASSERT((boost::is_same<result_of::value_at_key<example::example_struct, fields::age>::type, int>));
|
||||
|
||||
BOOST_TEST(size(bert) == 2);
|
||||
|
||||
BOOST_MPL_ASSERT((boost::is_same<traits::category_of<example::example_struct>::type, random_access_traversal_tag>));
|
||||
|
||||
BOOST_MPL_ASSERT((traits::is_sequence<example::example_struct>));
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
Reference in New Issue
Block a user