C++ Logo

std-proposals

Advanced search

[std-proposals] Where standard library for working with packs?

From: Nikl Kelbon <kelbonage_at_[hidden]>
Date: Sat, 12 Aug 2023 15:18:17 +0400
A huge amount of code, extremely complex and slowing down compilation
speed, is written to do simple things.
Typical examples: searching in a pack by index, checking that pack contains
type, checking that all elements in the pack are unique

Seemingly strange and inapplicable things in practice, such as sorting
types in a pack, can actually be incredibly useful
Example:
there is a std::variant, but i want
* always get by type, since this is logical, and repeating types in a
variant are either an error or extremely strange code
* variant<int, double> must be equal to variant<double, int> because I want
to generate fewer types / code

But I can't write

using namespace std::types;
template<typename... Ts>
using my_variant = decltype(pack<Ts...> | sort | remove_duplicates |
insert<std::variant>);

***

Another example: I want a memory-efficient tuple. For this I want to sort
the types by size(alligment...)

---
I could implement this in a separate library, BUT
1. No one will connect the library for the sake of this, everyone will
write their own curves and bicycles incomprehensible to the reader for
thousands of lines
2. Any implementation outside the standard library would be very
inefficient, while the standard would allow compilers to make intrinsics.
So i propose a stl-algorithms std::ranges like standard library part, which
will consists of such basic primitives like find, sort, reverse, unique for
types

Received on 2023-08-12 11:18:29