Implicit instantiation of undefined template

boyangz
2013-09-11
2013-09-12
  • boyangz
    boyangz
    2013-09-11

    Hi,

    Thanks for building a great library.

    I am having some difficulties using blitz array with custom classes. In my case, the custom class inherits complex<double>. When I use real(Array<complex<double>, 1>(1,3)), it returns 1, but if I do the same with my custom class, it doesn't work. The compiler error 'implicit instantiation of undefined template 'blitz::Fn_real<custom_double>' is inside class _bz_ArrayExprUnaryOp on line 505: typedef _bz_typename T_op::T_numtype T_numtype;

    Below is a sample code that illustrates the error. Any help would be greatly appreciated.

    #include <iostream>
    #include <blitz/array.h>
    #include <complex>
    
    using namespace std;
    using namespace blitz;
    
    class custom_double : public complex<double>
    {
    public:
        custom_double(const complex<double>& in) { complex<double>::operator = (in); }
        custom_double& operator = (const complex<double>& in) { complex<double>::operator = (in); return *this; }
    };
    
    int main(int argc, const char * argv[])
    {
        Array<custom_double, 1> custom_instance;
        custom_instance = custom_double(complex<double>(1,2));
    
        Array<double, 1> double_instance;
        double_instance = real(custom_instance);
        return 0;
    }
    
     
  • boyangz
    boyangz
    2013-09-12

    Would it be possible to get blitz into treating the custom_double class as a complex type? I think the problem is blitz doesn't realize that custom_double is a complex type.