Travis Vitek wrote:
[...]
Here is one alternative that we might want to consider. Instead of
stripping cv qualifiers, we add them and then provide a specialization
for the cv-qualified type.

  template <class T>
  struct is_cv_void { typedef false_type type; };

  template <> struct
  struct is_cv_void<const volatile void> { typedef true_type type; };

  template <class T>
  is_void: is_cv_void<const volatile T> { };

It is a bit of a compromise between the two implementations shown above.
This has the advantage over the "alternative approach" that it reduces
the number of templates to parse. It also eliminates the need to
instantiate remove_cv that is used in the template metaprogramming case.

Interesting idea!


Martin, if you still have your performance numbers, could you compare
this to the previously proposed options?

The test script I've been using most recently is here:
  http://people.apache.org/~sebor/templatetest

This script is slightly different than the test case I used to
produce the original numbers. The original test also used the
-A option with EDG eccp, while this one doesn't.

Running it like this
    $ ~/tmp/templatetest -c "eccp gcc" -i 20 -t 1000

produces these results (I modified the output to show only
user times in a M:SS format in an easy-to-read table):

    generating 20 instantiations of 1000 distinct types...
                            ECCP    GCC
                             3.9  4.3.0
    with add_cv             0:28   0:22   # using is_cv_void
    without remove_const    0:24   0:19
    with remove_const       0:49   0:18
    with inline expansion   0:39   0:18

Btw., the EDG eccp times are without the -A strict conformance
option that we use; the times with the option are usually much
longer (I'd have to modify my script to pass arguments to it
to get those results).

Martin

Reply via email to