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

Name

Description

obj

The byte container to inspect.

prefix

The prefix bytes to compare against the start of obj.

Created with MrDocs