File indexing completed on 2024-11-15 09:31:58
0001
0002
0003
0004
0005
0006
0007 #if !defined(BOOST_SPIRIT_ITERATOR_REF_COUNTED_POLICY_MAR_16_2007_1108AM)
0008 #define BOOST_SPIRIT_ITERATOR_REF_COUNTED_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 #if defined(BOOST_HAS_THREADS)
0013 #include <boost/detail/atomic_count.hpp>
0014 #endif
0015 #include <cstdlib>
0016
0017 namespace boost { namespace spirit { namespace iterator_policies
0018 {
0019
0020
0021
0022
0023
0024
0025
0026 struct ref_counted
0027 {
0028
0029 struct unique
0030 {
0031 void swap(unique&) {}
0032
0033
0034
0035 template <typename MultiPass>
0036 static void clone(MultiPass& mp)
0037 {
0038 if (0 != mp.shared())
0039 ++mp.shared()->count;
0040 }
0041
0042
0043
0044 template <typename MultiPass>
0045 static bool release(MultiPass& mp)
0046 {
0047 return 0 != mp.shared() && 0 == --mp.shared()->count;
0048 }
0049
0050
0051
0052
0053 template <typename MultiPass>
0054 static bool is_unique(MultiPass const& mp)
0055 {
0056 return 0 == mp.shared() || 1 == mp.shared()->count;
0057 }
0058
0059 template <typename MultiPass>
0060 static void destroy(MultiPass&) {}
0061 };
0062
0063
0064 struct shared
0065 {
0066 shared() : count(1) {}
0067
0068 #if defined(BOOST_HAS_THREADS)
0069 boost::detail::atomic_count count;
0070 #else
0071 std::size_t count;
0072 #endif
0073 };
0074
0075 };
0076
0077 }}}
0078
0079 #endif