Boost logo

Boost Users :

From: David Abrahams (dave_at_[hidden])
Date: 2007-10-31 11:38:20


on Tue Oct 30 2007, "Ovanes Markarian" <om_boost-AT-keywallet.com> wrote:

> Hello!
>
> Does anybody else experience a problem using enable_if templates in Visual C++ Express 2005 SP1?
> I get compiler errors in this code:
>
> template<class LookUpType_>
> typename boost::enable_if_c<is_const, result_type>::type
> at(LookUpType_ const& key)const
> {
> return has_key(view_, key);
> }
>
> template<class LookUpType_>
> typename boost::disable_if_c<is_const, result_type>::type
> at(LookUpType_ const& key)
> {
> return has_key(view_, key);
> }
>
> It blames that type is not a member of enable_if_c or disable_if_c?
> This is really strance, since this should not be considered by
> compiler as a possible template instantiation. is_const is an enum
> value containing either true or false.

In order for SFINAE to work, at least one argument to [dis|en]able_if
has to depend on a template argument (in this case, LookUpType_ is the
only one). As written, none of them do.

I don't know what you're doing with is_const, but at least in the
Boost world that is a template that requires a template argument in
that context. For example,

        template<class LookUpType_>
        typename boost::disable_if_c<boost::is_const<LookUpType_>, result_type>::type
            at(LookUpType_ const& key)
        {
            return has_key(view_, key);
        }

HTH,

-- 
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com

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