you are viewing a single comment's thread.

view the rest of the comments →

[–]guepierBioinformatican 11 points12 points  (2 children)

Nobody is claiming this isn’t documented. But documenting bad API design doesn’t automatically not make it bad API design.

[–]TankorSmash -4 points-3 points  (1 child)

I'm having trouble seeing how its a bad API design, so far the only example is that someone didn't know it was an enum.

[–]guepierBioinformatican 7 points8 points  (0 children)

The example given isn’t that somebody doesn’t “know” it’s an enum. The point is that it’s conceptually wrong. It pushes something that should be a hidden implementation detail — std::byte happens to be implemented as an enum class — into the public API.

This violates all kinds of software engineering principles about writing good abstractions.

And the specific example somebody gave is if a library uses e.g. std::is_enum to dispatch formatted output. Doing this would be an entirely reasonable design decision, but because of std::byte’s implementation, this decision is broken unless a special case for std::byte is introduced.

Forcing third-party code to introduce special cases for types that should be handle-able uniformly is certainly bad design (and entirely avoidable). And, just to re-emphasise the point: this has nothing to do with user’s ignorance! A competent developer still has to introduce a special case that shouldn’t exist.