| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206 | // Boost.Bimap//// Copyright (c) 2006-2007 Matias Capeletto//// 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)/// \file set_of.hpp/// \brief Include support for set constrains for the bimap container#ifndef BOOST_BIMAP_SET_OF_HPP#define BOOST_BIMAP_SET_OF_HPP#if defined(_MSC_VER)#pragma once#endif#include <boost/config.hpp>#include <boost/bimap/detail/user_interface_config.hpp>#include <functional>#include <boost/mpl/bool.hpp>#include <boost/mpl/aux_/na.hpp>#include <boost/concept_check.hpp>#include <boost/bimap/detail/concept_tags.hpp>#include <boost/bimap/detail/generate_index_binder.hpp>#include <boost/bimap/detail/generate_view_binder.hpp>#include <boost/bimap/detail/generate_relation_binder.hpp>#include <boost/bimap/tags/support/value_type_of.hpp>#include <boost/multi_index/ordered_index.hpp>#include <boost/bimap/views/map_view.hpp>#include <boost/bimap/views/set_view.hpp>namespace boost {namespace bimaps {/// \brief Set Type Specification/**This struct is used to specify a set specification.It is not a container, it is just a metaprogramming facility toexpress the type of a set. Generally, this specification willbe used in other place to create a container.It has the same syntax that an std::set instantiation, exceptthat the allocator cannot be specified. The rationale behindthis difference is that the allocator is not part of the settype specification, rather it is a container configurationparameter.The first parameter is the type of the objects in the set, andthe second one is a Functor that compares them.Bimap binding metafunctions can be used with this class inthe following way:\codeusing namespace support;BOOST_STATIC_ASSERT( is_set_type_of< set_of<Type> >::value )BOOST_STATIC_ASSERT(     is_same     <        set_of<Type,KeyCompare>::index_bind        <            KeyExtractor,            Tag        >::type,        ordered_unique< tag<Tag>, KeyExtractor, KeyCompare >    >::value)typedef bimap<    set_of<Type>, RightKeyType> bimap_with_left_type_as_set;BOOST_STATIC_ASSERT(    is_same    <        set_of<Type>::map_view_bind        <            member_at::left,            bimap_with_left_type_as_set        >::type,        map_view< member_at::left, bimap_with_left_type_as_set >    >::value)\endcodeSee also set_of_relation.                                                                        **/template<    class KeyType,    class KeyCompare = std::less< BOOST_DEDUCED_TYPENAME         ::boost::bimaps::tags::support::value_type_of<KeyType>::type >>struct set_of : public ::boost::bimaps::detail::set_type_of_tag{    /// User type, can be tagged    typedef KeyType user_type;    /// Type of the object that will be stored in the set    typedef BOOST_DEDUCED_TYPENAME ::boost::bimaps::tags::support::        value_type_of<user_type>::type value_type;    /// Functor that compare two keys    typedef KeyCompare key_compare;    struct lazy_concept_checked    {        BOOST_CLASS_REQUIRE ( value_type,                              boost, AssignableConcept );        BOOST_CLASS_REQUIRE4( key_compare, bool, value_type, value_type,                              boost, BinaryFunctionConcept );        typedef set_of type;    };    BOOST_BIMAP_GENERATE_INDEX_BINDER_1CP(        // binds to        multi_index::ordered_unique,        // with        key_compare    )    BOOST_BIMAP_GENERATE_MAP_VIEW_BINDER(        // binds to        views::map_view    )    BOOST_BIMAP_GENERATE_SET_VIEW_BINDER(        // binds to        views::set_view    )    typedef mpl::bool_<false> mutable_key;};/// \brief Set Of Relation Specification/**This struct is similar to set_of but it is bind logically to arelation. It is used in the bimap instantiation to specify thedesired type of the main view. This struct implements internallya metafunction named bind_to that manages the quite complicatedtask of finding the right type of the set for the relation.\codetemplate<class Relation>struct bind_to{    typedef -unspecified- type;};\endcodeSee also set_of, is_set_type_of_relation.                                                                **/template< class KeyCompare = std::less< _relation > >struct set_of_relation : public ::boost::bimaps::detail::set_type_of_relation_tag{    /// Functor that compare two keys    typedef KeyCompare key_compare;    BOOST_BIMAP_GENERATE_RELATION_BINDER_1CP(        // binds to        set_of,        // with        key_compare    )    typedef mpl::bool_<false>  left_mutable_key;    typedef mpl::bool_<false> right_mutable_key;};} // namespace bimaps} // namespace boost#endif // BOOST_BIMAP_SET_OF_HPP
 |