Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/libs/function/test/stateless_test.cpp @ 12

Last change on this file since 12 was 12, checked in by landauf, 17 years ago

added boost

File size: 940 bytes
Line 
1// Boost.Function library
2
3//  Copyright Douglas Gregor 2001-2003. Use, modification and
4//  distribution is subject to the Boost Software License, Version
5//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
6//  http://www.boost.org/LICENSE_1_0.txt)
7
8// For more information, see http://www.boost.org
9
10#include <boost/test/minimal.hpp>
11#include <boost/function.hpp>
12#include <stdexcept>
13
14struct stateless_integer_add {
15  int operator()(int x, int y) const { return x+y; }
16
17  void* operator new(std::size_t, stateless_integer_add*)
18  {
19    throw std::runtime_error("Cannot allocate a stateless_integer_add");
20  }
21
22  void operator delete(void*, stateless_integer_add*) throw()
23  {
24  }
25};
26
27namespace boost {
28  template<>
29  struct is_stateless<stateless_integer_add> {
30    BOOST_STATIC_CONSTANT(bool, value = true);
31  };
32}
33
34int test_main(int, char*[])
35{
36  boost::function2<int, int, int> f;
37  f = stateless_integer_add();
38
39  return 0;
40}
Note: See TracBrowser for help on using the repository browser.