Skip to main content

Timeline for Piping operator in c++

Current License: CC BY-SA 4.0

9 events
when toggle format what by license comment
Feb 7, 2021 at 10:42 vote accept SomeProgrammer
Feb 6, 2021 at 17:29 comment added SomeProgrammer Let us continue this discussion in chat.
Feb 6, 2021 at 17:00 comment added SomeProgrammer No - constexpr doesn't really work (it would be up to the user to mark the lambda constexpr) - my piping operator just needs to do too many things at run-time to be constexpr. However, the compiler can do absolutely anything it wants as long as it does not have observable behaviour, so I think the "inline" just makes it a bit more transparent to the compiler
Feb 6, 2021 at 16:54 comment added Toby Speight OOh - perhaps it would make sense to add constexpr to the declaration? I'm not 100% sure about that, though - I'm just a beginner with constexpr. IIRC, the lambda can also be declared constexpr, but I'm really walking on thin ice now...
Feb 6, 2021 at 16:48 comment added SomeProgrammer yes it surprised me as well. In fact both versions of my code inlined the function, but the version with "inline" straight up calculated everything at compile - time, while the version without inline had to call the lambda.
Feb 6, 2021 at 16:47 comment added Toby Speight It's worth searching the web for good articles on perfect forwarding and forwarding references. Another good search term is universal references, which is the older term for this construct.
Feb 6, 2021 at 16:41 comment added Toby Speight I'm surprised by that. If the inline is helpful, then continue using it. I don't think it can do any harm.
Feb 6, 2021 at 16:40 comment added SomeProgrammer Thank you for all your feedback and explaining perfect forwarding!! I had never quite understood it until now... About the "inline" keyword, the compiler (-O3) seemed to be better at optimising my code when the "inline" was there??
Feb 6, 2021 at 15:28 history answered Toby Speight CC BY-SA 4.0