PageRenderTime 18ms CodeModel.GetById 14ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/Src/Dependencies/Boost/libs/function/test/function_arith_cxx98.cpp

http://hadesmem.googlecode.com/
C++ | 34 lines | 19 code | 9 blank | 6 comment | 1 complexity | f1d3604597336bcc5efdd7dda2aa408a MD5 | raw file
 1// Function library
 2
 3// Copyright (C) 2001-2003 Douglas Gregor
 4
 5// Use, modification and distribution is subject to the Boost Software 
 6// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at 
 7// http://www.boost.org/LICENSE_1_0.txt) 
 8
 9// For more information, see http://www.boost.org/
10
11    
12#include <boost/function.hpp>
13#include <iostream>
14
15
16float mul_ints(int x, int y) { return ((float)x) * y; }
17struct int_div { 
18  float operator()(int x, int y) const { return ((float)x)/y; }; 
19};
20
21int main()
22{
23    boost::function<float (int x, int y)> f;
24    f = int_div();
25    std::cout << f(5, 3) << std::endl;
26    if (f)
27  std::cout << f(5, 3) << std::endl;
28else
29  std::cout << "f has no target, so it is unsafe to call" << std::endl;
30    f = 0;
31    f = &mul_ints;
32  
33    return 0;
34}