C++ Logo

std-proposals

Advanced search

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

From: Desmond Gold Bongcawel <desmondbongcawel922_at_[hidden]>
Date: Sat, 5 Mar 2022 22:45:10 +0800
I know this is a silly minor addition, but this would help reduce the
duplication of writing (std::numbers::pi * 2) whenever they exist in
specific formulas.

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

Synopsis:
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:45:23