forked from boostorg/function
Function: Merge from trunk.
- Remove extra definition of operator(), since it's inline anyway. Fixes #4765. - Make sure that the cv flags are copied when we copy a reference to a function object. Fixes #4325 - Fully qualified function calls to avoid ambiguity with new additions to standard. Thanks to Conrad Poelman. Fixes #4073 - Remove iterator workaround for newer versions of Visual Age C++. Thanks to 'ccambly'. Fixes #3912 - Fix unused variable warning for Visual C++. Fixes #3618 - Testing flag for Visual C++. - Removed all but one old-style cast, prevents GCC warnings, but breaks GCC 2.95.3. Fixes #3410 - Fixed tab and newline issues from inspection report. [SVN r70361]
This commit is contained in:
@ -10,22 +10,28 @@
|
||||
|
||||
|
||||
#include <boost/function.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <iostream>
|
||||
#include <functional>
|
||||
|
||||
struct X {
|
||||
int foo(int);
|
||||
std::ostream& foo2(std::ostream&) const;
|
||||
};
|
||||
int X::foo(int x) { return -x; }
|
||||
std::ostream& X::foo2(std::ostream& x) const { return x; }
|
||||
|
||||
int main()
|
||||
{
|
||||
boost::function<int (X*, int)> f;
|
||||
boost::function<std::ostream& (X*, std::ostream&)> f2;
|
||||
|
||||
f = &X::foo;
|
||||
|
||||
X x;
|
||||
f(&x, 5);
|
||||
f = &X::foo;
|
||||
f2 = &X::foo2;
|
||||
|
||||
return 0;
|
||||
X x;
|
||||
BOOST_TEST(f(&x, 5) == -5);
|
||||
BOOST_TEST(f2(&x, boost::ref(std::cout)) == std::cout);
|
||||
|
||||
return ::boost::report_errors();
|
||||
}
|
||||
|
Reference in New Issue
Block a user