Symphilosophein 狂者進取,狷者有所不為也。
Data member with reference type is not const inside a const member function due to C++'s type system.
i.e
c.v is decorated from right to left thus
int& const data_member;
is not valid.
struct Fun { int &a; void run() const { a += 1; } }; int main() { int a = 42; [&a] { a += 1; }(); Fun f{a}; f.run(); }
Note: Only a member of this blog may post a comment.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.