Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/boost/flyweight/static_holder.hpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /* Copyright 2006-2009 Joaquin M Lopez Munoz.
0002  * Distributed under the Boost Software License, Version 1.0.
0003  * (See accompanying file LICENSE_1_0.txt or copy at
0004  * http://www.boost.org/LICENSE_1_0.txt)
0005  *
0006  * See http://www.boost.org/libs/flyweight for library home page.
0007  */
0008 
0009 #ifndef BOOST_FLYWEIGHT_STATIC_HOLDER_HPP
0010 #define BOOST_FLYWEIGHT_STATIC_HOLDER_HPP
0011 
0012 #if defined(_MSC_VER)
0013 #pragma once
0014 #endif
0015 
0016 #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
0017 #include <boost/flyweight/static_holder_fwd.hpp>
0018 #include <boost/flyweight/holder_tag.hpp>
0019 #include <boost/mpl/aux_/lambda_support.hpp>
0020 
0021 /* Simplest holder storing the T object as a local static variable.
0022  */
0023 
0024 namespace boost{
0025 
0026 namespace flyweights{
0027 
0028 template<typename C>
0029 struct static_holder_class:holder_marker
0030 {
0031   static C& get()
0032   {
0033     static C c;
0034     return c;
0035   }
0036 
0037   typedef static_holder_class type;
0038   BOOST_MPL_AUX_LAMBDA_SUPPORT(1,static_holder_class,(C))
0039 };
0040 
0041 /* static_holder_class specifier */
0042 
0043 struct static_holder:holder_marker
0044 {
0045   template<typename C>
0046   struct apply
0047   {
0048     typedef static_holder_class<C> type;
0049   };
0050 };
0051 
0052 } /* namespace flyweights */
0053 
0054 } /* namespace boost */
0055 
0056 #endif