mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-04 04:44:27 +02:00
docs: ext
header files got comments describing their purpose
This commit is contained in:
@@ -20,6 +20,9 @@
|
|||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
// SOFTWARE.
|
// SOFTWARE.
|
||||||
|
|
||||||
|
// Copy-pasted C++ standard libraries to be replaced with `import std;` when available
|
||||||
|
// `#include <algorithm.h>` is too heavy to do in every translation unit
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <mp-units/bits/hacks.h> // IWYU pragma: keep
|
#include <mp-units/bits/hacks.h> // IWYU pragma: keep
|
||||||
@@ -33,37 +36,6 @@
|
|||||||
|
|
||||||
namespace mp_units::detail {
|
namespace mp_units::detail {
|
||||||
|
|
||||||
// TODO refactor two below functions with std::ranges when moved to modules
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Returns the first successful value obtained from applying the function object to the elements of a given
|
|
||||||
* range, if any.
|
|
||||||
*
|
|
||||||
* @tparam InputIt must meet the requirements of LegacyInputIterator
|
|
||||||
* @tparam UnaryFunction must meet the requirements of MoveConstructible
|
|
||||||
* @param first the beginning of the range of elements to examine
|
|
||||||
* @param last the end of the range of elements to examine
|
|
||||||
* @param f function object, to be applied to the result of dereferencing every iterator in the range
|
|
||||||
* @return std::invoke_result_t<UnaryPredicate, std::iter_value_t<InputIt>>
|
|
||||||
*/
|
|
||||||
template<class InputIt, class UnaryFunction>
|
|
||||||
constexpr std::invoke_result_t<UnaryFunction, std::iter_value_t<InputIt>> get_first_of(InputIt first, InputIt last,
|
|
||||||
UnaryFunction f)
|
|
||||||
{
|
|
||||||
for (; first != last; ++first)
|
|
||||||
if (auto opt = f(*first)) return *opt;
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class Rng, class UnaryFunction>
|
|
||||||
constexpr auto get_first_of(const Rng& rng, UnaryFunction f)
|
|
||||||
{
|
|
||||||
using std::begin, std::end;
|
|
||||||
return get_first_of(begin(rng), end(rng), f);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO remove all the below and use std when moved to modules
|
|
||||||
template<class InputIt, class ForwardIt>
|
template<class InputIt, class ForwardIt>
|
||||||
constexpr InputIt find_first_of(InputIt first, InputIt last, ForwardIt s_first, ForwardIt s_last)
|
constexpr InputIt find_first_of(InputIt first, InputIt last, ForwardIt s_first, ForwardIt s_last)
|
||||||
{
|
{
|
||||||
@@ -207,5 +179,4 @@ constexpr copy_result<std::ranges::borrowed_iterator_t<R>, O> copy(R&& r, O resu
|
|||||||
return ::mp_units::detail::copy(std::ranges::begin(r), std::ranges::end(r), std::move(result));
|
return ::mp_units::detail::copy(std::ranges::begin(r), std::ranges::end(r), std::move(result));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace mp_units::detail
|
} // namespace mp_units::detail
|
||||||
|
@@ -20,6 +20,9 @@
|
|||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
// SOFTWARE.
|
// SOFTWARE.
|
||||||
|
|
||||||
|
// To be replaced with:
|
||||||
|
// P3094: std::basic_fixed_string
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// TODO use <algorithm> when moved to C++20 modules (parsing takes too long for each translation unit)
|
// TODO use <algorithm> when moved to C++20 modules (parsing takes too long for each translation unit)
|
||||||
|
@@ -20,6 +20,9 @@
|
|||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
// SOFTWARE.
|
// SOFTWARE.
|
||||||
|
|
||||||
|
// To be replaced with:
|
||||||
|
// P3133: Fast first-factor finding function
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <mp-units/ext/algorithm.h>
|
#include <mp-units/ext/algorithm.h>
|
||||||
@@ -112,6 +115,22 @@ template<std::size_t N>
|
|||||||
return product;
|
return product;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class InputIt, class UnaryFunction>
|
||||||
|
constexpr std::invoke_result_t<UnaryFunction, std::iter_value_t<InputIt>> get_first_of(InputIt first, InputIt last,
|
||||||
|
UnaryFunction f)
|
||||||
|
{
|
||||||
|
for (; first != last; ++first)
|
||||||
|
if (auto opt = f(*first)) return *opt;
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class Rng, class UnaryFunction>
|
||||||
|
constexpr auto get_first_of(const Rng& rng, UnaryFunction f)
|
||||||
|
{
|
||||||
|
using std::begin, std::end;
|
||||||
|
return get_first_of(begin(rng), end(rng), f);
|
||||||
|
}
|
||||||
|
|
||||||
// A configurable instantiation of the "wheel factorization" algorithm [1] for prime numbers.
|
// A configurable instantiation of the "wheel factorization" algorithm [1] for prime numbers.
|
||||||
//
|
//
|
||||||
// Instantiate with N to use a "basis" of the first N prime numbers. Higher values of N use fewer trial divisions, at
|
// Instantiate with N to use a "basis" of the first N prime numbers. Higher values of N use fewer trial divisions, at
|
||||||
|
@@ -1,5 +1,8 @@
|
|||||||
// https://stackoverflow.com/questions/81870/is-it-possible-to-print-a-variables-type-in-standard-c/56766138#56766138
|
// https://stackoverflow.com/questions/81870/is-it-possible-to-print-a-variables-type-in-standard-c/56766138#56766138
|
||||||
|
|
||||||
|
// To be replaced with:
|
||||||
|
// P2830: Standardized Constexpr Type Ordering
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||||
|
Reference in New Issue
Block a user