Tootfinder

Opt-in global Mastodon full text search. Join the index!

@smurthys@hachyderm.io
2024-05-23 18:29:03

Wish #cpp allowed concept definitions in class scope, not just namespace scope. DRY, better encapsulate class, reduce litter outside class.
E.g., if a class has many functions w "strict bool" parameter:
- (a) works, not DRY
- (b) DRY but concept visible in client along with class
//a: repeat w each function
template<typename B> requires std::same_as<B, bo…

@smurthys@hachyderm.io
2024-05-23 18:29:03

Wish #cpp allowed concept definitions in class scope, not just namespace scope. DRY, better encapsulate class, reduce litter outside class.
E.g., if a class has many functions w "strict bool" parameter:
- (a) works, not DRY
- (b) DRY but concept visible in client along with class
//a: repeat w each function
template<typename B> requires std::same_as<B, bo…

@smurthys@hachyderm.io
2024-03-25 14:38:28

Code in posts complaining about C is quite often actually/largely C code. ☹️
#cpp #cPlusPlus #c #peeve

@smurthys@hachyderm.io
2024-04-21 01:35:46

Returned to C programming after needing 25 attempts to make one basket, while my wife made at least five in the meantime. 😓
"Play to your strengths" is how I consoled myself. 😁
#cpp #workAndPlay

A toy indoor basketball net hung on a white interior closet door.
@smurthys@hachyderm.io
2024-04-21 01:35:46

Returned to C programming after needing 25 attempts to make one basket, while my wife made at least five in the meantime. 😓
"Play to your strengths" is how I consoled myself. 😁
#cpp #workAndPlay

A toy indoor basketball net hung on a white interior closet door.
@matematico314@social.linux.pizza
2024-05-27 19:46:45

kkkk, bug pra pegar distraídos rs. Mas até que eu percebi ršpido aonde estava errado, nem precisei do depurador. #cpp

Tela de um IDE de c++ aonde se lê o seguinte código:
bool smartFileLoaderClass
@smurthys@hachyderm.io
2024-06-18 16:22:10

`enum class` does not make the enum a class.
An old C saying.
#cpp #saying #programming

@matematico314@social.linux.pizza
2024-05-26 16:56:14

Vocês costumam nomear seus arquivos de header em c como .h ou como .hpp? #cpp

@smurthys@hachyderm.io
2024-06-16 19:06:08

True story: At the end of a class introducing C operator overloading, a student approached me and said: "I think you just broke me."
#cpp #teaching #trueStory

@smurthys@hachyderm.io
2024-04-15 18:14:42

A "simple" #cpp exploration in #CompilerExplorer evolves to a "library" and you have to move code to an IDE to manage complexity. 😟
But a testament to Compiler Explorer's ability to support serious experimentation and take ideas quite far. Not just a scratchpad.
Pr…

@smurthys@hachyderm.io
2024-04-15 18:14:42

A "simple" #cpp exploration in #CompilerExplorer evolves to a "library" and you have to move code to an IDE to manage complexity. 😟
But a testament to Compiler Explorer's ability to support serious experimentation and take ideas quite far. Not just a scratchpad.
Pr…

@smurthys@hachyderm.io
2024-05-23 18:06:13

Writers and artists: musings
C programmers: usings
#ifkyk #cpp #cPlusPlus #pun

@smurthys@hachyderm.io
2024-05-23 18:06:13

Writers and artists: musings
C programmers: usings
#ifkyk #cpp #cPlusPlus #pun

@smurthys@hachyderm.io
2024-04-15 19:37:18

Starting a new C project in VS Code is such a pain. 🤕
You'd think copying the .vscode folder from another working project (with same tools and settings) makes the new project buildable straightaway, but no. Instead, I have to make all the same mistakes and fixes with every new project.
What a waste of time. ☹️
#cpp

@smurthys@hachyderm.io
2024-04-15 19:37:18

Starting a new C project in VS Code is such a pain. 🤕
You'd think copying the .vscode folder from another working project (with same tools and settings) makes the new project buildable straightaway, but no. Instead, I have to make all the same mistakes and fixes with every new project.
What a waste of time. ☹️
#cpp

@smurthys@hachyderm.io
2024-06-07 21:44:25

Keep your drafts N4659, N4868, N4950,... and keep your hands off my cppreference dot com. 🤓
#cpp #learning

@smurthys@hachyderm.io
2024-06-03 17:23:43

So, what happened to the C `constexpr switch`? Or is the cruelty of `constexpr if` chain the point? 😕
#cpp #question #programming

@smurthys@hachyderm.io
2024-06-03 15:00:00

C peeps, raise your hand if these days you seem to instinctively open angle bracket after decltype and static_assert. TMP FTW.

#cpp #TMP #metaProgramming

@smurthys@hachyderm.io
2024-06-02 18:07:58

GCC compiler messages for C are more/quite useful now, once you fish them out of the template vomit. Fishing is still a requirement though.
#cpp #GCC

Yellow text on black background:

warning: this 'if' clause does not guard...  -Wmisleading-indentation]
   27 |           if constexpr (...)
      |             ^~
note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
@smurthys@hachyderm.io
2024-06-14 19:43:37

Unit testing custom exceptions expected in C fn.s, it's better to check if exception has the right context info (say error code). Checking what() instead is a maintenance nightmare: need lot of changes if msg format changes.
IIUC Catch2 only permits matching on what(). Is Google Test better? Or is there a better way to do this in Catch2 and I just don't know?
PS: Exception subclassing is not the solution.

@smurthys@hachyderm.io
2024-03-28 21:02:56

Proposal to improve #cpp type safety. 💬 🔃 🙏🏽 💡
1. Lossless assignment
long l := 1; //OK
float f := 1; //OK
int i := false; //OK
char c := 128; //error if signed 8-bit char
bool b := 5; //error
2. "Strict assignment" requires exact type
int i ::= 1; //OK
long l ::= 1; //error
float f ::= 1; //error
int i ::= false; //error

3.…

@smurthys@hachyderm.io
2024-05-28 02:43:00

Keep your drafts N4659, N4868, N4950,... and leave me cppreference dot com. 🤓
#cpp #learning

@smurthys@hachyderm.io
2024-06-07 19:27:08

Ironically, C template programming can end up promoting the use of macros because too much template boiler plate, especially in member function templates in class templates.
E.g., a well-designed and formatted macro reducing five lines of boiler plate to just one line. And the macro is used eight times which greatly improves overall readability compared to the original noisy and recurring template boiler plate.

@smurthys@hachyderm.io
2024-05-29 22:56:47

I just wrote a C function with two uninitialized variables whose values are defined by non-trivial logic that follows. Justified, yet I feel like I committed a crime. But that's how rare uninitialized variables should be in code.
Did my best to assure future readers of the code:
//x, y guaranteed to have intentional values before use
X x;
Y y;
PS: I'm aware of lambdas, structured bindings, std::pair 🙏🏽

@smurthys@hachyderm.io
2024-06-05 20:14:18

English saying: April showers bring May flowers.
C saying: auto variables bring decltype inspections.
#cpp #sayings #joke #nerdJoke

@smurthys@hachyderm.io
2024-06-05 20:14:18

English saying: April showers bring May flowers.
C saying: auto variables bring decltype inspections.
#cpp #sayings #joke #nerdJoke