- Variadic Templates - 3 Updates
- Variadic Templates - 2 Updates
- main2(), kernel_main (c/c++) - 1 Update
- how/why it is written ... int &numberRef; vs int& numberRef; - 2 Updates
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Jul 13 12:02PM +0200 On 13.07.2019 11:30, Stefan Ram wrote: > | > With "error: ", does he mean that this will be reported as > an error? Yes. > How can the variadic template know that the args > have to match the parameter list of f? Because (but this is just my understanding from what you present here), not shown above, it indirectly forwards the arguments to `f`. I guess the reason Bjarne doesn't show that is because it's non-trivial, involving the constructor creating a pack of arguments as a data member, and then, asynchronously, the real thread function picking up those arguments and forwarding them to `f`. The real thread function part that forwards the arguments is necessarily generated by the constructor, by instantiating some template. > inbuilt feature of variadic templates I have not learned > about yet? AFAIK the template does not even know that f is > a function (prototype). Right, that's an orange herring. Cheers!, - Alf |
Sam <sam@email-scan.com>: Jul 13 11:19AM -0400 Stefan Ram writes: > With "error: ", does he mean that this will be reported as > an error? How can the variadic template know that the args > have to match the parameter list of f? The template does not care. The template will be expanded, as called, using whatever parameters went into the parameter pack. At this point the number of parameters to the function will not match, and a compilation error will occur. |
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Jul 13 10:38PM +0200 On 13.07.2019 18:15, Stefan Ram wrote: > in ::std::bind in <functional> here. But this will not catch a > wrong type of an argument. But maybe there are implementations > of ::std::bind around that will detect this too. Apparently you're saying that with `std::bind` you can bind an incorrect type of argument, and not have it checked if you don't try to call the result functor. That makes sense. A class template can have member functions that wouldn't compile if they were called. template< class T > struct S { void foo() { 1*T(); } }; auto main() -> int { S<char*> o; #ifdef FAIL o.foo(); #else (void) o;
Subscribe to:
Post Comments (Atom)
|
No comments:
Post a Comment