From 5ae01ad6a901da8491b626050d53bd24264efb57 Mon Sep 17 00:00:00 2001 From: Joel de Guzman Date: Tue, 28 Oct 2014 09:06:42 +0800 Subject: [PATCH] - Added sfinae test case for fold - Some cleanup --- test/Jamfile | 1 - test/algorithm/fold.cpp | 39 +++++++++++++++++++++++++++++++++++++-- test/algorithm/fold2.cpp | 8 -------- 3 files changed, 37 insertions(+), 11 deletions(-) delete mode 100644 test/algorithm/fold2.cpp diff --git a/test/Jamfile b/test/Jamfile index 879b0f40..6e3ca32e 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -28,7 +28,6 @@ project [ run algorithm/find.cpp : : : : ] [ run algorithm/find_if.cpp : : : : ] [ run algorithm/fold.cpp : : : : ] - [ run algorithm/fold2.cpp : : : : ] [ run algorithm/for_each.cpp : : : : ] [ run algorithm/insert.cpp : : : : ] [ run algorithm/insert_range.cpp : : : : ] diff --git a/test/algorithm/fold.cpp b/test/algorithm/fold.cpp index 1db08181..2df01adf 100644 --- a/test/algorithm/fold.cpp +++ b/test/algorithm/fold.cpp @@ -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 @@ -120,6 +120,26 @@ int add(int lhs, int rhs) return lhs + rhs; } +struct functor +{ + template + 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 container{1, 2, 3}; + functor f; + boost::fusion::fold(container, 0, f); + } +#endif + + { + boost::fusion::vector vec; + visitor v; + boost::fusion::fold(vec, 0, v); + } + } + return boost::report_errors(); } - diff --git a/test/algorithm/fold2.cpp b/test/algorithm/fold2.cpp deleted file mode 100644 index 51ef975d..00000000 --- a/test/algorithm/fold2.cpp +++ /dev/null @@ -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"