Strange "->* []" expression in C++ source code of cpp.react library

c++, c++11, language-lawyer, operator-arrow-star

Solution

The only example on the linked page where I see `->*` is this:

auto in = D::MakeVar(0);

auto op1 = in ->* [] (int in)
{
    int result = in /* Costly operation #1 */;
    return result;
};

auto op2 = in ->* [] (int in)
{
    int result = in /* Costly operation #2 */;
    return result;
};

Here's my guess - whatever type is returned by `D::MakeVar()` overloads the pointer-to-member operator `->*`, and the second argument for that overloaded operator is a function object, i.e. the lambda expression.

As for this example:

auto volume = (width,height,depth) ->* [] (int w, int h, int d) {
    return w * h * d;
};

I'm guessing whatever types `width`, `height` & `depth` are, overload the comma operator, and the result yields the same type as what `MakeVar` yields, or another type that overloads `->*`. The rest is the same as the first example.

Problem

Here is a C++ snippet that I found in the documentation of the cpp.react library: ``` auto in = D::MakeVar(0); auto op1 = in ->* [] (int in) { int result = in /* Costly operation #1 */; return result; }; ``` I have never seen the `->* []` notation. First, I thought that it was just a typo, but I also found such an expression in the source code: ``` auto volume = (width,height,depth) ->* [] (int w, int h, int d) { return w * h * d; }; ``` Is this valid C++11 (or C++14)? What does it mean?

Original source

Related problems