|
Boost : |
From: Sohail Somani (sohail_at_[hidden])
Date: 2008-04-12 16:24:53
Marco wrote:
> On Sat, 12 Apr 2008 21:13:40 +0200, Anand Shankar
> <anand.shankar.k_at_[hidden]> wrote:
>
>> Hi,
>>
>> Here's a solution similar to Marco's - finds the first non default type
>> using template specialization.
>> It uses sizeof to check whether the types following first non-default
>> type
>> are conforming.
>>
>> Anand.
>>
>
> Really a nice solution!
Correct me if my thinking is incorrect but I think a solution using a
variable number of template specialization has an implicit O(f(N))
complexity where f(N) is some non-constant function of N. The compiler
needs to iterate through all the specializations in order to find the
match, which is the same as you explicitly iterating through some sort
of fusion data structure. It may optimize this somehow but it still
isn't O(1).
Interesting puzzle. Can't wait to see all the answers.
-- Sohail Somani http://uint32t.blogspot.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk