Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C++
Pascal-like set class
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Rich Herrick, post: 1509266"] I agree. To be honest, I had forget about the == and != operators, and in my code I use the contains() member. I think I will remove them on future releases. But I still waffle back and forth on << and >>. I can see where they are extraneous, but I tend to like and use them a lot. The ! and void* operator I will probably remove also. Because, the reason I wrote it was because I wanted low-level control of the layout and the size. If I have a set with n items and n <= CHAR_BIT, I may want to fit them all into am unsigned char instead of an unsigned int. I do a lot of embedded software, dealing with drivers and memory-mapped registers and such. I'm use to have that kind of control, and tend to write interfaces with that in mind. I also deal with resources that are more constrained than an app. writer on a PC might. So, I guess the simple answer to your question is they wouldn't, except when the array is only one element in size, then I may want to use the smallest int type I can. Depends on what you are asking. If you are asking why pascal_set instead of bitset, then the answer is pascal_set is more typesafe then bitset and I want to mimic the Pascal set type as closely as I could, although I suppose I could have just wrapped bitset inside pascal_set. If you are asking why I didn't just wrap bitset inside my class instead of using an array, it comes down to control. I wanted control of the size and control of the bit-order. A lot of what I do interfaces with other languages (I write a lot of C, C++ and Ada--both '83 and '95), and memory-mapped registers. I have to know the layout. pascal_set makes it nice when dealing with set of bit flags in a memory-mapped register or an Ada bit array. Though its implementation specific, Ada compilers tend to use the MSB as bit 0 on a big-endian machine and the LSB as bit 0 on a little-endian machine. I wanted to be able to set my bit order to match. Plus, I want to see if I could use templates to create compile-set constant sets, which I may not be able to do with bitset. This is how the setof template evolved. My reasons probably aren't good enough for someone looking for a set class to choose mine over bitset or even set. But that's OK, I wrote it for me, and found it useful and a joy to use and thought to share it with anyone you may be interested. I am currently using it recreationally in writing some Interactive Fiction. And while writing this, I just thought of a big bug in the whole "traits" thing I must now fix.... Regards. [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C++
Pascal-like set class
Top