LEFT | RIGHT |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2006 INRIA | 3 * Copyright (c) 2006 INRIA |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 5 * This program is free software; you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 2 as | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 std::cout << "invoke cbTwo a=" << a << std::endl; | 63 std::cout << "invoke cbTwo a=" << a << std::endl; |
64 return -5; | 64 return -5; |
65 } | 65 } |
66 }; | 66 }; |
67 | 67 |
68 } // unnamed namespace | 68 } // unnamed namespace |
69 | 69 |
70 | 70 |
71 int main (int argc, char *argv[]) | 71 int main (int argc, char *argv[]) |
72 { | 72 { |
| 73 CommandLine cmd; |
| 74 cmd.Parse(argc, argv); |
| 75 |
73 // return type: double | 76 // return type: double |
74 // first arg type: double | 77 // first arg type: double |
75 // second arg type: double | 78 // second arg type: double |
76 Callback<double, double, double> one; | 79 Callback<double, double, double> one; |
77 // build callback instance which points to cbOne function | 80 // build callback instance which points to cbOne function |
78 one = MakeCallback (&CbOne); | 81 one = MakeCallback (&CbOne); |
79 // this is not a null callback | 82 // this is not a null callback |
80 NS_ASSERT (!one.IsNull ()); | 83 NS_ASSERT (!one.IsNull ()); |
81 // invoke cbOne function through callback instance | 84 // invoke cbOne function through callback instance |
82 double retOne; | 85 double retOne; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 #if 0 | 117 #if 0 |
115 // This is a slightly different example, in which the code will compile | 118 // This is a slightly different example, in which the code will compile |
116 // but because callbacks are type-safe, will cause a fatal error at runtime· | 119 // but because callbacks are type-safe, will cause a fatal error at runtime· |
117 // (the difference here is that Assign() is called instead of operator=) | 120 // (the difference here is that Assign() is called instead of operator=) |
118 Callback<void, float> three; | 121 Callback<void, float> three; |
119 three.Assign (MakeCallback (&CbOne)); | 122 three.Assign (MakeCallback (&CbOne)); |
120 #endif | 123 #endif |
121 | 124 |
122 return 0; | 125 return 0; |
123 } | 126 } |
LEFT | RIGHT |