<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/131937>131937</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [clang-tidy] Check request: boost-use-math-constants
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang-tidy
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          denzor200
      </td>
    </tr>
</table>

<pre>
    
Needs a check that will find constants and function calls to math functions that can be replaced with Boost's mathematical constants from the Math library and offers fix-it hints(the same check as modernize-use-std-numbers, but for earlier C++ standarts).

Here is table of all available constants:
https://www.boost.org/doc/libs/1_87_0/libs/math/doc/html/math_toolkit/constants.html

BEFORE
```
double sqrt(double);
double log2(double);
template<typename T>
void sink(T&& val) {}

#define MY_PI 3.1415926

void foo() {
    const double Pi = 3.141592653589;
    const auto Use = Pi / 2;
    static constexpr double Euler = 2.7182818;

    log2(exp(1));
    log2(Euler);
    1 / sqrt(MY_PI);
    sink(MY_PI);
 sink(static_cast<float>(MY_PI));
}
```

AFTER
```
#include <boost/math/constants/constants.hpp>

double sqrt(double);
double log2(double);
template<typename T>
void sink(T&& val) {}

#define MY_PI 3.1415926

void foo() {
    const double Pi = boost::math::double_constants::pi;
    const auto Use = Pi / 2; // no match for Pi
    static constexpr double Euler = boost::math::double_constants::e;

 boost::math::double_constants::log2_e;
 boost::math::double_constants::log2_e;
 boost::math::double_constants::one_div_root_pi;
 sink(boost::math::double_constants::pi);
 sink(boost::math::float_constants::pi);
}
```

This check doesn't require C++11 in Boost 1.75.0 and older.
This check requires C++11 in Boost 1.86.0 and older, and C++14 in Boost 1.87.0 and newer.

</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzcVk1v4zYQ_TX0ZWBBoixLOuhgOzHaw7bBIj30ZFDiyGJDkV6SspP99QUp-SsNiuTSQwEDljjvzQzfDDVk1oq9QqxItib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