C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Size parameter for template UD literals.

From: Chris Gary <cgary512_at_[hidden]>
Date: Wed, 20 Sep 2023 23:36:21 -0600
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 05:36:34