imgtools/imglib/boostlibrary/boost/utility/in_place_factory.hpp
author Mike Kinghan <mikek@symbian.org>
Tue, 13 Jul 2010 15:21:54 +0100
changeset 24 936784880b21
parent 2 39c28ec933dd
permissions -rwxr-xr-x
Seems I can't "unforget" erroneously forgotten files, so will have to forget them and then re-add them
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
     1
// Copyright (C) 2003, Fernando Luis Cacciola Carballal.
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
     2
// Copyright (C) 2007, Tobias Schwinger.
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
     3
//
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
     4
// Use, modification, and distribution is subject to the Boost Software
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
     5
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
     6
// http://www.boost.org/LICENSE_1_0.txt)
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
     7
//
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
     8
// See http://www.boost.org/lib/optional for documentation.
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
     9
//
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    10
// You are welcome to contact the author at:
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    11
//  fernando_cacciola@hotmail.com
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    12
//
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    13
#ifndef BOOST_UTILITY_INPLACE_FACTORY_04APR2007_HPP
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    14
#ifndef BOOST_PP_IS_ITERATING
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    15
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    16
#include <boost/utility/detail/in_place_factory_prefix.hpp>
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    17
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    18
namespace boost {
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    19
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    20
class in_place_factory_base {} ;
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    21
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    22
#define  BOOST_PP_ITERATION_LIMITS (0, BOOST_MAX_INPLACE_FACTORY_ARITY)
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    23
#define  BOOST_PP_FILENAME_1 <boost/utility/in_place_factory.hpp>
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    24
#include BOOST_PP_ITERATE()
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    25
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    26
} // namespace boost
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    27
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    28
#include <boost/utility/detail/in_place_factory_suffix.hpp>
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    29
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    30
#define BOOST_UTILITY_INPLACE_FACTORY_04APR2007_HPP
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    31
#else
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    32
#define N BOOST_PP_ITERATION()
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    33
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    34
#if N
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    35
template< BOOST_PP_ENUM_PARAMS(N, class A) >
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    36
#endif
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    37
class BOOST_PP_CAT(in_place_factory,N)
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    38
  : 
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    39
  public in_place_factory_base
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    40
{
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    41
public:
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    42
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    43
  explicit BOOST_PP_CAT(in_place_factory,N)
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    44
      ( BOOST_PP_ENUM_BINARY_PARAMS(N,A,const& a) )
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    45
#if N > 0
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    46
    : BOOST_PP_ENUM(N, BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_INIT, _)
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    47
#endif
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    48
  {}
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    49
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    50
  template<class T>
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    51
  void* apply(void* address
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    52
      BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(T)) const
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    53
  {
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    54
    return new(address) T( BOOST_PP_ENUM_PARAMS(N, m_a) );
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    55
  }
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    56
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    57
  template<class T>
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    58
  void* apply(void* address, std::size_t n
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    59
      BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(T)) const
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    60
  {
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    61
    for(char* next = address = this->BOOST_NESTED_TEMPLATE apply<T>(address);
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    62
        !! --n;)
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    63
      this->BOOST_NESTED_TEMPLATE apply<T>(next = next+sizeof(T));
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    64
    return address; 
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    65
  }
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    66
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    67
  BOOST_PP_REPEAT(N, BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_DECL, _)
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    68
};
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    69
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    70
#if N > 0
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    71
template< BOOST_PP_ENUM_PARAMS(N, class A) >
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    72
inline BOOST_PP_CAT(in_place_factory,N)< BOOST_PP_ENUM_PARAMS(N, A) >
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    73
in_place( BOOST_PP_ENUM_BINARY_PARAMS(N, A, const& a) )
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    74
{
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    75
  return BOOST_PP_CAT(in_place_factory,N)< BOOST_PP_ENUM_PARAMS(N, A) >
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    76
      ( BOOST_PP_ENUM_PARAMS(N, a) );
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    77
}
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    78
#else
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    79
inline in_place_factory0 in_place()
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    80
{
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    81
  return in_place_factory0();
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    82
}
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    83
#endif
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    84
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    85
#undef N
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    86
#endif
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    87
#endif
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    88