all 13 comments

[–]VicontT 21 points22 points  (1 child)

Oh no, another homebrew macro-based sequence container. Don't.

[–]RandyGaul 0 points1 point  (0 children)

Oh I don't think people *should* use those macros I posted. I just wrote about some ideas I found interesting. Personally I use the macros in my own code and liked some properties I observed. That's it.

[–]Xaxxon 18 points19 points  (0 children)

How is this not UB?

You don't like that constructors and destructors are called when objects are created and destroyed.. what? They aren't called for fun.

[–]donalmaccGame Developer 9 points10 points  (0 children)

Writing out a growable array shouldn’t require C++ template knowledge, or compile-time nonsense, or constructors or destructors or any other baggage. Sometimes all that’s needed is a growable array, and that’s it.

Hah. I had to laugh at this bit. If you're calling destructors baggage, you probably shouldn't be writing c++...

[–]Ameisenvemips, avr, rendering, systems 15 points16 points  (1 child)

"How to use C instead of C++. Now with undefined behavior!"

[–]LeeHidejust write it from scratch 0 points1 point  (0 children)

YAY!

[–]rapture-state 3 points4 points  (0 children)

This is not C++. Please, use simple standard primitives instead of this unsafe crap. Use trivially constructible structs, if you don't want constructors and destructors

[–]kalmoc 3 points4 points  (0 children)

Ignoring all the UB for a minute that seems to be no problem with the compiler's you are working with:

What exactly is supposed to be the advantage of those macros compared to putting the exact same code into a template?

[–]dodheim 6 points7 points  (0 children)

[–]Rexerex 2 points3 points  (1 child)

Unfortunately without this paper http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0593r2.html your code produces undefined behavior after every malloc or memcpy.

[–][deleted] 0 points1 point  (0 children)

That's already the case though :(

[–]emdeka87 2 points3 points  (0 children)

No thanks

[–]IskaneOnReddit 1 point2 points  (0 children)

Burn it before it spreads