Compare commits

..

7 Commits

Author SHA1 Message Date
eb665d2508 This commit was manufactured by cvs2svn to create tag
'Version_1_23_0'.

[SVN r10562]
2001-07-06 20:31:02 +00:00
93ad5963c9 function_base.hpp:
- Changed "RET" to "type" in the IF template metafunction because
	  the GCC source headers define RET as a macro.


[SVN r10509]
2001-07-02 15:25:04 +00:00
48948088fd function_template.hpp:
- One argument functions model AdaptableUnaryFunction
	- Two argument functions model AdaptableBinaryFunction


[SVN r10502]
2001-07-01 19:17:38 +00:00
1f24873577 The void partial specialization of the function classes has been removed in
favor of a common interface. Regardless of the compiler's capabilities, the
result type of a Boost.Function function object that was declared void will
be "unused". This allows the result of a Boost.Function function object to
be passed as a parameter regardless of whether the function is declared as
returning void. It greatly simplifies the use of Boost.Function objects with
wrapper objects (i.e., when the side effects are important, but the result
isn't: consider binding and composition when calling a std::for_each loop)


[SVN r10491]
2001-07-01 02:17:36 +00:00
53f9f4484f Removed consts and associated const_casts from Borland workaround code.
[SVN r10486]
2001-06-29 20:34:32 +00:00
db362782ac function_n_test.cpp:
function_test.cpp:
	- Removed silly ';;' constructs: MSVC seems to handle the updated
	  code much better.

regression.cfg:
	- Fixed typos


[SVN r10482]
2001-06-29 19:35:40 +00:00
73f380d5ac Boost.Function:
- Redesigned decision procedure for "is it a function pointer" vs.
	  "is it an object".
	- No longer requires copy constructions of function objects during
	  assignment or construction.
	- Added operator! to boost::function_base instead of relying on
	  safe_bool conversion.
	- BOOST_NO_DEPENDENT_BASE_LOOKUP is now unnecessary
	- BOOST_WEAK_CONVERSION_OPERATORS is now unnecessary
	- BOOST_WEAK_FUNCTION_TEMPLATE_ORDERING is now unnecessary


[SVN r10481]
2001-06-29 19:33:29 +00:00
17 changed files with 363 additions and 1376 deletions

View File

@ -456,56 +456,66 @@ namespace boost {
function() : base_type() {}
template<typename Functor>
function(Functor BOOST_MSVC_INCLUDE(const &) f) : base_type(f) {}
function(const Functor& f) : base_type(f) {}
#ifdef __BORLANDC__
template<typename Functor>
function(Functor* f) : base_type(f) {}
#endif // __BORLANDC__
function(const function& f) : base_type(static_cast<const base_type&>(f)){}
template<typename Functor>
function& operator=(const Functor& f)
{
this->assign_to(f);
return *this;
}
#ifdef __BORLANDC__
template<typename Functor>
function& operator=(Functor* f)
{
this->assign_to(f);
return *this;
}
#endif // __BORLANDC__
function& operator=(const base_type& f)
{
this->assign_to_own(f);
return *this;
}
function& operator=(const function& f)
{
if (this == &f)
return *this;
const base_type& bf = static_cast<const base_type&>(f);
base_type* self = this;
self->set(bf);
this->assign_to_own(f);
return *this;
}
template<typename Functor>
void set(const Functor& f)
{
this->assign_to(f);
}
#ifdef __BORLANDC__
template<typename Functor>
void set(Functor* f)
{
this->assign_to(f);
}
#endif // __BORLANDC__
void set(const base_type& f)
{
this->assign_to_own(f);
}
void set(const function& f)
{
if (this == &f)
return;
const base_type& bf = static_cast<const base_type&>(f);
base_type* self = this;
self->set(bf);
this->assign_to_own(f);
}
void swap(function& other)
{
#ifndef BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS
std::swap(this->manager, other.manager);
std::swap(this->functor, other.functor);
std::swap(this->invoker, other.invoker);
#else
std::swap(this->impl, other.impl);
#endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS
}
#ifdef BOOST_NO_DEPENDENT_BASE_LOOKUP
template<typename Functor>
function& operator=(Functor BOOST_MSVC_INCLUDE(const &) f)
{
this->set(f);
return *this;
}
base_type& operator=(const base_type& f)
{
this->set(f);
return *this;
}
#endif // BOOST_NO_DEPENDENT_BASE_LOOKUP
};
template<typename R,

View File

@ -27,6 +27,7 @@
#define BOOST_FUNCTION_PARMS
#define BOOST_FUNCTION_ARGS
#define BOOST_FUNCTION_FUNCTION function0
#define BOOST_FUNCTION_BASE function0_base
#define BOOST_FUNCTION_INVOKER_BASE invoker_base0
#define BOOST_FUNCTION_FUNCTION_INVOKER function_invoker0
#define BOOST_FUNCTION_VOID_FUNCTION_INVOKER void_function_invoker0
@ -46,6 +47,7 @@
#undef BOOST_FUNCTION_PARMS
#undef BOOST_FUNCTION_ARGS
#undef BOOST_FUNCTION_FUNCTION
#undef BOOST_FUNCTION_BASE
#undef BOOST_FUNCTION_INVOKER_BASE
#undef BOOST_FUNCTION_FUNCTION_INVOKER
#undef BOOST_FUNCTION_VOID_FUNCTION_INVOKER

View File

@ -27,6 +27,7 @@
#define BOOST_FUNCTION_PARMS T1 a1
#define BOOST_FUNCTION_ARGS a1
#define BOOST_FUNCTION_FUNCTION function1
#define BOOST_FUNCTION_BASE function1_base
#define BOOST_FUNCTION_INVOKER_BASE invoker_base1
#define BOOST_FUNCTION_FUNCTION_INVOKER function_invoker1
#define BOOST_FUNCTION_VOID_FUNCTION_INVOKER void_function_invoker1
@ -46,6 +47,7 @@
#undef BOOST_FUNCTION_PARMS
#undef BOOST_FUNCTION_ARGS
#undef BOOST_FUNCTION_FUNCTION
#undef BOOST_FUNCTION_BASE
#undef BOOST_FUNCTION_INVOKER_BASE
#undef BOOST_FUNCTION_FUNCTION_INVOKER
#undef BOOST_FUNCTION_VOID_FUNCTION_INVOKER

View File

@ -27,6 +27,7 @@
#define BOOST_FUNCTION_PARMS T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6, T7 a7, T8 a8, T9 a9, T10 a10
#define BOOST_FUNCTION_ARGS a1, a2, a3, a4, a5, a6, a7, a8, a9, a10
#define BOOST_FUNCTION_FUNCTION function10
#define BOOST_FUNCTION_BASE function10_base
#define BOOST_FUNCTION_INVOKER_BASE invoker_base10
#define BOOST_FUNCTION_FUNCTION_INVOKER function_invoker10
#define BOOST_FUNCTION_VOID_FUNCTION_INVOKER void_function_invoker10
@ -46,6 +47,7 @@
#undef BOOST_FUNCTION_PARMS
#undef BOOST_FUNCTION_ARGS
#undef BOOST_FUNCTION_FUNCTION
#undef BOOST_FUNCTION_BASE
#undef BOOST_FUNCTION_INVOKER_BASE
#undef BOOST_FUNCTION_FUNCTION_INVOKER
#undef BOOST_FUNCTION_VOID_FUNCTION_INVOKER

View File

@ -27,6 +27,7 @@
#define BOOST_FUNCTION_PARMS T1 a1, T2 a2
#define BOOST_FUNCTION_ARGS a1, a2
#define BOOST_FUNCTION_FUNCTION function2
#define BOOST_FUNCTION_BASE function2_base
#define BOOST_FUNCTION_INVOKER_BASE invoker_base2
#define BOOST_FUNCTION_FUNCTION_INVOKER function_invoker2
#define BOOST_FUNCTION_VOID_FUNCTION_INVOKER void_function_invoker2
@ -46,6 +47,7 @@
#undef BOOST_FUNCTION_PARMS
#undef BOOST_FUNCTION_ARGS
#undef BOOST_FUNCTION_FUNCTION
#undef BOOST_FUNCTION_BASE
#undef BOOST_FUNCTION_INVOKER_BASE
#undef BOOST_FUNCTION_FUNCTION_INVOKER
#undef BOOST_FUNCTION_VOID_FUNCTION_INVOKER

View File

@ -27,6 +27,7 @@
#define BOOST_FUNCTION_PARMS T1 a1, T2 a2, T3 a3
#define BOOST_FUNCTION_ARGS a1, a2, a3
#define BOOST_FUNCTION_FUNCTION function3
#define BOOST_FUNCTION_BASE function3_base
#define BOOST_FUNCTION_INVOKER_BASE invoker_base3
#define BOOST_FUNCTION_FUNCTION_INVOKER function_invoker3
#define BOOST_FUNCTION_VOID_FUNCTION_INVOKER void_function_invoker3
@ -46,6 +47,7 @@
#undef BOOST_FUNCTION_PARMS
#undef BOOST_FUNCTION_ARGS
#undef BOOST_FUNCTION_FUNCTION
#undef BOOST_FUNCTION_BASE
#undef BOOST_FUNCTION_INVOKER_BASE
#undef BOOST_FUNCTION_FUNCTION_INVOKER
#undef BOOST_FUNCTION_VOID_FUNCTION_INVOKER

View File

@ -27,6 +27,7 @@
#define BOOST_FUNCTION_PARMS T1 a1, T2 a2, T3 a3, T4 a4
#define BOOST_FUNCTION_ARGS a1, a2, a3, a4
#define BOOST_FUNCTION_FUNCTION function4
#define BOOST_FUNCTION_BASE function4_base
#define BOOST_FUNCTION_INVOKER_BASE invoker_base4
#define BOOST_FUNCTION_FUNCTION_INVOKER function_invoker4
#define BOOST_FUNCTION_VOID_FUNCTION_INVOKER void_function_invoker4
@ -46,6 +47,7 @@
#undef BOOST_FUNCTION_PARMS
#undef BOOST_FUNCTION_ARGS
#undef BOOST_FUNCTION_FUNCTION
#undef BOOST_FUNCTION_BASE
#undef BOOST_FUNCTION_INVOKER_BASE
#undef BOOST_FUNCTION_FUNCTION_INVOKER
#undef BOOST_FUNCTION_VOID_FUNCTION_INVOKER

View File

@ -27,6 +27,7 @@
#define BOOST_FUNCTION_PARMS T1 a1, T2 a2, T3 a3, T4 a4, T5 a5
#define BOOST_FUNCTION_ARGS a1, a2, a3, a4, a5
#define BOOST_FUNCTION_FUNCTION function5
#define BOOST_FUNCTION_BASE function5_base
#define BOOST_FUNCTION_INVOKER_BASE invoker_base5
#define BOOST_FUNCTION_FUNCTION_INVOKER function_invoker5
#define BOOST_FUNCTION_VOID_FUNCTION_INVOKER void_function_invoker5
@ -46,6 +47,7 @@
#undef BOOST_FUNCTION_PARMS
#undef BOOST_FUNCTION_ARGS
#undef BOOST_FUNCTION_FUNCTION
#undef BOOST_FUNCTION_BASE
#undef BOOST_FUNCTION_INVOKER_BASE
#undef BOOST_FUNCTION_FUNCTION_INVOKER
#undef BOOST_FUNCTION_VOID_FUNCTION_INVOKER

View File

@ -27,6 +27,7 @@
#define BOOST_FUNCTION_PARMS T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6
#define BOOST_FUNCTION_ARGS a1, a2, a3, a4, a5, a6
#define BOOST_FUNCTION_FUNCTION function6
#define BOOST_FUNCTION_BASE function6_base
#define BOOST_FUNCTION_INVOKER_BASE invoker_base6
#define BOOST_FUNCTION_FUNCTION_INVOKER function_invoker6
#define BOOST_FUNCTION_VOID_FUNCTION_INVOKER void_function_invoker6
@ -46,6 +47,7 @@
#undef BOOST_FUNCTION_PARMS
#undef BOOST_FUNCTION_ARGS
#undef BOOST_FUNCTION_FUNCTION
#undef BOOST_FUNCTION_BASE
#undef BOOST_FUNCTION_INVOKER_BASE
#undef BOOST_FUNCTION_FUNCTION_INVOKER
#undef BOOST_FUNCTION_VOID_FUNCTION_INVOKER

View File

@ -27,6 +27,7 @@
#define BOOST_FUNCTION_PARMS T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6, T7 a7
#define BOOST_FUNCTION_ARGS a1, a2, a3, a4, a5, a6, a7
#define BOOST_FUNCTION_FUNCTION function7
#define BOOST_FUNCTION_BASE function7_base
#define BOOST_FUNCTION_INVOKER_BASE invoker_base7
#define BOOST_FUNCTION_FUNCTION_INVOKER function_invoker7
#define BOOST_FUNCTION_VOID_FUNCTION_INVOKER void_function_invoker7
@ -46,6 +47,7 @@
#undef BOOST_FUNCTION_PARMS
#undef BOOST_FUNCTION_ARGS
#undef BOOST_FUNCTION_FUNCTION
#undef BOOST_FUNCTION_BASE
#undef BOOST_FUNCTION_INVOKER_BASE
#undef BOOST_FUNCTION_FUNCTION_INVOKER
#undef BOOST_FUNCTION_VOID_FUNCTION_INVOKER

View File

@ -27,6 +27,7 @@
#define BOOST_FUNCTION_PARMS T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6, T7 a7, T8 a8
#define BOOST_FUNCTION_ARGS a1, a2, a3, a4, a5, a6, a7, a8
#define BOOST_FUNCTION_FUNCTION function8
#define BOOST_FUNCTION_BASE function8_base
#define BOOST_FUNCTION_INVOKER_BASE invoker_base8
#define BOOST_FUNCTION_FUNCTION_INVOKER function_invoker8
#define BOOST_FUNCTION_VOID_FUNCTION_INVOKER void_function_invoker8
@ -46,6 +47,7 @@
#undef BOOST_FUNCTION_PARMS
#undef BOOST_FUNCTION_ARGS
#undef BOOST_FUNCTION_FUNCTION
#undef BOOST_FUNCTION_BASE
#undef BOOST_FUNCTION_INVOKER_BASE
#undef BOOST_FUNCTION_FUNCTION_INVOKER
#undef BOOST_FUNCTION_VOID_FUNCTION_INVOKER

View File

@ -27,6 +27,7 @@
#define BOOST_FUNCTION_PARMS T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6, T7 a7, T8 a8, T9 a9
#define BOOST_FUNCTION_ARGS a1, a2, a3, a4, a5, a6, a7, a8, a9
#define BOOST_FUNCTION_FUNCTION function9
#define BOOST_FUNCTION_BASE function9_base
#define BOOST_FUNCTION_INVOKER_BASE invoker_base9
#define BOOST_FUNCTION_FUNCTION_INVOKER function_invoker9
#define BOOST_FUNCTION_VOID_FUNCTION_INVOKER void_function_invoker9
@ -46,6 +47,7 @@
#undef BOOST_FUNCTION_PARMS
#undef BOOST_FUNCTION_ARGS
#undef BOOST_FUNCTION_FUNCTION
#undef BOOST_FUNCTION_BASE
#undef BOOST_FUNCTION_INVOKER_BASE
#undef BOOST_FUNCTION_FUNCTION_INVOKER
#undef BOOST_FUNCTION_VOID_FUNCTION_INVOKER

View File

@ -22,13 +22,6 @@
#include <boost/config.hpp>
#include <boost/type_traits.hpp>
// Microsoft Visual C++ 6.0sp5 has lots of quirks
#ifdef BOOST_MSVC
# define BOOST_MSVC_INCLUDE(x) x
#else
# define BOOST_MSVC_INCLUDE(x)
#endif
namespace boost {
namespace detail {
namespace function {
@ -42,7 +35,7 @@ namespace boost {
template<typename Then, typename Else>
struct Result
{
typedef Then RET;
typedef Then type;
};
};
@ -51,29 +44,28 @@ namespace boost {
template<typename Then, typename Else>
struct Result
{
typedef Else RET;
typedef Else type;
};
};
template<bool Condition>
struct Selector
{
typedef SelectThen RET;
typedef SelectThen type;
};
template<>
struct Selector<false>
{
typedef SelectElse RET;
typedef SelectElse type;
};
} // end namespace intimate
template<bool Condition, typename Then, typename Else>
struct IF
{
typedef typename intimate::Selector<Condition>::RET select;
typedef typename select::template Result<Then,Else>::RET RET;
typedef RET type;
typedef typename intimate::Selector<Condition>::type select;
typedef typename select::template Result<Then,Else>::type type;
};
/**
@ -110,13 +102,11 @@ namespace boost {
*/
template<typename T> struct function_return_type { typedef T type; };
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
template<>
struct function_return_type<void>
{
typedef unusable type;
};
#endif /* BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION */
// The operation type to perform on the given functor/function pointer
enum functor_manager_operation_type { clone_functor, destroy_functor };
@ -183,23 +173,22 @@ namespace boost {
}
else {
/* Cast from the void pointer to the functor pointer type */
functor_type* f =
reinterpret_cast<functor_type*>(function_obj_ptr.obj_ptr);
functor_type* f =
reinterpret_cast<functor_type*>(function_obj_ptr.obj_ptr);
# ifndef BOOST_NO_STD_ALLOCATOR
/* Cast from the functor pointer type to the allocator's pointer
type */
pointer_type victim = static_cast<pointer_type>(f);
/* Cast from the functor pointer type to the allocator's pointer
type */
pointer_type victim = static_cast<pointer_type>(f);
// Destroy and deallocate the functor
allocator.destroy(victim);
allocator.deallocate(victim, 1);
// Destroy and deallocate the functor
allocator.destroy(victim);
allocator.deallocate(victim, 1);
# else
delete f;
delete f;
# endif // BOOST_NO_STD_ALLOCATOR
return any_pointer(static_cast<void*>(0));
return any_pointer(static_cast<void*>(0));
}
}
@ -210,8 +199,8 @@ namespace boost {
manage(any_pointer functor_ptr, functor_manager_operation_type op)
{
typedef typename IF<(is_pointer<functor_type>::value),
function_ptr_tag,
function_obj_tag>::RET tag_type;
function_ptr_tag,
function_obj_tag>::type tag_type;
return manager(functor_ptr, op, tag_type());
}
@ -285,22 +274,19 @@ namespace boost {
detail::function::any_pointer functor;
#endif // BOOST_FUNCTION_USE_VIRTUAL_FUNCTIONS
#ifndef BOOST_WEAK_CONVERSION_OPERATORS
private:
struct dummy {
void nonnull() {};
};
typedef void (dummy::*safe_bool)();
public:
operator safe_bool () const
{
return (this->empty())? 0 : &dummy::nonnull;
}
#else
public:
operator bool() const { return !this->empty(); }
#endif // BOOST_WEAK_CONVERSION_OPERATORS
{ return (this->empty())? 0 : &dummy::nonnull; }
safe_bool operator!() const
{ return (this->empty())? &dummy::nonnull : 0; }
};
/* Poison comparison between Boost.Function objects (because it is

File diff suppressed because it is too large Load Diff

View File

@ -130,7 +130,7 @@ test_zero_args()
// Construction from another function (that is empty)
v1.clear();
func_void_type v2(v1);;
func_void_type v2(v1);
BOOST_TEST(!v2);
// Assignment to an empty function
@ -227,10 +227,10 @@ test_zero_args()
BOOST_TEST(global_int == 5);
global_int = 0;
v2();
BOOST_TEST(global_int == 5);;
BOOST_TEST(global_int == 5);
// Construct a function given another function containing a function
func_void_type v3(v1);;
func_void_type v3(v1);
// Invocation of a function
global_int = 0;
@ -552,7 +552,7 @@ test_emptiness()
BOOST_TEST(f2.empty());
function0<double> f3;
f3 = f2;;
f3 = f2;
BOOST_TEST(f3.empty());
}

View File

@ -130,7 +130,7 @@ test_zero_args()
// Construction from another function (that is empty)
v1.clear();
func_void_type v2(v1);;
func_void_type v2(v1);
BOOST_TEST(!v2);
// Assignment to an empty function
@ -227,10 +227,10 @@ test_zero_args()
BOOST_TEST(global_int == 5);
global_int = 0;
v2();
BOOST_TEST(global_int == 5);;
BOOST_TEST(global_int == 5);
// Construct a function given another function containing a function
func_void_type v3(v1);;
func_void_type v3(v1);
// Invocation of a function
global_int = 0;
@ -552,7 +552,7 @@ test_emptiness()
BOOST_TEST(f2.empty());
function<double> f3;
f3 = f2;;
f3 = f2;
BOOST_TEST(f3.empty());
}

View File

@ -1,7 +1,7 @@
// Boost.Function regression test configuration file
// From the boost/status directory, run
// ./regressions --tests ../libs/function/test/regression.cfg --o function.html
// ./regression --tests ../libs/function/test/regression.cfg -o function.html
run libs/function/test/allocator_test.cpp