Skip to content

[const.wrap.class] Simplify constraint of function call operator of constant_wrapper? #8200

@hewillk

Description

@hewillk

Currently, it is defined as:

template<constexpr-param T, constexpr-param... Args>
  constexpr auto operator()(this T, Args...) noexcept
    requires requires(Args...) { constant_wrapper<T::value(Args::value...)>(); }
      { return constant_wrapper<T::value(Args::value...)>{}; }

The requires clause here is
requires requires(Args...) { constant_wrapper<T::value(Args::value...)>(); }

First, the Args... here seems redundant, since we can already access the Args... in the template parameter list.
Second, the () here actually means the construction of constant_wrapper, it seems that using {} is more appropriate and consistent with the return statement and the function body.

So in my opinion, this should be better with (most likely editorial):

template<constexpr-param T, constexpr-param... Args>
  constexpr auto operator()(this T, Args...) noexcept
    requires requires { constant_wrapper<T::value(Args::value...)>{}; }
      { return constant_wrapper<T::value(Args::value...)>{}; }

Or even better with typename (probably not editorial):

template<constexpr-param T, constexpr-param... Args>
  constexpr auto operator()(this T, Args...) noexcept
    requires requires { typename constant_wrapper<T::value(Args::value...)>; }
      { return constant_wrapper<T::value(Args::value...)>{}; }

Please let me know if I'm missing anything.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions