Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:38:38

0001 /////////////////////////////////////////////////////////////////////////////
0002 //
0003 // (C) Copyright Ion Gaztanaga  2006-2013
0004 //
0005 // Distributed under the Boost Software License, Version 1.0.
0006 //    (See accompanying file LICENSE_1_0.txt or copy at
0007 //          http://www.boost.org/LICENSE_1_0.txt)
0008 //
0009 // See http://www.boost.org/libs/intrusive for documentation.
0010 //
0011 /////////////////////////////////////////////////////////////////////////////
0012 
0013 #ifndef BOOST_INTRUSIVE_ANY_HOOK_HPP
0014 #define BOOST_INTRUSIVE_ANY_HOOK_HPP
0015 
0016 #include <boost/intrusive/detail/config_begin.hpp>
0017 #include <boost/intrusive/intrusive_fwd.hpp>
0018 #include <boost/intrusive/detail/any_node_and_algorithms.hpp>
0019 #include <boost/intrusive/options.hpp>
0020 #include <boost/intrusive/detail/generic_hook.hpp>
0021 #include <boost/intrusive/detail/mpl.hpp>
0022 #include <boost/intrusive/pointer_rebind.hpp>
0023 
0024 #if defined(BOOST_HAS_PRAGMA_ONCE)
0025 #  pragma once
0026 #endif
0027 
0028 namespace boost {
0029 namespace intrusive {
0030 
0031 //! Helper metafunction to define a \c \c any_base_hook that yields to the same
0032 //! type when the same options (either explicitly or implicitly) are used.
0033 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
0034 template<class ...Options>
0035 #else
0036 template<class O1 = void, class O2 = void, class O3 = void>
0037 #endif
0038 struct make_any_base_hook
0039 {
0040    /// @cond
0041    typedef typename pack_options
0042       < hook_defaults,
0043       #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
0044       O1, O2, O3
0045       #else
0046       Options...
0047       #endif
0048       >::type packed_options;
0049 
0050    typedef generic_hook
0051    < AnyAlgorithm
0052    , any_node_traits<typename packed_options::void_pointer>
0053    , typename packed_options::tag
0054    , packed_options::link_mode
0055    , AnyBaseHookId
0056    > implementation_defined;
0057    /// @endcond
0058    typedef implementation_defined type;
0059 };
0060 
0061 //! Derive a class from this hook in order to store objects of that class
0062 //! in an intrusive container.
0063 //!
0064 //! The hook admits the following options: \c tag<>, \c void_pointer<> and
0065 //! \c link_mode<>.
0066 //!
0067 //! \c tag<> defines a tag to identify the node.
0068 //! The same tag value can be used in different classes, but if a class is
0069 //! derived from more than one \c any_base_hook, then each \c any_base_hook needs its
0070 //! unique tag.
0071 //!
0072 //! \c link_mode<> will specify the linking mode of the hook (\c normal_link, \c safe_link).
0073 //!
0074 //! \c void_pointer<> is the pointer type that will be used internally in the hook
0075 //! and the container configured to use this hook.
0076 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
0077 template<class ...Options>
0078 #else
0079 template<class O1, class O2, class O3>
0080 #endif
0081 class any_base_hook
0082    :  public make_any_base_hook
0083       #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
0084       <O1, O2, O3>
0085       #else
0086       <Options...>
0087       #endif
0088       ::type
0089 {
0090    #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
0091    public:
0092    //! <b>Effects</b>: If link_mode is or \c safe_link
0093    //!   initializes the node to an unlinked state.
0094    //!
0095    //! <b>Throws</b>: Nothing.
0096    any_base_hook();
0097 
0098    //! <b>Effects</b>: If link_mode is or \c safe_link
0099    //!   initializes the node to an unlinked state. The argument is ignored.
0100    //!
0101    //! <b>Throws</b>: Nothing.
0102    //!
0103    //! <b>Rationale</b>: Providing a copy-constructor
0104    //!   makes classes using the hook STL-compliant without forcing the
0105    //!   user to do some additional work. \c swap can be used to emulate
0106    //!   move-semantics.
0107    any_base_hook(const any_base_hook& );
0108 
0109    //! <b>Effects</b>: Empty function. The argument is ignored.
0110    //!
0111    //! <b>Throws</b>: Nothing.
0112    //!
0113    //! <b>Rationale</b>: Providing an assignment operator
0114    //!   makes classes using the hook STL-compliant without forcing the
0115    //!   user to do some additional work. \c swap can be used to emulate
0116    //!   move-semantics.
0117    any_base_hook& operator=(const any_base_hook& );
0118 
0119    //! <b>Effects</b>: If link_mode is \c normal_link, the destructor does
0120    //!   nothing (ie. no code is generated). If link_mode is \c safe_link and the
0121    //!   object is stored in a container an assertion is raised.
0122    //!
0123    //! <b>Throws</b>: Nothing.
0124    ~any_base_hook();
0125 
0126    //! <b>Precondition</b>: link_mode must be \c safe_link.
0127    //!
0128    //! <b>Returns</b>: true, if the node belongs to a container, false
0129    //!   otherwise. This function can be used to test whether \c container::iterator_to
0130    //!   will return a valid iterator.
0131    //!
0132    //! <b>Complexity</b>: Constant
0133    bool is_linked() const;
0134    #endif
0135 };
0136 
0137 //! Helper metafunction to define a \c \c any_member_hook that yields to the same
0138 //! type when the same options (either explicitly or implicitly) are used.
0139 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
0140 template<class ...Options>
0141 #else
0142 template<class O1 = void, class O2 = void, class O3 = void>
0143 #endif
0144 struct make_any_member_hook
0145 {
0146    /// @cond
0147    typedef typename pack_options
0148       < hook_defaults,
0149       #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
0150       O1, O2, O3
0151       #else
0152       Options...
0153       #endif
0154       >::type packed_options;
0155 
0156    typedef generic_hook
0157    < AnyAlgorithm
0158    , any_node_traits<typename packed_options::void_pointer>
0159    , member_tag
0160    , packed_options::link_mode
0161    , NoBaseHookId
0162    > implementation_defined;
0163    /// @endcond
0164    typedef implementation_defined type;
0165 };
0166 
0167 //! Store this hook in a class to be inserted
0168 //! in an intrusive container.
0169 //!
0170 //! The hook admits the following options: \c void_pointer<> and
0171 //! \c link_mode<>.
0172 //!
0173 //! \c link_mode<> will specify the linking mode of the hook (\c normal_link or \c safe_link).
0174 //!
0175 //! \c void_pointer<> is the pointer type that will be used internally in the hook
0176 //! and the container configured to use this hook.
0177 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
0178 template<class ...Options>
0179 #else
0180 template<class O1, class O2, class O3>
0181 #endif
0182 class any_member_hook
0183    :  public make_any_member_hook
0184       #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
0185       <O1, O2, O3>
0186       #else
0187       <Options...>
0188       #endif
0189       ::type
0190 {
0191    #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
0192    public:
0193    //! <b>Effects</b>: If link_mode is or \c safe_link
0194    //!   initializes the node to an unlinked state.
0195    //!
0196    //! <b>Throws</b>: Nothing.
0197    any_member_hook() BOOST_NOEXCEPT;
0198 
0199    //! <b>Effects</b>: If link_mode is or \c safe_link
0200    //!   initializes the node to an unlinked state. The argument is ignored.
0201    //!
0202    //! <b>Throws</b>: Nothing.
0203    //!
0204    //! <b>Rationale</b>: Providing a copy-constructor
0205    //!   makes classes using the hook STL-compliant without forcing the
0206    //!   user to do some additional work. \c swap can be used to emulate
0207    //!   move-semantics.
0208    any_member_hook(const any_member_hook&) BOOST_NOEXCEPT;
0209 
0210    //! <b>Effects</b>: Empty function. The argument is ignored.
0211    //!
0212    //! <b>Throws</b>: Nothing.
0213    //!
0214    //! <b>Rationale</b>: Providing an assignment operator
0215    //!   makes classes using the hook STL-compliant without forcing the
0216    //!   user to do some additional work. \c swap can be used to emulate
0217    //!   move-semantics.
0218    any_member_hook& operator=(const any_member_hook&) BOOST_NOEXCEPT;
0219 
0220    //! <b>Effects</b>: If link_mode is \c normal_link, the destructor does
0221    //!   nothing (ie. no code is generated). If link_mode is \c safe_link and the
0222    //!   object is stored in a container an assertion is raised.
0223    //!
0224    //! <b>Throws</b>: Nothing.
0225    ~any_member_hook();
0226 
0227    //! <b>Precondition</b>: link_mode must be \c safe_link.
0228    //!
0229    //! <b>Returns</b>: true, if the node belongs to a container, false
0230    //!   otherwise. This function can be used to test whether \c container::iterator_to
0231    //!   will return a valid iterator.
0232    //!
0233    //! <b>Complexity</b>: Constant
0234    bool is_linked() const BOOST_NOEXCEPT;
0235    #endif
0236 };
0237 
0238 /// @cond
0239 
0240 namespace detail{
0241 
0242 BOOST_INTRUSIVE_INTERNAL_STATIC_BOOL_IS_TRUE(old_proto_value_traits_base_hook, hooktags::is_base_hook)
0243 
0244 //!This option setter specifies that the container
0245 //!must use the specified base hook
0246 template<class BasicHook, template <class> class NodeTraits>
0247 struct any_to_some_hook
0248 {
0249    typedef typename BasicHook::template pack<empty>::proto_value_traits old_proto_value_traits;
0250 
0251    template<class Base>
0252    struct pack : public Base
0253    {
0254       struct proto_value_traits
0255       {
0256          //proto_value_traits::hooktags::is_base_hook is used by get_value_traits
0257          //to detect base hooks, so mark it in case BasicHook has it.
0258          struct hooktags
0259          {
0260             static const bool is_base_hook = old_proto_value_traits_base_hook_bool_is_true
0261                <old_proto_value_traits>::value;
0262          };
0263 
0264          typedef old_proto_value_traits basic_hook_t;
0265          static const bool is_any_hook = true;
0266 
0267          template<class VoidPtr>
0268          struct node_traits_from_voidptr
0269          {  typedef NodeTraits<VoidPtr> type;  };
0270       };
0271    };
0272 };
0273 
0274 }  //namespace detail{
0275 
0276 /// @endcond
0277 
0278 //!This option setter specifies that
0279 //!any hook should behave as an slist hook
0280 template<class BasicHook>
0281 struct any_to_slist_hook
0282 /// @cond
0283    :  public detail::any_to_some_hook<BasicHook, any_slist_node_traits>
0284 /// @endcond
0285 {};
0286 
0287 //!This option setter specifies that
0288 //!any hook should behave as an list hook
0289 template<class BasicHook>
0290 struct any_to_list_hook
0291 /// @cond
0292    :  public detail::any_to_some_hook<BasicHook, any_list_node_traits>
0293 /// @endcond
0294 {};
0295 
0296 //!This option setter specifies that
0297 //!any hook should behave as a set hook
0298 template<class BasicHook>
0299 struct any_to_set_hook
0300 /// @cond
0301    :  public detail::any_to_some_hook<BasicHook, any_rbtree_node_traits>
0302 /// @endcond
0303 {};
0304 
0305 //!This option setter specifies that
0306 //!any hook should behave as an avl_set hook
0307 template<class BasicHook>
0308 struct any_to_avl_set_hook
0309 /// @cond
0310    :  public detail::any_to_some_hook<BasicHook, any_avltree_node_traits>
0311 /// @endcond
0312 {};
0313 
0314 //!This option setter specifies that any
0315 //!hook should behave as a bs_set hook
0316 template<class BasicHook>
0317 struct any_to_bs_set_hook
0318 /// @cond
0319    :  public detail::any_to_some_hook<BasicHook, any_tree_node_traits>
0320 /// @endcond
0321 {};
0322 
0323 //!This option setter specifies that any hook
0324 //!should behave as an unordered set hook
0325 template<class BasicHook>
0326 struct any_to_unordered_set_hook
0327 /// @cond
0328    :  public detail::any_to_some_hook<BasicHook, any_unordered_node_traits>
0329 /// @endcond
0330 {};
0331 
0332 
0333 } //namespace intrusive
0334 } //namespace boost
0335 
0336 #include <boost/intrusive/detail/config_end.hpp>
0337 
0338 #endif //BOOST_INTRUSIVE_ANY_HOOK_HPP