|
Boost Users : |
From: jajarvi (jajarvi_at_[hidden])
Date: 2004-06-08 07:52:20
On Jun 7, 2004, at 7:11 PM, Hurd, Matthew wrote:
>
SFINAE does not kick in, because the condition
(is_arithmetic<std::string>::value) is not dependent on any template
arguments.
Cheers, Jaakko
> template< bool >
> typename boost::enable_if_c<
> boost::is_arithmetic<std::string>::value, void >::type
> exchange_code( boost::call_traits<std::string>::param_type
> new_exchange_code )
> {
> lock lk(guard_ );
> exchange_code<false>( new_exchange_code);
> }
>
> template< bool >
> typename boost::disable_if_c<
> boost::is_arithmetic<std::string>::value , void >::type
> exchange_code( boost::call_traits<std::string>::param_type
> new_exchange_code )
> {
> exchange_code<false>( new_exchange_code);
> }
>
> Forget the relevance of the is_arithmetic bit, I use my own needs_lock
> thingo.
>
> For a start:
>
> The compiler correctly identifies that ::type is not a member, but
> SFINAE does not seem to kick in if I'm reading it correctly.
> ____________________
> c:\source\matt\trading_engine\controller\instrument.hpp(66) : error
> C2039: 'type' : is not a member of 'boost::enable_if_c<B,T>'
> with
> [
> B=false,
> T=void
> ]
> c:\source\matt\trading_engine\controller\instrument.hpp(143) :
> see reference to class template instantiation 'te::instrument<S>' being
> compiled
> ____________________
>
> template< bool >
> typename boost::disable_if_c<
> boost::is_arithmetic<std::string>::value , void >::type
> exchange_code( boost::call_traits<std::string>::param_type
> new_exchange_code )
> {
> exchange_code<false>( new_exchange_code);
> }
>
> Is fine...
>
> Flipping the conditions round by changing to is_arithmetic< int > flips
> the failures around.
>
> Same issue with the extra parameter approach:
>
> template< bool >
> void
> exchange_code( boost::call_traits<std::string>::param_type
> new_exchange_code,
> typename boost::enable_if_c< boost::is_arithmetic<int>::value, void
>> ::type* dummy = 0 )
> {
> lock lk(guard_ );
> exchange_code<false>( new_exchange_code);
> }
>
> template< bool >
> void
> exchange_code( boost::call_traits<std::string>::param_type
> new_exchange_code,
> typename boost::disable_if_c< boost::is_arithmetic<int>::value ,
> void >::type* dummy = 0 )
> {
> exchange_code<false>( new_exchange_code);
> }
>
> Is SFINAE meant to work in this way with member templates with
> enable_if, vc7.1 and boost 1.31?
>
> Something simple is probably escaping me...
>
> Any thoughts?
>
>
> Regards,
>
> Matt Hurd.
> _______________
>
> Matt Hurd
> +61.2.8226.5029
> hurdm_at_[hidden]
> Susquehanna
> _______________
>
>
>
> IMPORTANT: The information contained in this email and/or its
> attachments is confidential. If you are not the intended recipient,
> please notify the sender immediately by reply and immediately delete
> this message and all its attachments. Any review, use, reproduction,
> disclosure or dissemination of this message or any attachment by an
> unintended recipient is strictly prohibited. Neither this message nor
> any attachment is intended as or should be construed as an offer,
> solicitation or recommendation to buy or sell any security or other
> financial instrument. Neither the sender, his or her employer nor any
> of their respective affiliates makes any warranties as to the
> completeness or accuracy of any of the information contained herein or
> that this message or any of its attachments is free of viruses.
>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
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