This is the mail archive of the mailing list for the libstdc++ project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: known duplicate code

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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]