/* Boost.MultiIndex test for terse key specification syntax. * * Copyright 2003-2018 Joaquin M Lopez Munoz. * 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) * * See http://www.boost.org/libs/multi_index for library home page. */ #include "test_key.hpp" #include /* keep it first to prevent nasty warns in MSVC */ #include #include "pre_multi_index.hpp" #include #if !defined(BOOST_MULTI_INDEX_KEY_SUPPORTED) #include BOOST_PRAGMA_MESSAGE("boost::multi_index::key not supported, skipping test") void test_key() { } #else #include #include using namespace boost::multi_index; namespace { struct base { int x; const int cx; int f(){return x;}; int cf()const{return x;}; }; int gf(const base& b){return b.x;} struct derived:base { int y; }; int gh(derived& d){return d.y;} int grh(std::reference_wrapper& d){return d.get().y;} } /* namespace */ void test_key() { BOOST_TEST((std::is_same< key<&base::x>,member >::value)); BOOST_TEST((std::is_same< key<&base::cx>,member >::value)); BOOST_TEST((std::is_same< key<&base::f>,mem_fun >::value)); BOOST_TEST((std::is_same< key<&base::cf>,const_mem_fun >::value)); BOOST_TEST((std::is_same< key,global_fun >::value)); BOOST_TEST((std::is_same< key<&base::x,&base::cx,&base::f,&base::cf,gf>, composite_key< base, member, member, mem_fun, const_mem_fun, global_fun > >::value)); BOOST_TEST((std::is_same< key<&base::x,&derived::y>, composite_key< derived, member, member > >::value)); BOOST_TEST((std::is_same< key, composite_key< derived, global_fun, global_fun > >::value)); BOOST_TEST((std::is_same< key, composite_key< std::reference_wrapper, global_fun, global_fun, global_fun&,int,grh> > >::value)); } #endif