- Added sfinae test case for fold

- Some cleanup
This commit is contained in:
Joel de Guzman
2014-10-28 09:06:42 +08:00
parent d5eb1e793c
commit 5ae01ad6a9
3 changed files with 37 additions and 11 deletions

View File

@ -2,7 +2,7 @@
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2007 Dan Marsden
Distributed under the Boost Software License, Version 1.0. (See accompanying
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/detail/lightweight_test.hpp>
@ -120,6 +120,26 @@ int add(int lhs, int rhs)
return lhs + rhs;
}
struct functor
{
template<typename T>
int
operator() (int hitherho, T const& cur) const
{
return int(hitherho + cur);
}
};
struct visitor
{
using result_type = int;
int operator()(int sum, long&)
{
return sum;
}
};
int
main()
{
@ -217,6 +237,21 @@ main()
BOOST_TEST(fusion::accumulate(vec, 0, add) == 3);
}
{
#if !defined(BOOST_NO_CXX11_DECLTYPE)
{
boost::fusion::vector<int, double, long> container{1, 2, 3};
functor f;
boost::fusion::fold(container, 0, f);
}
#endif
{
boost::fusion::vector<long> vec;
visitor v;
boost::fusion::fold(vec, 0, v);
}
}
return boost::report_errors();
}

View File

@ -1,8 +0,0 @@
/*=============================================================================
Copyright (c) 2010 Christopher Schmidt
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 "fold.hpp"