When I uncomment the conditional expression, the program will not be able to compile under visual C ++ 2008.
#include <iostream> #include <boost/bind.hpp> #include <boost/thread.hpp> typedef boost::function<void(int, int)> vii_t; typedef boost::function<void(int)> vi_t; void foo(int a, int b){} void bar(int a){} int main(int argc, char* argv[]) { //vi_t test= true ? boost::bind(foo, _1, 100) : boost::bind(bar, _1); vi_t test1 = boost::bind(foo, _1, 100); vi_t test2 = boost::bind(bar, _1); //test(1); test1(1); test2(1); return 0; }
source share