D vs C++11

mist none at none.none
Sat Nov 3 08:06:35 PDT 2012


Ye, that is exactly what I meant when said C++ has no real 
context capture and thus no real delegates here.

On Saturday, 3 November 2012 at 15:04:25 UTC, Paulo Pinto wrote:
> On Saturday, 3 November 2012 at 12:56:36 UTC, mist wrote:
>> http://codepad.org/s38L9tUr
>>
>> Am I misunderstanding something regarding C++ here?
>>
>> On Saturday, 3 November 2012 at 02:44:49 UTC, Mehrdad wrote:
>>> On Saturday, 3 November 2012 at 02:27:21 UTC, mist wrote:
>>>> Regarding delegates - I think deal is that none of this C++ 
>>>> stuff can automatically capture local function context with 
>>>> delegate, so there are no _real_ delegates.
>>>
>>>
>>>
>>> I don't understand what you mean...
>>>
>>> std::function<int(int)> make_adder(int a)
>>> {
>>> 	return [=](int b) { return a + b; };
>>> }
>
> You could use the following instead
>
> auto f = [&](){ return x; };
>
> but then you cannot return the lambda.
>
> --
> Paulo




More information about the Digitalmars-d mailing list