Files
fusion/test/sequence/tuple_construction.cpp
T

50 lines
1.5 KiB
C++
Raw Normal View History

2006-08-22 15:57:13 +00:00
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Jarvi
2011-09-16 05:27:16 +00:00
Copyright (c) 2001-2011 Joel de Guzman
2006-08-22 15:57:13 +00:00
2008-08-20 08:20:19 +00:00
Distributed under the Boost Software License, Version 1.0. (See accompanying
2007-03-02 10:44:14 +00:00
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
2006-08-22 15:57:13 +00:00
==============================================================================*/
#include <boost/fusion/tuple/tuple.hpp>
2007-10-24 02:32:28 +00:00
#include <boost/fusion/adapted/mpl.hpp>
2006-08-22 15:57:13 +00:00
2012-09-04 05:04:25 +00:00
#define NO_CONSTRUCT_FROM_NIL
2006-08-22 15:57:13 +00:00
#define FUSION_SEQUENCE tuple
#define FUSION_AT get
#include "construction.hpp"
// Bug in C++03 tuple? Cannot construct from a std::pair without including
// std::pair fusion adaption
#if !defined(BOOST_FUSION_HAS_VARIADIC_TUPLE)
# include <boost/fusion/adapted/std_pair.hpp>
#endif
struct test_conversion
{
test_conversion(int value) : value_(value) {}
int value_;
};
2006-08-22 15:57:13 +00:00
int
main()
{
test();
{
using namespace boost::fusion;
const tuple<int, test_conversion> instance(std::pair<int, int>(1, 9));
BOOST_TEST(boost::fusion::get<0>(instance) == 1);
BOOST_TEST(boost::fusion::get<1>(instance).value_ == 9);
}
{
using namespace boost::fusion;
const std::pair<int, int> init(16, 4);
const tuple<int, test_conversion> instance(init);
BOOST_TEST(boost::fusion::get<0>(instance) == 16);
BOOST_TEST(boost::fusion::get<1>(instance).value_ == 4);
}
2006-08-22 15:57:13 +00:00
return boost::report_errors();
}