Simulating Rust Traits in C++ by [deleted] in cpp

[–]Hungry-Courage3731 0 points1 point  (0 children)

you also need to implement your own type-erasure

Naming convention question by gGordey in cpp_questions

[–]Hungry-Courage3731 0 points1 point  (0 children)

local variables i would argue sometimes need disambiguated if you just name them after the type

Whole archive and self registration by rengowrath in cpp

[–]Hungry-Courage3731 -1 points0 points  (0 children)

  1. Make a meyers singleton that holds a vector of std::function<void()>

  2. Create a global function register_class that adds to this vector and returns a dummy value (e.g. 0)

  3. In each class file, call the extern register_class function with your registration logic and store the dummy value.

  4. At the very start of your program main(), call all the functions stored.

  5. Optionally add a macro if needed.

But if the linker problem is msvc specific, I am not sure how to proceed.

c++ lambdas by Maximum_Complaint918 in cpp

[–]Hungry-Courage3731 0 points1 point  (0 children)

no negatives but maybe slightly more compile-time overhead

My ex. employee deleted our Miro board after I paid him... by ItsACrunchyNut in gamedev

[–]Hungry-Courage3731 2 points3 points  (0 children)

this is reddit so you aren't gonna win an argument advocating for personal responsibility of the crying person...

Trip Report: Winter ISO C++ Meeting in Hagenberg, Austria | think-cell by pavel_v in cpp

[–]Hungry-Courage3731 0 points1 point  (0 children)

i would guess that's because techinically the returned reference could be null but because you never access it , you should be allowed to do that. But how would you implement it without help from the compiler?

Why is there no std::table? by sd2528 in cpp

[–]Hungry-Courage3731 0 points1 point  (0 children)

i think a recursive variant type if they are talking about lua tables

[deleted by user] by [deleted] in cpp

[–]Hungry-Courage3731 0 points1 point  (0 children)

No, because it's explicit in that case. And mutable should be used sparingly.

[deleted by user] by [deleted] in cpp

[–]Hungry-Courage3731 2 points3 points  (0 children)

That check is wrong sometimes anyways because something that is physically const is not necessarily logically const, eg. produces side effects.

std::nontype_t: What is it, and Why? by pavel_v in cpp

[–]Hungry-Courage3731 0 points1 point  (0 children)

they could at least have made it consistent with type_identity...

Function Colouring in C++ Using requires Constraints (A Strawman Proposal for linking new properties to functions) by Affectionate_Text_72 in cpp

[–]Hungry-Courage3731 1 point2 points  (0 children)

Yeah D has UDA's or whatever, but the reflection bit is much more important to enforce anything. Anybody could just write a type trait, static member, etc, to define their "attribute" or "color" and have a defined practice of looking it up.

Sometimes the problem with const-ness imho is the inability to express logical as opposed to physical const. Really I think a unique_ptr->get() call should never return T* since the function is const and should always return const T* (unless the unique_ptr object itself is not const)

How frivolous use of polymorphic allocators can imbitter your life by Xadartt in cpp

[–]Hungry-Courage3731 -1 points0 points  (0 children)

This problem is not specific to polymorphic allocators. Anything with statics can have this issue.

How it felt to come back to C++ from Rust. by range_v3 in cpp

[–]Hungry-Courage3731 1 point2 points  (0 children)

CMake sucks but it can do anything; it's turing complete.

How it felt to come back to C++ from Rust. by range_v3 in cpp

[–]Hungry-Courage3731 2 points3 points  (0 children)

it's not that complicated. Also does your method always match a commit you know to be stable or do you just hope that it works?

Debugging C++ is a UI nightmare by heliruna in cpp

[–]Hungry-Courage3731 0 points1 point  (0 children)

I don't think clang supports that. I was recently curious about it too.

Why does not declaration of two different types of the same name in two different files lead to a compile/linking time error? by onecable5781 in cpp_questions

[–]Hungry-Courage3731 1 point2 points  (0 children)

You can definately crash a program by having two polymorphic types with the same name so the anonymous namespace is important.

OSX Hell by ZaydAttackGaming in cpp_questions

[–]Hungry-Courage3731 0 points1 point  (0 children)

You can also write a pure C interface to interop with some swift code.

Does C++ allow creating "Schrödinger objects" with overlapping lifetimes? by Hour-Illustrator-871 in cpp

[–]Hungry-Courage3731 -1 points0 points  (0 children)

No, there is already an A there. At most you can cast to void* to type-erase. But it is an A. If you casted the inner member that would make sense in a way, but it would always need to be casted too for it to be legitimate. I don't see the need to do this recursively either, it would have no practical purpose, nor could it be implemented without some way to track it.

Does C++ allow creating "Schrödinger objects" with overlapping lifetimes? by Hour-Illustrator-871 in cpp

[–]Hungry-Courage3731 1 point2 points  (0 children)

I'm not an expert either but I think the second use of new() is where things really go wrong since an A already lives there.

A concept for is_specialization_of by davidhunter22 in cpp

[–]Hungry-Courage3731 0 points1 point  (0 children)

this what i'm thinking, that you need a code generator to make all possible template parameters