operator-arrow-star

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

依然范特西╮ 提交于 2019-12-03 02:33:01
问题 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? 回答1: The only example

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

本小妞迷上赌 提交于 2019-12-02 16:05:53
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? The only example on the linked page where I see ->* is this: auto in = D::MakeVar(0); auto op1 = in ->* [] (int in) { int

What is ->* operator in C++?

懵懂的女人 提交于 2019-11-30 06:07:26
C++ continues to surprise me. Today i found out about the ->* operator. It is overloadable but i have no idea how to invoke it. I manage to overload it in my class but i have no clue how to call it. struct B { int a; }; struct A { typedef int (A::*a_func)(void); B *p; int a,b,c; A() { a=0; } A(int bb) { b=b; c=b; } int operator + (int a) { return 2; } int operator ->* (a_func a) { return 99; } int operator ->* (int a) { return 94; } int operator * (int a) { return 2; } B* operator -> () { return p; } int ff() { return 4; } }; void main() { A a; A*p = &a; a + 2; } edit: Thanks to the answer. To

What is ->* operator in C++?

て烟熏妆下的殇ゞ 提交于 2019-11-29 05:53:02
问题 C++ continues to surprise me. Today i found out about the ->* operator. It is overloadable but i have no idea how to invoke it. I manage to overload it in my class but i have no clue how to call it. struct B { int a; }; struct A { typedef int (A::*a_func)(void); B *p; int a,b,c; A() { a=0; } A(int bb) { b=b; c=b; } int operator + (int a) { return 2; } int operator ->* (a_func a) { return 99; } int operator ->* (int a) { return 94; } int operator * (int a) { return 2; } B* operator -> () {

What are the Pointer-to-Member ->* and .* Operators in C++?

自作多情 提交于 2019-11-26 15:53:47
Yes, I've seen this question and this FAQ (wrong link) this FAQ , but I still don't understand what ->* and .* mean in C++. Those pages provide information about the operators (such as overloading), but don't seem to explain well what they are . What are ->* and .* in C++, and when do you need to use them as compared to -> and . ? Armen Tsirunyan I hope this example will clear things for you //we have a class struct X { void f() {} void g() {} }; typedef void (X::*pointer)(); //ok, let's take a pointer and assign f to it. pointer somePointer = &X::f; //now I want to call somePointer. But for

What are the Pointer-to-Member ->* and .* Operators in C++?

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-26 04:39:05
问题 Yes, I\'ve seen this question and this FAQ (wrong link) this FAQ, but I still don\'t understand what ->* and .* mean in C++. Those pages provide information about the operators (such as overloading), but don\'t seem to explain well what they are . What are ->* and .* in C++, and when do you need to use them as compared to -> and . ? 回答1: I hope this example will clear things for you //we have a class struct X { void f() {} void g() {} }; typedef void (X::*pointer)(); //ok, let's take a