Boost logo

Boost :

From: David Abrahams (david.abrahams_at_[hidden])
Date: 2002-02-23 11:50:15


----- Original Message -----
From: "Aleksey Gurtovoy" <alexy_at_[hidden]>

> #include <iostream>
>
> template< typename T > struct A {};
>
> namespace aux {
> template< typename T >
> struct foo_impl
> {
> template< typename U >
> static void foo(A<U> const&, long)
> {
> std::cout << "foo(A<U> const&)\n";
> }
>
> static void foo(T const&, int)
> {
> std::cout << "foo(T const&)\n";
> }
> };
> }
>
> template< typename T >
> void foo(T const& t)
> {
> aux::foo_impl<T>::foo(t, 1L);
> }
>
> int main()
> {
> foo(int());
> foo(A<int>());
> return 0;
> }
>
> That's more, I belive that the technique allows you to simulate partial
> ordering of any number of overloaded function templates, not just 2 of
them.

Whoa, that's tricky! How do you extend it to more overloads?


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk