[SciPy-Dev] bool wrapper in sparse

Blake Griffith blake.a.griffith@gmail....
Wed Jun 26 16:22:52 CDT 2013


So basically I define a class that behaves like bool, but add compiler
specific parameters to make instance of this class 1 byte?


On Wed, Jun 26, 2013 at 12:17 PM, Pauli Virtanen <pav@iki.fi> wrote:

> 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
>
> _______________________________________________
> SciPy-Dev mailing list
> SciPy-Dev@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-dev/attachments/20130626/d4b7554f/attachment.html 


More information about the SciPy-Dev mailing list