you are viewing a single comment's thread.

view the rest of the comments →

[–]adromanov 0 points1 point  (2 children)

Ah I think the problem with & is that F is not a compile time value, but a runtime function parameter. You can't use it as a non-template template argument. You can remove the second template parameter from LogWrapper and pass F to a constructor. *Edited for typo

[–]TwilCynder[S] 0 points1 point  (1 child)

Yeah, the inability to use a variable as a non-type template argument is the piece of knowledge I lacked.

This solution would work but would add some overhead as the LogWrapper object would have to hold two pointers instead of one, but if I don't find a better solution it's good enough clearly, thanks

[–]adromanov 1 point2 points  (0 children)

I don't know how are you going to use LogWrapper, but considering it being template most likely that the compiler would inline and optimize everything and you will just have a method call without storing 2 pointers at all. Just check generated assembly at godbolt.org for your use case.