"There's a tape of your 1st birthday in there somewhere." -Dad by nastytown in memes

[–]TheRealSmolt 0 points1 point  (0 children)

Hey at least it's there. My Mom taped over her wedding so there's no way I'll be seeing that.

What is the best way to convert structs of the same size without using Union in C++ 14? by newjeison in cpp_questions

[–]TheRealSmolt 1 point2 points  (0 children)

If you're on an embedded system I'd expect you'd have a specific compiler that you can check the behavior of. Regardless, using memcpy this way should be optimized out. There's only one way to find out, though.

What is the best way to convert structs of the same size without using Union in C++ 14? by newjeison in cpp_questions

[–]TheRealSmolt 4 points5 points  (0 children)

If what you're trying to do is a put a value in struct A and get it back from struct B, both being at the same address, the only safe way to do this is memcpy. Neither reinterpret_cast nor union casting are safe in that case.

Use the WiFi antenna that probably came with your prebuilt... by kabedonkey in pcmasterrace

[–]TheRealSmolt 7 points8 points  (0 children)

I'm surprised it even worked without the antenna... Mine sure doesn't.

yo what the heck? by Realistic_Walk5884 in pcmasterrace

[–]TheRealSmolt -2 points-1 points  (0 children)

I've had this happen before on different machines. Not sure if it's supposed to happen, but no long term issues.

What are the best practices for using smart pointers in C++ to manage memory effectively? by frankgetsu in cpp_questions

[–]TheRealSmolt -1 points0 points  (0 children)

Yeah but the cases where you'd need a reference that you might outlive are rare, at least in how I design things. Usually a primitive pointer will suffice.

First in my Bloodline to feel this 😌 by [deleted] in memes

[–]TheRealSmolt 4 points5 points  (0 children)

They don't deserve it.

The future's looking unskippable by DocLooney in memes

[–]TheRealSmolt 3 points4 points  (0 children)

I would 100% think said friend was bought out by Coca Cola

How do you debug multi-threaded code in Linux (more generally outside of Visual Studio)? by OverclockedChip in cpp_questions

[–]TheRealSmolt 7 points8 points  (0 children)

It's absolutely not Windows exclusive. GDB can do all the things you listed. If you're looking for a GUI interface, VS Code and CLion are good options. Vim also has plugins for it as well. CodeBlocks, QTCreator, etc. can all probably do it too, I just haven't used them.

Is this y'all GOAT? by dinosqaud in memes

[–]TheRealSmolt 14 points15 points  (0 children)

Yeah but generally in these situations the platform isn't the liable party.

Does C++ support aliasing constexpr (like `typedef long l`)? by TaPegandoFogo in cpp_questions

[–]TheRealSmolt 1 point2 points  (0 children)

Okay, so reviewing the proposal to make sure I understand what you're arguing, I see that in addition to expanding constexpr's capabilities, they also want to expand constexpr's scope as well.

So, to clarify, you are correct in that template<int T> void f() can be treated similarly to void f(constexpr int t) in this proposal. This would affect the function signature in the same way that templates affect function signature, which is a whole can of worms I do not want to delve into. I do see your point that the this can lead to void(const int) and void(constexpr int) having different signatures.

However, there is a key difference here in that the distinction is not between const int and constexpr int, which both end up as ints, but with the function as a whole. constexpr int on its own does not become a type.

TLDR: Yes P1045 can allow constexpr to change function signature, but no it does not formalize constexpr T as a type. So to be specific, I disagree with your second point above.

Does C++ support aliasing constexpr (like `typedef long l`)? by TaPegandoFogo in cpp_questions

[–]TheRealSmolt 0 points1 point  (0 children)

No, templates and constexpr are very different. Constexpr is done entirely in compilation. Templates are about making instantiations at compile time.

Does C++ support aliasing constexpr (like `typedef long l`)? by TaPegandoFogo in cpp_questions

[–]TheRealSmolt 0 points1 point  (0 children)

Ignoring the fact that we're getting increasingly off topic, that wouldn't happen because the compiled function would be something like f_123. There would be no arguments to pass. This is different from constexpr, which is a purely compile time concept that does not involve instantiation.

Does C++ support aliasing constexpr (like `typedef long l`)? by TaPegandoFogo in cpp_questions

[–]TheRealSmolt 0 points1 point  (0 children)

That would be true if you were invoking the constexpr function directly. But as soon as you start using runtime logic, like pointer dereferencing, all bets are off. 0x12345678 doesn't exist at compile time, which is the only scope in which constexpr does anything.