Ticket #2481: make_shared_access.patch

File make_shared_access.patch, 24.7 KB (added by Michael Marcin <mike.marcin@…>, 14 years ago)
  • make_shared.hpp

     
    8888
    8989} // namespace detail
    9090
    91 // Zero-argument versions
    92 //
    93 // Used even when variadic templates are available because of the new T() vs new T issue
    94 
    95 template< class T > boost::shared_ptr< T > make_shared()
     91namespace detail
    9692{
    97     boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >() );
     93class make_shared_access
     94{
     95public:
    9896
    99     detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt );
     97        template< class T >
     98        static boost::shared_ptr< T > make_shared()
     99        {
     100                boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >() );
    100101
    101     void * pv = pd->address();
     102                detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt );
    102103
    103     new( pv ) T();
    104     pd->set_initialized();
     104                void * pv = pd->address();
    105105
    106     return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) );
    107 }
     106                new( pv ) T();
     107                pd->set_initialized();
    108108
    109 template< class T, class A > boost::shared_ptr< T > allocate_shared( A const & a )
    110 {
    111     boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >(), a );
     109                return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) );
     110        }
    112111
    113     detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt );
     112        template< class T, class A >
     113        static boost::shared_ptr< T > allocate_shared( A const & a )
     114        {
     115                boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >(), a );
    114116
    115     void * pv = pd->address();
     117                detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt );
    116118
    117     new( pv ) T();
    118     pd->set_initialized();
     119                void * pv = pd->address();
    119120
    120     return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) );
     121                new( pv ) T();
     122                pd->set_initialized();
     123
     124                return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) );
     125        }
     126
     127#if defined( BOOST_HAS_VARIADIC_TMPL ) && defined( BOOST_HAS_RVALUE_REFS )
     128        /// @todo implement var args version
     129#else
     130    template< class T, class A1 >
     131    static boost::shared_ptr< T > make_shared( A1 const & a1 )
     132    {
     133        boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >() );
     134
     135        detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt );
     136
     137        void * pv = pd->address();
     138
     139        new( pv ) T( a1 );
     140        pd->set_initialized();
     141
     142        return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) );
     143    }
     144
     145    template< class T, class A, class A1 >
     146    static boost::shared_ptr< T > allocate_shared( A const & a, A1 const & a1 )
     147    {
     148        boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >(), a );
     149
     150        detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt );
     151
     152        void * pv = pd->address();
     153
     154        new( pv ) T( a1 );
     155        pd->set_initialized();
     156
     157        return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) );
     158    }
     159
     160    template< class T, class A1, class A2 >
     161    static boost::shared_ptr< T > make_shared( A1 const & a1, A2 const & a2 )
     162    {
     163        boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >() );
     164
     165        detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt );
     166
     167        void * pv = pd->address();
     168
     169        new( pv ) T( a1, a2 );
     170        pd->set_initialized();
     171
     172        return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) );
     173    }
     174
     175    template< class T, class A, class A1, class A2 >
     176    static boost::shared_ptr< T > allocate_shared( A const & a, A1 const & a1, A2 const & a2 )
     177    {
     178        boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >(), a );
     179
     180        detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt );
     181
     182        void * pv = pd->address();
     183
     184        new( pv ) T( a1, a2 );
     185        pd->set_initialized();
     186
     187        return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) );
     188    }
     189
     190    template< class T, class A1, class A2, class A3 >
     191    static boost::shared_ptr< T > make_shared( A1 const & a1, A2 const & a2, A3 const & a3 )
     192    {
     193        boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >() );
     194
     195        detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt );
     196
     197        void * pv = pd->address();
     198
     199        new( pv ) T( a1, a2, a3 );
     200        pd->set_initialized();
     201
     202        return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) );
     203    }
     204
     205    template< class T, class A, class A1, class A2, class A3 >
     206    static boost::shared_ptr< T > allocate_shared( A const & a, A1 const & a1, A2 const & a2, A3 const & a3 )
     207    {
     208        boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >(), a );
     209
     210        detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt );
     211
     212        void * pv = pd->address();
     213
     214        new( pv ) T( a1, a2, a3 );
     215        pd->set_initialized();
     216
     217        return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) );
     218    }
     219
     220    template< class T, class A1, class A2, class A3, class A4 >
     221    static boost::shared_ptr< T > make_shared( A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4 )
     222    {
     223        boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >() );
     224
     225        detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt );
     226
     227        void * pv = pd->address();
     228
     229        new( pv ) T( a1, a2, a3, a4 );
     230        pd->set_initialized();
     231
     232        return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) );
     233    }
     234
     235    template< class T, class A, class A1, class A2, class A3, class A4 >
     236    static boost::shared_ptr< T > allocate_shared( A const & a, A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4 )
     237    {
     238        boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >(), a );
     239
     240        detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt );
     241
     242        void * pv = pd->address();
     243
     244        new( pv ) T( a1, a2, a3, a4 );
     245        pd->set_initialized();
     246
     247        return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) );
     248    }
     249
     250    template< class T, class A1, class A2, class A3, class A4, class A5 >
     251    static boost::shared_ptr< T > make_shared( A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5 )
     252    {
     253        boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >() );
     254
     255        detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt );
     256
     257        void * pv = pd->address();
     258
     259        new( pv ) T( a1, a2, a3, a4, a5 );
     260        pd->set_initialized();
     261
     262        return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) );
     263    }
     264
     265    template< class T, class A, class A1, class A2, class A3, class A4, class A5 >
     266    static boost::shared_ptr< T > allocate_shared( A const & a, A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5 )
     267    {
     268        boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >(), a );
     269
     270        detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt );
     271
     272        void * pv = pd->address();
     273
     274        new( pv ) T( a1, a2, a3, a4, a5 );
     275        pd->set_initialized();
     276
     277        return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) );
     278    }
     279
     280    template< class T, class A1, class A2, class A3, class A4, class A5, class A6 >
     281    static boost::shared_ptr< T > make_shared( A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5, A6 const & a6 )
     282    {
     283        boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >() );
     284
     285        detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt );
     286
     287        void * pv = pd->address();
     288
     289        new( pv ) T( a1, a2, a3, a4, a5, a6 );
     290        pd->set_initialized();
     291
     292        return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) );
     293    }
     294
     295    template< class T, class A, class A1, class A2, class A3, class A4, class A5, class A6 >
     296    static boost::shared_ptr< T > allocate_shared( A const & a, A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5, A6 const & a6 )
     297    {
     298        boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >(), a );
     299
     300        detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt );
     301
     302        void * pv = pd->address();
     303
     304        new( pv ) T( a1, a2, a3, a4, a5, a6 );
     305        pd->set_initialized();
     306
     307        return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) );
     308    }
     309
     310    template< class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7 >
     311    static boost::shared_ptr< T > make_shared( A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5, A6 const & a6, A7 const & a7 )
     312    {
     313        boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >() );
     314
     315        detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt );
     316
     317        void * pv = pd->address();
     318
     319        new( pv ) T( a1, a2, a3, a4, a5, a6, a7 );
     320        pd->set_initialized();
     321
     322        return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) );
     323    }
     324
     325    template< class T, class A, class A1, class A2, class A3, class A4, class A5, class A6, class A7 >
     326    static boost::shared_ptr< T > allocate_shared( A const & a, A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5, A6 const & a6, A7 const & a7 )
     327    {
     328        boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >(), a );
     329
     330        detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt );
     331
     332        void * pv = pd->address();
     333
     334        new( pv ) T( a1, a2, a3, a4, a5, a6, a7 );
     335        pd->set_initialized();
     336
     337        return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) );
     338    }
     339
     340    template< class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8 >
     341    static boost::shared_ptr< T > make_shared( A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5, A6 const & a6, A7 const & a7, A8 const & a8 )
     342    {
     343        boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >() );
     344
     345        detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt );
     346
     347        void * pv = pd->address();
     348
     349        new( pv ) T( a1, a2, a3, a4, a5, a6, a7, a8 );
     350        pd->set_initialized();
     351
     352        return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) );
     353    }
     354
     355    template< class T, class A, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8 >
     356    static boost::shared_ptr< T > allocate_shared( A const & a, A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5, A6 const & a6, A7 const & a7, A8 const & a8 )
     357    {
     358        boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >(), a );
     359
     360        detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt );
     361
     362        void * pv = pd->address();
     363
     364        new( pv ) T( a1, a2, a3, a4, a5, a6, a7, a8 );
     365        pd->set_initialized();
     366
     367        return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) );
     368    }
     369
     370    template< class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9 >
     371    static boost::shared_ptr< T > make_shared( A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5, A6 const & a6, A7 const & a7, A8 const & a8, A9 const & a9 )
     372    {
     373        boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >() );
     374
     375        detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt );
     376
     377        void * pv = pd->address();
     378
     379        new( pv ) T( a1, a2, a3, a4, a5, a6, a7, a8, a9 );
     380        pd->set_initialized();
     381
     382        return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) );
     383    }
     384
     385    template< class T, class A, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9 >
     386    static boost::shared_ptr< T > allocate_shared( A const & a, A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5, A6 const & a6, A7 const & a7, A8 const & a8, A9 const & a9 )
     387    {
     388        boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >(), a );
     389
     390        detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt );
     391
     392        void * pv = pd->address();
     393
     394        new( pv ) T( a1, a2, a3, a4, a5, a6, a7, a8, a9 );
     395        pd->set_initialized();
     396
     397        return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) );
     398    }
     399#endif
     400};
     401}  // namespace detail
     402
     403// Zero-argument versions
     404//
     405// Used even when variadic templates are available because of the new T() vs new T issue
     406
     407template< class T > boost::shared_ptr< T > make_shared()
     408{
     409        return detail::make_shared_access::make_shared<T>();
    121410}
    122411
     412template< class T, class A > boost::shared_ptr< T > allocate_shared( A const & a )
     413{
     414        return detail::make_shared_access::allocate_shared<T>();
     415}
     416
    123417#if defined( BOOST_HAS_VARIADIC_TMPL ) && defined( BOOST_HAS_RVALUE_REFS )
    124418
    125419// Variadic templates, rvalue reference
     
    159453template< class T, class A1 >
    160454boost::shared_ptr< T > make_shared( A1 const & a1 )
    161455{
    162     boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >() );
    163 
    164     detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt );
    165 
    166     void * pv = pd->address();
    167 
    168     new( pv ) T( a1 );
    169     pd->set_initialized();
    170 
    171     return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) );
     456        return detail::make_shared_access::make_shared<T>(a1);
    172457}
    173458
    174459template< class T, class A, class A1 >
    175460boost::shared_ptr< T > allocate_shared( A const & a, A1 const & a1 )
    176461{
    177     boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >(), a );
    178 
    179     detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt );
    180 
    181     void * pv = pd->address();
    182 
    183     new( pv ) T( a1 );
    184     pd->set_initialized();
    185 
    186     return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) );
     462    return detail::make_shared_access::allocate_shared<T>(a,a1);
    187463}
    188464
    189465template< class T, class A1, class A2 >
    190466boost::shared_ptr< T > make_shared( A1 const & a1, A2 const & a2 )
    191467{
    192     boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >() );
    193 
    194     detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt );
    195 
    196     void * pv = pd->address();
    197 
    198     new( pv ) T( a1, a2 );
    199     pd->set_initialized();
    200 
    201     return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) );
     468   return detail::make_shared_access::make_shared<T>(a1,a2);
    202469}
    203470
    204471template< class T, class A, class A1, class A2 >
    205472boost::shared_ptr< T > allocate_shared( A const & a, A1 const & a1, A2 const & a2 )
    206473{
    207     boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >(), a );
    208 
    209     detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt );
    210 
    211     void * pv = pd->address();
    212 
    213     new( pv ) T( a1, a2 );
    214     pd->set_initialized();
    215 
    216     return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) );
     474    return detail::make_shared_access::allocate_shared<T>(a,a1,a2);
    217475}
    218476
    219477template< class T, class A1, class A2, class A3 >
    220478boost::shared_ptr< T > make_shared( A1 const & a1, A2 const & a2, A3 const & a3 )
    221479{
    222     boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >() );
    223 
    224     detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt );
    225 
    226     void * pv = pd->address();
    227 
    228     new( pv ) T( a1, a2, a3 );
    229     pd->set_initialized();
    230 
    231     return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) );
     480        return detail::make_shared_access::make_shared<T>(a1,a2,a3);
    232481}
    233482
    234483template< class T, class A, class A1, class A2, class A3 >
    235484boost::shared_ptr< T > allocate_shared( A const & a, A1 const & a1, A2 const & a2, A3 const & a3 )
    236485{
    237     boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >(), a );
    238 
    239     detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt );
    240 
    241     void * pv = pd->address();
    242 
    243     new( pv ) T( a1, a2, a3 );
    244     pd->set_initialized();
    245 
    246     return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) );
     486    return detail::make_shared_access::allocate_shared<T>(a,a1,a2,a3);
    247487}
    248488
    249489template< class T, class A1, class A2, class A3, class A4 >
    250490boost::shared_ptr< T > make_shared( A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4 )
    251491{
    252     boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >() );
    253 
    254     detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt );
    255 
    256     void * pv = pd->address();
    257 
    258     new( pv ) T( a1, a2, a3, a4 );
    259     pd->set_initialized();
    260 
    261     return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) );
     492    return detail::make_shared_access::make_shared<T>(a1,a2,a3,a4);
    262493}
    263494
    264495template< class T, class A, class A1, class A2, class A3, class A4 >
    265496boost::shared_ptr< T > allocate_shared( A const & a, A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4 )
    266497{
    267     boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >(), a );
    268 
    269     detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt );
    270 
    271     void * pv = pd->address();
    272 
    273     new( pv ) T( a1, a2, a3, a4 );
    274     pd->set_initialized();
    275 
    276     return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) );
     498    return detail::make_shared_access::allocate_shared<T>(a,a1,a2,a3,a4);
    277499}
    278500
    279501template< class T, class A1, class A2, class A3, class A4, class A5 >
    280502boost::shared_ptr< T > make_shared( A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5 )
    281503{
    282     boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >() );
    283 
    284     detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt );
    285 
    286     void * pv = pd->address();
    287 
    288     new( pv ) T( a1, a2, a3, a4, a5 );
    289     pd->set_initialized();
    290 
    291     return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) );
     504    return detail::make_shared_access::make_shared<T>(a1,a2,a3,a4,a5);
    292505}
    293506
    294507template< class T, class A, class A1, class A2, class A3, class A4, class A5 >
    295508boost::shared_ptr< T > allocate_shared( A const & a, A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5 )
    296509{
    297     boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >(), a );
    298 
    299     detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt );
    300 
    301     void * pv = pd->address();
    302 
    303     new( pv ) T( a1, a2, a3, a4, a5 );
    304     pd->set_initialized();
    305 
    306     return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) );
     510    return detail::make_shared_access::allocate_shared<T>(a,a1,a2,a3,a4,a5);
    307511}
    308512
    309513template< class T, class A1, class A2, class A3, class A4, class A5, class A6 >
    310514boost::shared_ptr< T > make_shared( A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5, A6 const & a6 )
    311515{
    312     boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >() );
    313 
    314     detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt );
    315 
    316     void * pv = pd->address();
    317 
    318     new( pv ) T( a1, a2, a3, a4, a5, a6 );
    319     pd->set_initialized();
    320 
    321     return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) );
     516    return detail::make_shared_access::make_shared<T>(a1,a2,a3,a4,a5,a6);
    322517}
    323518
    324519template< class T, class A, class A1, class A2, class A3, class A4, class A5, class A6 >
    325520boost::shared_ptr< T > allocate_shared( A const & a, A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5, A6 const & a6 )
    326521{
    327     boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >(), a );
    328 
    329     detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt );
    330 
    331     void * pv = pd->address();
    332 
    333     new( pv ) T( a1, a2, a3, a4, a5, a6 );
    334     pd->set_initialized();
    335 
    336     return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) );
     522    return detail::make_shared_access::allocate_shared<T>(a,a1,a2,a3,a4,a5,a6);
    337523}
    338524
    339525template< class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7 >
    340526boost::shared_ptr< T > make_shared( A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5, A6 const & a6, A7 const & a7 )
    341527{
    342     boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >() );
    343 
    344     detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt );
    345 
    346     void * pv = pd->address();
    347 
    348     new( pv ) T( a1, a2, a3, a4, a5, a6, a7 );
    349     pd->set_initialized();
    350 
    351     return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) );
     528    return detail::make_shared_access::make_shared<T>(a1,a2,a3,a4,a5,a6,a7);
    352529}
    353530
    354531template< class T, class A, class A1, class A2, class A3, class A4, class A5, class A6, class A7 >
    355532boost::shared_ptr< T > allocate_shared( A const & a, A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5, A6 const & a6, A7 const & a7 )
    356533{
    357     boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >(), a );
    358 
    359     detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt );
    360 
    361     void * pv = pd->address();
    362 
    363     new( pv ) T( a1, a2, a3, a4, a5, a6, a7 );
    364     pd->set_initialized();
    365 
    366     return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) );
     534    return detail::make_shared_access::allocate_shared<T>(a,a1,a2,a3,a4,a5,a6,a7);
    367535}
    368536
    369537template< class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8 >
    370538boost::shared_ptr< T > make_shared( A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5, A6 const & a6, A7 const & a7, A8 const & a8 )
    371539{
    372     boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >() );
    373 
    374     detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt );
    375 
    376     void * pv = pd->address();
    377 
    378     new( pv ) T( a1, a2, a3, a4, a5, a6, a7, a8 );
    379     pd->set_initialized();
    380 
    381     return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) );
     540    return detail::make_shared_access::make_shared<T>(a1,a2,a3,a4,a5,a6,a7,a8);
    382541}
    383542
    384543template< class T, class A, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8 >
    385544boost::shared_ptr< T > allocate_shared( A const & a, A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5, A6 const & a6, A7 const & a7, A8 const & a8 )
    386545{
    387     boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >(), a );
    388 
    389     detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt );
    390 
    391     void * pv = pd->address();
    392 
    393     new( pv ) T( a1, a2, a3, a4, a5, a6, a7, a8 );
    394     pd->set_initialized();
    395 
    396     return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) );
     546    return detail::make_shared_access::allocate_shared<T>(a,a1,a2,a3,a4,a5,a6,a7,a8);
    397547}
    398548
    399549template< class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9 >
    400550boost::shared_ptr< T > make_shared( A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5, A6 const & a6, A7 const & a7, A8 const & a8, A9 const & a9 )
    401551{
    402     boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >() );
    403 
    404     detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt );
    405 
    406     void * pv = pd->address();
    407 
    408     new( pv ) T( a1, a2, a3, a4, a5, a6, a7, a8, a9 );
    409     pd->set_initialized();
    410 
    411     return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) );
     552    return detail::make_shared_access::make_shared<T>(a1,a2,a3,a4,a5,a6,a7,a8,a9);
    412553}
    413554
    414555template< class T, class A, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9 >
    415556boost::shared_ptr< T > allocate_shared( A const & a, A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5, A6 const & a6, A7 const & a7, A8 const & a8, A9 const & a9 )
    416557{
    417     boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >(), a );
     558    return detail::make_shared_access::allocate_shared<T>(a,a1,a2,a3,a4,a5,a6,a7,a8,a9);
     559}
    418560
    419     detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt );
     561using detail::make_shared_access;
    420562
    421     void * pv = pd->address();
    422 
    423     new( pv ) T( a1, a2, a3, a4, a5, a6, a7, a8, a9 );
    424     pd->set_initialized();
    425 
    426     return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) );
    427 }
    428 
    429563#endif
    430564
    431565} // namespace boost