[SciPy-Dev] bool wrapper in sparse
Pauli Virtanen
pav at iki.fi
Wed Jun 26 13:17:51 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?
I somehow doubt that
class Foo
{
char b;
};
assert(sizeof(b) == sizeof(char));
is guaranteed by C++ standards. However, we can just start inserting
compiler-specific packing pragmas for those cases where it isn't true.
For safety, however, it's probably best to include the assert statement
in one of the routines. The compiler should optimize it away, and it
will break scipy test suite if the file is miscompiled.
--
Pauli Virtanen
More information about the SciPy-Dev
mailing list