Boost logo

Boost Users :

From: Neal Becker (ndbecker2_at_[hidden])
Date: 2007-08-31 11:51:12


Neal Becker wrote:

> The following code:
>
> template<typename int_t>
> inline typename boost::enable_if_c<boost::is_integral<int_t>::value,
> std::complex<int_t> >::value operator >> (std::complex<int_t> const&x, int
> bits) {
> return std::complex<int_t> (real (x) >> bits, imag (x) >> bits);
> }
>
> // template<typename int_t>
> // inline std::complex<int_t>
> // operator >> (std::complex<int_t> const&x, int bits) {
> // return std::complex<int_t> (real (x) >> bits, imag (x) >> bits);
> // }
>
> int main() {
> std::cout << (x >> 1) << '\n';
> }
>
> gives:
> error: no match for 'operator>>' in 'x >> 1' (gcc-4.1.2)
>
> Uncomment the commented out version (without enable_if) and it compiles.
> What's wrong here?

I figured it out, this works:
template<typename int_t>
inline typename boost::enable_if<boost::is_integral<int_t>, std::complex<int_t> >::type
operator >> (std::complex<int_t> const&x, int bits) {
  return std::complex<int_t> (real (x) >> bits, imag (x) >> bits);
}


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