mirror of
https://github.com/boostorg/function.git
synced 2025-06-25 20:11:37 +02:00
Compare commits
9 Commits
boost-1.36
...
svn-branch
Author | SHA1 | Date | |
---|---|---|---|
687dff0782 | |||
80a3f47099 | |||
2a85edbd31 | |||
5c514ebe35 | |||
6a3f0df553 | |||
64c8d10fa8 | |||
a2a810d2c1 | |||
d84481361f | |||
872f12efee |
@ -10,6 +10,8 @@
|
|||||||
// William Kempf, Jesse Jones and Karl Nelson were all very helpful in the
|
// William Kempf, Jesse Jones and Karl Nelson were all very helpful in the
|
||||||
// design of this library.
|
// design of this library.
|
||||||
|
|
||||||
|
#include <functional> // unary_function, binary_function
|
||||||
|
|
||||||
#include <boost/preprocessor/iterate.hpp>
|
#include <boost/preprocessor/iterate.hpp>
|
||||||
#include <boost/detail/workaround.hpp>
|
#include <boost/detail/workaround.hpp>
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#define BOOST_FUNCTION_PROLOGUE_HPP
|
#define BOOST_FUNCTION_PROLOGUE_HPP
|
||||||
# include <cassert>
|
# include <cassert>
|
||||||
# include <algorithm>
|
# include <algorithm>
|
||||||
|
# include <functional> // unary_function, binary_function
|
||||||
# include <boost/throw_exception.hpp>
|
# include <boost/throw_exception.hpp>
|
||||||
# include <boost/config.hpp>
|
# include <boost/config.hpp>
|
||||||
# include <boost/function/function_base.hpp>
|
# include <boost/function/function_base.hpp>
|
||||||
|
@ -30,6 +30,14 @@
|
|||||||
#endif
|
#endif
|
||||||
#include <boost/function_equal.hpp>
|
#include <boost/function_equal.hpp>
|
||||||
|
|
||||||
|
// Define BOOST_FUNCTION_STD_NS to the namespace that contains type_info.
|
||||||
|
#ifdef BOOST_NO_EXCEPTION_STD_NAMESPACE
|
||||||
|
// Embedded VC++ does not have type_info in namespace std
|
||||||
|
# define BOOST_FUNCTION_STD_NS
|
||||||
|
#else
|
||||||
|
# define BOOST_FUNCTION_STD_NS std
|
||||||
|
#endif
|
||||||
|
|
||||||
// Borrowed from Boost.Python library: determines the cases where we
|
// Borrowed from Boost.Python library: determines the cases where we
|
||||||
// need to use std::type_info::name to compare instead of operator==.
|
// need to use std::type_info::name to compare instead of operator==.
|
||||||
# if (defined(__GNUC__) && __GNUC__ >= 3) \
|
# if (defined(__GNUC__) && __GNUC__ >= 3) \
|
||||||
@ -59,7 +67,7 @@ namespace boost { namespace python { namespace objects {
|
|||||||
|
|
||||||
#if defined (BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \
|
#if defined (BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \
|
||||||
|| defined(BOOST_BCB_PARTIAL_SPECIALIZATION_BUG) \
|
|| defined(BOOST_BCB_PARTIAL_SPECIALIZATION_BUG) \
|
||||||
|| !(BOOST_STRICT_CONFIG || !defined(__SUNPRO_CC) || __SUNPRO_CC > 0x540)
|
|| !(defined(BOOST_STRICT_CONFIG) || !defined(__SUNPRO_CC) || __SUNPRO_CC > 0x540)
|
||||||
# define BOOST_FUNCTION_NO_FUNCTION_TYPE_SYNTAX
|
# define BOOST_FUNCTION_NO_FUNCTION_TYPE_SYNTAX
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -215,8 +223,8 @@ namespace boost {
|
|||||||
// DPG TBD: Since we're only storing a pointer, it's
|
// DPG TBD: Since we're only storing a pointer, it's
|
||||||
// possible that the user could ask for a base class or
|
// possible that the user could ask for a base class or
|
||||||
// derived class. Is that okay?
|
// derived class. Is that okay?
|
||||||
const std::type_info& check_type =
|
const BOOST_FUNCTION_STD_NS::type_info& check_type =
|
||||||
*static_cast<const std::type_info*>(out_buffer.const_obj_ptr);
|
*static_cast<const BOOST_FUNCTION_STD_NS::type_info*>(out_buffer.const_obj_ptr);
|
||||||
if (BOOST_FUNCTION_COMPARE_TYPE_ID(check_type, typeid(F)))
|
if (BOOST_FUNCTION_COMPARE_TYPE_ID(check_type, typeid(F)))
|
||||||
out_buffer.obj_ptr = in_buffer.obj_ptr;
|
out_buffer.obj_ptr = in_buffer.obj_ptr;
|
||||||
else
|
else
|
||||||
@ -265,8 +273,8 @@ namespace boost {
|
|||||||
else if (op == destroy_functor_tag)
|
else if (op == destroy_functor_tag)
|
||||||
out_buffer.func_ptr = 0;
|
out_buffer.func_ptr = 0;
|
||||||
else /* op == check_functor_type_tag */ {
|
else /* op == check_functor_type_tag */ {
|
||||||
const std::type_info& check_type =
|
const BOOST_FUNCTION_STD_NS::type_info& check_type =
|
||||||
*static_cast<const std::type_info*>(out_buffer.const_obj_ptr);
|
*static_cast<const BOOST_FUNCTION_STD_NS::type_info*>(out_buffer.const_obj_ptr);
|
||||||
if (BOOST_FUNCTION_COMPARE_TYPE_ID(check_type, typeid(Functor)))
|
if (BOOST_FUNCTION_COMPARE_TYPE_ID(check_type, typeid(Functor)))
|
||||||
out_buffer.obj_ptr = &in_buffer.func_ptr;
|
out_buffer.obj_ptr = &in_buffer.func_ptr;
|
||||||
else
|
else
|
||||||
@ -284,13 +292,11 @@ namespace boost {
|
|||||||
reinterpret_cast<const functor_type*>(&in_buffer.data);
|
reinterpret_cast<const functor_type*>(&in_buffer.data);
|
||||||
new ((void*)&out_buffer.data) functor_type(*in_functor);
|
new ((void*)&out_buffer.data) functor_type(*in_functor);
|
||||||
} else if (op == destroy_functor_tag) {
|
} else if (op == destroy_functor_tag) {
|
||||||
functor_type* out_functor =
|
|
||||||
reinterpret_cast<functor_type*>(&out_buffer.data);
|
|
||||||
// Some compilers (Borland, vc6, ...) are unhappy with ~functor_type.
|
// Some compilers (Borland, vc6, ...) are unhappy with ~functor_type.
|
||||||
out_functor->~Functor();
|
reinterpret_cast<functor_type*>(&out_buffer.data)->~Functor();
|
||||||
} else /* op == check_functor_type_tag */ {
|
} else /* op == check_functor_type_tag */ {
|
||||||
const std::type_info& check_type =
|
const BOOST_FUNCTION_STD_NS::type_info& check_type =
|
||||||
*static_cast<const std::type_info*>(out_buffer.const_obj_ptr);
|
*static_cast<const BOOST_FUNCTION_STD_NS::type_info*>(out_buffer.const_obj_ptr);
|
||||||
if (BOOST_FUNCTION_COMPARE_TYPE_ID(check_type, typeid(Functor)))
|
if (BOOST_FUNCTION_COMPARE_TYPE_ID(check_type, typeid(Functor)))
|
||||||
out_buffer.obj_ptr = &in_buffer.data;
|
out_buffer.obj_ptr = &in_buffer.data;
|
||||||
else
|
else
|
||||||
@ -350,8 +356,8 @@ namespace boost {
|
|||||||
# endif // BOOST_NO_STD_ALLOCATOR
|
# endif // BOOST_NO_STD_ALLOCATOR
|
||||||
out_buffer.obj_ptr = 0;
|
out_buffer.obj_ptr = 0;
|
||||||
} else /* op == check_functor_type_tag */ {
|
} else /* op == check_functor_type_tag */ {
|
||||||
const std::type_info& check_type =
|
const BOOST_FUNCTION_STD_NS::type_info& check_type =
|
||||||
*static_cast<const std::type_info*>(out_buffer.const_obj_ptr);
|
*static_cast<const BOOST_FUNCTION_STD_NS::type_info*>(out_buffer.const_obj_ptr);
|
||||||
if (BOOST_FUNCTION_COMPARE_TYPE_ID(check_type, typeid(Functor)))
|
if (BOOST_FUNCTION_COMPARE_TYPE_ID(check_type, typeid(Functor)))
|
||||||
out_buffer.obj_ptr = in_buffer.obj_ptr;
|
out_buffer.obj_ptr = in_buffer.obj_ptr;
|
||||||
else
|
else
|
||||||
@ -482,13 +488,13 @@ public:
|
|||||||
|
|
||||||
/** Retrieve the type of the stored function object, or typeid(void)
|
/** Retrieve the type of the stored function object, or typeid(void)
|
||||||
if this is empty. */
|
if this is empty. */
|
||||||
const std::type_info& target_type() const
|
const BOOST_FUNCTION_STD_NS::type_info& target_type() const
|
||||||
{
|
{
|
||||||
if (!vtable) return typeid(void);
|
if (!vtable) return typeid(void);
|
||||||
|
|
||||||
detail::function::function_buffer type;
|
detail::function::function_buffer type;
|
||||||
vtable->manager(functor, type, detail::function::get_functor_type_tag);
|
vtable->manager(functor, type, detail::function::get_functor_type_tag);
|
||||||
return *static_cast<const std::type_info*>(type.const_obj_ptr);
|
return *static_cast<const BOOST_FUNCTION_STD_NS::type_info*>(type.const_obj_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Functor>
|
template<typename Functor>
|
||||||
|
@ -446,6 +446,17 @@ namespace boost {
|
|||||||
typename Allocator = BOOST_FUNCTION_DEFAULT_ALLOCATOR
|
typename Allocator = BOOST_FUNCTION_DEFAULT_ALLOCATOR
|
||||||
>
|
>
|
||||||
class BOOST_FUNCTION_FUNCTION : public function_base
|
class BOOST_FUNCTION_FUNCTION : public function_base
|
||||||
|
|
||||||
|
#if BOOST_FUNCTION_NUM_ARGS == 1
|
||||||
|
|
||||||
|
, public std::unary_function<T0,R>
|
||||||
|
|
||||||
|
#elif BOOST_FUNCTION_NUM_ARGS == 2
|
||||||
|
|
||||||
|
, public std::binary_function<T0,T1,R>
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
#ifndef BOOST_NO_VOID_RETURNS
|
#ifndef BOOST_NO_VOID_RETURNS
|
||||||
|
@ -4,6 +4,10 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
Automatic redirection failed, please go to
|
Automatic redirection failed, please go to
|
||||||
<a href="../../doc/html/function.html">../../doc/html/function.html</a>
|
<a href="../../doc/html/function.html">../../doc/html/function.html</a> <hr>
|
||||||
|
<p><EFBFBD> Copyright Beman Dawes, 2001</p>
|
||||||
|
<p>Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
file <a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or copy
|
||||||
|
at <a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>)</p>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
68
test/Jamfile
68
test/Jamfile
@ -1,68 +0,0 @@
|
|||||||
# Function library
|
|
||||||
|
|
||||||
# Copyright (C) 2001-2003 Douglas Gregor
|
|
||||||
|
|
||||||
# Use, modification and distribution is subject to the Boost Software License,
|
|
||||||
# Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
|
||||||
# http://www.boost.org/LICENSE_1_0.txt)
|
|
||||||
|
|
||||||
# For more information, see http://www.boost.org/
|
|
||||||
|
|
||||||
|
|
||||||
# Testing Jamfile autogenerated from XML source
|
|
||||||
subproject libs/function/test ;
|
|
||||||
|
|
||||||
# bring in rules for testing
|
|
||||||
SEARCH on testing.jam = $(BOOST_BUILD_PATH) ;
|
|
||||||
include testing.jam ;
|
|
||||||
|
|
||||||
# Make tests run by default.
|
|
||||||
DEPENDS all : test ;
|
|
||||||
|
|
||||||
{
|
|
||||||
# look in BOOST_ROOT for sources first, just in this Jamfile
|
|
||||||
local SEARCH_SOURCE = $(BOOST_ROOT) $(SEARCH_SOURCE) ;
|
|
||||||
|
|
||||||
test-suite function
|
|
||||||
:
|
|
||||||
[ run libs/function/test/function_test.cpp : : : : lib_function_test ]
|
|
||||||
|
|
||||||
[ run libs/function/test/function_n_test.cpp : : : : ]
|
|
||||||
|
|
||||||
[ run libs/function/test/allocator_test.cpp : : : : ]
|
|
||||||
|
|
||||||
[ run libs/function/test/stateless_test.cpp : : : : ]
|
|
||||||
|
|
||||||
[ run libs/function/test/lambda_test.cpp : : : : ]
|
|
||||||
|
|
||||||
[ compile-fail libs/function/test/function_test_fail1.cpp : : : : ]
|
|
||||||
|
|
||||||
[ compile-fail libs/function/test/function_test_fail2.cpp : : : : ]
|
|
||||||
|
|
||||||
[ compile libs/function/test/function_30.cpp : : : : ]
|
|
||||||
|
|
||||||
[ run libs/function/test/function_arith_cxx98.cpp : : : : ]
|
|
||||||
|
|
||||||
[ run libs/function/test/function_arith_portable.cpp : : : : ]
|
|
||||||
|
|
||||||
[ run libs/function/test/sum_avg_cxx98.cpp : : : : ]
|
|
||||||
|
|
||||||
[ run libs/function/test/sum_avg_portable.cpp : : : : ]
|
|
||||||
|
|
||||||
[ run libs/function/test/mem_fun_cxx98.cpp : : : : ]
|
|
||||||
|
|
||||||
[ run libs/function/test/mem_fun_portable.cpp : : : : ]
|
|
||||||
|
|
||||||
[ run libs/function/test/std_bind_cxx98.cpp : : : : ]
|
|
||||||
|
|
||||||
[ run libs/function/test/std_bind_portable.cpp : : : : ]
|
|
||||||
|
|
||||||
[ run libs/function/test/function_ref_cxx98.cpp : : : : ]
|
|
||||||
|
|
||||||
[ run libs/function/test/function_ref_portable.cpp : : : : ]
|
|
||||||
|
|
||||||
[ run libs/function/test/contains_test.cpp : : : : ]
|
|
||||||
|
|
||||||
[ run libs/function/test/contains2_test.cpp : : : : ]
|
|
||||||
;
|
|
||||||
}
|
|
Reference in New Issue
Block a user