forked from boostorg/fusion
tests covering defect in fusion::fold loop unrolling picked up by Christian Holmquist
[SVN r37984]
This commit is contained in:
@ -10,6 +10,7 @@
|
|||||||
#include <boost/fusion/sequence/adapted/mpl.hpp>
|
#include <boost/fusion/sequence/adapted/mpl.hpp>
|
||||||
#include <boost/fusion/sequence/io/out.hpp>
|
#include <boost/fusion/sequence/io/out.hpp>
|
||||||
#include <boost/fusion/sequence/intrinsic/at.hpp>
|
#include <boost/fusion/sequence/intrinsic/at.hpp>
|
||||||
|
#include <boost/fusion/sequence/generation/make_vector.hpp>
|
||||||
#include <boost/fusion/algorithm/iteration/fold.hpp>
|
#include <boost/fusion/algorithm/iteration/fold.hpp>
|
||||||
#include <boost/fusion/algorithm/iteration/accumulate.hpp>
|
#include <boost/fusion/algorithm/iteration/accumulate.hpp>
|
||||||
#include <boost/type_traits/is_same.hpp>
|
#include <boost/type_traits/is_same.hpp>
|
||||||
@ -18,6 +19,8 @@
|
|||||||
#include <boost/mpl/int.hpp>
|
#include <boost/mpl/int.hpp>
|
||||||
#include <boost/mpl/vector.hpp>
|
#include <boost/mpl/vector.hpp>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
using boost::mpl::if_;
|
using boost::mpl::if_;
|
||||||
using boost::mpl::int_;
|
using boost::mpl::int_;
|
||||||
using boost::is_same;
|
using boost::is_same;
|
||||||
@ -73,6 +76,16 @@ struct count_ints
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct appender
|
||||||
|
{
|
||||||
|
typedef std::string result_type;
|
||||||
|
|
||||||
|
std::string operator()(char c, std::string const& str) const
|
||||||
|
{
|
||||||
|
return str + c;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
@ -112,6 +125,11 @@ main()
|
|||||||
BOOST_TEST(n == 3);
|
BOOST_TEST(n == 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
BOOST_TEST(fusion::fold(fusion::make_vector('a','b','c','d','e'), std::string(""), appender())
|
||||||
|
== "abcde");
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
typedef vector<int, char, int, double> vector_type;
|
typedef vector<int, char, int, double> vector_type;
|
||||||
vector_type v(12345, 'x', 678910, 3.36);
|
vector_type v(12345, 'x', 678910, 3.36);
|
||||||
@ -145,6 +163,10 @@ main()
|
|||||||
BOOST_TEST(n == 3);
|
BOOST_TEST(n == 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
BOOST_TEST(fusion::accumulate(fusion::make_vector('a','b','c','d','e'), std::string(""), appender())
|
||||||
|
== "abcde");
|
||||||
|
}
|
||||||
|
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user