[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] FFT update
- From: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
- Date: Sun, 24 Jan 2010 01:49:22 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type; bh=i4IRy4+99TsHbLHjL1SPbFa0EKPsrp3Y4rx7bSGUEso=; b=VZFL0wv9YrAJM/o6ogW6Y1cSBqmGlClTh7BUJp8w8T2+SGq5I4ZfE3mkmbzFlw7CbH 3BqwqCoLNutbk8xbseDetshmHDclGX60Bjx2lZ9rakQws1qf5zuQnwE4fpuL2EfXUqvm sRwtUs0+OvUhToY4pf/xjiDTH4DzddJkkXR5E=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=W+mKPAu8sw7zDkQmODnCwGW+WIzKm7rvay/IJVRvXyrxNgqV0JziLpljHs8GpcM1Ff gt+M+G1ZC64wo6UVi0Rzh/M/2zCcq8ufKPV8z8dBb6Uk8NTG9eJUJS+2oZAGQs9q9tTo cjRlq1jchs8bG5kRp/35HX2rXeOaEjlt5P3/U=
2010/1/23 Benoit Jacob <jacob.benoit.1@xxxxxxxxx>:
> By the way, this "ReturnByValue::coeff() crashes by infinite
> recursion" thing is really ugly, I wonder how to fix it!!
>
> C++0x at last brings the ability to remove a base class function from
> a derived class... I wonder how to implement that idea in C++98. Is
> that enable_if?
Forget enable_if, forget C++0x, forget boost, i'm your new idol.
If we want to make sure that using ReturnByValue::coeff() generates an
error at compile time without generating an error until it's actually
used, we can define a class:
class Unusable
{
// implement copy ctor/operator as private to disable them
Unusable(const Unusable&) {}
void operator=(const Unusable&) {}
};
We then let ReturnByValue::coeff() return that:
class ReturnByValue
{
....
Unusable coeff(int, int) { return Unusable(); }
....
};
The result is that when the user does e.g.
x = retval.coeff(i);
or
x = retval.coeff(i) + 123;
he gets compilation errors.
Just doing
retval.coeff(i);
doesn't give an error, but that should be optimizable as just a NOP anyway.
With this, i go to bed full^Wproud of myself.
Benoit
>
> Benoit
>
> 2010/1/23 Benoit Jacob <jacob.benoit.1@xxxxxxxxx>:
>> Hi,
>>
>> Here's an example: see attached file.
>> Enjoy!!
>> Benoit
>>
>> 2010/1/22 Benoit Jacob <jacob.benoit.1@xxxxxxxxx>:
>>> ok let me write an example...
>>>
>>> 2010/1/22 Jitse Niesen <jitse@xxxxxxxxxxxxxxxxx>:
>>>> On Fri, 22 Jan 2010, Benoit Jacob wrote:
>>>>
>>>>> Our "policy" is now:
>>>>> - try to return by value, optimizing with the ReturnByValue class,
>>>>> wherever possible;
>>>>> - otherwise you can just use references.
>>>>
>>>> Can somebody please explain how to use the ReturnByValue class?
>>>> Or should I just extrapolate from the source code?
>>>> I could not find any documentation.
>>>>
>>>> Jitse
>>>>
>>>>
>>>>
>>>
>>
>