Date: Fri, 22 Sep 2023 01:20:06 +0200
Il 21/09/23 21:12, Chris Gary via Std-Proposals ha scritto:
>
> template< std::size_t size_ >
> constexpr char only_constexpr_example( const char (&str)[size_] ) noexcept
> {
> // In a constexpr context, the size and contents of str are "known".
>
> // Really no different than a numeric UD-literal.
> //
> // This declaration makes the function constexpr-only
> // since it requires knowledge of str's contents at compile time.
> using chars = char_list< str... >;
>
> // If the size of an array is known, this can be the
> // same as an element-by-element copy construction
> // at runtime.
> constexpr char str2[]{ str... };
>
> return str2[0];
> }`
This sounds akin to constexpr function parameters (p1045).
My 2 c,
>
> template< std::size_t size_ >
> constexpr char only_constexpr_example( const char (&str)[size_] ) noexcept
> {
> // In a constexpr context, the size and contents of str are "known".
>
> // Really no different than a numeric UD-literal.
> //
> // This declaration makes the function constexpr-only
> // since it requires knowledge of str's contents at compile time.
> using chars = char_list< str... >;
>
> // If the size of an array is known, this can be the
> // same as an element-by-element copy construction
> // at runtime.
> constexpr char str2[]{ str... };
>
> return str2[0];
> }`
This sounds akin to constexpr function parameters (p1045).
My 2 c,
-- Giuseppe D'Angelo
Received on 2023-09-21 23:20:11