Skip to content

Commit

Permalink
cut c_array::size
Browse files Browse the repository at this point in the history
Summary:
The intention of `c_array` is to be a minimal struct wrapping a C array. No member functions, etc.

For cases which need member functions, use `std::array`.

Reviewed By: Gownta

Differential Revision: D58312956

fbshipit-source-id: 8240dfb0c3dc883da208e15d19b8e68cf43515bf
  • Loading branch information
yfeldblum authored and facebook-github-bot committed Jun 8, 2024
1 parent e591cf8 commit 7cd8d52
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 6 additions & 3 deletions folly/futures/Promise.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#pragma once

#include <array>
#include <functional>

#include <folly/Portability.h>
Expand Down Expand Up @@ -55,11 +56,13 @@ class FOLLY_EXPORT BrokenPromise : public PromiseException {
static FOLLY_CONSTEVAL auto make_error_message() {
constexpr auto prefix =
detail::pretty_carray_from("Broken promise for type name `");
constexpr auto prefix_size = std::size(prefix.data);
constexpr auto name = detail::pretty_name_carray<T>();
c_array<char, name.size() - 1 + prefix.size() - 1 + 2> ret{};
constexpr auto name_size = std::size(name.data);
c_array<char, name_size - 1 + prefix_size - 1 + 2> ret{};
char* dest = ret.data;
dest = detail::pretty_carray_copy(dest, prefix.data, prefix.size() - 1);
dest = detail::pretty_carray_copy(dest, name.data, name.size() - 1);
dest = detail::pretty_carray_copy(dest, prefix.data, prefix_size - 1);
dest = detail::pretty_carray_copy(dest, name.data, name_size - 1);
detail::pretty_carray_copy(dest, "`", 2);
return ret;
}
Expand Down
2 changes: 0 additions & 2 deletions folly/lang/CArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ namespace folly {
// Prefer std::array when using C++17 or later.
template <typename V, size_t N>
struct c_array {
constexpr size_t size() const noexcept { return N; }

V data[N];
};

Expand Down

0 comments on commit 7cd8d52

Please sign in to comment.