The char traits for byte-like types.
More...
#include <bytes.hpp>
|
static constexpr void | assign (char_type &c1, const char_type &c2) |
| Assigns c2 to c1.
|
|
static constexpr char_type * | assign (char_type *ptr, std::size_t count, char_type value) |
| Assigns value to each byte in [ptr, ptr+count).
|
|
static constexpr bool | eq (char_type a, char_type b) |
| Returns true if bytes are equal.
|
|
static constexpr bool | lt (char_type a, char_type b) |
| Returns true if byte a is less than byte b.
|
|
static constexpr char_type * | move (char_type *dest, const char_type *src, std::size_t count) |
| Copies count bytes from src to dest. Performs correctly even if ranges overlap.
|
|
static constexpr char_type * | copy (char_type *dest, const char_type *src, std::size_t count) |
| Copies count bytes from src to dest. The ranges must not overlap.
|
|
static constexpr int | compare (const char_type *a, const char_type *b, std::size_t count) |
| Compares lexicographically the bytes in two ranges of equal length.
|
|
static std::size_t | length (const char_type *s) |
| Returns the length of a null-terminated byte string.
|
|
static constexpr const char_type * | find (const char_type *s, std::size_t count, const char_type &value) |
| Finds the value in the range of bytes and returns the pointer to the first occurrence or nullptr if not found.
|
|
template<typename T>
struct evmc::byte_traits< T >
The char traits for byte-like types.
See: https://en.cppreference.com/w/cpp/string/char_traits.
Definition at line 17 of file bytes.hpp.
◆ char_type
The byte type.
Definition at line 21 of file bytes.hpp.
◆ assign() [1/2]
Assigns c2 to c1.
Definition at line 24 of file bytes.hpp.
◆ assign() [2/2]
Assigns value to each byte in [ptr, ptr+count).
Definition at line 27 of file bytes.hpp.
28 {
29 std::fill_n(ptr, count, value);
30 return ptr;
31 }
◆ compare()
Compares lexicographically the bytes in two ranges of equal length.
Definition at line 57 of file bytes.hpp.
58 {
59 for (; count != 0; --count, ++a, ++b)
60 {
62 return -1;
64 return 1;
65 }
66 return 0;
67 }
static constexpr bool lt(char_type a, char_type b)
Returns true if byte a is less than byte b.
◆ copy()
Copies count bytes from src to dest. The ranges must not overlap.
Definition at line 50 of file bytes.hpp.
51 {
52 std::copy_n(src, count, dest);
53 return dest;
54 }
◆ eq()
Returns true if bytes are equal.
Definition at line 34 of file bytes.hpp.
◆ find()
Finds the value in the range of bytes and returns the pointer to the first occurrence or nullptr if not found.
Definition at line 78 of file bytes.hpp.
81 {
82 const auto end = s + count;
83 const auto p = std::find(s, end, value);
84 return p != end ? p : nullptr;
85 }
◆ length()
Returns the length of a null-terminated byte string.
Definition at line 71 of file bytes.hpp.
72 {
73 return std::strlen(reinterpret_cast<const char*>(s));
74 }
◆ lt()
Returns true if byte a is less than byte b.
Definition at line 37 of file bytes.hpp.
◆ move()
Copies count bytes from src to dest. Performs correctly even if ranges overlap.
Definition at line 40 of file bytes.hpp.
41 {
42 if (dest < src)
43 std::copy_n(src, count, dest);
44 else if (src < dest)
45 std::copy_backward(src, src + count, dest + count);
46 return dest;
47 }
The documentation for this struct was generated from the following file: