|
Boost Users : |
From: David Abrahams (dave_at_[hidden])
Date: 2007-08-31 11:50:12
on Fri Aug 31 2007, Neal Becker <ndbecker2-AT-gmail.com> wrote:
> 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?
You need to replace ::value with ::type in the enable_if_c
invocation. Though I don't know why you'd use enable_if_c when
enable_if is so much nicer here.
inline typename boost::enable_if<boost::is_integral<int_t>, std::complex<int_t> >::type
BTW, the standard doesn't support instantiationi of std::complex on
anything other than a floating point type.
-- Dave Abrahams Boost Consulting http://www.boost-consulting.com The Astoria Seminar ==> http://www.astoriaseminar.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