Reputation: 117
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!
Upvotes: 5
Views: 141
Reputation: 117
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.
Upvotes: 4
Reputation: 41760
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
.
Upvotes: 10