[SciPy-Dev] bool wrapper in sparse

Pauli Virtanen pav at iki.fi
Wed Jun 26 13:03:37 EDT 2013


26.06.2013 19:34, Nathaniel Smith kirjoitti:
[clip]
> In c++, user classes can't inherit from primitive types. Thus spake Bjarne.
>
> Make a memory-layout compatible class (i.e., one with a single npy_bool
> member), and then cast back and forth as needed?

This may also needs appropriate constructors and operator=()

npy_bool_wrapper() { value = 0; }
npy_bool_wrapper(int x) { value = x ? 1 : 0; }
npy_bool_wrapper& operator=(npy_bool_wrapper& x) { value = x; }

and ditto possibly for += and other operators.

-- 
Pauli Virtanen




More information about the SciPy-Dev mailing list