function_template.hpp:

- Remove tabs

prologue.hpp:
  - get BOOST_PP_INC


[SVN r15501]
This commit is contained in:
Douglas Gregor
2002-09-24 19:52:56 +00:00
parent 6c8e07793d
commit 68d6a1354e
2 changed files with 44 additions and 43 deletions

View File

@ -9,4 +9,5 @@
# include <boost/preprocessor/enum_params.hpp> # include <boost/preprocessor/enum_params.hpp>
# include <boost/preprocessor/cat.hpp> # include <boost/preprocessor/cat.hpp>
# include <boost/preprocessor/repeat.hpp> # include <boost/preprocessor/repeat.hpp>
# include <boost/preprocessor/inc.hpp>
#endif // BOOST_FUNCTION_PROLOGUE_HPP #endif // BOOST_FUNCTION_PROLOGUE_HPP

View File

@ -14,7 +14,7 @@
// For more information, see http://www.boost.org // For more information, see http://www.boost.org
// Note: this header is a header template and must NOT have multiple-inclusion // Note: this header is a header template and must NOT have multiple-inclusion
// protection. // protection.
#include <boost/function/detail/prologue.hpp> #include <boost/function/detail/prologue.hpp>
#define BOOST_FUNCTION_TEMPLATE_PARMS BOOST_PP_ENUM_PARAMS(BOOST_FUNCTION_NUM_ARGS, typename T) #define BOOST_FUNCTION_TEMPLATE_PARMS BOOST_PP_ENUM_PARAMS(BOOST_FUNCTION_NUM_ARGS, typename T)
@ -31,7 +31,7 @@
#define BOOST_FUNCTION_ARG_TYPE(J,I,D) \ #define BOOST_FUNCTION_ARG_TYPE(J,I,D) \
typedef BOOST_PP_CAT(T,I) BOOST_PP_CAT(arg, BOOST_PP_CAT(BOOST_PP_INC(I),_type)); typedef BOOST_PP_CAT(T,I) BOOST_PP_CAT(arg, BOOST_PP_CAT(BOOST_PP_INC(I),_type));
#define BOOST_FUNCTION_ARG_TYPES BOOST_PP_REPEAT(BOOST_FUNCTION_NUM_ARGS,BOOST_FUNCTION_ARG_TYPE,) #define BOOST_FUNCTION_ARG_TYPES BOOST_PP_REPEAT(BOOST_FUNCTION_NUM_ARGS,BOOST_FUNCTION_ARG_TYPE,BOOST_PP_EMPTY)
// Type of the default allocator // Type of the default allocator
#ifndef BOOST_NO_STD_ALLOCATOR #ifndef BOOST_NO_STD_ALLOCATOR
@ -42,7 +42,7 @@
// Comma if nonzero number of arguments // Comma if nonzero number of arguments
#if BOOST_FUNCTION_NUM_ARGS == 0 #if BOOST_FUNCTION_NUM_ARGS == 0
# define BOOST_FUNCTION_COMMA # define BOOST_FUNCTION_COMMA
#else #else
# define BOOST_FUNCTION_COMMA , # define BOOST_FUNCTION_COMMA ,
#endif // BOOST_FUNCTION_NUM_ARGS > 0 #endif // BOOST_FUNCTION_NUM_ARGS > 0
@ -52,7 +52,7 @@
#define BOOST_FUNCTION_FUNCTION_INVOKER \ #define BOOST_FUNCTION_FUNCTION_INVOKER \
BOOST_JOIN(function_invoker,BOOST_FUNCTION_NUM_ARGS) BOOST_JOIN(function_invoker,BOOST_FUNCTION_NUM_ARGS)
#define BOOST_FUNCTION_VOID_FUNCTION_INVOKER \ #define BOOST_FUNCTION_VOID_FUNCTION_INVOKER \
BOOST_JOIN(void_function_invoker,BOOST_FUNCTION_NUM_ARGS) BOOST_JOIN(void_function_invoker,BOOST_FUNCTION_NUM_ARGS)
#define BOOST_FUNCTION_FUNCTION_OBJ_INVOKER \ #define BOOST_FUNCTION_FUNCTION_OBJ_INVOKER \
BOOST_JOIN(function_obj_invoker,BOOST_FUNCTION_NUM_ARGS) BOOST_JOIN(function_obj_invoker,BOOST_FUNCTION_NUM_ARGS)
#define BOOST_FUNCTION_VOID_FUNCTION_OBJ_INVOKER \ #define BOOST_FUNCTION_VOID_FUNCTION_OBJ_INVOKER \
@ -126,7 +126,7 @@ namespace boost {
> >
struct BOOST_FUNCTION_VOID_FUNCTION_OBJ_INVOKER struct BOOST_FUNCTION_VOID_FUNCTION_OBJ_INVOKER
{ {
static unusable invoke(any_pointer function_obj_ptr static unusable invoke(any_pointer function_obj_ptr
BOOST_FUNCTION_COMMA BOOST_FUNCTION_COMMA
BOOST_FUNCTION_PARMS) BOOST_FUNCTION_PARMS)
@ -158,7 +158,7 @@ namespace boost {
> >
struct BOOST_FUNCTION_STATELESS_VOID_FUNCTION_OBJ_INVOKER struct BOOST_FUNCTION_STATELESS_VOID_FUNCTION_OBJ_INVOKER
{ {
static unusable invoke(any_pointer BOOST_FUNCTION_COMMA static unusable invoke(any_pointer BOOST_FUNCTION_COMMA
BOOST_FUNCTION_PARMS) BOOST_FUNCTION_PARMS)
{ {
@ -241,12 +241,12 @@ namespace boost {
> >
class BOOST_FUNCTION_FUNCTION : public function_base class BOOST_FUNCTION_FUNCTION : public function_base
{ {
typedef typename detail::function::function_return_type<R>::type typedef typename detail::function::function_return_type<R>::type
internal_result_type; internal_result_type;
public: public:
BOOST_STATIC_CONSTANT(int, args = BOOST_FUNCTION_NUM_ARGS); BOOST_STATIC_CONSTANT(int, args = BOOST_FUNCTION_NUM_ARGS);
#if BOOST_FUNCTION_NUM_ARGS == 1 #if BOOST_FUNCTION_NUM_ARGS == 1
typedef T0 argument_type; typedef T0 argument_type;
#elif BOOST_FUNCTION_NUM_ARGS == 2 #elif BOOST_FUNCTION_NUM_ARGS == 2
@ -272,7 +272,7 @@ namespace boost {
// one with a default parameter. // one with a default parameter.
template<typename Functor> template<typename Functor>
BOOST_FUNCTION_FUNCTION(Functor BOOST_FUNCTION_TARGET_FIX(const &) f) : BOOST_FUNCTION_FUNCTION(Functor BOOST_FUNCTION_TARGET_FIX(const &) f) :
function_base(), function_base(),
invoker(0) invoker(0)
{ {
this->assign_to(f); this->assign_to(f);
@ -291,7 +291,7 @@ namespace boost {
{ {
assert(!this->empty()); assert(!this->empty());
internal_result_type result = invoker(function_base::functor internal_result_type result = invoker(function_base::functor
BOOST_FUNCTION_COMMA BOOST_FUNCTION_COMMA
BOOST_FUNCTION_ARGS); BOOST_FUNCTION_ARGS);
@ -305,10 +305,10 @@ namespace boost {
// The distinction between when to use BOOST_FUNCTION_FUNCTION and // The distinction between when to use BOOST_FUNCTION_FUNCTION and
// when to use self_type is obnoxious. MSVC cannot handle self_type as // when to use self_type is obnoxious. MSVC cannot handle self_type as
// the return type of these assignment operators, but Borland C++ cannot // the return type of these assignment operators, but Borland C++ cannot
// handle BOOST_FUNCTION_FUNCTION as the type of the temporary to // handle BOOST_FUNCTION_FUNCTION as the type of the temporary to
// construct. // construct.
template<typename Functor> template<typename Functor>
BOOST_FUNCTION_FUNCTION& BOOST_FUNCTION_FUNCTION&
operator=(Functor BOOST_FUNCTION_TARGET_FIX(const &) f) operator=(Functor BOOST_FUNCTION_TARGET_FIX(const &) f)
{ {
self_type(f).swap(*this); self_type(f).swap(*this);
@ -339,8 +339,8 @@ namespace boost {
void clear() void clear()
{ {
if (function_base::manager) { if (function_base::manager) {
function_base::functor = function_base::functor =
function_base::manager(function_base::functor, function_base::manager(function_base::functor,
detail::function::destroy_functor_tag); detail::function::destroy_functor_tag);
} }
@ -360,7 +360,7 @@ namespace boost {
typedef void (dummy::*safe_bool)(); typedef void (dummy::*safe_bool)();
public: public:
operator safe_bool () const operator safe_bool () const
{ return (this->empty())? 0 : &dummy::nonnull; } { return (this->empty())? 0 : &dummy::nonnull; }
bool operator!() const bool operator!() const
@ -373,9 +373,9 @@ namespace boost {
if (!f.empty()) { if (!f.empty()) {
invoker = f.invoker; invoker = f.invoker;
function_base::manager = f.manager; function_base::manager = f.manager;
function_base::functor = function_base::functor =
f.manager(f.functor, detail::function::clone_functor_tag); f.manager(f.functor, detail::function::clone_functor_tag);
} }
} }
template<typename Functor> template<typename Functor>
@ -389,7 +389,7 @@ namespace boost {
void assign_to(FunctionPtr f, detail::function::function_ptr_tag) void assign_to(FunctionPtr f, detail::function::function_ptr_tag)
{ {
clear(); clear();
if (f) { if (f) {
typedef typename detail::function::BOOST_FUNCTION_GET_FUNCTION_INVOKER< typedef typename detail::function::BOOST_FUNCTION_GET_FUNCTION_INVOKER<
FunctionPtr, FunctionPtr,
@ -397,11 +397,11 @@ namespace boost {
BOOST_FUNCTION_TEMPLATE_ARGS BOOST_FUNCTION_TEMPLATE_ARGS
>::type >::type
invoker_type; invoker_type;
invoker = &invoker_type::invoke; invoker = &invoker_type::invoke;
function_base::manager = function_base::manager =
&detail::function::functor_manager<FunctionPtr, Allocator>::manage; &detail::function::functor_manager<FunctionPtr, Allocator>::manage;
function_base::functor = function_base::functor =
function_base::manager(detail::function::make_any_pointer( function_base::manager(detail::function::make_any_pointer(
// should be a reinterpret cast, but some compilers // should be a reinterpret cast, but some compilers
// insist on giving cv-qualifiers to free functions // insist on giving cv-qualifiers to free functions
@ -409,7 +409,7 @@ namespace boost {
), ),
detail::function::clone_functor_tag); detail::function::clone_functor_tag);
} }
} }
#if BOOST_FUNCTION_NUM_ARGS > 0 #if BOOST_FUNCTION_NUM_ARGS > 0
template<typename MemberPtr> template<typename MemberPtr>
@ -418,24 +418,24 @@ namespace boost {
this->assign_to(mem_fn(f)); this->assign_to(mem_fn(f));
} }
#endif // BOOST_FUNCTION_NUM_ARGS > 0 #endif // BOOST_FUNCTION_NUM_ARGS > 0
template<typename FunctionObj> template<typename FunctionObj>
void assign_to(FunctionObj f, detail::function::function_obj_tag) void assign_to(FunctionObj f, detail::function::function_obj_tag)
{ {
if (!detail::function::has_empty_target(addressof(f))) { if (!detail::function::has_empty_target(addressof(f))) {
typedef typedef
typename detail::function::BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER< typename detail::function::BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER<
FunctionObj, FunctionObj,
R BOOST_FUNCTION_COMMA R BOOST_FUNCTION_COMMA
BOOST_FUNCTION_TEMPLATE_ARGS BOOST_FUNCTION_TEMPLATE_ARGS
>::type >::type
invoker_type; invoker_type;
invoker = &invoker_type::invoke; invoker = &invoker_type::invoke;
function_base::manager = &detail::function::functor_manager< function_base::manager = &detail::function::functor_manager<
FunctionObj, Allocator>::manage; FunctionObj, Allocator>::manage;
#ifndef BOOST_NO_STD_ALLOCATOR #ifndef BOOST_NO_STD_ALLOCATOR
typedef typename Allocator::template rebind<FunctionObj>::other typedef typename Allocator::template rebind<FunctionObj>::other
allocator_type; allocator_type;
typedef typename allocator_type::pointer pointer_type; typedef typename allocator_type::pointer pointer_type;
allocator_type allocator; allocator_type allocator;
@ -447,38 +447,38 @@ namespace boost {
#else #else
FunctionObj* new_f = new FunctionObj(f); FunctionObj* new_f = new FunctionObj(f);
#endif // BOOST_NO_STD_ALLOCATOR #endif // BOOST_NO_STD_ALLOCATOR
function_base::functor = function_base::functor =
detail::function::make_any_pointer(static_cast<void*>(new_f)); detail::function::make_any_pointer(static_cast<void*>(new_f));
} }
} }
template<typename FunctionObj> template<typename FunctionObj>
void assign_to(const reference_wrapper<FunctionObj>& f, void assign_to(const reference_wrapper<FunctionObj>& f,
detail::function::function_obj_ref_tag) detail::function::function_obj_ref_tag)
{ {
if (!detail::function::has_empty_target(f.get_pointer())) { if (!detail::function::has_empty_target(f.get_pointer())) {
typedef typedef
typename detail::function::BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER< typename detail::function::BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER<
FunctionObj, FunctionObj,
R BOOST_FUNCTION_COMMA R BOOST_FUNCTION_COMMA
BOOST_FUNCTION_TEMPLATE_ARGS BOOST_FUNCTION_TEMPLATE_ARGS
>::type >::type
invoker_type; invoker_type;
invoker = &invoker_type::invoke; invoker = &invoker_type::invoke;
function_base::manager = &detail::function::trivial_manager; function_base::manager = &detail::function::trivial_manager;
function_base::functor = function_base::functor =
function_base::manager( function_base::manager(
detail::function::make_any_pointer( detail::function::make_any_pointer(
const_cast<FunctionObj*>(f.get_pointer())), const_cast<FunctionObj*>(f.get_pointer())),
detail::function::clone_functor_tag); detail::function::clone_functor_tag);
} }
} }
template<typename FunctionObj> template<typename FunctionObj>
void assign_to(FunctionObj, detail::function::stateless_function_obj_tag) void assign_to(FunctionObj, detail::function::stateless_function_obj_tag)
{ {
typedef typedef
typename detail::function:: typename detail::function::
BOOST_FUNCTION_GET_STATELESS_FUNCTION_OBJ_INVOKER< BOOST_FUNCTION_GET_STATELESS_FUNCTION_OBJ_INVOKER<
FunctionObj, FunctionObj,
@ -494,7 +494,7 @@ namespace boost {
typedef internal_result_type (*invoker_type)(detail::function::any_pointer typedef internal_result_type (*invoker_type)(detail::function::any_pointer
BOOST_FUNCTION_COMMA BOOST_FUNCTION_COMMA
BOOST_FUNCTION_TEMPLATE_ARGS); BOOST_FUNCTION_TEMPLATE_ARGS);
invoker_type invoker; invoker_type invoker;
}; };
@ -506,7 +506,7 @@ namespace boost {
Allocator Allocator
>& f1, >& f1,
BOOST_FUNCTION_FUNCTION< BOOST_FUNCTION_FUNCTION<
R BOOST_FUNCTION_COMMA R BOOST_FUNCTION_COMMA
BOOST_FUNCTION_TEMPLATE_ARGS, BOOST_FUNCTION_TEMPLATE_ARGS,
Allocator Allocator
>& f2) >& f2)
@ -518,7 +518,7 @@ namespace boost {
#if BOOST_FUNCTION_NUM_ARGS == 0 #if BOOST_FUNCTION_NUM_ARGS == 0
#define BOOST_FUNCTION_PARTIAL_SPEC R (void) #define BOOST_FUNCTION_PARTIAL_SPEC R (void)
#else #else
#define BOOST_FUNCTION_PARTIAL_SPEC R (BOOST_PP_ENUM_PARAMS(BOOST_FUNCTION_NUM_ARGS,T)) #define BOOST_FUNCTION_PARTIAL_SPEC R (BOOST_PP_ENUM_PARAMS(BOOST_FUNCTION_NUM_ARGS,T))
#endif #endif
@ -526,10 +526,10 @@ template<typename R BOOST_FUNCTION_COMMA
BOOST_FUNCTION_TEMPLATE_PARMS, BOOST_FUNCTION_TEMPLATE_PARMS,
typename Allocator> typename Allocator>
class function<BOOST_FUNCTION_PARTIAL_SPEC, Allocator> class function<BOOST_FUNCTION_PARTIAL_SPEC, Allocator>
: public BOOST_FUNCTION_FUNCTION<R, BOOST_FUNCTION_TEMPLATE_ARGS : public BOOST_FUNCTION_FUNCTION<R, BOOST_FUNCTION_TEMPLATE_ARGS
BOOST_FUNCTION_COMMA Allocator> BOOST_FUNCTION_COMMA Allocator>
{ {
typedef BOOST_FUNCTION_FUNCTION<R, BOOST_FUNCTION_TEMPLATE_ARGS typedef BOOST_FUNCTION_FUNCTION<R, BOOST_FUNCTION_TEMPLATE_ARGS
BOOST_FUNCTION_COMMA Allocator> base_type; BOOST_FUNCTION_COMMA Allocator> base_type;
typedef function self_type; typedef function self_type;
@ -538,11 +538,11 @@ public:
function() : base_type() {} function() : base_type() {}
template<typename Functor> template<typename Functor>
function(Functor BOOST_FUNCTION_TARGET_FIX(const &) f) : base_type(f) {} function(Functor BOOST_FUNCTION_TARGET_FIX(const &) f) : base_type(f) {}
function(const self_type& f) : base_type(static_cast<const base_type&>(f)){} function(const self_type& f) : base_type(static_cast<const base_type&>(f)){}
template<typename Functor> template<typename Functor>
self_type& operator=(Functor BOOST_FUNCTION_TARGET_FIX(const &) f) self_type& operator=(Functor BOOST_FUNCTION_TARGET_FIX(const &) f)
{ {
@ -557,7 +557,7 @@ public:
} }
self_type& operator=(const self_type& f) self_type& operator=(const self_type& f)
{ {
self_type(f).swap(*this); self_type(f).swap(*this);
return *this; return *this;
} }