| 1 | #include <boost/system/system_error.hpp>
|
|---|
| 2 | #define TR1
|
|---|
| 3 | #if defined(TR1)
|
|---|
| 4 | #include <functional> // MSVS 2008: std::tr1::function<> and std::tr1::bind<>, among others
|
|---|
| 5 | #else
|
|---|
| 6 | #include <boost/function.hpp>
|
|---|
| 7 | #endif
|
|---|
| 8 | #include <boost/bind.hpp>
|
|---|
| 9 |
|
|---|
| 10 | using boost::system::error_code;
|
|---|
| 11 | #if defined(TR1)
|
|---|
| 12 | using std::tr1::function;
|
|---|
| 13 | #else
|
|---|
| 14 | using boost::function;
|
|---|
| 15 | #endif
|
|---|
| 16 |
|
|---|
| 17 | using boost::bind; // <== notice this
|
|---|
| 18 |
|
|---|
| 19 | // declare global from elsewhere
|
|---|
| 20 | void AddErrorSink(function<void(error_code)> fn);
|
|---|
| 21 |
|
|---|
| 22 | class D
|
|---|
| 23 | {
|
|---|
| 24 | public:
|
|---|
| 25 | typedef function<void(void)> Action;
|
|---|
| 26 | void AddErrorAction(Action &a);
|
|---|
| 27 |
|
|---|
| 28 | protected:
|
|---|
| 29 | void exec_actor(Action &a, error_code ec);
|
|---|
| 30 | };
|
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 | void D::AddErrorAction(Action &a)
|
|---|
| 34 | {
|
|---|
| 35 | // when TR1 is defined for compilation, this line fails:
|
|---|
| 36 | // >> error C2668: 'boost::bind' : ambiguous call to overloaded function
|
|---|
| 37 | // ambiguity shown between boost::bind and std::tr1::bind
|
|---|
| 38 | // can be overcome by qualifying call ("boost::bind")
|
|---|
| 39 | AddErrorSink(bind(&D::exec_actor, this, a, _1));
|
|---|
| 40 | }
|
|---|