today I came across this weird code:
auto rovoid_iterator ( Construct ROII* const at, auto(ROII&)(auto(*)(Str&&)noexcept->void) ->void //WTF?? ) -> void; What the hell is this weird second parameter??
Thanks in advance!
Okay, let's deconstruct this abomination.
First, there's a inner type:
auto(*)(Str&&) noexcept -> void This is a pointer to function taking a Str rvalue-reference as parameter. It's also a noexcept function.
Let's call that S
using S = auto(*)(Str&&) noexcept -> void; Then the outer part of the parameter can be subtitued like that:
auto(ROII&)(S) -> void As you stated in the comments, ROII is an empty macro. So in the end it reads like that:
auto(&)(S) -> void That code appear to be a parameter which would be a reference to function that take a S which is and return void.
at has a name, so it was decided that the first argument deserved a name in the declaration but not the second.Okay I asked the dev who wrote this:
auto(ROII&)(auto(*)(Str&&)noexcept->void) ->void Is a reference to a function which takes a function pointer as argument. This function pointer is a pointer because its okay to pass nullptr if you dont need it, but the first function must be passed thats why it is a reference. The second pointer is a pointer to a function wich is noexcept and takes a rvalue reference to a string as paremeter. ROII marks game ready functions.
int***, which has three stars after the int).
Str&&as argument and they all returnvoid. Or I may be confused.