Web++: A C++ Web Framework
You can pass std::tuple's elements in any order with this. I'm using this for passing allocators in any order; there was simpler solutions for that but allocators don't usually support copy assignment operator but do support copy constructors.
It got even better than that, now it "default constructs" the ones that you didn't pass too.
But clang doesn't seem to like it. I suppose I need to extract one of those lambdas out as a struct to fix that!
It would be less pretty though :)
But clang doesn't seem to like it. I suppose I need to extract one of those lambdas out as a struct to fix that!
It would be less pretty though :)
Web++: A C++ Web Framework
It got even better than that, now it "default constructs" the ones that you didn't pass too. But clang doesn't seem to like it. I suppose I need to extract one of those lambdas out as a struct to fix that! It would be less pretty though :)
I end up doing this;
C++ is stupid π
C++ is stupid π
The choice between
1.
For the first one I have to change lots of things, but it seems more convenient choice!
What do you think?
1.
Traits and SubTraits
2. TraitsPack and Traits
seems really hard.For the first one I have to change lots of things, but it seems more convenient choice!
What do you think?
This is "Interesting, confusing, feels like it should perform better, but you know it doesn't" kinda code.
The benchmark
Inspired by: Printing 1 to 1000 without loop or conditionals
The benchmark
Inspired by: Printing 1 to 1000 without loop or conditionals
Which one is the best alternative to
With these, you can make the static_assert(false), type-dependent; thus instead of evaluating it at point of compiling the function, it gets evaluated when the function's type is known which means
And also there's a std::dependent_false proposal which in this code is an alternative for always_fasle.
Click here to see the code
static_assert(false, "oops")?With these, you can make the static_assert(false), type-dependent; thus instead of evaluating it at point of compiling the function, it gets evaluated when the function's type is known which means
if constexpr statements work in that time.And also there's a std::dependent_false proposal which in this code is an alternative for always_fasle.
Click here to see the code
Web++: A C++ Web Framework
Which one is the best alternative to static_assert(false, "oops")? With these, you can make the static_assert(false), type-dependent; thus instead of evaluating it at point of compiling the function, it gets evaluated when the function's type is known whichβ¦
There are also alternatives to the "
!sizeof(decltype(input))" part which you can see here.artificial::mind blog
always_false<T>
template <class T> struct foo { static_assert(false, "must use correct specialization"); }; template <> struct foo<int> { // valid use of foo<T> ... }; Sometimes, good intentions are punished by the compiler: <source>:4:19: error: static assertion failed:β¦
Replace a template parameter of a templated type from A to B.
With this you are able to change a template parameter of a type from the old type to the new type that you specify.
This is particularity good for when you have want to change the allocator type from current allocator to the new allocator you want without knowing the templated type.
The source code
I'm going to use this to identify, and change your allocator type after finding the best allocator that matches your needs; but this thing is good for other template meta programmings as well.
Of course this has some limitations as well. For example if your templated type includes "auto" or "decltype(auto)" or any non-type template parameters, you will have a problem. This code only works on templated types that their types are types themselves and won't work on types that include template template (template <template...> typename) template parameters.
With this you are able to change a template parameter of a type from the old type to the new type that you specify.
This is particularity good for when you have want to change the allocator type from current allocator to the new allocator you want without knowing the templated type.
The source code
I'm going to use this to identify, and change your allocator type after finding the best allocator that matches your needs; but this thing is good for other template meta programmings as well.
Of course this has some limitations as well. For example if your templated type includes "auto" or "decltype(auto)" or any non-type template parameters, you will have a problem. This code only works on templated types that their types are types themselves and won't work on types that include template template (template <template...> typename) template parameters.
Meet tuple_filter; it helps you filter the types inside a std::tuple or any tuple-like type based on a C++20 concepts (or older versions if you'd like).
Unfortunately we're not able to directly pass a C++20 concept as a template so the user of this type has to pass a
See the source code on the Compiler Explorer
I've also implemented this in another way long ago while implementing the"extension system" of this project.
Here's the source code of that implementation on GitHub.
Unfortunately we're not able to directly pass a C++20 concept as a template so the user of this type has to pass a
template<typename> typename template struct containing static constexpr bool value.See the source code on the Compiler Explorer
I've also implemented this in another way long ago while implementing the"extension system" of this project.
Here's the source code of that implementation on GitHub.
Github removing bans for Iranian residence.
Good, now can we remove the git and browser's proxy configurations for github!
Honestly I didn't expected github to do this; now I know other companies CAN do this but they just DON'T WANT TO.
Nat Friedman Tweet about this
My Reply to that tweet
Github blog post about this
Good, now can we remove the git and browser's proxy configurations for github!
Honestly I didn't expected github to do this; now I know other companies CAN do this but they just DON'T WANT TO.
Nat Friedman Tweet about this
My Reply to that tweet
Github blog post about this
I introduce you "recursively_replace_template_parameter" type which does exactly what the name says (suggest a better name if you know any).
It recursively replaces template parameters from the specified template type to the new specified template type.
This is particularly good for example when you want to replace std::allocator with std::pmr::polymorphic_allocator in a series of types.
For example, you can replace vector<string> with pmr::vector<pmr::string> with it.
On Godbolt
GitHub Link
It recursively replaces template parameters from the specified template type to the new specified template type.
This is particularly good for example when you want to replace std::allocator with std::pmr::polymorphic_allocator in a series of types.
For example, you can replace vector<string> with pmr::vector<pmr::string> with it.
On Godbolt
GitHub Link
Web++: A C++ Web Framework
I introduce you "recursively_replace_template_parameter" type which does exactly what the name says (suggest a better name if you know any). It recursively replaces template parameters from the specified template type to the new specified template type. β¦
And the code for those 4 TMP utilities are this. π
I should/could also add the non-type template parameter replacer as well, but the I don't need it; at least not yet.
You can find the source at the core/std/type_traits.hpp file in Web++ project.
Template meta programming could be better if the language maker do something about it. You can do really interesting stuff with it.
The purpose of this utility that I made was to make sure my allocator_pack can correctly and recursively replace all the allocators in the specified type with the new allocator type that we find is the best choice there.
This way, the fastest allocator in the allocator pack (or I should call it resource pack maybe) is chosen without the user (or the library) explicitly telling it what allocator it should use.
I should/could also add the non-type template parameter replacer as well, but the I don't need it; at least not yet.
You can find the source at the core/std/type_traits.hpp file in Web++ project.
Template meta programming could be better if the language maker do something about it. You can do really interesting stuff with it.
The purpose of this utility that I made was to make sure my allocator_pack can correctly and recursively replace all the allocators in the specified type with the new allocator type that we find is the best choice there.
This way, the fastest allocator in the allocator pack (or I should call it resource pack maybe) is chosen without the user (or the library) explicitly telling it what allocator it should use.
This is my first live coding on Instagram. what do you think?
#code #coding #programming #live #livecoding #cplusplus #cpp #dev #development #tech #technology #techie #webdev #web #webdesign #webdevelopment
https://www.instagram.com/tv/CKRiu5ujo2g/?igshid=eg82mly0orvv
#code #coding #programming #live #livecoding #cplusplus #cpp #dev #development #tech #technology #techie #webdev #web #webdesign #webdevelopment
https://www.instagram.com/tv/CKRiu5ujo2g/?igshid=eg82mly0orvv
Web++: A C++ Web Framework
This is my first live coding on Instagram. what do you think? #code #coding #programming #live #livecoding #cplusplus #cpp #dev #development #tech #technology #techie #webdev #web #webdesign #webdevelopment https://www.instagram.com/tv/CKRiu5ujo2g/?igshid=eg82mly0orvv
Here you can find it on YouTube.
YouTube
Live Coding (Working on cookies) | web++
This is my first live coding I've done on Instagram;Web++ Github project: https://github.com/the-moisrex/webpp
YouTube is finding one of my videos violating copyright;
It's me during live coding, the sound of my keyboard typing.
I guess I typed a music π
https://youtu.be/W9qYYFHcm2k?t=2267
It's me during live coding, the sound of my keyboard typing.
I guess I typed a music π
https://youtu.be/W9qYYFHcm2k?t=2267