Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,3 @@ jobs:
- uses: actions/checkout@v4
- name: test
run: bazel test --cxxopt='-Werror' --cxxopt='-std=c++20' --repo_env=CC=clang --test_output=errors ...

windows-latest-cpp20-cmake-mvsc:
runs-on: windows-2019
steps:
- name: checkout
uses: actions/checkout@v4
- name: cmake build
run: |
cmake --preset msvc-16-config-debug
cmake --build --preset msvc-16-build-debug
11 changes: 6 additions & 5 deletions metaprogramming/invocable_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,15 @@ class InvocableMapEntry {
// the constexpr-ness of the string can't be propagated. This essentially
// means you get one shot at defining the function.
template <typename... Args>
constexpr auto operator()(const char* key, Args&&... args) __attribute__((
enable_if(std::string_view(key) ==
std::get<I>(tup_container_v.*nameable_member).name_,
""))) {
constexpr auto operator()(const char* key, Args&&... args) const
__attribute__((
enable_if(std::string_view(key) ==
std::get<I>(tup_container_v.*nameable_member).name_,
""))) {
static_assert(std::is_base_of_v<InvocableMapEntry, CrtpBase>,
"You must derive from the invocable map.");

return (*static_cast<CrtpBase*>(this))
return (*static_cast<const CrtpBase*>(this))
.template InvocableMapCall<I, Args...>(key,
std::forward<Args>(args)...);
}
Expand Down
6 changes: 3 additions & 3 deletions metaprogramming/invocable_map_20.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ class InvocableMap20 {
#if __cplusplus >= 202002L
public:
template <StringLiteral key_literal, std::size_t Idx, typename... Args>
constexpr auto Do(Args&&... args) {
return (*static_cast<CrtpBase*>(this))
constexpr auto Do(Args&&... args) const {
return (*static_cast<const CrtpBase*>(this))
.template InvocableMap20Call<Idx, key_literal, Args...>(
std::forward<Args>(args)...);
}
Expand All @@ -82,7 +82,7 @@ class InvocableMap20 {
}

template <StringLiteral string_literal, typename... Args>
constexpr auto Call(Args&&... args) {
constexpr auto Call(Args&&... args) const {
return Do<string_literal,
SelectCandidate(
string_literal,
Expand Down
2 changes: 1 addition & 1 deletion metaprogramming/invocable_map_20_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class SampleClassNowExposingCallOperator1
&NameContainer::container1_>;

template <size_t I, StringLiteral key_literal, typename... Args>
auto InvocableMap20Call(Args&&... ts) {
auto InvocableMap20Call(Args&&... ts) const {
if (std::string_view(key_literal.value) == "Foo") {
EXPECT_TRUE(I == 0);
EXPECT_TRUE((std::is_same_v<std::tuple<Args...>, std::tuple<int>>));
Expand Down
4 changes: 2 additions & 2 deletions metaprogramming/invocable_map_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class SampleClassNowExposingCallOperator1
friend class jni::metaprogramming::InvocableMapEntry;

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

template <size_t I, typename... Args>
auto InvocableMapCall(const char* key, Args&&... args) {
auto InvocableMapCall(const char* key, Args&&... args) const {
if (std::string_view(key) == "Fizz") {
EXPECT_TRUE(I == 0);
EXPECT_TRUE((std::is_same_v<std::tuple<Args...>, std::tuple<int>>));
Expand Down