Boost logo

Boost :

From: Darin Adler (darin_at_[hidden])
Date: 1999-12-11 01:53:15


I now understand that the standard allows specializing a function template
but not partially specializing a function template.

I'm not sure what partially specializing a function template would mean. For
example, take my original example from my comp.std.c++ posting. Make class U
be a class template instead:

    // header file

    #include <algorithm>

    namespace N {

    template<typename T>
    class U
    {
    public:
        // ...
        void swap(U&);
        U& operator=(const U&);
        // ...
    };

    }

    namespace std {

    template<typename T>
    inline void swap(N::U<T>& one, N::U<T>& other)
    {
        one.swap(other);
    }

    }

    // implementation file

    namespace N {

    template<typename T>
    void U<T>::swap(U& other)
    {
        std::swap(m1, other.m1);
        std::swap(m2, other.m2);
    }

    template<typename T>
    U<T>& U<T>::operator=(const U& other)
    {
        U copy(other);
        swap(copy);
        return *this;
    }

    }

Is the std::swap specialization now a partial specialization? If so, there's
still a problem with <smart_ptr.hpp>, since shared_ptr is a class template.

    -- Darin

PS: I guess I'm violating my own suggestion to have this discussion on
comp.std.c++ instead of here.


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