mirror of
https://github.com/boostorg/function.git
synced 2026-01-26 08:52:23 +01:00
Merged revisions 43810-43907 via svnmerge from
https://svn.boost.org/svn/boost/trunk ................ r43810 | eric_niebler | 2008-03-23 14:51:40 -0700 (Sun, 23 Mar 2008) | 1 line mark up new foreach tests ................ r43823 | fmhess | 2008-03-24 08:07:00 -0700 (Mon, 24 Mar 2008) | 3 lines Fixed compile error with new enable_shared_from_this code, reported by Tim Blechmann ................ r43825 | ramey | 2008-03-24 08:46:09 -0700 (Mon, 24 Mar 2008) | 1 line removed EXIT_SUCCESS ................ r43826 | ramey | 2008-03-24 08:46:43 -0700 (Mon, 24 Mar 2008) | 1 line fixed minor typo ................ r43829 | pdimov | 2008-03-24 09:00:28 -0700 (Mon, 24 Mar 2008) | 1 line New enable_shared_from_this tests, fix. ................ r43838 | danieljames | 2008-03-24 10:03:15 -0700 (Mon, 24 Mar 2008) | 12 lines Merge new changes to unordered & hash. - Unordered tests can run lightweight test or Boost.Test (at least theoretically). - Workaround Open BSD's incorrect numeric_limits. - Move the hash extensions in their own file. - Various small improvements to the unordered docs. - Fix some unordered examples. Merged revisions 43117-43837 via svnmerge from https://svn.boost.org/svn/boost/branches/unordered/trunk ................ r43845 | dave | 2008-03-24 11:27:22 -0700 (Mon, 24 Mar 2008) | 1 line Work around vc9 bugs ................ r43847 | anthonyw | 2008-03-24 14:44:36 -0700 (Mon, 24 Mar 2008) | 1 line removed forward declaration for undefined type exclusive_lock ................ r43852 | hkaiser | 2008-03-25 06:40:53 -0700 (Tue, 25 Mar 2008) | 1 line Wave: Removed an assertion causing compilation problems on certain platforms. ................ r43856 | pdimov | 2008-03-25 08:46:40 -0700 (Tue, 25 Mar 2008) | 1 line _internal_accept_owner now checks if _owned isn't already true. ................ r43861 | dave | 2008-03-25 13:47:38 -0700 (Tue, 25 Mar 2008) | 2 lines Work around intel-10.0-win compiler bug ................ r43864 | dave | 2008-03-25 15:28:59 -0700 (Tue, 25 Mar 2008) | 2 lines Account for intel 10.x compiler bug ................ r43865 | dave | 2008-03-25 16:06:50 -0700 (Tue, 25 Mar 2008) | 2 lines Work around intel-win-10.0 preprocessor bug ................ r43866 | danieljames | 2008-03-26 02:10:29 -0700 (Wed, 26 Mar 2008) | 3 lines Boost.Thread's documentation no longer has a build section - so just link to the library's documentation like we do for other libraries. ................ r43867 | bemandawes | 2008-03-26 08:59:52 -0700 (Wed, 26 Mar 2008) | 1 line Initial commit ................ r43873 | pdimov | 2008-03-26 11:34:29 -0700 (Wed, 26 Mar 2008) | 1 line Added "Throws: nothing" to get_deleter. ................ r43875 | bemandawes | 2008-03-26 14:26:55 -0700 (Wed, 26 Mar 2008) | 1 line Initial commit ................ r43876 | danieljames | 2008-03-26 22:49:45 -0700 (Wed, 26 Mar 2008) | 2 lines Update the thread links in the generated getting started documentation. ................ r43879 | chris_kohlhoff | 2008-03-27 07:18:07 -0700 (Thu, 27 Mar 2008) | 3 lines Fix double-free error that occurs when an exception is thrown from a handler that has been dispatched (i.e. not posted) through a strand. ................ r43880 | ramey | 2008-03-27 08:53:37 -0700 (Thu, 27 Mar 2008) | 1 line removed suppression of builds for certain platforms with shared libraries ................ r43882 | ramey | 2008-03-27 10:11:23 -0700 (Thu, 27 Mar 2008) | 1 line tweaks to sneak past PGI compiler error message ................ r43883 | ramey | 2008-03-27 10:12:22 -0700 (Thu, 27 Mar 2008) | 1 line added test to check warnings on type trait ................ r43884 | dgregor | 2008-03-27 12:44:37 -0700 (Thu, 27 Mar 2008) | 1 line Change Boost.Function allocator behavior, from Emil Dotchevski ................ r43887 | pdimov | 2008-03-27 15:13:55 -0700 (Thu, 27 Mar 2008) | 1 line Silence unused parameter warning. ................ r43888 | pdimov | 2008-03-27 15:20:11 -0700 (Thu, 27 Mar 2008) | 1 line detail::yield(k) added. ................ r43895 | danieljames | 2008-03-27 16:38:01 -0700 (Thu, 27 Mar 2008) | 25 lines Merged revisions 43838-43894 via svnmerge from https://svn.boost.org/svn/boost/branches/unordered/trunk ........ r43840 | danieljames | 2008-03-24 17:25:07 +0000 (Mon, 24 Mar 2008) | 1 line Fix a g++ warning. ........ r43844 | danieljames | 2008-03-24 17:56:28 +0000 (Mon, 24 Mar 2008) | 1 line It's a new-ish year. ........ r43885 | danieljames | 2008-03-27 20:36:10 +0000 (Thu, 27 Mar 2008) | 1 line The release script doesn't need to copy images and css - because that's now done in the jamfiles. Also tweak the shell script a tad bit. ........ r43890 | danieljames | 2008-03-27 23:01:40 +0000 (Thu, 27 Mar 2008) | 1 line Starting to add a docbook bibliography. ........ r43894 | danieljames | 2008-03-27 23:24:18 +0000 (Thu, 27 Mar 2008) | 1 line Redeclare 'data' in iterator_base to help compilers which have trouble with accessing the nested typedef. ........ ................ r43900 | noel_belcourt | 2008-03-27 19:10:04 -0700 (Thu, 27 Mar 2008) | 4 lines Fix address-model support for 32/64 bit code generation. Replaced -mcmodel with -m32 / -m64. ................ r43901 | bemandawes | 2008-03-27 19:11:13 -0700 (Thu, 27 Mar 2008) | 1 line Remove per email from Dave ................ r43906 | eric_niebler | 2008-03-27 23:10:55 -0700 (Thu, 27 Mar 2008) | 1 line proto support for BOOST_PROTO_MAX_FUNCTION_CALL_ARITY ................ [SVN r43910]
This commit is contained in:
@@ -27,6 +27,14 @@ struct counting_allocator : public std::allocator<T>
|
||||
typedef counting_allocator<U> other;
|
||||
};
|
||||
|
||||
counting_allocator()
|
||||
{
|
||||
}
|
||||
|
||||
template<typename U>
|
||||
counting_allocator( counting_allocator<U> )
|
||||
{
|
||||
}
|
||||
|
||||
T* allocate(std::size_t n)
|
||||
{
|
||||
@@ -41,20 +49,27 @@ struct counting_allocator : public std::allocator<T>
|
||||
}
|
||||
};
|
||||
|
||||
struct plus_int
|
||||
struct enable_small_object_optimization
|
||||
{
|
||||
};
|
||||
|
||||
struct disable_small_object_optimization
|
||||
{
|
||||
int unused_state_data[32];
|
||||
};
|
||||
|
||||
template <typename base>
|
||||
struct plus_int: base
|
||||
{
|
||||
int operator()(int x, int y) const { return x + y; }
|
||||
|
||||
int unused_state_data[32];
|
||||
};
|
||||
|
||||
static int do_minus(int x, int y) { return x-y; }
|
||||
|
||||
struct DoNothing
|
||||
template <typename base>
|
||||
struct DoNothing: base
|
||||
{
|
||||
void operator()() const {}
|
||||
|
||||
int unused_state_data[32];
|
||||
};
|
||||
|
||||
static void do_nothing() {}
|
||||
@@ -62,33 +77,57 @@ static void do_nothing() {}
|
||||
int
|
||||
test_main(int, char*[])
|
||||
{
|
||||
function2<int, int, int, counting_allocator<int> > f;
|
||||
f = plus_int();
|
||||
function2<int, int, int> f;
|
||||
f.assign( plus_int<disable_small_object_optimization>(), counting_allocator<int>() );
|
||||
f.clear();
|
||||
BOOST_CHECK(alloc_count == 1);
|
||||
BOOST_CHECK(dealloc_count == 1);
|
||||
|
||||
alloc_count = 0;
|
||||
dealloc_count = 0;
|
||||
f = &do_minus;
|
||||
f.assign( plus_int<enable_small_object_optimization>(), counting_allocator<int>() );
|
||||
f.clear();
|
||||
BOOST_CHECK(alloc_count == 0);
|
||||
BOOST_CHECK(dealloc_count == 0);
|
||||
f.assign( plus_int<disable_small_object_optimization>(), std::allocator<int>() );
|
||||
f.clear();
|
||||
f.assign( plus_int<enable_small_object_optimization>(), std::allocator<int>() );
|
||||
f.clear();
|
||||
|
||||
function0<void, counting_allocator<int> > fv;
|
||||
alloc_count = 0;
|
||||
dealloc_count = 0;
|
||||
fv = DoNothing();
|
||||
f.assign( &do_minus, counting_allocator<int>() );
|
||||
f.clear();
|
||||
BOOST_CHECK(alloc_count == 0);
|
||||
BOOST_CHECK(dealloc_count == 0);
|
||||
f.assign( &do_minus, std::allocator<int>() );
|
||||
f.clear();
|
||||
|
||||
function0<void> fv;
|
||||
alloc_count = 0;
|
||||
dealloc_count = 0;
|
||||
fv.assign( DoNothing<disable_small_object_optimization>(), counting_allocator<int>() );
|
||||
fv.clear();
|
||||
BOOST_CHECK(alloc_count == 1);
|
||||
BOOST_CHECK(dealloc_count == 1);
|
||||
|
||||
alloc_count = 0;
|
||||
dealloc_count = 0;
|
||||
fv = &do_nothing;
|
||||
fv.assign( DoNothing<enable_small_object_optimization>(), counting_allocator<int>() );
|
||||
fv.clear();
|
||||
BOOST_CHECK(alloc_count == 0);
|
||||
BOOST_CHECK(dealloc_count == 0);
|
||||
fv.assign( DoNothing<disable_small_object_optimization>(), std::allocator<int>() );
|
||||
fv.clear();
|
||||
fv.assign( DoNothing<enable_small_object_optimization>(), std::allocator<int>() );
|
||||
fv.clear();
|
||||
|
||||
alloc_count = 0;
|
||||
dealloc_count = 0;
|
||||
fv.assign( &do_nothing, counting_allocator<int>() );
|
||||
fv.clear();
|
||||
BOOST_CHECK(alloc_count == 0);
|
||||
BOOST_CHECK(dealloc_count == 0);
|
||||
fv.assign( &do_nothing, std::allocator<int>() );
|
||||
fv.clear();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user