I am trying to use some sample code and my compiler won't compile this line:
static void exitActions(Host& h, Bool<true>) {}
Compiler is MS VS2005. I don't recognise Bool - so not sure how to replace it. Is this default parameter equivalent:
static void exitActions(Host& h, bool b = true) {}
The sample is from http://accu.org/index.php/journals/252. The code is just snippets in the text - no snippet about what is #include'd - so hard to work out. There is no definition for a Bool template.
I guess Bool
is defined like
template <bool B> struct Bool{};
You can use this for some rudimentary pattern matching:
void exitActions(Bool<true>) { std::cout << "called with true\n"; }
void exitActions(Bool<false>) { std::cout << "called with false\n"; }
int main()
{
exitActions(Bool<true>()); // prints "called with true"
exitActions(Bool<false>()); // prints "called with false"
}
This of course only makes sense if you overload Bool<true>
with Bool<false>
. But in the source http://accu.org/index.php/journals/252 (guessed by Marcin), this is the case.
There is also a similar function call
Tran<T,S,T>::entryActions(host_, Bool<false>());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With