
On Thu, Jul 08, 2004 at 01:44:28PM -0500, Larry Evans wrote:
On 07/08/2004 12:58 PM, David B. Held wrote:
This is what I would like to do:
template <class P1, class P2> struct sp { template <typename T> struct nested { }; };
template <typename T> struct less;
template <class P1, class P2, typename T> struct less<sp<P1, P2>::nested<T> > : binary_function<...> { bool operator()(...); };
However, it doesn't work. From my research, it seems that the problem is that T is in a non-deduced context, but I don't see why that would be an issue, since this is how I expect it to get instantiated:
less<sp<p1, p2>::nested<int> > comp;
Thus, I don't see any deduction as being necessary, but obviously I don't exactly understand how to get what I want.
I very much sympathize with you; however, I have no answers :(
Depending on how much control you have over various parts, you maybe can kludge it along the lines of: struct i_am_a_nested_thingy {}; template <class P1, class P2> struct sp { template <typename T> struct nested : public i_am_a_nested_thingy { typedef P1 NestedP1; typedef P2 NestedP2; }; }; template <typename T> struct less; template <typename T> struct less_helper; template <typename T> struct less_helper<T,true> : binary_function<...> { typedef typename T::NestedP1 P1; typedef typename T::NestedP2 P2; bool operator()(...); }; template <typename T> struct less_helper<T,false> { // default impl (if there is one) }; template <class P1, class P2, typename T> struct less<T> : public less_helper<T,is_base_and_derived<i_am_a_nested_thingy,T>::value> { }; ... less<sp<p1, p2>::nested<int> > comp; ... -- -Brian McNamara (lorgon@cc.gatech.edu)