[SciPy-Dev] bool wrapper in sparse

Pauli Virtanen pav@iki...
Thu Jun 27 16:56:13 CDT 2013


27.06.2013 00:22, Blake Griffith kirjoitti:
> So basically I define a class that behaves like bool, but add compiler
> specific parameters to make instance of this class 1 byte?

Pretty much so, for known compilers (gcc, msvc).

I'd also put an assertion somewhere in the code. Either inside one of 
the functions, or try to construct a compile-time assertion via some 
trickery. C++11 has static_assert that would do the job, but that's a 
bit too new standard to rely on. However, there are some tricks to do it 
in any case (check stackoverflow for "sizeof compile time assert").

-- 
Pauli Virtanen



More information about the SciPy-Dev mailing list