What type of data Return value Boost :: Bind
? I want to make a function that will take the result of the Boost :: Bind
, but I do not know what type of value it returns.
void work (int num) {
STD :: COUT & LT; & LT; Num & lt; & lt; STD :: ENDL;
}
INT MAIN () {
Auto Test = Boost :: Bind (Work, 5);
}
Answer 1, Authority 100%
Boost :: Bind
The entity is template, and the type returned by it may (and it will) depend on the types of transmitted arguments. However, if you want to be attached to a specific option, it comes to the help comes DECLTYPE
. Example :
# include & lt; iostream & gt;
#Include & lt; boost / bind / bind.hpp & gt;
Void Work (int num) {
STD :: COUT & LT; & LT; Num & lt; & lt; STD :: ENDL;
}
Void F (DeclType (Boost :: Bind (Work, Int ())) Arg) {
arg ();
}
INT MAIN () {
AUTO TEST = Boost :: Bind (Work, 10);
F (test);
}
I specifically pointed out int ()
in f
to show that the dependence is from the type, and not from the value.
At the same time, the idea of what is needed to rely on the resulting type Boost :: Bind
seems to me doubtful.