Boost logo

Boost Users :

From: Jeremy Siek (jsiek_at_[hidden])
Date: 2002-11-07 10:34:17


Hi Richard,

On Wed, 6 Nov 2002, loopylozzysdad wrote:
Richar> Hi,
Richar>
Richar> I did work out the answer to my own question. I can't explain
Richar> how/why this works but by copying from the header files I ended up
Richar> with the following changes to Jeremy's posted code...[1]
Richar> Good luck if you want it - please don't ask me to explain it!

I can explain it :)

As hinted by the #ifndef, the commented out version of container_gen uses
partial specialization. The first parameter to container_gen is
specialized, but the second is left as a template. Partial spec. is not
yet supported by VC++ (but soon will be).

The change you made is one of the classic ways of replacing partial
specialization with full specialization. You remove the unspecialized
parameter, and instead add a nested class template (here it is bind_).

Cheers,
Jeremy

Richar> Richard
Richar>
Richar>
Richar> [1]
Richar> Comment out from original ....
Richar> //struct ordered_set_by_nameS { };
Richar>
Richar> //#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
Richar> //namespace boost {
Richar> // template <class ValueType>
Richar> //struct container_gen<ordered_set_by_nameS, ValueType> {
Richar> // typedef std::multiset<ValueType, order_by_name<ValueType> >
Richar> type;
Richar> // };
Richar> //template <>
Richar> //struct parallel_edge_traits<ordered_set_by_nameS> {
Richar> // typedef allow_parallel_edge_tag type;
Richar> // };
Richar> // }
Richar> //#endif
Richar>
Richar> Replaced by .....
Richar> namespace boost {
Richar> struct orderedmultisetS {
Richar> template <class T>
Richar> struct bind_ { typedef std::multiset<T, order_by_name<T> >
Richar> type; }; // std::less<T>
Richar> };
Richar>
Richar> BOOST_CONTAINER_SELECTOR(orderedmultisetS);
Richar>
Richar> template <>
Richar> struct parallel_edge_traits<orderedmultisetS> {
Richar> typedef disallow_parallel_edge_tag type;
Richar> };
Richar>
Richar> }
Richar>

----------------------------------------------------------------------
 Jeremy Siek http://php.indiana.edu/~jsiek/
 Ph.D. Student, Indiana Univ. B'ton email: jsiek_at_[hidden]
 C++ Booster (http://www.boost.org) office phone: (812) 855-3608
----------------------------------------------------------------------


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net