conform to TR1 to the letter

[SVN r48243]
This commit is contained in:
Joel de Guzman
2008-08-20 08:20:19 +00:00
parent c51fc2ebee
commit e165418461
4 changed files with 62 additions and 2 deletions

View File

@ -89,6 +89,7 @@ import testing ;
[ run sequence/tuple_misc.cpp : : : : ]
[ run sequence/tuple_mutate.cpp : : : : ]
[ run sequence/tuple_tie.cpp : : : : ]
[ run sequence/tr1_tuple_auto_conv.cpp : : : : ]
[ run sequence/transform_view.cpp : : : : ]
[ run sequence/vector_comparison.cpp : : : : ]
[ run sequence/vector_construction.cpp : : : : ]

View File

@ -57,7 +57,9 @@ test()
FUSION_SEQUENCE<> empty0;
#ifndef TR1_TUPLE_TEST
FUSION_SEQUENCE<> empty1(empty);
#endif
FUSION_SEQUENCE<int> t1;
BOOST_TEST(FUSION_AT<0>(t1) == int());

View File

@ -0,0 +1,56 @@
#include <boost/tr1/memory.hpp>
#include <boost/tr1/tuple.hpp>
#include <boost/any.hpp>
#include <iostream>
namespace Core
{
class AutoConverter
{
std::tr1::shared_ptr<boost::any> t_;
public:
AutoConverter(std::tr1::shared_ptr<boost::any> const & t)
: t_(t)
{}
template <typename C>
operator C ()
{
try
{
boost::any & a = (*t_);
return boost::any_cast<C>(a);
}
catch(boost::bad_any_cast & e)
{
std::cerr << "Internal conversion bug: "
<< "Failed to convert data holder to "
<< typeid(C).name() << "\n"
<< e.what()
<< std::endl;
C c = C();
return c;
}
}
};
inline AutoConverter Demo()
{
std::tr1::shared_ptr<boost::any> p_result
(new boost::any(std::tr1::make_tuple(1, 2, 3, 4)));
return p_result;
}
} // namespace Core
int main(int argc, char* argv[])
{
std::tr1::tuple<int, int, int, int> test = Core::Demo();
return 0;
}

View File

@ -8,6 +8,7 @@
#include <boost/fusion/tuple/tuple.hpp>
#include <boost/fusion/adapted/mpl.hpp>
#define TR1_TUPLE_TEST
#define FUSION_SEQUENCE tuple
#define FUSION_AT get
#include "construction.hpp"