Damn C++ and damn D!
Timon Gehr
timon.gehr at gmx.ch
Fri Feb 10 12:03:24 PST 2012
On 02/10/2012 06:49 PM, Kai Meyer wrote:
> 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.
>>
>
> lambda instead of macro?
>
Won't work. Or am I missing something?
More information about the Digitalmars-d
mailing list