|
Boost : |
From: dexsch (DavidS_at_[hidden])
Date: 2002-02-19 21:50:38
--- In boost_at_y..., wb_at_f... wrote:
> David Abrahams <david.abrahams_at_r...> wrote on Mon Feb 18 10:20:48
2002:
>
> | ----- Original Message -----
> | From: "Peter Dimov" <pdimov_at_m...>
> | To: <boost_at_y...>
> |
> |
> | > From: "Daniel Frey" <daniel.frey_at_a...>
> | > >>>
[snip]
> | And along these lines I want the ability to put a
typedef /anywhere/ in a
> | template declaration after the first argument (this is Walter
Brown's idea):
> |
> | template <class A, typdef some_complicated_expression<A> x; class
Y = X&, int z>
> | struct Foo
> | { ... };
>
[snip]
> I was originally motivated by the distasteful and error-prone need
> to duplicate some complicated type expressions in several places
> within a function template:
>
> template< class T1, class T2, class T3 >
> typename complicated_expression<T1,T2,T3>::type
> f( T1 const &, ...) {
> typedef typename complicated_expression<T1,T2,T3>::type
result;
> // ...
> return typename other_expression<result>::type( ... );
> }
>
[snip]
What's wrong with declaring a template class prior to
the template in question and creating all the typedefs
you need in go.
template <typename T1, typename T2, typename T3>
struct ftypedefs
{
typedef complicated_expression<T1,T2,T3>::type result;
typedef other_expresion<result>::type resulttype;
};
typedef ftypedefs<T1,T2,T3> F123;
template <typename T1, typename T2, typename T3>
F123::result f(const T1&,...) {
return F123::resulttype(...); }
Why on earth would you ever want to return a complicated type
and not make that a simple typedef usable by the caller ?
dex
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk