Skip to content

Commit

Permalink
Tweaks from review
Browse files Browse the repository at this point in the history
  • Loading branch information
ksperling-apple committed Oct 28, 2023
1 parent 6c82391 commit a391a32
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/lib/core/Unchecked.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

namespace chip {

/// Unchecked is disambiguation tag that can be used to provide and select a variant of a
/// Unchecked is a disambiguation tag that can be used to provide and select a variant of a
/// constructor or other method that omits the runtime checks performed by the default variant.
struct UncheckedType
{
Expand Down
12 changes: 10 additions & 2 deletions src/lib/support/Span.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,14 @@ class Span
bool operator==(const Span<U> & other) const = delete;

// Creates a Span without checking whether databuf is a null pointer.
//
// Note: The normal (checked) constructor should be used for general use;
// this overload exists for special use cases where databuf is guaranteed
// to be valid (not null) and a constexpr constructor is required.
//
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61648 prevents making
// operator""_span a friend (and this constructor private).

constexpr Span(UncheckedType tag, pointer databuf, size_t datalen) : mDataBuf(databuf), mDataLen(datalen) {}

private:
Expand All @@ -177,9 +185,9 @@ class Span

inline namespace literals {

inline constexpr Span<char const> operator"" _span(char const * literal, size_t size)
inline constexpr Span<const char> operator"" _span(const char * literal, size_t size)
{
return Span<char const>(Unchecked, literal, size);
return Span<const char>(Unchecked, literal, size);
}

} // namespace literals
Expand Down

0 comments on commit a391a32

Please sign in to comment.