mirror of
https://github.com/boostorg/utility.git
synced 2025-06-25 20:11:33 +02:00
Compare commits
21 Commits
svn-branch
...
svn-branch
Author | SHA1 | Date | |
---|---|---|---|
03b91da372 | |||
3f72b10182 | |||
71cb8cb574 | |||
c950825ef4 | |||
66ca84a45d | |||
06404f7d39 | |||
2d860e2574 | |||
66514f61ff | |||
63cde4d3fd | |||
1950f292df | |||
92a0602190 | |||
c9a3ab1d04 | |||
0782034333 | |||
0808883f3c | |||
2f69501e55 | |||
5b83f641a8 | |||
c730ab4ffb | |||
e55610a0d0 | |||
bf968794c9 | |||
ce6e9c6698 | |||
7ac180ed54 |
@ -3,9 +3,8 @@
|
||||
<HTML>
|
||||
|
||||
<HEAD>
|
||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
|
||||
<LINK REL="stylesheet" TYPE="text/css" HREF="../../boost.css">
|
||||
<TITLE>Header </TITLE>
|
||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
|
||||
<TITLE>In_place_factory Documentation</TITLE>
|
||||
</HEAD>
|
||||
|
||||
<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080">
|
||||
@ -77,7 +76,7 @@ object is likely to be temporary and serve no purpose besides being the source</
|
||||
</pre>
|
||||
<p>A solution to this problem is to support direct construction of the contained
|
||||
object right in the container's storage.<br>
|
||||
In this shceme, the user supplies the arguments for the X constructor
|
||||
In this scheme, the user supplies the arguments for the X constructor
|
||||
directly to the container:</p>
|
||||
<pre>struct C
|
||||
{
|
||||
@ -138,7 +137,7 @@ The following simplified example shows the basic idea. A complete example follow
|
||||
|
||||
void foo()
|
||||
{
|
||||
C c( in_place(123,"hello" ) ;
|
||||
C c( in_place(123,"hello") ) ;
|
||||
}
|
||||
</pre>
|
||||
|
||||
|
@ -32,6 +32,10 @@ inline void current_function_helper()
|
||||
|
||||
# define BOOST_CURRENT_FUNCTION __PRETTY_FUNCTION__
|
||||
|
||||
#elif defined(__DMC__) && (__DMC__ >= 0x810)
|
||||
|
||||
# define BOOST_CURRENT_FUNCTION __PRETTY_FUNCTION__
|
||||
|
||||
#elif defined(__FUNCSIG__)
|
||||
|
||||
# define BOOST_CURRENT_FUNCTION __FUNCSIG__
|
||||
|
@ -1,4 +1,5 @@
|
||||
// Copyright (C) 2003, Fernando Luis Cacciola Carballal.
|
||||
// Copyright (C) 2007, Tobias Schwinger.
|
||||
//
|
||||
// Use, modification, and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@ -9,25 +10,27 @@
|
||||
// You are welcome to contact the author at:
|
||||
// fernando_cacciola@hotmail.com
|
||||
//
|
||||
#ifndef BOOST_UTILITY_DETAIL_INPLACE_FACTORY_PREFIX_25AGO2003_HPP
|
||||
#define BOOST_UTILITY_DETAIL_INPLACE_FACTORY_PREFIX_25AGO2003_HPP
|
||||
#ifndef BOOST_UTILITY_DETAIL_INPLACE_FACTORY_PREFIX_04APR2007_HPP
|
||||
#define BOOST_UTILITY_DETAIL_INPLACE_FACTORY_PREFIX_04APR2007_HPP
|
||||
|
||||
#include <new>
|
||||
#include <cstddef>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/preprocessor/cat.hpp>
|
||||
#include <boost/preprocessor/punctuation/paren.hpp>
|
||||
#include <boost/preprocessor/iteration/iterate.hpp>
|
||||
#include <boost/preprocessor/repetition/repeat.hpp>
|
||||
#include <boost/preprocessor/repetition/enum.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_params.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_binary_params.hpp>
|
||||
#include <boost/preprocessor/cat.hpp>
|
||||
#include <boost/preprocessor/arithmetic/inc.hpp>
|
||||
#include <boost/preprocessor/punctuation/paren.hpp>
|
||||
#include <boost/preprocessor/facilities/empty.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_trailing_params.hpp>
|
||||
|
||||
#define BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_INIT(z,n,_) BOOST_PP_CAT(m_a,n) BOOST_PP_LPAREN() BOOST_PP_CAT(a,n) BOOST_PP_RPAREN()
|
||||
#define BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_DECL(z,n,_) BOOST_PP_CAT(A,n) const& BOOST_PP_CAT(m_a,n);
|
||||
#define BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_ARG(z,n,_) BOOST_PP_CAT(m_a,n)
|
||||
|
||||
#define BOOST_MAX_INPLACE_FACTORY_ARITY 10
|
||||
|
||||
#undef BOOST_UTILITY_DETAIL_INPLACE_FACTORY_SUFFIX_25AGO2003_HPP
|
||||
#undef BOOST_UTILITY_DETAIL_INPLACE_FACTORY_SUFFIX_04APR2007_HPP
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
// Copyright (C) 2003, Fernando Luis Cacciola Carballal.
|
||||
// Copyright (C) 2007, Tobias Schwinger.
|
||||
//
|
||||
// Use, modification, and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@ -9,15 +10,14 @@
|
||||
// You are welcome to contact the author at:
|
||||
// fernando_cacciola@hotmail.com
|
||||
//
|
||||
#ifndef BOOST_UTILITY_DETAIL_INPLACE_FACTORY_SUFFIX_25AGO2003_HPP
|
||||
#define BOOST_UTILITY_DETAIL_INPLACE_FACTORY_SUFFIX_25AGO2003_HPP
|
||||
#ifndef BOOST_UTILITY_DETAIL_INPLACE_FACTORY_SUFFIX_04APR2007_HPP
|
||||
#define BOOST_UTILITY_DETAIL_INPLACE_FACTORY_SUFFIX_04APR2007_HPP
|
||||
|
||||
#undef BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_INIT
|
||||
#undef BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_DECL
|
||||
#undef BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_ARG
|
||||
#undef BOOST_MAX_INPLACE_FACTORY_ARITY
|
||||
|
||||
#undef BOOST_UTILITY_DETAIL_INPLACE_FACTORY_PREFIX_25AGO2003_HPP
|
||||
#undef BOOST_UTILITY_DETAIL_INPLACE_FACTORY_PREFIX_04APR2007_HPP
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -21,66 +21,69 @@
|
||||
template<typename F BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
||||
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
||||
struct result_of<F(BOOST_RESULT_OF_ARGS)>
|
||||
: detail::result_of<F, F(BOOST_RESULT_OF_ARGS)> {};
|
||||
: boost::detail::result_of_impl<F, F(BOOST_RESULT_OF_ARGS), (boost::detail::has_result_type<F>::value)> {};
|
||||
#endif
|
||||
|
||||
#undef BOOST_RESULT_OF_ARGS
|
||||
|
||||
#if BOOST_PP_ITERATION() >= 1
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<typename R, typename FArgs BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
||||
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
||||
struct result_of<R (*)(BOOST_RESULT_OF_ARGS), FArgs>
|
||||
struct result_of_impl<R (*)(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)), FArgs, false>
|
||||
{
|
||||
typedef R type;
|
||||
};
|
||||
|
||||
template<typename R, typename FArgs BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
||||
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
||||
struct result_of<R (&)(BOOST_RESULT_OF_ARGS), FArgs>
|
||||
struct result_of_impl<R (&)(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)), FArgs, false>
|
||||
{
|
||||
typedef R type;
|
||||
};
|
||||
|
||||
#undef BOOST_RESULT_OF_ARGS
|
||||
|
||||
#if BOOST_PP_ITERATION() > 1 && !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551))
|
||||
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551))
|
||||
template<typename R, typename FArgs BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
||||
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
||||
struct result_of<R (T0::*)
|
||||
struct result_of_impl<R (T0::*)
|
||||
(BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_PP_ITERATION(),T)),
|
||||
FArgs>
|
||||
FArgs, false>
|
||||
{
|
||||
typedef R type;
|
||||
};
|
||||
|
||||
template<typename R, typename FArgs BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
||||
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
||||
struct result_of<R (T0::*)
|
||||
struct result_of_impl<R (T0::*)
|
||||
(BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_PP_ITERATION(),T))
|
||||
const,
|
||||
FArgs>
|
||||
FArgs, false>
|
||||
{
|
||||
typedef R type;
|
||||
};
|
||||
|
||||
template<typename R, typename FArgs BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
||||
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
||||
struct result_of<R (T0::*)
|
||||
struct result_of_impl<R (T0::*)
|
||||
(BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_PP_ITERATION(),T))
|
||||
volatile,
|
||||
FArgs>
|
||||
FArgs, false>
|
||||
{
|
||||
typedef R type;
|
||||
};
|
||||
|
||||
template<typename R, typename FArgs BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
||||
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
||||
struct result_of<R (T0::*)
|
||||
struct result_of_impl<R (T0::*)
|
||||
(BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_PP_ITERATION(),T))
|
||||
const volatile,
|
||||
FArgs>
|
||||
FArgs, false>
|
||||
{
|
||||
typedef R type;
|
||||
};
|
||||
#endif
|
||||
|
||||
}
|
||||
#endif
|
||||
|
@ -1,4 +1,5 @@
|
||||
// Copyright (C) 2003, Fernando Luis Cacciola Carballal.
|
||||
// Copyright (C) 2007, Tobias Schwinger.
|
||||
//
|
||||
// Use, modification, and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@ -9,50 +10,79 @@
|
||||
// You are welcome to contact the author at:
|
||||
// fernando_cacciola@hotmail.com
|
||||
//
|
||||
#ifndef BOOST_UTILITY_INPLACE_FACTORY_25AGO2003_HPP
|
||||
#define BOOST_UTILITY_INPLACE_FACTORY_25AGO2003_HPP
|
||||
#ifndef BOOST_UTILITY_INPLACE_FACTORY_04APR2007_HPP
|
||||
#ifndef BOOST_PP_IS_ITERATING
|
||||
|
||||
#include <boost/utility/detail/in_place_factory_prefix.hpp>
|
||||
|
||||
#include <boost/type.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
class in_place_factory_base {} ;
|
||||
|
||||
#define BOOST_DEFINE_INPLACE_FACTORY_CLASS(z,n,_) \
|
||||
template< BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(n),class A) > \
|
||||
class BOOST_PP_CAT(in_place_factory, BOOST_PP_INC(n) ) : public in_place_factory_base \
|
||||
{ \
|
||||
public: \
|
||||
\
|
||||
BOOST_PP_CAT(in_place_factory, BOOST_PP_INC(n) ) ( BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_INC(n),A,const& a) ) \
|
||||
: \
|
||||
BOOST_PP_ENUM( BOOST_PP_INC(n), BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_INIT, _ ) \
|
||||
{} \
|
||||
\
|
||||
template<class T> \
|
||||
void apply ( void* address BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(T) ) const \
|
||||
{ \
|
||||
new ( address ) T ( BOOST_PP_ENUM_PARAMS( BOOST_PP_INC(n), m_a ) ) ; \
|
||||
} \
|
||||
\
|
||||
BOOST_PP_REPEAT( BOOST_PP_INC(n), BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_DECL, _) \
|
||||
} ; \
|
||||
\
|
||||
template< BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(n),class A) > \
|
||||
BOOST_PP_CAT(in_place_factory, BOOST_PP_INC(n) ) < BOOST_PP_ENUM_PARAMS( BOOST_PP_INC(n), A ) > \
|
||||
in_place ( BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_INC(n),A, const& a) ) \
|
||||
{ \
|
||||
return BOOST_PP_CAT(in_place_factory, BOOST_PP_INC(n) ) < BOOST_PP_ENUM_PARAMS( BOOST_PP_INC(n), A ) > \
|
||||
( BOOST_PP_ENUM_PARAMS( BOOST_PP_INC(n), a ) ) ; \
|
||||
} ; \
|
||||
|
||||
BOOST_PP_REPEAT( BOOST_MAX_INPLACE_FACTORY_ARITY, BOOST_DEFINE_INPLACE_FACTORY_CLASS, BOOST_PP_EMPTY() )
|
||||
#define BOOST_PP_ITERATION_LIMITS (0, BOOST_MAX_INPLACE_FACTORY_ARITY)
|
||||
#define BOOST_PP_FILENAME_1 <boost/utility/in_place_factory.hpp>
|
||||
#include BOOST_PP_ITERATE()
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/utility/detail/in_place_factory_suffix.hpp>
|
||||
|
||||
#define BOOST_UTILITY_INPLACE_FACTORY_04APR2007_HPP
|
||||
#else
|
||||
#define N BOOST_PP_ITERATION()
|
||||
|
||||
#if N
|
||||
template< BOOST_PP_ENUM_PARAMS(N, class A) >
|
||||
#endif
|
||||
class BOOST_PP_CAT(in_place_factory,N)
|
||||
:
|
||||
public in_place_factory_base
|
||||
{
|
||||
public:
|
||||
|
||||
explicit BOOST_PP_CAT(in_place_factory,N)
|
||||
( BOOST_PP_ENUM_BINARY_PARAMS(N,A,const& a) )
|
||||
#if N > 0
|
||||
: BOOST_PP_ENUM(N, BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_INIT, _)
|
||||
#endif
|
||||
{}
|
||||
|
||||
template<class T>
|
||||
void* apply(void* address
|
||||
BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(T)) const
|
||||
{
|
||||
return new(address) T( BOOST_PP_ENUM_PARAMS(N, m_a) );
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void* apply(void* address, std::size_t n
|
||||
BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(T)) const
|
||||
{
|
||||
for(char* next = address = this->BOOST_NESTED_TEMPLATE apply<T>(address);
|
||||
!! --n;)
|
||||
this->BOOST_NESTED_TEMPLATE apply<T>(next = next+sizeof(T));
|
||||
return address;
|
||||
}
|
||||
|
||||
BOOST_PP_REPEAT(N, BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_DECL, _)
|
||||
};
|
||||
|
||||
#if N > 0
|
||||
template< BOOST_PP_ENUM_PARAMS(N, class A) >
|
||||
inline BOOST_PP_CAT(in_place_factory,N)< BOOST_PP_ENUM_PARAMS(N, A) >
|
||||
in_place( BOOST_PP_ENUM_BINARY_PARAMS(N, A, const& a) )
|
||||
{
|
||||
return BOOST_PP_CAT(in_place_factory,N)< BOOST_PP_ENUM_PARAMS(N, A) >
|
||||
( BOOST_PP_ENUM_PARAMS(N, a) );
|
||||
}
|
||||
#else
|
||||
inline in_place_factory0 in_place()
|
||||
{
|
||||
return in_place_factory0();
|
||||
}
|
||||
#endif
|
||||
|
||||
#undef N
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -15,6 +15,8 @@
|
||||
#include <boost/preprocessor.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <boost/mpl/has_xxx.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
|
||||
#ifndef BOOST_RESULT_OF_NUM_ARGS
|
||||
# define BOOST_RESULT_OF_NUM_ARGS 10
|
||||
@ -29,28 +31,48 @@ namespace detail {
|
||||
|
||||
BOOST_MPL_HAS_XXX_TRAIT_DEF(result_type)
|
||||
|
||||
template<typename F, typename FArgs, bool HasResultType> struct get_result_of;
|
||||
|
||||
template<typename F, typename FArgs>
|
||||
struct get_result_of<F, FArgs, true>
|
||||
{
|
||||
typedef typename F::result_type type;
|
||||
};
|
||||
|
||||
template<typename F, typename FArgs>
|
||||
struct get_result_of<F, FArgs, false>
|
||||
{
|
||||
typedef typename F::template result<FArgs>::type type;
|
||||
};
|
||||
template<typename F, typename FArgs, bool HasResultType> struct result_of_impl;
|
||||
|
||||
template<typename F>
|
||||
struct get_result_of<F, F(void), false>
|
||||
struct result_of_void_impl
|
||||
{
|
||||
typedef void type;
|
||||
};
|
||||
|
||||
template<typename R>
|
||||
struct result_of_void_impl<R (*)(void)>
|
||||
{
|
||||
typedef R type;
|
||||
};
|
||||
|
||||
template<typename R>
|
||||
struct result_of_void_impl<R (&)(void)>
|
||||
{
|
||||
typedef R type;
|
||||
};
|
||||
|
||||
template<typename F, typename FArgs>
|
||||
struct result_of : get_result_of<F, FArgs, (has_result_type<F>::value)> {};
|
||||
struct result_of_impl<F, FArgs, true>
|
||||
{
|
||||
typedef typename F::result_type type;
|
||||
};
|
||||
|
||||
template<typename FArgs>
|
||||
struct is_function_with_no_args : mpl::false_ {};
|
||||
|
||||
template<typename F>
|
||||
struct is_function_with_no_args<F(void)> : mpl::true_ {};
|
||||
|
||||
template<typename F, typename FArgs>
|
||||
struct result_of_nested_result : F::template result<FArgs>
|
||||
{};
|
||||
|
||||
template<typename F, typename FArgs>
|
||||
struct result_of_impl<F, FArgs, false>
|
||||
: mpl::if_<is_function_with_no_args<FArgs>,
|
||||
result_of_void_impl<F>,
|
||||
result_of_nested_result<F, FArgs> >::type
|
||||
{};
|
||||
|
||||
} // end namespace detail
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
// Copyright (C) 2003, Fernando Luis Cacciola Carballal.
|
||||
// Copyright (C) 2007, Tobias Schwinger.
|
||||
//
|
||||
// Use, modification, and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@ -9,8 +10,8 @@
|
||||
// You are welcome to contact the author at:
|
||||
// fernando_cacciola@hotmail.com
|
||||
//
|
||||
#ifndef BOOST_UTILITY_TYPED_INPLACE_FACTORY_25AGO2003_HPP
|
||||
#define BOOST_UTILITY_TYPED_INPLACE_FACTORY_25AGO2003_HPP
|
||||
#ifndef BOOST_UTILITY_TYPED_INPLACE_FACTORY_04APR2007_HPP
|
||||
#ifndef BOOST_PP_IS_ITERATING
|
||||
|
||||
#include <boost/utility/detail/in_place_factory_prefix.hpp>
|
||||
|
||||
@ -18,40 +19,59 @@ namespace boost {
|
||||
|
||||
class typed_in_place_factory_base {} ;
|
||||
|
||||
#define BOOST_DEFINE_TYPED_INPLACE_FACTORY_CLASS(z,n,_) \
|
||||
template< class T, BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(n),class A) > \
|
||||
class BOOST_PP_CAT(typed_in_place_factory, BOOST_PP_INC(n) ) : public typed_in_place_factory_base \
|
||||
{ \
|
||||
public: \
|
||||
\
|
||||
typedef T value_type ; \
|
||||
\
|
||||
BOOST_PP_CAT(typed_in_place_factory, BOOST_PP_INC(n) ) ( BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_INC(n),A,const& a) ) \
|
||||
: \
|
||||
BOOST_PP_ENUM( BOOST_PP_INC(n), BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_INIT, _ ) \
|
||||
{} \
|
||||
\
|
||||
void apply ( void* address ) const \
|
||||
{ \
|
||||
new ( address ) T ( BOOST_PP_ENUM_PARAMS( BOOST_PP_INC(n), m_a ) ) ; \
|
||||
} \
|
||||
\
|
||||
BOOST_PP_REPEAT( BOOST_PP_INC(n), BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_DECL, _) \
|
||||
} ; \
|
||||
\
|
||||
template< class T, BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(n),class A) > \
|
||||
BOOST_PP_CAT(typed_in_place_factory, BOOST_PP_INC(n) ) < T , BOOST_PP_ENUM_PARAMS( BOOST_PP_INC(n), A ) > \
|
||||
in_place ( BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_INC(n),A, const& a) ) \
|
||||
{ \
|
||||
return BOOST_PP_CAT(typed_in_place_factory, BOOST_PP_INC(n) ) < T, BOOST_PP_ENUM_PARAMS( BOOST_PP_INC(n), A ) > \
|
||||
( BOOST_PP_ENUM_PARAMS( BOOST_PP_INC(n), a ) ) ; \
|
||||
} ; \
|
||||
|
||||
BOOST_PP_REPEAT( BOOST_MAX_INPLACE_FACTORY_ARITY, BOOST_DEFINE_TYPED_INPLACE_FACTORY_CLASS, BOOST_PP_EMPTY() )
|
||||
#define BOOST_PP_ITERATION_LIMITS (0, BOOST_MAX_INPLACE_FACTORY_ARITY)
|
||||
#define BOOST_PP_FILENAME_1 <boost/utility/typed_in_place_factory.hpp>
|
||||
#include BOOST_PP_ITERATE()
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/utility/detail/in_place_factory_suffix.hpp>
|
||||
|
||||
#define BOOST_UTILITY_TYPED_INPLACE_FACTORY_04APR2007_HPP
|
||||
#else
|
||||
#define N BOOST_PP_ITERATION()
|
||||
|
||||
template< class T BOOST_PP_ENUM_TRAILING_PARAMS(N,class A) >
|
||||
class BOOST_PP_CAT(typed_in_place_factory,N)
|
||||
:
|
||||
public typed_in_place_factory_base
|
||||
{
|
||||
public:
|
||||
|
||||
typedef T value_type;
|
||||
|
||||
explicit BOOST_PP_CAT(typed_in_place_factory,N)
|
||||
( BOOST_PP_ENUM_BINARY_PARAMS(N, A, const& a) )
|
||||
#if N > 0
|
||||
: BOOST_PP_ENUM(N, BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_INIT, _)
|
||||
#endif
|
||||
{}
|
||||
|
||||
void* apply (void* address) const
|
||||
{
|
||||
return new(address) T( BOOST_PP_ENUM_PARAMS(N, m_a) );
|
||||
}
|
||||
|
||||
void* apply (void* address, std::size_t n) const
|
||||
{
|
||||
for(char* next = address = this->apply(address); !! --n;)
|
||||
this->apply(next = next+sizeof(T));
|
||||
return address;
|
||||
}
|
||||
|
||||
BOOST_PP_REPEAT(N, BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_DECL, _)
|
||||
};
|
||||
|
||||
template< class T BOOST_PP_ENUM_TRAILING_PARAMS(N, class A) >
|
||||
inline BOOST_PP_CAT(typed_in_place_factory,N)<
|
||||
T BOOST_PP_ENUM_TRAILING_PARAMS(N, A) >
|
||||
in_place( BOOST_PP_ENUM_BINARY_PARAMS(N, A, const& a) )
|
||||
{
|
||||
return BOOST_PP_CAT(typed_in_place_factory,N)<
|
||||
T BOOST_PP_ENUM_TRAILING_PARAMS(N, A) >( BOOST_PP_ENUM_PARAMS(N, a) );
|
||||
}
|
||||
|
||||
#undef N
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2002, Fernando Luis Cacciola Carballal.
|
||||
// (C) 2002, Fernando Luis Cacciola Carballal.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@ -9,8 +9,9 @@
|
||||
#ifndef BOOST_UTILITY_VALUE_INIT_21AGO2002_HPP
|
||||
#define BOOST_UTILITY_VALUE_INIT_21AGO2002_HPP
|
||||
|
||||
#include "boost/detail/select_type.hpp"
|
||||
#include "boost/type_traits/cv_traits.hpp"
|
||||
#include <boost/detail/select_type.hpp>
|
||||
#include <boost/type_traits/cv_traits.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
@ -39,8 +40,11 @@ struct non_const_T_base
|
||||
template<class T>
|
||||
struct select_base
|
||||
{
|
||||
typedef typename
|
||||
boost::detail::if_true< ::boost::is_const<T>::value >
|
||||
typedef
|
||||
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
typename
|
||||
#endif
|
||||
::boost::detail::if_true< ::boost::is_const<T>::value >
|
||||
::template then< const_T_base<T>, non_const_T_base<T> >::type type ;
|
||||
} ;
|
||||
|
||||
|
@ -33,5 +33,4 @@ test-suite utility
|
||||
[ compile-fail ../value_init_test_fail1.cpp ]
|
||||
[ compile-fail ../value_init_test_fail2.cpp ]
|
||||
[ compile-fail ../value_init_test_fail3.cpp ]
|
||||
[ run none_test.cpp ]
|
||||
;
|
||||
|
@ -1,22 +0,0 @@
|
||||
// Copyright 2007 Fernando Luis Cacciola Carballal. Use, modification, and distribution
|
||||
// are subject to the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or a copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt.)
|
||||
|
||||
// See http://www.boost.org/libs/utility for documentation.
|
||||
|
||||
// Boost test program for noost::none_t and boost::none
|
||||
|
||||
// Test strategy contributed by Richard Smith
|
||||
|
||||
#include <boost/optional/optional.hpp> // Test none.hpp is included with <optional.hpp>
|
||||
|
||||
// Left undefined to cause a linker error if this overload is incorrectly selected.
|
||||
void verify_no_implicit_conversion_to_int ( int i ) ;
|
||||
|
||||
void verify_no_implicit_conversion_to_int ( boost::optional<int> const& ) {}
|
||||
|
||||
int main()
|
||||
{
|
||||
verify_no_implicit_conversion_to_int( boost::none );
|
||||
}
|
@ -24,6 +24,24 @@ struct int_result_type_and_float_result_of
|
||||
template<typename F> struct result { typedef float type; };
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct int_result_type_template { typedef int result_type; };
|
||||
|
||||
template<typename T>
|
||||
struct int_result_of_template
|
||||
{
|
||||
template<typename F> struct result;
|
||||
template<typename This, typename That> struct result<This(That)> { typedef int type; };
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct int_result_type_and_float_result_of_template
|
||||
{
|
||||
typedef int result_type;
|
||||
template<typename F> struct result;
|
||||
template<typename This, typename That> struct result<This(That)> { typedef float type; };
|
||||
};
|
||||
|
||||
struct X {};
|
||||
|
||||
int main()
|
||||
@ -32,10 +50,13 @@ int main()
|
||||
|
||||
typedef int (*func_ptr)(float, double);
|
||||
typedef int (&func_ref)(float, double);
|
||||
typedef int (*func_ptr_0)();
|
||||
typedef int (&func_ref_0)();
|
||||
typedef int (X::*mem_func_ptr)(float);
|
||||
typedef int (X::*mem_func_ptr_c)(float) const;
|
||||
typedef int (X::*mem_func_ptr_v)(float) volatile;
|
||||
typedef int (X::*mem_func_ptr_cv)(float) const volatile;
|
||||
typedef int (X::*mem_func_ptr_0)();
|
||||
|
||||
BOOST_STATIC_ASSERT((is_same<result_of<int_result_type(float)>::type, int>::value));
|
||||
BOOST_STATIC_ASSERT((is_same<result_of<int_result_of(double)>::type, int>::value));
|
||||
@ -43,11 +64,22 @@ int main()
|
||||
BOOST_STATIC_ASSERT((is_same<result_of<const int_result_of(double)>::type, int>::value));
|
||||
BOOST_STATIC_ASSERT((is_same<result_of<volatile int_result_of(void)>::type, void>::value));
|
||||
BOOST_STATIC_ASSERT((is_same<result_of<int_result_type_and_float_result_of(char)>::type, int>::value));
|
||||
BOOST_STATIC_ASSERT((is_same<result_of<int_result_type_template<void>(float)>::type, int>::value));
|
||||
BOOST_STATIC_ASSERT((is_same<result_of<int_result_of_template<void>(double)>::type, int>::value));
|
||||
BOOST_STATIC_ASSERT((is_same<result_of<int_result_of_template<void>(void)>::type, void>::value));
|
||||
BOOST_STATIC_ASSERT((is_same<result_of<const int_result_of_template<void>(double)>::type, int>::value));
|
||||
BOOST_STATIC_ASSERT((is_same<result_of<volatile int_result_of_template<void>(void)>::type, void>::value));
|
||||
BOOST_STATIC_ASSERT((is_same<result_of<int_result_type_and_float_result_of_template<void>(char)>::type, int>::value));
|
||||
BOOST_STATIC_ASSERT((is_same<result_of<func_ptr(char, float)>::type, int>::value));
|
||||
BOOST_STATIC_ASSERT((is_same<result_of<func_ref(char, float)>::type, int>::value));
|
||||
BOOST_STATIC_ASSERT((is_same<result_of<func_ptr_0()>::type, int>::value));
|
||||
BOOST_STATIC_ASSERT((is_same<result_of<func_ref_0()>::type, int>::value));
|
||||
BOOST_STATIC_ASSERT((is_same<result_of<mem_func_ptr(X,char)>::type, int>::value));
|
||||
BOOST_STATIC_ASSERT((is_same<result_of<mem_func_ptr_c(X,char)>::type, int>::value));
|
||||
BOOST_STATIC_ASSERT((is_same<result_of<mem_func_ptr_v(X,char)>::type, int>::value));
|
||||
BOOST_STATIC_ASSERT((is_same<result_of<mem_func_ptr_cv(X,char)>::type, int>::value));
|
||||
BOOST_STATIC_ASSERT((is_same<result_of<mem_func_ptr_0(X)>::type, int>::value));
|
||||
BOOST_STATIC_ASSERT((is_same<result_of<func_ptr(void)>::type, int>::value));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -163,9 +163,9 @@ void f() {
|
||||
<code><em>N</em> > 0</code> or <code>void</code>
|
||||
when <code><em>N</em> = 0</code>. For additional
|
||||
information about <code>result_of</code>, see the
|
||||
current draft of the C++ Library TR, <a
|
||||
href="http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/papers/2004/n1647.pdf">N1647</a>,
|
||||
or the <code>result_of</code> <a
|
||||
C++ Library Technical Report, <a
|
||||
href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1836.pdf">N1836</a>,
|
||||
or, for motivation and design rationale, the <code>result_of</code> <a
|
||||
href="http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1454.html">proposal</a>.</p>
|
||||
|
||||
<p>Class template <code>result_of</code> resides in
|
||||
|
Reference in New Issue
Block a user