Date: Thu, 21 Sep 2023 01:08:01 -0600
Never mind, I just discovered the "string literal operator template".
On Wed, Sep 20, 2023 at 11:36 PM Chris Gary <cgary512_at_[hidden]> wrote:
> The thought just occurred to me that I really need to have the characters
> themselves available as template parameters in order to create static
> buffers.
>
> In essence, a variation of numeric literal that can handle other types of
> code unit...
>
> On Wed, Sep 20, 2023 at 10:53 PM Chris Gary <cgary512_at_[hidden]> wrote:
>
>> I believe this is not allowed, and that the idea hasn't circulated:
>>
>> template< std::size_t size_ >
>> constexpr FancyString operator ""_Str( const char (&str)[size_] ) noexcept
>> {
>> etc...
>> }
>>
>> I can't think of an ambiguity w.r.t. other variations of UD literals
>> here, the only difference between the two-argument version being the
>> template parameter array size (including null), which is also known at
>> compile time. Presently, this can be emulated (badly) with just ordinary
>> constructors.
>>
>> The purpose is to allow UD literals like the above to be used in a
>> constexpr context where the size parameter is forwarded to a template
>> instantiation.
>>
>
On Wed, Sep 20, 2023 at 11:36 PM Chris Gary <cgary512_at_[hidden]> wrote:
> The thought just occurred to me that I really need to have the characters
> themselves available as template parameters in order to create static
> buffers.
>
> In essence, a variation of numeric literal that can handle other types of
> code unit...
>
> On Wed, Sep 20, 2023 at 10:53 PM Chris Gary <cgary512_at_[hidden]> wrote:
>
>> I believe this is not allowed, and that the idea hasn't circulated:
>>
>> template< std::size_t size_ >
>> constexpr FancyString operator ""_Str( const char (&str)[size_] ) noexcept
>> {
>> etc...
>> }
>>
>> I can't think of an ambiguity w.r.t. other variations of UD literals
>> here, the only difference between the two-argument version being the
>> template parameter array size (including null), which is also known at
>> compile time. Presently, this can be emulated (badly) with just ordinary
>> constructors.
>>
>> The purpose is to allow UD literals like the above to be used in a
>> constexpr context where the size parameter is forwarded to a template
>> instantiation.
>>
>
Received on 2023-09-21 07:08:15