forked from boostorg/fusion
Merge remote-tracking branch 'official/develop' into fusion_adapters
This commit is contained in:
@ -23,6 +23,7 @@
|
||||
#include <boost/fusion/sequence/comparison/less_equal.hpp>
|
||||
#include <boost/fusion/sequence/comparison/greater.hpp>
|
||||
#include <boost/fusion/sequence/comparison/greater_equal.hpp>
|
||||
#include <boost/fusion/sequence/convert.hpp>
|
||||
#include <boost/fusion/mpl.hpp>
|
||||
#include <boost/fusion/support/is_view.hpp>
|
||||
#include <boost/tuple/tuple.hpp>
|
||||
@ -87,7 +88,14 @@ main()
|
||||
fusion::list<int, std::string> l(tuples::make_tuple(123, "Hola!!!"));
|
||||
l = tuples::make_tuple(123, "Hola!!!");
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
// conversion vector to boost tuple
|
||||
boost::tuple<int, std::string> t = convert<boost_tuple_tag>(make_vector(123, "Hola!!!"));
|
||||
BOOST_TEST(get<0>(t) == 123);
|
||||
BOOST_TEST(get<1>(t) == "Hola!!!");
|
||||
}
|
||||
|
||||
{
|
||||
// test from Ticket #1601, submitted by Shunsuke Sogame
|
||||
// expanded by Stjepan Rajko
|
||||
|
16
test/sequence/deque_hash.cpp
Normal file
16
test/sequence/deque_hash.cpp
Normal file
@ -0,0 +1,16 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2014 Christoph Weiss
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#include <boost/fusion/container/deque/deque.hpp>
|
||||
|
||||
#define FUSION_SEQUENCE deque
|
||||
#include "hash.hpp"
|
||||
|
||||
int main()
|
||||
{
|
||||
hash_test();
|
||||
return boost::report_errors();
|
||||
}
|
58
test/sequence/hash.cpp
Normal file
58
test/sequence/hash.cpp
Normal file
@ -0,0 +1,58 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2014 Christoph Weiss
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/include/adapt_struct.hpp>
|
||||
#include <boost/fusion/sequence/hash.hpp>
|
||||
|
||||
struct test_struct
|
||||
{
|
||||
test_struct(bool bb, int ii, char cc, std::string const& ss) :
|
||||
b(bb),
|
||||
i(ii),
|
||||
c(cc),
|
||||
s(ss) {}
|
||||
|
||||
bool b;
|
||||
int i;
|
||||
char c;
|
||||
std::string s;
|
||||
};
|
||||
|
||||
BOOST_FUSION_ADAPT_STRUCT(
|
||||
test_struct,
|
||||
(bool, b)
|
||||
(int, i)
|
||||
(char, c)
|
||||
(std::string, s)
|
||||
)
|
||||
|
||||
int main()
|
||||
{
|
||||
using boost::fusion::hash_value;
|
||||
|
||||
const test_struct a0(false, 1, 'c', "Hello Nurse"),
|
||||
a1(false, 1, 'c', "Hello Nurse"),
|
||||
b(true, 1, 'c', "Hello Nurse"),
|
||||
c(false, 0, 'c', "Hello Nurse"),
|
||||
d(false, 1, 'd', "Hello Nurse"),
|
||||
e(false, 1, 'c', "Hello World");
|
||||
|
||||
BOOST_TEST(hash_value(a0) == hash_value(a1));
|
||||
BOOST_TEST(hash_value(a0) != hash_value(b));
|
||||
BOOST_TEST(hash_value(a0) != hash_value(c));
|
||||
BOOST_TEST(hash_value(a0) != hash_value(d));
|
||||
BOOST_TEST(hash_value(a0) != hash_value(e));
|
||||
BOOST_TEST(hash_value(b) != hash_value(c));
|
||||
BOOST_TEST(hash_value(b) != hash_value(d));
|
||||
BOOST_TEST(hash_value(b) != hash_value(d));
|
||||
BOOST_TEST(hash_value(c) != hash_value(d));
|
||||
BOOST_TEST(hash_value(c) != hash_value(e));
|
||||
BOOST_TEST(hash_value(d) != hash_value(e));
|
||||
}
|
34
test/sequence/hash.hpp
Normal file
34
test/sequence/hash.hpp
Normal file
@ -0,0 +1,34 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2014 Christoph Weiss
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/sequence/hash.hpp>
|
||||
#include <boost/functional/hash.hpp>
|
||||
|
||||
void
|
||||
hash_test()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
|
||||
const FUSION_SEQUENCE<int, char, bool, std::string> v0(42, 'x', false, "Aurea prima");
|
||||
const FUSION_SEQUENCE<int, char, bool, std::string> v1(42, 'x', false, "Aurea prima");
|
||||
BOOST_TEST(hash_value(v0) == hash_value(v1));
|
||||
|
||||
const FUSION_SEQUENCE<int, char, bool, std::string> w(41, 'x', false, "Aurea prima");
|
||||
BOOST_TEST(hash_value(w) != hash_value(v0));
|
||||
|
||||
const FUSION_SEQUENCE<int, char, bool, std::string> x(42, 'y', false, "Aurea prima");
|
||||
BOOST_TEST(hash_value(x) != hash_value(v0));
|
||||
|
||||
const FUSION_SEQUENCE<int, char, bool, std::string> y(42, 'x', true, "Aurea prima");
|
||||
BOOST_TEST(hash_value(y) != hash_value(v0));
|
||||
|
||||
const FUSION_SEQUENCE<int, char, bool, std::string> z(42, 'x', false, "quae vindice nullo");
|
||||
BOOST_TEST(hash_value(z) != hash_value(v0));
|
||||
}
|
16
test/sequence/list_hash.cpp
Normal file
16
test/sequence/list_hash.cpp
Normal file
@ -0,0 +1,16 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2014 Christoph Weiss
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#include <boost/fusion/container/list/list.hpp>
|
||||
|
||||
#define FUSION_SEQUENCE list
|
||||
#include "hash.hpp"
|
||||
|
||||
int main()
|
||||
{
|
||||
hash_test();
|
||||
return boost::report_errors();
|
||||
}
|
46
test/sequence/std_tuple.cpp
Normal file
46
test/sequence/std_tuple.cpp
Normal file
@ -0,0 +1,46 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2014 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)
|
||||
==============================================================================*/
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
// adapted/std_tuple.hpp only supports implementations using variadic templates
|
||||
#if !defined(BOOST_NO_CXX11_HDR_TUPLE) && \
|
||||
!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/adapted/std_tuple.hpp>
|
||||
#include <boost/fusion/sequence/convert.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include <tuple>
|
||||
#include <string>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
using namespace boost;
|
||||
|
||||
{
|
||||
// conversion vector to std tuple
|
||||
std::tuple<int, std::string> t = convert<std_tuple_tag>(make_vector(123, "Hola!!!"));
|
||||
BOOST_TEST(std::get<0>(t) == 123);
|
||||
BOOST_TEST(std::get<1>(t) == "Hola!!!");
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
@ -1,5 +1,10 @@
|
||||
#include <boost/tr1/memory.hpp>
|
||||
#include <boost/tr1/tuple.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_HDR_TUPLE) && \
|
||||
!defined(BOOST_NO_CXX11_SMART_PTR)
|
||||
|
||||
#include <memory>
|
||||
#include <tuple>
|
||||
#include <boost/any.hpp>
|
||||
#include <iostream>
|
||||
|
||||
@ -7,10 +12,10 @@ namespace Core
|
||||
{
|
||||
class AutoConverter
|
||||
{
|
||||
std::tr1::shared_ptr<boost::any> t_;
|
||||
std::shared_ptr<boost::any> t_;
|
||||
|
||||
public:
|
||||
AutoConverter(std::tr1::shared_ptr<boost::any> const & t)
|
||||
AutoConverter(std::shared_ptr<boost::any> const & t)
|
||||
: t_(t)
|
||||
{}
|
||||
|
||||
@ -40,8 +45,8 @@ namespace Core
|
||||
|
||||
inline AutoConverter Demo()
|
||||
{
|
||||
std::tr1::shared_ptr<boost::any> p_result
|
||||
(new boost::any(std::tr1::make_tuple(1, 2, 3, 4)));
|
||||
std::shared_ptr<boost::any> p_result
|
||||
(new boost::any(std::make_tuple(1, 2, 3, 4)));
|
||||
return p_result;
|
||||
}
|
||||
|
||||
@ -50,7 +55,16 @@ namespace Core
|
||||
|
||||
int main()
|
||||
{
|
||||
std::tr1::tuple<int, int, int, int> test = Core::Demo();
|
||||
std::tuple<int, int, int, int> test = Core::Demo();
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
16
test/sequence/tuple_hash.cpp
Normal file
16
test/sequence/tuple_hash.cpp
Normal file
@ -0,0 +1,16 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2014 Christoph Weiss
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#include <boost/fusion/tuple/tuple.hpp>
|
||||
|
||||
#define FUSION_SEQUENCE tuple
|
||||
#include "hash.hpp"
|
||||
|
||||
int main()
|
||||
{
|
||||
hash_test();
|
||||
return boost::report_errors();
|
||||
}
|
16
test/sequence/vector_hash.cpp
Normal file
16
test/sequence/vector_hash.cpp
Normal file
@ -0,0 +1,16 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2014 Christoph Weiss
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
|
||||
#define FUSION_SEQUENCE vector
|
||||
#include "hash.hpp"
|
||||
|
||||
int main()
|
||||
{
|
||||
hash_test();
|
||||
return boost::report_errors();
|
||||
}
|
Reference in New Issue
Block a user