$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Dave Gomboc (dave_at_[hidden])
Date: 2005-07-04 11:06:37
> The Function Type library uses tag types to represent a type's
> attributation, such as its calling convention or wether it is
> variadic.
>
> Tags that represent the values of a single property are called
> property tags. These tags can be used to determine whether one
> property of a type has a particular value.
>
> is_function< T, variadic >
> is_function< T, default_call >
>
> Does it work?
It's better than before. I still think you shouldn't mix "uses tag
types" (plural) with "a type's attributation" (singular), but you're
the author. ;-) I'd still go with "to represent attributations of
types", similar to how I wrote that line previously. Oh, also, fix
the spelling of "whether".
> I have. Try these use cases:
>
> // a remove constness (of the pointee) from a member
> function pointer type T
> function_type<signature<T>,tag<signature<T>,non_const>
>::type
>
> // shortcut:
> function_type<T, non_const >::type
>
> or
>
> // create a (possibly decorated) function type's
> variadic version
> function_type<signature<T>,tag<signature<T>,variadic>
>::type
>
> // shortcut:
> function_type<T, variadic >::type
Is manipulating these using MPL containers too much hassle for too
little benefit?
If <T, nonvariadic, variadic, variadic, nonvariadic, variadic> is
really going to be the same as <T, variadic, nonvariadic, variadic>,
then even testing for equivalence between tags becomes somewhat of a
chore.
> Well, we /could/ only allow overriding only in this very
> context, however, it
> would make things inconsistent and more complicated to explain,
IMO.
> I don't see a problem in allowing it either, because most
> error situations are
> pretty obvious
>
> a = 1;
> a = 2; // <-- should this line fail to compile?
No, your example above is (roughly speaking)
X = tag<T, nonvariadic>;
X = tag<T, variadic>;
Which sequentially assigns different values to X.
By writing tag<T, variadic, nonvariadic>, to my eyes you're writing
something akin to "a = 1 and a = 2 (at the same time)" [One example
in runtime-C++ is calling f(a=1, a=2), which does not at all
guarantee that a=2 at the end of this expression! But a guru may
come up with a better example.] Then, you specify a rule that says
"If I assign more than one value at the same time, I really mean the
last one", which is different behaviour than runtime-C++ gives.
That's why this asymmetric disambiguation behaviour feels awkward to
me.
> plus 'tag' seldom has to be used directly by the user, anyway.
>
> Further there is the technical side of the story:
>
> tag<A,B>
>
> only describes a type (talking C++ type system context here)
> and thus does not trigger a template instantiation. So the
> error message you get would probably involve a lot of trace
> (to where its PoI is) output and be questionable useful,
> because of this.
Explicit instantiation of templates is our friend in such cases.
This is nothing new to template users.
Dave