C++ Logo


Advanced search

[std-proposals] Introducing std::numbers::tau

From: Desmond Gold Bongcawel <desmondbongcawel922_at_[hidden]>
Date: Sat, 5 Mar 2022 22:48:39 +0800
[resent the mail]

I know this is a silly minor addition, but this would help reduce the
duplication of writing (std::numbers::pi * 2) wherever they exist in some
particular computations such as computing the circumference of the circle.

The constant tau already existed in other programming languages such as C#,
rust, etc.

Synopsis in <numbers>:
namespace std::numbers {
  // ...
  template<class T> inline constexpr T tau_v = /* unspecified */;

  // ...
  template<floating_point T> inline constexpr T tau_v<T> = /* see
description */;

  // ...
  inline constexpr double tau = tau_v<double>;
} // namespace std::numbers

In variable template std::numbers::tau_v

expression equivalent to:
  2 * std::numbers::pi_v<T>

template <floating_point T>
inline constexpr T tau_v<T> = T(6.283185307179586476925286766559005768L);

Received on 2022-03-05 14:48:51