util::HasPrefix

Check whether a container begins with the given prefix.

Synopsis

Declared in <util/string.h>

template<
    typename T1,
    size_t PREFIX_LEN>
[[nodiscard]]
bool
HasPrefix(
    T1 const& obj,
    std::array<uint8_t, PREFIX_LEN> const& prefix);

Return Value

true if obj is at least PREFIX_LEN long and starts with prefix.

NOTE

The return value should not be discarded.

Parameters

NameDescription
objThe byte container to inspect.
prefixThe prefix bytes to compare against the start of obj.