#include#include // constructor for a class that takes one argument class MyClass { public: MyClass(int x_) : x(x_) { std::cout << "constructor\n"; } int x; }; void myFunction(MyClass *a, boost::call_traits ::param_type b, bool isConstructing) { // check if the current call is constructing an object if (isConstructing) { std::cout << "Constructing MyClass...\n"; } a->x++; std::cout << a->x << ", " << b << "\n"; } int main() { MyClass a(5); // bind myFunction to a and pass in 6 as an argument boost::bind(&myFunction, &a, 6, _1)(boost::is_constructing ()); // output: Constructing MyClass... // 6, 6 return 0; }
#includeThis example shows how to use CallArgs isConstructing to determine if the function call is constructing an int object. We bind myFunction to 5 and pass in boost::is_constructing#include void myFunction(int x, bool isConstructing) { if (isConstructing) { std::cout << "Constructing...\n"; } std::cout << x << "\n"; } int main() { // bind myFunction to 5 and pass in boost::is_constructing () boost::bind(&myFunction, 5, _1)(boost::is_constructing ()); // output: Constructing... // 5 return 0; }