Compare commits

..

1 Commits

Author SHA1 Message Date
nobody
747e059847 This commit was manufactured by cvs2svn to create branch
'iter-adaptor-and-categories'.

[SVN r10453]
2001-06-27 22:12:20 +00:00
17 changed files with 1377 additions and 364 deletions

View File

@@ -456,66 +456,56 @@ namespace boost {
function() : base_type() {}
template<typename Functor>
function(const Functor& f) : base_type(f) {}
#ifdef __BORLANDC__
template<typename Functor>
function(Functor* f) : base_type(f) {}
#endif // __BORLANDC__
function(Functor BOOST_MSVC_INCLUDE(const &) f) : base_type(f) {}
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)
{
this->assign_to_own(f);
if (this == &f)
return *this;
const base_type& bf = static_cast<const base_type&>(f);
base_type* self = this;
self->set(bf);
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)
{
this->assign_to_own(f);
if (this == &f)
return;
const base_type& bf = static_cast<const base_type&>(f);
base_type* self = this;
self->set(bf);
}
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,7 +27,6 @@
#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
@@ -47,7 +46,6 @@
#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,7 +27,6 @@
#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
@@ -47,7 +46,6 @@
#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,7 +27,6 @@
#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
@@ -47,7 +46,6 @@
#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,7 +27,6 @@
#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
@@ -47,7 +46,6 @@
#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,7 +27,6 @@
#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
@@ -47,7 +46,6 @@
#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,7 +27,6 @@
#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
@@ -47,7 +46,6 @@
#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,7 +27,6 @@
#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
@@ -47,7 +46,6 @@
#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,7 +27,6 @@
#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
@@ -47,7 +46,6 @@
#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,7 +27,6 @@
#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
@@ -47,7 +46,6 @@
#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,7 +27,6 @@
#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
@@ -47,7 +46,6 @@
#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,7 +27,6 @@
#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
@@ -47,7 +46,6 @@
#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,6 +22,13 @@
#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 {
@@ -35,7 +42,7 @@ namespace boost {
template<typename Then, typename Else>
struct Result
{
typedef Then type;
typedef Then RET;
};
};
@@ -44,28 +51,29 @@ namespace boost {
template<typename Then, typename Else>
struct Result
{
typedef Else type;
typedef Else RET;
};
};
template<bool Condition>
struct Selector
{
typedef SelectThen type;
typedef SelectThen RET;
};
template<>
struct Selector<false>
{
typedef SelectElse type;
typedef SelectElse RET;
};
} // end namespace intimate
template<bool Condition, typename Then, typename Else>
struct IF
{
typedef typename intimate::Selector<Condition>::type select;
typedef typename select::template Result<Then,Else>::type type;
typedef typename intimate::Selector<Condition>::RET select;
typedef typename select::template Result<Then,Else>::RET RET;
typedef RET type;
};
/**
@@ -102,11 +110,13 @@ 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 };
@@ -173,22 +183,23 @@ 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));
}
}
@@ -199,8 +210,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>::type tag_type;
function_ptr_tag,
function_obj_tag>::RET tag_type;
return manager(functor_ptr, op, tag_type());
}
@@ -274,19 +285,22 @@ 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; }
safe_bool operator!() const
{ return (this->empty())? &dummy::nonnull : 0; }
{
return (this->empty())? 0 : &dummy::nonnull;
}
#else
public:
operator bool() const { return !this->empty(); }
#endif // BOOST_WEAK_CONVERSION_OPERATORS
};
/* 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
// ./regression --tests ../libs/function/test/regression.cfg -o function.html
// ./regressions --tests ../libs/function/test/regression.cfg --o function.html
run libs/function/test/allocator_test.cpp