Damn C++ and damn D!

Kai Meyer kai at unixlords.com
Fri Feb 10 09:49:09 PST 2012


lambda instead of macro?

On 02/05/2012 07:57 AM, Timon Gehr wrote:
> On 02/05/2012 03:53 PM, so wrote:
>> On Sunday, 5 February 2012 at 14:24:20 UTC, Timon Gehr wrote:
>>
>>> This should work:
>>>
>>> #define DOTDOTDOT ...
>>>
>>> template<class T> void fun(T a){
>>> if(cond<T>::value) {
>>> auto var = make(a);
>>> DOTDOTDOT;
>>> }else{
>>> auto tmp = make(a);
>>> auto var = make_proxy(tmp);
>>> DOTDOTDOT;
>>> }
>>> }
>>
>> It won't work.
>> You now have two scopes and you have to repeat every line after "var"
>> for both scopes. Now you have to maintain both of them.
>
> You just maintain the macro.
>
>> And this grows
>> exponentially for every new condition you have.
>>
>
> It certainly has limits. I completely agree that C++s generic
> programming facilities are severely underpowered.
>



More information about the Digitalmars-d mailing list