[SciPy-Dev] bool wrapper in sparse

Blake Griffith blake.a.griffith at gmail.com
Wed Jun 26 12:17:18 EDT 2013


Hello scipy, I'm working on the bool_ops.h file in sparse/sparsetools which
wraps numpy bool type for the c++ routines. Currently it just does

typedef npy_int8 npy_bool_wrapper;

So the underlying int can roll over to zero, giving a False when we should
have a True. I'm trying to make a class which inherits from npy_int8, then
override the addition operators to behave like normal boolean arithmetic (1
+ 1 = 1). But I'm having a few problems.

When I try to do something simple like:

class npy_bool_wrapper : public npy_int8 {};

I get an error for that line:

error: expected class-name before '{' token

When I try to implement it like a class template, like in complex_ops.h

template <class c_type, class npy_type>
class bool_wrapper : public npy_type {};
typedef bool_wrapper<int, npy_int8> npy_bool_wrapper;

I get:

error: base type 'signed char' fails to be a struct or class type
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scipy-dev/attachments/20130626/030c2109/attachment.html>


More information about the SciPy-Dev mailing list