Show newer

C baggage to unlearn: in-place operators return a reference to the object

what's the difference between

template<typename T>
auto add1(const T& a, const T& b)
{ return a + b; }

and

template<typename T>
auto add2(T a, const T& b)
{ return a += b; }

?

would you call a wrapper type, that holds a pointer to a container provides a range interface through that pointer, a range_reference or a reference_range?

hmmm... referring_range?? indirect_range???

why would you ever need aligned storage for a single object that just holds a couple of references?

the aligned storage
github.com/OpenBW/openbw/blob/

the class it's used with
github.com/OpenBW/openbw/blob/

is it some kind of "as long as it's aligned it's atomic" x86 nonsense? tempted to just nuke it all...

Show thread

things that bit me:

operator precedence
note: algebra am I right?

overload resolution
note: a universal reference without type constraints in an overload set should be a yellow flag

value/reference semantics:
note: if you want to absolutely make sure you are referring to a value as a constant and not owning one, use const pointer to const value (or something like std::reference_wrapper to exclude nullptr), not a const reference, since, as we all know, a const reference can bind to a temporary and extend its lifetime.

final thoughts: god I wish I had a garbage collector or a borrow checker to save me from... wait none of these are memory errors? how come?

Show thread

ended up reworking a lot of the ui code... all the Xes and Ys and half-assed SDL wrappers were getting on my nerves, so partially replaced them with my own half-assed SDL wrappers and vector library...

notabug.org/fuglycodelord420/o

what's new objectively? well you can make an SCV now by pressing S...

Show thread

so the only value of CMake is that it works on windows? which would be negative value... like every system comes with it's own programming environment and package manager and stuff, and you're like "no, the objective reasons by which you chose your system are irrelevant, a language gotta have a unified build system that nullifies them, hurr durr"...

witness code compression (>^-^)>
ix.io/3vy0/cpp

>but you introduced three new libraries :v

libraries don't count :V

>but your version is also slower :v

it can be optimized >:V nothing inherently slow about it :<

Show thread

apparently MSVC has no problem binding temporaries to lvalue references... why yes, of course, let's break the most basic building blocks of the language

libstdc++ manual: These debugging containers are functionally equivalent to the standard drop-in containers used in debug mode [1]

me: but why isn't std::string detecting iterator invalidation, like __gnu_debug::string, what am I doing wrong :/

libstdc++ manual: *goes on a huge rant about how awesome libstdc++ is* ... The end result is that we have achieved per-use recompilation but have had to give up some checking of the std::basic_string class template (namely, safe iterators). [2]

me: why thanks for being so honest and upfront about that, I totally didn't waste all day looking into this thanks to you -_-

1. gcc.gnu.org/onlinedocs/libstdc
2. gcc.gnu.org/onlinedocs/libstdc

my brain on c++:
spends hours on an elaborate meta programming to implement private friend functions with perfect forwarding, only to realize that it's solving the wrong problem and all it actually needed was a const member function...

compiler bugs, will they ever stop harassing me?

ix.io/3pji/cpp

aka another reason to never use built-in arithmetic types.

Undefined behaviour means "if you do this, anything may happen", and even though you most certainly shouldn't do it, it doesn't mean "don't do this", hence if you actually define it to something specific, you create a subset and not a superset of the programming language.

clang is infinite looping and/or crashing on me again -_-

JUCE framework is a freakin joke. Here I thought it's a comprehensive toolkit for low level audio programming, but turns out it's a useless Qt wannabe.

You know what's important for audio programming? Threads. Can you please thread safety, a framework that takes away my main() and handles GUI with a custom freakin build system? No? Apparently that's fine because 32 bits ops are atomic on x86, hurr durr. Also the only sample type is float, cause you know C++ is known for no generic code whatsoever, none, not a part of the language, never been. Wanna playback a standard pcm data from memory? How about a backwards file stream API that has a specialization to read from memory, and a audio callback that is going to convert it to float regardless of what it is and what the sound hardware supports? And don't forget to bring your own ring buffer, pleb. If you don't have one go to our community forum, where you will be told to git gud.

so since we don't have a proper search till c++20:
ix.io/3nAa/cpp
gotta love the do-if-while.

shame ix.io html doesn't highlight the if though, so maybe
curl ix.io/3nAa+cpp
instead.

the rage type is just a simple aggregate that holds the two iterators and provides the usual begin-end interface, no magic there.

why do bit operations on bool return an int? doesn't that defeat the whole point of bool? do I have to redefine every single fundamental type to not be insane?!

stlab.cc/2020/12/01/forest-int
it's like beads on a string, so lets call it... a forest... of course... following in the footsteps of std::vector -_-

why the hell is set_difference not allowed to be in-place?

Show older
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.