The effect of automatic type deduction

Let's say that I am writing a function that returns some kind of proxy object, for example, for lazy evaluation or for some other purpose. If I write code like

auto x = func(); 

then x will be the return type, not the type of object I wanted to proxy. Is it possible to change auto or decltype to use them in this situation will return the actual result that I want to return, and not the type of the proxy object itself?

+4
source share
2 answers

Random thoughts:

Perhaps you can get the type of the proxy object using decltype(*func()) or, in addition, to access the proxy object. There are no modifiers for auto , except for the usual const , & etc.

If this is a lazy estimate, you probably don't want the final type of object right now, do you?

If the proxy server has a cenversion statement for the destination object, how does auto know that it should be used? What if there are more?

+3
source

Why not print the text inside func() so you return?

0
source

All Articles