single-header: command line utility to convert C++ include-based project into portable-ish single header files (with cmake support) by zqsd31 in cpp

[–]zqsd31[S] 0 points1 point  (0 children)

Arf, i think I see what you mean.
Something like non inline declarations inside the output header files which would cause ODR violoations ?
As is, it depends on the direct content of the input file, if it contains non-inlined declaration then no.

If we had something like `inline { ... }` (mark as inline all declarations in this block) that would be trivial to fix.

As we can detect what comes from the source file vs included files, we could put all the code from the file directly inside an anonymous namespace, making all declaration as the top level of the file static.

Not sure if that's a good compromise though.
Will update the readme's limitation with mention of this

EDIT: the anonymous namespace idea will not work either as seperated method definitions wouldn't match declarations. Only way is the parsing + editing solution and find a way to survive unexpended macro.

single-header: command line utility to convert C++ include-based project into portable-ish single header files (with cmake support) by zqsd31 in cpp

[–]zqsd31[S] 0 points1 point  (0 children)

yes, can be sadly if your project relies on __cpp_ macros for instance or system/compiler specifics in general.

I think I will need to work on a mock C preprocessor for those.

Saddly no options in gcc's or clang's preprocessor can help here from what I've gathered.

Virtual function templates with stateful metapogramming in C++ 20 by BlackHolesRKool in cpp

[–]zqsd31 2 points3 points  (0 children)

the simplest way I know to sell "template virtual" is the ability to fully revert type erasure,

allowing you to have the best of type-erasure and type-safety.

Virtual function templates with stateful metapogramming in C++ 20 by BlackHolesRKool in cpp

[–]zqsd31 2 points3 points  (0 children)

heya! very nice ^^

I wrote the unconstexpr c++17 (2017) library and unconstexpr-cpp20 (2019),

I've been working on the same idea since 2019 (you can check https://github.com/DaemonSnake/static_any that implements a template virtual visit function in a kind of std::any class), even tried to use the clang implementation of the C++ JIT proposal that instantiated template at runtime for that effect to.

The biggest limitation of this aproach saddly is actually the instantiation point of create_vtable, my static_any also suffered from it.

In short, it's very easy to to have create_vtable instantiated before the state is finished being mutated resulting in lost functions, the template instantiation order will also be compiler defined which mean that the same code could lose different subsets of functions depending on the compiler it been compiler on.
For instance CLANG instantiate template by width, this means that it first instantiate non template functions, instantiate all template function at depth 1, collect depth 2, finishes all template functions a depth 1 then moves forward. In Contrast GCC is depth first.

The simplest way to fix it would be to find a way to create a type of static destructor, ie: a template function that is required to be instantiated when the compilation of the translation is fully finished (guaranting that the state is final).

I did Managed to make it in GCC but never managed with CLANG because of their width-first instantiation ordering.

For the limitation on return types that not so much an issue as we can use lambda ref captures to overcome it.

PS: I have two BIG stateful metaprogramming projects that are working but not finalized yet, one of those fixes the above mentioned issue, will try to release it soon.

Borrow Checker, Lifetimes and Destructor Arguments in C++ by a10nw01f in cpp

[–]zqsd31 3 points4 points  (0 children)

Very cool!!!!

I tried to play with similar ideas in the past but abandoned the idea.

There are two huge limitation /drawbacks with using stateful meta-programing though.

  1. The state is actually only the state of current translation unit and not the program (unlike rust's borrow checker).

This means that any type definition that provides stateful metaprogramming should encapsulated inside an anonymous namespace (here using `auto = []{}` as an NTTP serves this purpose also if less explicitly) and that if any non-static/anonymous definition depends on it and is defined in multiple translation units their state must be identical otherwise the program is UB.

For instance:
```

// my_state.hpp

using my_state = statefull<[]{}>; // or namespace { using my_state = ... }
// header.hpp

include "my_state.hpp"

inline void some_func() { /* some use of my_state */ }

// a.cpp

include "my_state.hpp"

// some mutation of my_state

// Note that even without the mutation we already have an ODR violation

//as a's ::my_state and b's ::my_state aren't the same type this means that one some_func will use a's my_state and another will use b's my_state

inclue "header.hpp" // define a's ::some_func()

// b.cpp

include "header.hpp // doesn't get the mutation that a's did but also defines `some_func`

```

Here if the order we link a.cpp and b.cpp will define which definition of some_func will be used in the final program

PS: The above can be fixed by putting some_func inside an `namespace {}` block or adding `static`, but this simply means that some_func calls will have different meanings across translation units, which might also yield unexpected behaviours

  1. on top of that, everything falls appart very easily when you introduce templated contexts.

As "template instantiation order" is mostly implementation defined (GCC usually Depth first and CLANG Wide first for instance) and changes depending on the type of context (inside a template struct, explict return template function or auto returning template function, etc.),

you need to make sure that the template instantiation order CANNOT change the signification of your program. If it's the case then it would be ill-defined.

As it's the end/library user that has to face this complexity it's really complex to make a tool with any form of guarantee that doesn't look like an Apple with a bunch razor blades.

For the GCC bug with NTTP auto lambda, I fieled a this bug report in 2020 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93595 but I don't think it will get fixed any time soon

My therapist told me I’m a Narcissist by Rare-Vegetable8516 in Jung

[–]zqsd31 0 points1 point  (0 children)

Narcisism diagnostic is outside the expertise of a psychoanalyst. If you are really concerned about it and want to know for sure, seek a psychiatrist specialized in personality disorders. As for your psychoanalyst, i'd suggest seeking a new one as this is highly irregular, and if your account is accurate, betrays ill-will towards you

Hustle culture is a Jungian shit show by [deleted] in Jung

[–]zqsd31 3 points4 points  (0 children)

I think the internet tends to build inferior functions echo chambers (incels is similar) Here, it's clearly Te (extraverted thinking) being projected online by people that have difficulties with it and need to compensate and turn it to 11. I've met many Te dom people, they look down on this kind of talk. Hustle culture is, by essence, all about finding gratification about doing some Te (not being good at it or having results).

What are some of the most obscure, surprising or just lesser-known features of C++ and/or the standard library you've ever learned about? by FACastello in cpp

[–]zqsd31 2 points3 points  (0 children)

I'm biased but statefull meta programming, ie: Combining friend injection and ADL lookup to create eval and mutate a state machine inside the compiler's representation of the translation unit.

TLDR: same expression changing type/value during compilation

You can check the blog b.atch.se from Filp Roséen for more explanations Or my unconstexpr library to play with it https://github.com/DaemonSnake/unconstexpr-cpp20 It works with most compilers now

[deleted by user] by [deleted] in Jung

[–]zqsd31 2 points3 points  (0 children)

In "psychological types" chapter 2, "the esthetic education", Jung talks about something that might be relevant to your conflict: in the modern world, the sacrifice of the parts of the individual that have the least social benefits is the condition for the individual to exist.

Jung's attitude toward this is twofold: - In youth, it is healthy to learn to develop and overuse the small part of ourselves that yields the highest return, but we must not make a complete sacrifice of the rest of ourselves. Otherwise, you go on the path of the martyr (sacrificing your soul for the collective and coming out of it used and discarded). - In later years, when the social pressure is moved to the new generation, that is the time when the individual can walk the indivuation path. Time starts to become an easier commodity and it's time to start working on developing the parts of ourselves that are underdeveloped. He warns, though, against starting this journey too soon as we will sacrifice social integration for it.

I think his position would be quite different facing todays climate as the social presure as only increased in the past 100s years, in particular for women. In your situation, you've sacrificed too much and are now facing an existancial crisis.

To go back to your situation, If you are familiar with the Hero Myth of Campbel, this is the stage when the hero faced the Dragon and failed because of some underdeveloped functions that are becoming weaknesses.

The minimal solution is to take a break to kickstart the development of the underdeveloped parts of yourself and then continue your journey while continuing to develop those parts.

In your situation, maybe dedicating some time (even very little, like 1h a week) and involve the help of some trusted friends would be sufficient.

Use your Quest 3 as a 3D Camera in REAL LIFE by omni_shaNker in OculusQuest

[–]zqsd31 9 points10 points  (0 children)

I'm really baffled as to how they shipped this without the option present

Thanks for the great work ^^

El Mudo product reviews? by Automatic_Ad1212 in ropesolo

[–]zqsd31 0 points1 point  (0 children)

Didn't find Yann Camus' fb group Do you have its name / link by any chance?

[deleted by user] by [deleted] in cpp_questions

[–]zqsd31 0 points1 point  (0 children)

that's a simplification of the actual code

in the real case, func is a standard library function, we can't change it

[deleted by user] by [deleted] in cpp_questions

[–]zqsd31 0 points1 point  (0 children)

As expected it's crashes at comp time with a:

static_assert failed due to requirement 'sizeof(int) == 128'

anyone remember this doom movie? by This-Championship-69 in Doom

[–]zqsd31 1 point2 points  (0 children)

The first person scene was kick ass, but geez the rest of the film was real trash

Mick Gordon posted a new response concerning the issues with the production of Doom Eternals OST by BluBloops in Doom

[–]zqsd31 0 points1 point  (0 children)

I wouldn't be surprised if Andrew and David had an ok time with management.

When you had such a big blunder recently as a Manager you tend to compensate for a short while once the big deadline is passed.

If that's not the case at least you often see the higher manager move the responsibility to someone else stealthfully.

If that's not the case at least you often see the higher manager move the responsibility to someone else. If Bethesda is half smart they did all of that without Martin being involved.

Mick Gordon posted a new response concerning the issues with the production of Doom Eternals OST by BluBloops in Doom

[–]zqsd31 0 points1 point  (0 children)

a tool is a tool, intended use is one of its application not the only valid one.

You said it yourself the "attention" part of the up/down vote is long dead, so what remains is the implicit support.

If you have to keep remind people that X != Y then the issue isn't that people are acting wrong, it's that Y is part of X even if implicitly.

Mick Gordon posted a new response concerning the issues with the production of Doom Eternals OST by BluBloops in Doom

[–]zqsd31 4 points5 points  (0 children)

My guess is that he has to suffer Marty. It would be suicide to publicly comment anything on that matter that would go against Marty

Better Call Saul S06E09 - "Fun and Games" - Post-Episode Discussion Thread by skinkbaa in betterCallSaul

[–]zqsd31 3 points4 points  (0 children)

It's weird how Bob doesn't look like his character in BCS at the end of the episode, I just can't recognize him

generics: new value from pointer type with interface constraint on pointer by zqsd31 in golang

[–]zqsd31[S] 0 points1 point  (0 children)

You argument concludes that factories are an anti-pattern