/*============================================================================== Copyright (c) 2005-2010 Joel de Guzman Copyright (c) 2010 Thomas Heller Copyright (c) 2015 John Fletcher 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 // for std::forward used by boost/range in some cases. #include #include #include #include #include #include #include #include #include #include #include #include namespace phoenix = boost::phoenix; struct Foo { Foo(const std::string& name, int value) : name_(name) , value_(value) { } std::string name_; int value_; }; typedef boost::shared_ptr FooPtr; int range_test_complex() { typedef std::vector V; V source; source.push_back(boost::make_shared("Foo", 10)); source.push_back(boost::make_shared("Bar", 20)); source.push_back(boost::make_shared("Baz", 30)); source.push_back(boost::make_shared("Baz", 30)); //duplicate is here std::vector result1; std::vector result2; using namespace boost::adaptors; using phoenix::arg_names::arg1; // This is failing for gcc 4.4 and 4.5 - reason not identified. #if ((BOOST_GCC_VERSION < 40400) || (BOOST_GCC_VERSION >= 40600)) boost::push_back(result1, source | transformed(phoenix::bind(&Foo::name_, *arg1)) | uniqued); for(unsigned i = 0; i < result1.size(); ++i) std::cout << result1[i] << "\n"; #endif // This is failing for gcc 4.4 and 4.5 - reason not identified. #if !(BOOST_GCC_VERSION < 40600) boost::push_back(result2, source | transformed(phoenix::bind(&Foo::value_, *arg1)) | uniqued); for(unsigned i = 0; i < result2.size(); ++i) std::cout << result2[i] << "\n"; #endif return 0; } int main() { return range_test_complex(); }