ていうか単なるfunctorのシンタックスシュガー? struct lambda { int a, b; lambda(int a_, int b_) : a(a_), b(b_) { } int operator(int x, int y) { return a * x + b * y } }; が、 lambda λ_1(1, 2); lambda λ_1(3, 4); で lambda g_λ = λ_1; int z = g_λ(5, 6); みたいな?
非const派はそもそもconst char* 型を使わないということだろう まあそれはともかく、もっと抽象的なクラスAで int getlength(A& a) ってあったら、これは長さを返すついでになにか 内部状態も変更するのかな、と推測してしまう int getlength(const A& a) ならAクラスから推測される長さを返す関数なんだと理解できる
>>663 7.1.6 [dcl.type] p4 Except that any class member declared mutable (7.1.1) can be modified, any attempt to modify a const object during its lifetime (3.8) results in undefined behavior.
Effects: Applies f to the result of dereferencing every iterator in the range [first,last), starting from first and proceeding to last - 1. [ Note: If the type of first satisfies the requirements of a mutable iterator, f may apply nonconstant functions through the dereferenced iterator