/* 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" #if !defined(BOOST_MULTI_INDEX_KEY_SUPPORTED) #include void test_key() { BOOST_TEST(false); /* boost::multi_index::key not supported */ } #else #include /* keep it first to prevent nasty warns in MSVC */ #include #include "pre_multi_index.hpp" #include #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_v< key<&base::x>,member >)); BOOST_TEST((std::is_same_v< key<&base::cx>,member >)); BOOST_TEST((std::is_same_v< key<&base::f>,mem_fun >)); BOOST_TEST((std::is_same_v< key<&base::cf>,const_mem_fun >)); BOOST_TEST((std::is_same_v< key,global_fun >)); BOOST_TEST((std::is_same_v< key<&base::x,&base::cx,&base::f,&base::cf,gf>, composite_key< base, member, member, mem_fun, const_mem_fun, global_fun > >)); BOOST_TEST((std::is_same_v< key<&base::x,&derived::y>, composite_key< derived, member, member > >)); BOOST_TEST((std::is_same_v< key, composite_key< derived, global_fun, global_fun > >)); BOOST_TEST((std::is_same_v< key, composite_key< std::reference_wrapper, global_fun, global_fun, global_fun&,int,grh> > >)); } #endif