known duplicate code
Howard Hinnant
hhinnant@apple.com
Thu Sep 14 22:53:00 GMT 2006
On Sep 14, 2006, at 5:58 AM, Benjamin Kosnik wrote:
>> I've seen compile time type selection like
>>
>> template <bool B, typename Then, typename Else>
>> struct IF
>> {
>> typedef Then type;
>> };
>> template <typename Then, typename Else>
>> struct IF<false, Then, Else>
>> {
>> typedef Else type;
>> };
>>
>> in more than one place. Here is a partial list:
>> - ext/pb_ds/detail/type_utils.hpp
>> - ext/pb_assoc/detail/type_utils.hpp
>> - ext/typelist.h
>> - tr1/hashtable_policy.h
>> - tr1/random
>
> Yep. This is what I was getting at with 2) traits. I think I've marked
> up some of the duplicates in hash_policy. I would like to remove this
> (and other) duplicates. There's also a conditional_type dupe, and some
> others.
>
> I'm trying to figure out what to do. One approach would to start an
> ext/traits file, and dump stuff there.
I'm interested in keeping a list of "can't live without" traits-like
material such as this. I also put both the enable_if and IF traits
in this category, though I've spelled them differently in the past.
It could be that such an organized list might evolve into a proposed
addition to the C++0X <type_traits> header. If it were to succeed,
it would have to be a very short list. I.e. this can't turn into a
dumping ground for everyone's favorite trait. This is a top 5 list.
-Howard
More information about the Libstdc++
mailing list