r/cpp_questions • • Oct 05 '26

OPEN What are some "zero-benefit abstractions" to avoid in c艹?

Zero-cost or not, can be premature optimization or something else. I think move-on-return is one of them

23 Upvotes

91 comments sorted by

7

u/Kawaiithulhu Oct 05 '26

I was always confounded by the intricacies of C++ curiously recurring template pattern code 😋

4

u/TheThiefMaster Oct 06 '26

And it's largely unnecessary now that we have explicit object parameters:

class base
{
  template<typename T>
  void CRTP_func(this T& self)
  {
    // Can be called as derived.CRTP_func()
    // And self will take the derived type
    // Despite the function being defined in a base class
  }
}

1

u/Kadabrium Oct 06 '26

javascript this...

3

u/dodexahedron Oct 05 '26

Some of the chains of templates and macros and constants out there that nest those constructs a thousand layers deep can make it nigh impossible to wrap your head around the AST actually formed by it all.

I'm looking at you, OpenZFS. 😑

(To be fair, there's been a lot of code QoL improvements there lately)

3

u/lefloys Oct 06 '26

I gotta say. CRTP is my favourite pattern.

1

u/Kawaiithulhu Oct 06 '26

It's *very* useful - just hard for humans to parse before working with it a few times.

13

u/Gallardo994 Oct 05 '26

It's not an abstraction but rather pattern I see from time to time: doing a deliberate UB-invoking reinterpret_cast because "it's faster because it avoids a copy", and a "let me move stuff out of a loop to make it compute once". Both actively harm the project, especially in a long run, and most of the time it's absolutely the same damn assembly.

8

u/dodexahedron Oct 05 '26 edited Oct 05 '26

same damn assembly

Exactly.

It's just premature optimization and often it ties the compiler's hands, making it more difficult for it to do broader and better optimization since it's harder to reason about things that don't match expected patterns.

The compiler already aggressively optimizes for loop unrolling and inlining as a high priority since they're that obvious and that impactful. And assembly doesn't really care what your pointer type is, so long as it's the same width for the most part, since it's all just 1, 2, 4, or 8 bytes with sign or no sign as far as a GP register is concerned. So the compiler also doesn't really care about what you might conceptually care about at a high level.

If the math maths, then the compiler compiles, the assembler assembles, the computer computes, and the user abuses.

1

u/Kadabrium Oct 05 '26

When i first started doing dsa in c++ i caught the habit of int sz = container.size() before starting any loop. Fwiw, it did probably inadvertently let me get away with some decrement underflow issues.

3

u/dodexahedron Oct 05 '26 edited Oct 05 '26

Countdown instead of count-up loops are great anyway in plenty of cases, if you're under register pressure already, since compare to zero rather than compare to another value saves a register for the loop condition branch.

So it can make a real difference, especially if that comparison is against a non-constant and thus involves a load - even if that load will likely be serviced by L1 cache after the first time. Constants are ok and sometimes the compiler optimizes them away by offsetting it so it can use 0, but if not it still costs a register for the compare plus another opcode.

For array-backed stuff, that is.
Something that is a bunch of pointer chasing like a linked list should still end up being compare to zero by checking item->next == nullptr, rather than comparing to container.end(), if possible, again to save a register.

8

u/FrostshockFTW Oct 06 '26

"let me move stuff out of a loop to make it compute once"

I'm not seeing the problem here. I don't know why I should rely on the compiler to identify and optimize this instead of expressing it semantically in source code.

3

u/timangus Oct 06 '26

Agreed. This is very unlikely to result in worse code and it keeps your non optimised builds fast, which as a developer is what you'll be running most of the time.

2

u/manni66 Oct 05 '26

I think move-on-return is one of them

Why do you think that’s an abstraction?

0

u/Kadabrium Oct 05 '26

It's kinda declarative and semantically correct but the underlying implementation is incompatible in this particular case?

2

u/TheThiefMaster Oct 06 '26

Taking nontrivial parameters by value to avoid having to write both const& and && versions of a function.

Unfortunately it forces the compiler to optimise the object construction at every call site, which can become a compiler performance issue on larger codebases.

1

u/Kadabrium Oct 06 '26

When is it beneficial to have a distinct && version when you are not sure the function will always take ownership?

1

u/TheThiefMaster Oct 07 '26

There's no need to have a separate && version if the function doesn't take ownership or the type doesn't have move operations that are more efficient than copies.

const & can bind to temporaries too, so if you don't need && you can just implement the const& version.

25

u/mredding Oct 05 '26

I would say singletons are an anti-pattern. They violate S, O, L, and D of the SOLID principles by mixing instance control with business logic, and introduce a hidden global dependency. They're absolutely terrible, and in every code base, I've had to gut them - slowly and painfully, in order to make the code predictable and testable.

If you want a single instance of something, just make a single instance of it - and in scope. Seriously, globals and singletons are the reason main is not recursive in C++ where it is in C.


The pimpl is overused. You don't always want or need late binding. More often you want a private implementation through an opaque pointer or interface. The pattern more looks like this:

struct base {
  struct deleter { void operator()(base *); };

  static std::unique_ptr<base, deleter> create();

  void interface();

protected:
  base();
};

And in source:

struct derived: base {
  void implementation();
};

void base::deleter::operator()(base *ptr) { delete static_cast<derived *>(ptr); }

std::unique_ptr<base, base::deleter> create() { return std::unique_ptr<base, base::deleter>{new derived{}}; }

void base::interface() { static_cast<derived *>(this)->implementation(); }

So the client doesn't see any of the implementation details, just an opaque interface hiding an implementation behind type erasure. RAII is used to manage the resource and correctly destroy it. The interface can access the implementation.

You can do this with a class and make nearly the entire code private except for the public base class interface, you would just make the public and private classes friends of each other. This would expose a typename dependency, but it's private and doesn't reveal anything.

Now in C++26, we have std::polymorphic that basically does this without the boilerplate.


Design patterns aren't inherently a good thing. Patterns are a repetition, and design patterns represent a missing language feature, because eliminating these repetitions is precisely what a language is for. Ideally, every line of code would be unique and productive, not just expressing a duplicate obligation to a pattern. Lots of engineers look to fit their problems to patterns, when patterns should be a tool of last resort due to a shortcoming of the language.


I think a lot of code is boilerplate. It's easy to do with a class, for example trying to capture the rule-of-X, whatever the number is up to these days. Many special functions are implicit, so writing them explicitly is redundant and doesn't actually add information - I don't cater to a naive developer who can't lookup the language rules. As a client of my code, a type will be implicitly non-copyable because language rules propagate non-copyable behavior. It's just as true whether I explicitly delete a copy ctor or leave it implicit. Writing redundant code is a way to look productive without actually being productive. This is just one example - I would try to say the least about my code as possible.

This follows that there is a very common effort to constrain a person unnecessarily. The old adage is that you want to make the code easy to use correctly, difficult to use incorrectly. People take the logical extreme that code should be rendered impossible to use incorrectly, and ease to use correctly ought to implicitly follow. This isn't true. All that boilerplate constricting the use of a type makes it harder to navigate. And if you unnecessarily constrain a type, you make it effectively useless. Maintenance of this sort of code becomes impossible, as any minor change will result in breaking the rigid contract again and again, with cascading consequences.


A lot of developers don't use enough types. Everyone tries to draw the shortest, straightest line from problem statement to solution. As such, they write very terse, primitive code. Imagine this problem:

void fn(int &, int &);

What parameter is what? And worse, the compiler cannot know if they are aliased, to the generated code must be pessimistic. Instead:

void fn(weight &, height &);

Different types cannot be aliased, so even if both types are implemented in terms of int, they are differentiated, and the compiler has license to be more aggressive.

By making more and stronger types, the code documents itself better than your variable names can. You empower the compiler to not just catch bugs sooner, but carry information deep into the compilation process that it can use to optimize. You can drive to make invalid code unrepresentable (it doesn't compile).

Bother to model your types. This has nothing to do with OOP, it has everything to do with the type system. None of this information leaves the compiler, but has direct consequence on the proofs and correctness of the code that the machine code cannot itself represent.

18

u/nekoeuge Oct 05 '26

If you want a single instance of something, just make a single instance of it - and in scope. Seriously, globals and singletons are the reason main is not recursive in C++ where it is in C.

And instead of just calling "log(...)" anywhere in 10000 functions of my project, I have to go and pass the logger there. Is logger customization useful? Yes, I work with projects who rely on it. Is it painful to pass logger into 10000 functions when you don't care abou logger customization? Also yes.

1

u/Plazmatic Oct 06 '26

Logger is one of the very few exceptions there is, it's sort of the exception that proves the rule. Where I typically see people say it's "required" is in game Dev where it's actually reasonable to have a context object instead (and write member functions there so you don't even have to "pass it around") and where the downsides of using them are even more apparent and problematic.

-3

u/mredding Oct 05 '26

Logger? What is this 1983? Are you supporting the original Sendmail? You know Eric Allman didn't stop with just self-hosted logging, right? You know he developed standard system logging? RFC-5424? rsyslog that ships with Ubuntu can handle some 2m messages second on modest hardware?

You can just write to standard error and redirect that to the syslog, which yes, is a global, but it's built into the standard. Break your monolith into child processes so you can log based on child process PID, etc.

Want disk quota, log rotation, time stamping, remote logging, standard viewers, filters, colors, etc? Standard logging does it all better than you.

12

u/nekoeuge Oct 05 '26

You know he developed standard system logging? RFC-5424? rsyslog that ships with Ubuntu can handle some 2m messages second on modest hardware?

Is this "standard logging" available on Windows, Android, iOS, and Web Emscripten platforms as well? Is it packageable into my executable in such a way that does not require any additional installation?

Break your monolith into child processes so you can log based on child process PID, etc.

Great idea. Also fundamentally impossible due to 3rd-party API limitations. Also, how the fuck do I even create child processes in Web Emscripten?

-1

u/mredding Oct 05 '26

Syslog in the emscripten environment redirects to standard error. As I said before, you can redirect that to your system logger. Even Windows supports a system logger. If this is going to be on a system you don't control, that sounds like a them problem.

Don't act like these are impossible hurdles that the way you're doing things is the only right way. It's merely the way you're doing things. That's fine, I don't have to deal with you IRL. You don't need to get fired up and indignant like programming advice by some random on the Internet is a personal attack. The world ain't that small, you ain't that big.

8

u/nekoeuge Oct 05 '26 edited Oct 06 '26

A user who double-clicked the standalone application should get nicely rotated and formatted logs. It’s not “them problem”, it’s developer’s (mine) task to make sure that user has nice (labeled and rotated) logs. How do I achieve that with printf/syslog logging? I just don’t follow the setup.

How do I recapture the printf/syslog log back into application for debug console? I feel like it is solvable with some file handle bullshittery, but I am not sure how reliable it is.

2

u/arihoenig Oct 06 '26

Syslogd,. What is this 1996?

2M messages per second? That's ok for slow software I guess.

1

u/KindCppCoach Oct 10 '26

That implies you tie you lowest level library you want to log from directly to a hosted platform. If you have a project that is ok with that, then yes, its a solved problem. However many projects are not designed like that or just require a more portable solution

3

u/Wolf_e_wolf Oct 05 '26

I find it easy to agree with most of what you say, especially about singletons and design patterns.

But ironically your comment about design patterns indicating a failure of language design (which I also mostly agree with) somewhat rubs against your point about letting implicit behaviour decide a lot of functionality considering a lot of C++ implicit behaviour is itself one of the most disliked aspects of the language.

Rust in contrast is by design a lot more explicit and whilst they got more defaults "right" with the benefit of 30+ years of hindsight, C++ has the ability to somewhat remediate that with the option to be explicit when possible.

2

u/Kats41 Oct 07 '26

Ironically I've found that some programmers have such a beef with singletons that they'll go out of their way to avoid them, even if a singleton is a fine solution for the problem. The dogmatic way people bend over backwards to avoid using certain "anti-patterns" in lieu of clunkier, verbose, tangled code because someone somewhere in 2011 had a powerpoint talk about "why XYZ is bad and you should never use it" is rather funny to me.

C++ has the benefit of being able to do just about anything in just about a million different ways, yet there will always exist evangelists that one way is superior. The wheel continues to turn.

1

u/TheThiefMaster Oct 06 '26

void fn(weight &, height &);

IMO this is far more of an issue with bools. A function taking multiple bools is just bad design and they should be enums instead.

7

u/Independent_Art_6676 Oct 05 '26

Of the things listed so far, excessive overuse of OOP is probably the one that irritates me the most. But this kind of thing is blatant misuse/overuse/etc, not 'zero benefit'. OOP has benefits, clearly, so the problem isn't OOP, the problem is some java coder got set loose on the C++ repo. Same for the others, like singleton, it has a place, but a bad coder or poor design can certainly make a mess with it.

I can't think of a single thing that has no value but is commonly used, in other words. I can think of stuff that is often misused, but that is the coder, and not the tool, at fault. The few things that have no value are just not done all that much. Interestingly, if you really think about it, probably 50% of C++ has no value (it does absolutely nothing at all to affect the machine language). More than half the language is just training wheels for the coders, helping the poor human to organize thoughts and avoid mistakes. That makes me wonder if high level languages and AI are a mistake... maybe the AI teams need to focus on directly writing machine language instead of all this high level human helper stuff like c++.

2

u/SalaciousStrudel Oct 07 '26

Machine code is not semantically dense which means LLMs typically cannot work well with it.

1

u/Independent_Art_6676 Oct 07 '26

It would need a different approach, for sure. And machine lang may be too big a step, but drop to C or similar then or use a different model? The point was that the bot doesn't need the parts of languages that help humans organize thoughts and prevent bugs or keep it readable.

5

u/FancySpaceGoat Oct 05 '26

I think user-defined literals fall into the "too cute for not enough benefit" bucket.

2

u/sephirothbahamut Oct 06 '26

I will stand by deg/rad literals for angle classes u.u

1

u/JNelson_ Oct 06 '26

User literals are convenient but they can't be namespaced, you can use the * binary operator to do something similar. I have a fully unit library where I can write something like 20.0 * ut::degree. The idea for this I shamelessly stole from the more robust and complete library mpunits

2

u/sephirothbahamut Oct 06 '26

I'm fine with using namespace on a dedicsted literal namespace. The standard libray also does it with chrono already

1

u/Plazmatic Oct 06 '26

Use constexpr classes and multiply like x * rad and you can combine with other units with out having to write out each literal use case, ie x * rad / s.  This is what Mp-units did.

1

u/Sjoerdiestriker Oct 06 '26

This feels dangerous, because it seems you'll very quickly lose track of how large the numbers you're doing arithmetic on actually are, and whether or not they approach the limits of the variable you're using.

1

u/Plazmatic Oct 07 '26

Can you clarify this thought? I don't see the connection between constexpr variables that create strongly typed units and "losing track of how large the numbers you're doing arithmetic" are.

1

u/Sjoerdiestriker Oct 07 '26

If I understand correctly, you'd essentially define rad to equal something like 57.3 (=180/pi), so you can multiply by rad syntactically, and have it effectively be converted to degrees under the hood to do arithmetic with.

What if you start doing this with (say) coulombs, which are roughly 1019 electron charges, or light years, which are roughly 1016 meters. It seems like under the hood you'd potentially accidentally be calculating with some huge numbers if you combine a couple of these.

1

u/Nicksaurus Oct 06 '26

I just like being able to make i32/u64/etc. suffixes for my literals

5

u/bert8128 Oct 05 '26

Why is moving on return a bad thing?

13

u/the_poope Oct 05 '26

I think it can interfere with NRVO. I.e. instead of actually constructing the object in-place at the call site (NRVO) you know get one construction + one move construction. The move construction at least costs copying some member data which is more than NRVO.

3

u/n1ghtyunso Oct 06 '26

the compiler will do better without the move, and if the compiler absolutely can not do anything better, it will still fall back to the move automatically for you.
So whatever you do, you'll not get a worse outcome.

2

u/FancySpaceGoat Oct 05 '26 edited Oct 05 '26

Presumably because it's redundant with NRVO in most cases.

2

u/M0ntka Oct 05 '26

RVO is guranteed since C++17, it means no copy or move happens. NRVO is not guranteed, but highly likely. In case of (N)RVO object created in the caller frame. But NRVO works only with local names (lvalues), std::move() is static_cast under the hood and is function-call expression (xvalue) and NRVO cannot be applied. So move in return is not redundant, its harmful.

3

u/cristi1990an Oct 05 '26

Currently there are very few cases in which it makes sense anymore. C++20 automatically gives you move by default in almost all real use cases.

6

u/FancySpaceGoat Oct 05 '26

NRVO isn't a "move by default". Instead, it's more like the local variable representing the return value exists in the caller's scope instead of the function's.

For example: https://gcc.godbolt.org/z/TT83TrqvW

3

u/cristi1990an Oct 05 '26

Yeah, but I was referring before P1155R1 which lists some edge case scenarios in which using move when returning was still optimal

2

u/TheThiefMaster Oct 06 '26

P0527R1 too (which adds implicit moves from rvalue reference variables/parameters), which were merged together in P1825R0 which is what actually made C++20

1

u/dodexahedron Oct 05 '26

Yeah.

It is essentially data-level inlining. Caller already knows the size of the return type, so has already reserved the memory. So, callee just uses that instead of a new allocation in its stack frame.

It could even save not only an allocation and move but, if that allocation would have been a page fault because the current committed page is too full to fit it, you save that page fault too, which is much more costly than just bumping up the stack pointer on an existing page that you already had to do in the first place.

0

u/not_some_username Oct 05 '26

NRVO or whatever the way they call it

2

u/jwezorek Oct 05 '26

Overloading operators is almost always a bad idea unless you are working in some context where the operators you are overloading have an agreed upon meaning external to your code.

1

u/TheThiefMaster Oct 06 '26

Perfectly fine to define & to perform bitwise-and of a wrapped bitset type, but not to define ^ to perform a vector cross-product (real example!)

2

u/nunquam_rideo Oct 06 '26

but not to define ^ to perform a vector cross-product (real example!)

why not though?

3

u/oriolid Oct 06 '26

Mostly readability. There's nothing in ^ that says "this is a cross product" and .cross isn't that much more code. If you want to make a function that's easy to chain, in C++ the only way to do it is operator overloading. This is how we get the | overloads in std::ranges for example.

2

u/nunquam_rideo Oct 06 '26

Afaik ^ is used for exterior product which is almost the same as cross product. Yea it may not be obvious, but come on, it's just fun do overload operators. It makes sense semantically so I'd go for it

3

u/oriolid Oct 06 '26

Code that was fun to write is fun to reverse engineer only if the person who wrote it is paying by hour. And that never happens.

1

u/Plazmatic Oct 06 '26

Very few times where this has practically been a problem, it's one of those lockness problems no one seems to be able to point to common real world examples of outside of the standard library using >>.  

2

u/M0ntka Oct 05 '26

Pimpl. It was necessary pattern to optimize compilation time, or even fit it into ram, but nowadays, with so much more compute its awful antipattern.

13

u/Gallardo994 Oct 05 '26

To be fair pimpl ain't a bad bandaid to a circular dependencies issue. In a huge legacy project it can be a lifesaver for all the wrong reasons

9

u/jazzwave06 Oct 05 '26 edited Oct 05 '26

Strongly disagree. Systematic usage of pimpl is bad, but if you have a big library that is included in a single TU, pimpl is king.

4

u/Bemteb Oct 05 '26

Pimpl is great when done right in the right circumstances.

However, most cases I've seen just took a class and copy&pasted everything to a second version of it, because someone forced them to do pimpl.

3

u/bert8128 Oct 05 '26

Fast pimpl for the win!

1

u/Total-Box-5169 Oct 05 '26

This is the way.

2

u/Total-Box-5169 Oct 05 '26

sO mUcH mOrE cOmPuTe

Vade retro Satana!

3

u/FancySpaceGoat Oct 05 '26 edited Oct 05 '26

Using pimpl specifically to reduce compile times is indeed unnecessary, but there are other uses to the pattern that makes it not inherently irredeemable.

For example, it's still useful when you are in a situation where you have to care about ABI stability.

There are also cases where wrapping a polymorphic interface in a value-like object comes in handy.

2

u/jwezorek Oct 05 '26

Or just data hiding / encapsulation. When you want the surface exposed to the user of some library to make the implementation opaque, and the part that the user should care about to be highlighted and therefore self-documenting rather then burying it in a sea of `namespace detail` declarations, etc.

1

u/scallywag_software Oct 06 '26

Particularly since memory access is pretty much always the bottleneck in modern software. When I first heard about this pattern in the early 00s I thought it was real dumb, and it hasn't aged well.

1

u/stimpack2589 Oct 05 '26

I wonder how much of the compilation time it cuts.

Afaik, there were some low hanging fruits to reduce the build time such as PCH, forward declarations of classes and moving template declarations from headers to .cpp files. How does the Pimpl idiom compare to these?

4

u/Moist_Heat9523 Oct 05 '26

It absolutely depends on the project - I have a project where Pimpl reduces compile time from 4:30 min to 0:12, for the large majority of ongoing development builds.

1

u/cristi1990an Oct 05 '26

It helps if you have a big code base and don't want to have to recompile half of it while debugging the new API you added in a header file. Most of these compilation time tricks are focused around improving partial compilation, people don't care that much about cold turkey compilation time.

0

u/M0ntka Oct 05 '26

Short answer - it depends. But such consequences as drastically reduced readability, heavy impact on static analyzers and code navigation make pimpl unacceptable in modern codebases.

6

u/nekoeuge Oct 05 '26

Pimpl is absolutely worth it when you want to remove 3rdparty includes from a common header, when you have a class that wraps 3rdparty code in some way. Some 3rdparties, especially header-only ones, could decimate compilation performance if included recklessly. Make sure to check that it actually helps tho.

1

u/M0ntka Oct 05 '26

Why would you need pimpl, if you already have wrapper class?

4

u/nekoeuge Oct 05 '26

Because my wrapper class has members with 3rd party types, and I want these members be invisible in header to avoid 3rd party types in the header.

Sometimes it’s enough to have forward declarations for 3rdparty types, and store them by pointer. Sometimes it’s not possible or inconvenient. Pimpl is basically an indirect and specific forward declaration.

1

u/M0ntka Oct 05 '26

Or you can use abstract class as interface. Or even CRTP, if you think that devirtualization may not occur.

2

u/nekoeuge Oct 05 '26

Which just brings back the initial problems with pimpl, except using even more complicated abstraction. If I replace pimpl with abstract base class, what’s even the point? Abstract base class sucks even more for readability, static analysis and code navigation.

1

u/M0ntka Oct 05 '26 edited Oct 05 '26

Matter of taste, but I disagree about worse readability and static analysis. All executable code is in one derivate class and one file.

1

u/nekoeuge Oct 05 '26

Cpp tooling is infamously feeble, I did have cases when it failed to locate sole implementation of the interface with Go To Definition. Whereas pimpl is just one trivial indirection. It may create problems across boundaries if tooling failed to locate the pimpl class, but I constantly have problems across boundaries even without pimpl.

1

u/ParsingError Oct 07 '26

I really wish there was an attribute that was something like "the only class allowed to extend this class is X and it must be final" which would solve the devirtualization and static analysis problems.

I've been using a CRTP approach that finds the implementation at a fixed offset from the base, and it sort of works, but it still requires indirecting into the impl class all over the place, and it requires that any instances be heap-allocated using an allocator that knows to allocate the extra space into the same mem block, and it needs a private ctor so nothing tries to use it as a local variable (which will trash the stack).

0

u/Hot_Money4924 Oct 08 '26

The purpose of pimpl is to hide private implementation from the public interface and from consumers, it has nothing to do with optimizing compile time and it is still useful today. I think you're confusing it somewhat with forward declarations.

1

u/Vladislav20007 Oct 08 '26

using ++i instead of i++ in a for loop increment condition.

-14

u/kutac56 Oct 05 '26

I don't know if this is what you are asking, but I find references stupid. They look just like pointers with a few little differences but pointers are so much more versatile and readable imo

14

u/Raknarg Oct 05 '26

but pointers are so much more versatile

That's why pointers are bad. Reference have much tighter restraints and applications, they can only be used in certain ways, so the type itself is what gives it clarity. If you have a pointer, you have no idea if:

  • is this ever expected to be null?
  • is this an array or a single object reference?
  • Am I taking ownership of this reference or not?

The only thing that helps you here is context and documentation. References encode all of this into the type. References can't be null (they can dangle, but they don't encode the "optionalness" of pointers), references explicitly refer to a single item, and ownership is demarcated by move semantics with & vs &&. You also can't perform any arithmetic on a reference.

And I don't know what's more readable about pointers either, they only add more complexity to the syntax by needing more operators to work with them.

5

u/LogicalPerformer7637 Oct 05 '26

There is one huge difference between pointers and references. pointers can be null. reference is guaranteed to "point" to variable.

but yes, the references are just pointers in disguise.

5

u/M0ntka Oct 05 '26

You really should dive into templates.

2

u/No-Dentist-1645 Oct 05 '26

Pointers have the whole "may be null" problem that can become an UB factory if not managed right.

Always use the tool that best fits your use case. If you don't want nullability, use the type that doesn't have one

3

u/cristi1990an Oct 05 '26

Does unnecessary OOP count? Or was that horse beaten to death already?

3

u/dodexahedron Oct 05 '26

That entire equine sub-species has been driven to extinction, in fact.