You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was experimenting with this library using the sample code in the recent C++ Team Blog. I wanted to make multiple methods that operated on the same proxy so I did something like the following:
But this won't compile because invoke() is non-const. Casting away the const works of course. Making the parameter non-const is not desirable because of the problem passing in temporary values.
The text was updated successfully, but these errors were encountered:
This is by design. Because proxy does not require P::operator* to be const, where P is the type of a potential contained value, proxy::invoke() is designed to be non-const.
Regarding your scenario, if you want to "make multiple methods that operated on the same proxy",
it is encouraged to pass parameters by pointer,
you may configure the proxy to be copyable by specifying minimum_copyability in you facade definition, so that you can pass the proxy by value, like arbitrary pointers, but your proxy will not accept non-copyable pointers, like std::unique_ptr, any longer.
Thank you for you comments! Please let us know if you have any further questions or suggestions!
I was experimenting with this library using the sample code in the recent C++ Team Blog. I wanted to make multiple methods that operated on the same proxy so I did something like the following:
But this won't compile because
invoke()
is non-const. Casting away the const works of course. Making the parameter non-const is not desirable because of the problem passing in temporary values.The text was updated successfully, but these errors were encountered: