Date: Tue, 15 Apr 2025 01:21:20 +0100
Has there ever been any talk about making a concept extensible? i.e.
you can change it after its original definition?
For example, let's say that "std::arithmetic" were to start out as:
template <typename T>
concept arithmetic = is_arithmetic_v<T>;
but we mark it as 'extensible' to indicate that you're allowed to
change it later, something like:
template <typename T>
extensible concept arithmetic = is_arithmetic_v<T>;
Then someone comes along and writes one of those arbitrary precision
math libraries, and they have a class called "HugeInt", and they want
to tell the compiler that "HugeInt" is an arithmetic type, so in the
header file for "HugeInt", they write a line something like as
follows:
concept arithmetic << HugeInt;
which changes the "std::arithmetic" concept as though it had
originally been written:
template <typename T>
concept arithmetic = is_arithmetic_v<T> || is_same_v<T, HugeInt>;
Of course, this would mean that "std::arithmetic" would have different
definitions in different translation units, but it wouldn't matter
because the translation units that don't include the HugeInt header
file won't ever use the HugeInt type.
you can change it after its original definition?
For example, let's say that "std::arithmetic" were to start out as:
template <typename T>
concept arithmetic = is_arithmetic_v<T>;
but we mark it as 'extensible' to indicate that you're allowed to
change it later, something like:
template <typename T>
extensible concept arithmetic = is_arithmetic_v<T>;
Then someone comes along and writes one of those arbitrary precision
math libraries, and they have a class called "HugeInt", and they want
to tell the compiler that "HugeInt" is an arithmetic type, so in the
header file for "HugeInt", they write a line something like as
follows:
concept arithmetic << HugeInt;
which changes the "std::arithmetic" concept as though it had
originally been written:
template <typename T>
concept arithmetic = is_arithmetic_v<T> || is_same_v<T, HugeInt>;
Of course, this would mean that "std::arithmetic" would have different
definitions in different translation units, but it wouldn't matter
because the translation units that don't include the HugeInt header
file won't ever use the HugeInt type.
Received on 2025-04-15 00:21:33