Skip to content

Commit 22eb958

Browse files
jwhpryorcopybara-github
authored andcommitted
No public description
PiperOrigin-RevId: 742923872
1 parent 9f035f1 commit 22eb958

File tree

5 files changed

+12
-21
lines changed

5 files changed

+12
-21
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,3 @@ jobs:
4646
- uses: actions/checkout@v4
4747
- name: test
4848
run: bazel test --cxxopt='-Werror' --cxxopt='-std=c++20' --repo_env=CC=clang --test_output=errors ...
49-
50-
windows-latest-cpp20-cmake-mvsc:
51-
runs-on: windows-2019
52-
steps:
53-
- name: checkout
54-
uses: actions/checkout@v4
55-
- name: cmake build
56-
run: |
57-
cmake --preset msvc-16-config-debug
58-
cmake --build --preset msvc-16-build-debug

metaprogramming/invocable_map.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,15 @@ class InvocableMapEntry {
9696
// the constexpr-ness of the string can't be propagated. This essentially
9797
// means you get one shot at defining the function.
9898
template <typename... Args>
99-
constexpr auto operator()(const char* key, Args&&... args) __attribute__((
100-
enable_if(std::string_view(key) ==
101-
std::get<I>(tup_container_v.*nameable_member).name_,
102-
""))) {
99+
constexpr auto operator()(const char* key, Args&&... args) const
100+
__attribute__((
101+
enable_if(std::string_view(key) ==
102+
std::get<I>(tup_container_v.*nameable_member).name_,
103+
""))) {
103104
static_assert(std::is_base_of_v<InvocableMapEntry, CrtpBase>,
104105
"You must derive from the invocable map.");
105106

106-
return (*static_cast<CrtpBase*>(this))
107+
return (*static_cast<const CrtpBase*>(this))
107108
.template InvocableMapCall<I, Args...>(key,
108109
std::forward<Args>(args)...);
109110
}

metaprogramming/invocable_map_20.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ class InvocableMap20 {
6464
#if __cplusplus >= 202002L
6565
public:
6666
template <StringLiteral key_literal, std::size_t Idx, typename... Args>
67-
constexpr auto Do(Args&&... args) {
68-
return (*static_cast<CrtpBase*>(this))
67+
constexpr auto Do(Args&&... args) const {
68+
return (*static_cast<const CrtpBase*>(this))
6969
.template InvocableMap20Call<Idx, key_literal, Args...>(
7070
std::forward<Args>(args)...);
7171
}
@@ -82,7 +82,7 @@ class InvocableMap20 {
8282
}
8383

8484
template <StringLiteral string_literal, typename... Args>
85-
constexpr auto Call(Args&&... args) {
85+
constexpr auto Call(Args&&... args) const {
8686
return Do<string_literal,
8787
SelectCandidate(
8888
string_literal,

metaprogramming/invocable_map_20_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class SampleClassNowExposingCallOperator1
5353
&NameContainer::container1_>;
5454

5555
template <size_t I, StringLiteral key_literal, typename... Args>
56-
auto InvocableMap20Call(Args&&... ts) {
56+
auto InvocableMap20Call(Args&&... ts) const {
5757
if (std::string_view(key_literal.value) == "Foo") {
5858
EXPECT_TRUE(I == 0);
5959
EXPECT_TRUE((std::is_same_v<std::tuple<Args...>, std::tuple<int>>));

metaprogramming/invocable_map_test.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class SampleClassNowExposingCallOperator1
5454
friend class jni::metaprogramming::InvocableMapEntry;
5555

5656
template <size_t I, typename... Args>
57-
auto InvocableMapCall(const char* key, Args&&... ts) {
57+
auto InvocableMapCall(const char* key, Args&&... ts) const {
5858
if (std::string_view(key) == "Foo") {
5959
EXPECT_TRUE(I == 0);
6060
EXPECT_TRUE((std::is_same_v<std::tuple<Args...>, std::tuple<int>>));
@@ -99,7 +99,7 @@ class SampleClassNowExposingCallOperator2
9999
friend class jni::metaprogramming::InvocableMapEntry;
100100

101101
template <size_t I, typename... Args>
102-
auto InvocableMapCall(const char* key, Args&&... args) {
102+
auto InvocableMapCall(const char* key, Args&&... args) const {
103103
if (std::string_view(key) == "Fizz") {
104104
EXPECT_TRUE(I == 0);
105105
EXPECT_TRUE((std::is_same_v<std::tuple<Args...>, std::tuple<int>>));

0 commit comments

Comments
 (0)