C++ Logo

std-proposals

Advanced search

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

From: Chris Gary <cgary512_at_[hidden]>
Date: Wed, 20 Sep 2023 22:53:03 -0600
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 04:53:16