Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-19 09:47:51

0001 //  Copyright (c) 2001, Daniel C. Nuffer
0002 //  Copyright (c) 2001-2011 Hartmut Kaiser
0003 // 
0004 //  Distributed under the Boost Software License, Version 1.0. (See accompanying
0005 //  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 
0007 #if !defined(BOOST_SPIRIT_ITERATOR_FIRST_OWNER_POLICY_MAR_16_2007_1108AM)
0008 #define BOOST_SPIRIT_ITERATOR_FIRST_OWNER_POLICY_MAR_16_2007_1108AM
0009 
0010 #include <boost/spirit/home/support/iterators/multi_pass_fwd.hpp>
0011 #include <boost/spirit/home/support/iterators/detail/multi_pass.hpp>
0012 
0013 namespace boost { namespace spirit { namespace iterator_policies
0014 {
0015     ///////////////////////////////////////////////////////////////////////////
0016     //  class first_owner
0017     //  Implementation of an OwnershipPolicy used by multi_pass
0018     //  This ownership policy dictates that the first iterator created will
0019     //  determine the lifespan of the shared components.  This works well for
0020     //  spirit, since no dynamic allocation of iterators is done, and all 
0021     //  copies are make on the stack.
0022     //
0023     //  There is a caveat about using this policy together with the std_deque
0024     //  StoragePolicy. Since first_owner always returns false from unique(),
0025     //  std_deque will only release the queued data if clear_queue() is called.
0026     ///////////////////////////////////////////////////////////////////////////
0027     struct first_owner
0028     {
0029         ///////////////////////////////////////////////////////////////////////
0030         struct unique : detail::default_ownership_policy
0031         {
0032             unique() : first(true) {}
0033             unique(unique const&) : first(false) {}
0034 
0035             // return true to indicate deletion of resources
0036             template <typename MultiPass>
0037             static bool release(MultiPass& mp)
0038             {
0039                 return mp.first;
0040             }
0041 
0042             // use swap from default policy
0043             // if we're the first, we still remain the first, even if assigned
0044             // to, so don't swap first.  swap is only called from operator=
0045 
0046             template <typename MultiPass>
0047             static bool is_unique(MultiPass const&) 
0048             {
0049                 return false; // no way to know, so always return false
0050             }
0051 
0052         protected:
0053             bool first;
0054         };
0055 
0056         ////////////////////////////////////////////////////////////////////////
0057         struct shared {};   // no shared data
0058     };
0059 
0060 }}}
0061 
0062 #endif