Boost logo

Boost Users :

Subject: Re: [Boost-users] enable-if overloading out the wazoo
From: John Dlugosz (JDlugosz_at_[hidden])
Date: 2010-04-26 19:40:10




> > template <typename T1, typename T2>
> > dim_s foo (const T1& left, const T2& right);
> >
> > Then, in a header that gets more concrete, provide its own form that
> is meant to be used when objects of those types are involved:
> >
> > template<typename T1, typename T2>
> > typename enable_if_c<
> > is_base_of<genericbase,T1>::value &&
> > is_base_of<genericbase,T2>::value,
> > dim_s>::type foo (const T1& left, const T2& right);
> >
> Isn't that causing ODR violation ?
> the enable_if'ed foo should also present in the header IMHO
>
> --
> ___________________________________________
> Joel Falcou - Assistant Professor


I'm assuming that you won't have any objects of the types being enabled unless that header is included. I know that the compiler needs to be aware of explicit specializations before making a call that would use one. But this isn't a specialization anyway, but an overloaded foo.

I see that overloading would not be allowed if it differs in the return type only. But I was under the impression that for templates they are indeed different templates. Now there is no way to distinguish between them as written, when is an extension of the issue I was asking about. I could put the enable_if in a dummy extra argument that has a default value -- that would prevent the signatures from being the same, and it would not affect my question.


--John





TradeStation Group, Inc. is a publicly-traded holding company (NASDAQ GS: TRAD) of three operating subsidiaries, TradeStation Securities, Inc. (Member NYSE, FINRA, SIPC and NFA), TradeStation Technologies, Inc., a trading software and subscription company, and TradeStation Europe Limited, a United Kingdom, FSA-authorized introducing brokerage firm. None of these companies provides trading or investment advice, recommendations or endorsements of any kind. The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.


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