On segunda-feira, 10 de junho de 2013 23.47.04, André Pönitz wrote:
> > Same problem with with "auto"-typed variables. For example when
> > auto-typing a function: Auto class::dostuff() -> vector<int>*;
>
>    struct Foo { vector<int> *foo() { return new vector<int>(); } };
>
>    int main() { auto xp = Foo().foo(); xp->@
>
> also seems to work there.

That's not the feature he requested.

He's asking for this:

struct Foo {
    auto foo() -> vector<int> *
    { return new vector<int>(); }
};

    auto x = f.foo();
    x->@

This corresponds to the qcompilerdetection.h macro Q_COMPILER_AUTO_FUNCTION.

Also note that C++14 will allow further reducing this to:
    auto foo()
    { return new vector<int>(); }

    auto x = f.foo();
    x->@

I named that feature Q_COMPILER_AUTO_RETURN_TYPE in my branch, but I don't
like the name. The committee is referring to this feature as "generalised
lambda" (or something similar, I have to go find the expression) because it is
similar to what you can do with a lambda:

    auto foo = []() { return new vector<int>(); }
    auto x = foo();
    x->@

In other words, there are two features we're looking for here:
 1) supporting the new style function declaration from C++11
 2) inferring the type from a function body, as in:

    []() { return new vector<int>(); } ()->@

In all the cases above, @ should be showing the expansion of vector<int>.

--
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to