mirror of
https://github.com/boostorg/function.git
synced 2026-01-29 07:32:15 +00:00
Compare commits
1 Commits
sandbox-br
...
svn-branch
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d6a9a888f1 |
@@ -1,9 +1,3 @@
|
||||
#
|
||||
# Copyright Troy D. Straszheim
|
||||
#
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# See http://www.boost.org/LICENSE_1_0.txt
|
||||
#
|
||||
#----------------------------------------------------------------------------
|
||||
# This file was automatically generated from the original CMakeLists.txt file
|
||||
# Add a variable to hold the headers for the library
|
||||
|
||||
@@ -1,8 +1,2 @@
|
||||
#
|
||||
# Copyright Troy D. Straszheim
|
||||
#
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# See http://www.boost.org/LICENSE_1_0.txt
|
||||
#
|
||||
boost_add_documentation(function.xml
|
||||
faq.xml history.xml misc.xml reference.xml tests.xml tutorial.xml)
|
||||
|
||||
@@ -35,12 +35,12 @@ form to use for your compiler.
|
||||
<row>
|
||||
<entry>
|
||||
<itemizedlist spacing="compact">
|
||||
<listitem><simpara>GNU C++ 2.95.x, 3.0.x and later versions</simpara></listitem>
|
||||
<listitem><simpara>GNU C++ 2.95.x, 3.0.x, 3.1.x</simpara></listitem>
|
||||
<listitem><simpara>Comeau C++ 4.2.45.2</simpara></listitem>
|
||||
<listitem><simpara>SGI MIPSpro 7.3.0</simpara></listitem>
|
||||
<listitem><simpara>Intel C++ 5.0, 6.0</simpara></listitem>
|
||||
<listitem><simpara>Compaq's cxx 6.2</simpara></listitem>
|
||||
<listitem><simpara>Microsoft Visual C++ 7.1 and later versions</simpara></listitem>
|
||||
<listitem><simpara>Microsoft Visual C++ 7.1</simpara></listitem>
|
||||
</itemizedlist>
|
||||
</entry>
|
||||
<entry>
|
||||
|
||||
@@ -262,12 +262,6 @@ namespace boost {
|
||||
A(a)
|
||||
{
|
||||
}
|
||||
|
||||
functor_wrapper(const functor_wrapper& f) :
|
||||
F(static_cast<const F&>(f)),
|
||||
A(static_cast<const A&>(f))
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -895,8 +889,4 @@ namespace detail {
|
||||
#undef BOOST_FUNCTION_ENABLE_IF_NOT_INTEGRAL
|
||||
#undef BOOST_FUNCTION_COMPARE_TYPE_ID
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
# pragma warning( pop )
|
||||
#endif
|
||||
|
||||
#endif // BOOST_FUNCTION_BASE_HEADER
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
// Note: this header is a header template and must NOT have multiple-inclusion
|
||||
// protection.
|
||||
#include <boost/function/detail/prologue.hpp>
|
||||
#include <boost/detail/no_exceptions_support.hpp>
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
# pragma warning( push )
|
||||
@@ -625,10 +624,14 @@ namespace boost {
|
||||
assign_to(const reference_wrapper<FunctionObj>& f,
|
||||
function_buffer& functor, function_obj_ref_tag)
|
||||
{
|
||||
functor.obj_ref.obj_ptr = (void *)f.get_pointer();
|
||||
functor.obj_ref.is_const_qualified = is_const<FunctionObj>::value;
|
||||
functor.obj_ref.is_volatile_qualified = is_volatile<FunctionObj>::value;
|
||||
return true;
|
||||
if (!boost::detail::function::has_empty_target(f.get_pointer())) {
|
||||
functor.obj_ref.obj_ptr = (void *)f.get_pointer();
|
||||
functor.obj_ref.is_const_qualified = is_const<FunctionObj>::value;
|
||||
functor.obj_ref.is_volatile_qualified = is_volatile<FunctionObj>::value;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
template<typename FunctionObj,typename Allocator>
|
||||
bool
|
||||
@@ -783,26 +786,24 @@ namespace boost {
|
||||
operator=(Functor BOOST_FUNCTION_TARGET_FIX(const &) f)
|
||||
{
|
||||
this->clear();
|
||||
BOOST_TRY {
|
||||
try {
|
||||
this->assign_to(f);
|
||||
} BOOST_CATCH (...) {
|
||||
} catch (...) {
|
||||
vtable = 0;
|
||||
BOOST_RETHROW;
|
||||
throw;
|
||||
}
|
||||
BOOST_CATCH_END
|
||||
return *this;
|
||||
}
|
||||
template<typename Functor,typename Allocator>
|
||||
void assign(Functor BOOST_FUNCTION_TARGET_FIX(const &) f, Allocator a)
|
||||
{
|
||||
this->clear();
|
||||
BOOST_TRY{
|
||||
try {
|
||||
this->assign_to_a(f,a);
|
||||
} BOOST_CATCH (...) {
|
||||
} catch (...) {
|
||||
vtable = 0;
|
||||
BOOST_RETHROW;
|
||||
throw;
|
||||
}
|
||||
BOOST_CATCH_END
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_SFINAE
|
||||
@@ -827,13 +828,12 @@ namespace boost {
|
||||
return *this;
|
||||
|
||||
this->clear();
|
||||
BOOST_TRY {
|
||||
try {
|
||||
this->assign_to_own(f);
|
||||
} BOOST_CATCH (...) {
|
||||
} catch (...) {
|
||||
vtable = 0;
|
||||
BOOST_RETHROW;
|
||||
throw;
|
||||
}
|
||||
BOOST_CATCH_END
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -965,7 +965,9 @@ namespace boost {
|
||||
if (&f == this)
|
||||
return;
|
||||
|
||||
BOOST_TRY {
|
||||
#if !defined(BOOST_NO_EXCEPTIONS)
|
||||
try {
|
||||
#endif
|
||||
if (!f.empty()) {
|
||||
this->vtable = f.vtable;
|
||||
if (this->has_trivial_copy_and_destroy())
|
||||
@@ -977,11 +979,12 @@ namespace boost {
|
||||
} else {
|
||||
clear();
|
||||
}
|
||||
} BOOST_CATCH (...) {
|
||||
#if !defined(BOOST_NO_EXCEPTIONS)
|
||||
} catch (...) {
|
||||
vtable = 0;
|
||||
BOOST_RETHROW;
|
||||
throw;
|
||||
}
|
||||
BOOST_CATCH_END
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,9 +1,3 @@
|
||||
#
|
||||
# Copyright Troy D. Straszheim
|
||||
#
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# See http://www.boost.org/LICENSE_1_0.txt
|
||||
#
|
||||
boost_additional_test_dependencies(function BOOST_DEPENDS test lambda)
|
||||
|
||||
|
||||
|
||||
@@ -128,10 +128,6 @@ test_main(int, char*[])
|
||||
BOOST_CHECK(dealloc_count == 0);
|
||||
fv.assign( &do_nothing, std::allocator<int>() );
|
||||
fv.clear();
|
||||
|
||||
function0<void> fv2;
|
||||
fv.assign(&do_nothing, std::allocator<int>() );
|
||||
fv2.assign(fv, std::allocator<int>() );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
using boost::function;
|
||||
using std::string;
|
||||
using namespace boost;
|
||||
using namespace std;
|
||||
|
||||
int global_int;
|
||||
|
||||
@@ -525,7 +525,7 @@ test_zero_args()
|
||||
static void
|
||||
test_one_arg()
|
||||
{
|
||||
std::negate<int> neg;
|
||||
negate<int> neg;
|
||||
|
||||
function<int (int)> f1(neg);
|
||||
BOOST_CHECK(f1(5) == -5);
|
||||
@@ -607,12 +607,12 @@ struct add_with_throw_on_copy {
|
||||
|
||||
add_with_throw_on_copy(const add_with_throw_on_copy&)
|
||||
{
|
||||
throw std::runtime_error("But this CAN'T throw");
|
||||
throw runtime_error("But this CAN'T throw");
|
||||
}
|
||||
|
||||
add_with_throw_on_copy& operator=(const add_with_throw_on_copy&)
|
||||
{
|
||||
throw std::runtime_error("But this CAN'T throw");
|
||||
throw runtime_error("But this CAN'T throw");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -621,38 +621,14 @@ test_ref()
|
||||
{
|
||||
add_with_throw_on_copy atc;
|
||||
try {
|
||||
boost::function<int (int, int)> f(boost::ref(atc));
|
||||
boost::function<int (int, int)> f(ref(atc));
|
||||
BOOST_CHECK(f(1, 3) == 4);
|
||||
}
|
||||
catch(std::runtime_error e) {
|
||||
catch(runtime_error e) {
|
||||
BOOST_ERROR("Nonthrowing constructor threw an exception");
|
||||
}
|
||||
}
|
||||
|
||||
static void dummy() {}
|
||||
|
||||
static void test_empty_ref()
|
||||
{
|
||||
boost::function<void()> f1;
|
||||
boost::function<void()> f2(boost::ref(f1));
|
||||
|
||||
try {
|
||||
f2();
|
||||
BOOST_ERROR("Exception didn't throw for reference to empty function.");
|
||||
}
|
||||
catch(std::runtime_error e) {}
|
||||
|
||||
f1 = dummy;
|
||||
|
||||
try {
|
||||
f2();
|
||||
}
|
||||
catch(std::runtime_error e) {
|
||||
BOOST_ERROR("Error calling referenced function.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void test_exception()
|
||||
{
|
||||
boost::function<int (int, int)> f;
|
||||
@@ -698,7 +674,6 @@ int test_main(int, char* [])
|
||||
test_emptiness();
|
||||
test_member_functions();
|
||||
test_ref();
|
||||
test_empty_ref();
|
||||
test_exception();
|
||||
test_implicit();
|
||||
test_call();
|
||||
|
||||
@@ -15,21 +15,21 @@
|
||||
#include <boost/lambda/bind.hpp>
|
||||
#include <boost/function.hpp>
|
||||
|
||||
using namespace std;
|
||||
using namespace boost;
|
||||
using namespace boost::lambda;
|
||||
|
||||
static unsigned
|
||||
func_impl(int arg1, bool arg2, double arg3)
|
||||
{
|
||||
using namespace std;
|
||||
return abs (static_cast<int>((arg2 ? arg1 : 2 * arg1) * arg3));
|
||||
}
|
||||
|
||||
int test_main(int, char*[])
|
||||
{
|
||||
using boost::function;
|
||||
using namespace boost::lambda;
|
||||
|
||||
function <unsigned(bool, double)> f1 = bind(func_impl, 15, _1, _2);
|
||||
function <unsigned(double)> f2 = boost::lambda::bind(f1, false, _1);
|
||||
function <unsigned()> f3 = boost::lambda::bind(f2, 4.0);
|
||||
function <unsigned(double)> f2 = bind(f1, false, _1);
|
||||
function <unsigned()> f3 = bind(f2, 4.0);
|
||||
|
||||
f3();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user