C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Detection of whether a determined user-defined literal is declared

From: Jens Maurer <jens.maurer_at_[hidden]>
Date: Tue, 15 Aug 2023 18:25:29 +0200
Hi,

Could you give a few examples how to use this facility,
and why the usual expression-checking machinery of
concepts isn't enough?

Jens


On 15/08/2023 17.56, veronica alphonso via Std-Proposals wrote:
> I would like to add a feature to the concepts(or type_traits if it's a better fit) library, which determines whether a user-defined literal is defined in the actual TU given the types of the param-list and the suffix for it, like:
>
> namespace std {
> enum class user_defined_literal_parameters : uint8_t{
> const_char_pointer = 0u,
> unsigned_long_long_int = 1u,
> long_double = 2u,
> char_ = 3u,
> wchar_t_ = 4u,
> char8_t_ = 5u,
> char16_t_ = 6u,
> char32_t_ = 7u,
> const_char_pointer_with_size = 8u,
> const_wchar_t_pointer_with_size = 9u,
> const_char8_t_pointer_with_size = 10u,
> const_char16_t_pointer_with_size = 11u,
> const_char32_t_pointer_with_size = 12u
> };
>
> template<user_defined_literal_parameters param, const char* suffix>
> concept user_defined_literal = /* to determine... */;
>
> template<class R, user_defined_literal_parameters param, const char* suffix>
> concept user_defined_literal_r = /* to determine... */;
> }
>
> where:
>
> - `R` is the returning type(can be optional in the form of an extra concept for the users that might don't care about the returning type of the user-defined literal)
>
> - `param` defines the parameter declaration clause and
>
> - `suffix` defines the user-defined suffix used for the user-defined literal
>

Received on 2023-08-15 16:25:35