mirror of
https://github.com/boostorg/fusion.git
synced 2025-07-20 15:52:13 +02:00
Rename the test tr1_tuple_auto_conv to std_tuple_auto_conv.
Signed-off-by: Kohei Takahashi <flast@flast.jp>
This commit is contained in:
56
test/sequence/std_tuple_auto_conv.cpp
Normal file
56
test/sequence/std_tuple_auto_conv.cpp
Normal file
@ -0,0 +1,56 @@
|
||||
#include <memory>
|
||||
#include <tuple>
|
||||
#include <boost/any.hpp>
|
||||
#include <iostream>
|
||||
|
||||
namespace Core
|
||||
{
|
||||
class AutoConverter
|
||||
{
|
||||
std::shared_ptr<boost::any> t_;
|
||||
|
||||
public:
|
||||
AutoConverter(std::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::shared_ptr<boost::any> p_result
|
||||
(new boost::any(std::make_tuple(1, 2, 3, 4)));
|
||||
return p_result;
|
||||
}
|
||||
|
||||
} // namespace Core
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
std::tuple<int, int, int, int> test = Core::Demo();
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user