On Wed, 2 May 2018, Tuzun, Robert wrote:

(1) define a typedef BoolLike to unsigned char, and also define constants 
TrueLike to 1 and FalseLike to 0.

true implicitly converts to 1, false implicitly to 0, so that last
part's mostly unnecessary...

Although if we *really* wanted to be able to ignore when we're not
using a real bool, we'd need a whole shim class, I think.  Otherwise

bool foo = 3, bar = 4;
assert(foo == bar);

suddenly breaks if you try to convert it to BoolLike.

(2) use vector<BoolLike>

Nice, contiguous memory, no excess memory usage, and readable.

That's a good idea.  We should probably be doing that everywhere we're
currently using small vectors of semantically-bool contents.  Then it
doesn't matter that the question of what's faster is system-dependent;
if the answer changes then you just change the typedef accordingly.
---
Roy

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Libmesh-devel mailing list
Libmesh-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libmesh-devel

Reply via email to