Boost logo

Boost Users :

Subject: Re: [Boost-users] boost::enable_if, did I get it wrong ?
From: Frank Mori Hess (frank.hess_at_[hidden])
Date: 2009-08-18 14:25:57


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tuesday 18 August 2009, topoden wrote:
> Hello,
>
> I'm trying to use boost::enable_if to customize function declaration for a
> particular set of template arguments. But instead of using SFINAE to remove
> incorrect declaration it produces error.

What you are doing is an error (and not just the extra void you have in the
return types). SFINAE drops template functions from consideration during
overload resolution. You would need to make the process member functions
templates (but you can't because there are no virtual template methods in
C++). It looks like what you are trying to do is provide a partial template
specialization of BaseListener when the second template parameter is void.

> template<class A, class B>
> struct BaseListener
> {
> typename boost::disable_if<boost::is_void< B >, void>::type
> void virtual process(A *, B *) = 0;
>
> typename boost::enable_if<boost::is_void< B >, void>::type
> void virtual process(A *) = 0;
> };
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkqK8jYACgkQ5vihyNWuA4X6EQCghDjl2cK4DNnny0rVa4Y0pANG
pQYAniT1sOhdA2nDKbJysoGBDuIKzaU/
=2eVR
-----END PGP SIGNATURE-----


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