FE 0.13.1
Header-only C++ frontend library
Loading...
Searching...
No Matches
algo.h File Reference
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <algorithm>
#include <array>
#include <bit>
#include <functional>
#include <iterator>
#include <ranges>
#include <string>
#include <string_view>
#include <type_traits>
Include dependency graph for algo.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  fe

Functions

Utility Functions
template<class D, class S>
requires (std::is_trivially_copyable_v<S> && std::is_trivially_copyable_v<D>)
constexpr D fe::bitcast_resize (const S &src) noexcept
 A bitcast from src of type S to D, supporting different sizes.
constexpr std::uint64_t fe::pad (std::uint64_t offset, std::uint64_t align) noexcept
 Rounds offset up to the next multiple of align.
constexpr bool fe::is_aligned (std::uint64_t offset, std::uint64_t align) noexcept
Algorithms
template<std::random_access_iterator I, class T, class L = std::less<>>
constexpr I fe::binary_find (I begin, I end, const T &val, L lt={}) noexcept
template<std::ranges::random_access_range R, class T, class L = std::less<>>
requires std::ranges::common_range<R>
constexpr auto fe::binary_find (R &&r, const T &val, L lt={}) noexcept
constexpr std::string_view fe::subview (std::string_view s, size_t i, size_t n=std::string_view::npos) noexcept
 Like std::string::substr, but works on std::string_view and clamps i instead of throwing.
void fe::find_and_replace (std::string &str, std::string_view what, std::string_view repl)
 Replaces all occurrences of what with repl.