C++ choose between runtime and compile time implementation functions
As of C++20, you can use std::is_constant_evaluated(), which is more portable and considerably easier to read.  I realize you have only tagged C++17, but I just wanted to point out that there is now a cleaner solution to this problem.
#include &lt;type_traits&gt;
#include &lt;cmath&gt;

namespace example
{
    namespace impl
    {
        template&lt;typename T&gt;
        constexpr auto sqrt(const T&amp; m) noexcept -&gt; decltype(std::sqrt(m)) {
            // implementation details
        }
    }

    template&lt;typename T&gt;
    constexpr auto sqrt(const T&amp; m) noexcept {
        if (std::is_constant_evaluated())
            return impl::sqrt(m);
        else
            return std::sqrt(m);
    }
}