
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); }