diff --git a/.github/workflows/bazel.yml b/.github/workflows/bazel.yml index f4cfa722..c7615de0 100644 --- a/.github/workflows/bazel.yml +++ b/.github/workflows/bazel.yml @@ -21,6 +21,7 @@ on: - "scripts/bazel.py" - "scripts/bazel.sh" - "scripts/compiler_discovery.py" + - "scripts/generate_operator_thunks.py" - "xyz/tutorials/BUILD.bazel" # No `paths:` filter here. The `bazel` summary job is a required status # check for merging to main, and a workflow that is filtered out by @@ -72,6 +73,7 @@ jobs: - "scripts/bazel.py" - "scripts/bazel.sh" - "scripts/compiler_discovery.py" + - "scripts/generate_operator_thunks.py" - "xyz/tutorials/BUILD.bazel" build: diff --git a/.github/workflows/clang-tidy.yml b/.github/workflows/clang-tidy.yml index c4d308be..025f9c09 100644 --- a/.github/workflows/clang-tidy.yml +++ b/.github/workflows/clang-tidy.yml @@ -18,6 +18,7 @@ on: - "**/.clang-tidy" - "scripts/cmake.py" - "scripts/cmake.sh" + - "scripts/generate_operator_thunks.py" # The clang-tidy job is not a required status check, so a `paths:` filter # here is safe: a pull request that touches nothing relevant simply gets no # check rather than an eternally pending one. @@ -36,6 +37,7 @@ on: - "**/.clang-tidy" - "scripts/cmake.py" - "scripts/cmake.sh" + - "scripts/generate_operator_thunks.py" workflow_dispatch: # One group per PR, or per ref for pushes and scheduled runs. A new push to a diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 15e70a09..3a741ef0 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -18,6 +18,7 @@ on: - "scripts/cmake.py" - "scripts/cmake.sh" - "scripts/compiler_discovery.py" + - "scripts/generate_operator_thunks.py" # No `paths:` filter here. The `cmake` summary job is a required status # check for merging to main, and a workflow that is filtered out by # `paths:` never reports a check, which leaves unrelated pull requests @@ -65,6 +66,7 @@ jobs: - "scripts/cmake.py" - "scripts/cmake.sh" - "scripts/compiler_discovery.py" + - "scripts/generate_operator_thunks.py" build: needs: detect-changes diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 175699d0..561852db 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -24,6 +24,7 @@ on: - "scripts/consteval_coverage.py" - "scripts/consteval_coverage_test.py" - "scripts/consteval_coverage.sh" + - "scripts/generate_operator_thunks.py" pull_request: paths: # Keep in sync with the `push.paths` list above. @@ -43,6 +44,7 @@ on: - "scripts/consteval_coverage.py" - "scripts/consteval_coverage_test.py" - "scripts/consteval_coverage.sh" + - "scripts/generate_operator_thunks.py" # One group per PR, or per ref for pushes and scheduled runs. A new push to a # PR cancels the runs for its previous head; main and scheduled runs only queue. diff --git a/.github/workflows/sanitizers.yml b/.github/workflows/sanitizers.yml index 28c16259..cc6635cd 100644 --- a/.github/workflows/sanitizers.yml +++ b/.github/workflows/sanitizers.yml @@ -21,6 +21,7 @@ on: - "scripts/bazel.py" - "scripts/bazel.sh" - "scripts/compiler_discovery.py" + - "scripts/generate_operator_thunks.py" - "xyz/tutorials/BUILD.bazel" # No `paths:` filter here. The `sanitizers` summary job is a required # status check for merging to main, and a workflow that is filtered out by @@ -72,6 +73,7 @@ jobs: - "scripts/bazel.py" - "scripts/bazel.sh" - "scripts/compiler_discovery.py" + - "scripts/generate_operator_thunks.py" - "xyz/tutorials/BUILD.bazel" sanitized-tests: diff --git a/BUILD.bazel b/BUILD.bazel index 22064613..03c65b5d 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -1,8 +1,22 @@ load("@apple_support//xcode:xcode_config.bzl", "xcode_config") load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") +load("@rules_python//python:py_binary.bzl", "py_binary") package(default_visibility = ["//visibility:public"]) +py_binary( + name = "py_generate_operator_thunks", + srcs = ["scripts/generate_operator_thunks.py"], + main = "scripts/generate_operator_thunks.py", +) + +genrule( + name = "generate_operator_thunks", + outs = ["xyz/detail/operator_thunks.hh"], + cmd = "$(location :py_generate_operator_thunks) --output $@", + tools = [":py_generate_operator_thunks"], +) + # Implementation headers. Visible only inside this repository; tests that # include them depend on this target directly. cc_library( @@ -62,6 +76,21 @@ cc_test( ], ) +cc_test( + name = "protocol_feature_test", + size = "small", + srcs = [ + "xyz/tests/feature_tests.cc", + ], + tags = ["manual"], + deps = [ + ":consteval_check", + ":detail", + ":protocol", + "@googletest//:gtest_main", + ], +) + # An xcode_config with no Xcode versions. build:macos in .bazelrc selects it # so the C++ toolchain does not fetch @local_config_xcode, which compiles and # runs xcode-locator and then xcodebuild for every installed Xcode on each diff --git a/CMakeLists.txt b/CMakeLists.txt index 3eea48a6..9ac3a2fb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -110,10 +110,31 @@ include(xyz_add_test) include(xyz_add_object_library) find_package(ClangTidy) +find_package(Python3 REQUIRED COMPONENTS Interpreter) + +set(XYZ_PROTOCOL_GENERATED_INCLUDE_DIRECTORY + "${CMAKE_CURRENT_BINARY_DIR}/generated") +set(XYZ_PROTOCOL_OPERATOR_THUNKS_HEADER + "${XYZ_PROTOCOL_GENERATED_INCLUDE_DIRECTORY}/xyz/detail/operator_thunks.hh") + +add_custom_command( + OUTPUT "${XYZ_PROTOCOL_OPERATOR_THUNKS_HEADER}" + COMMAND + Python3::Interpreter + "${CMAKE_CURRENT_SOURCE_DIR}/scripts/generate_operator_thunks.py" + --output "${XYZ_PROTOCOL_OPERATOR_THUNKS_HEADER}" + DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/scripts/generate_operator_thunks.py" + COMMENT "Generating xyz/detail/operator_thunks.hh" + VERBATIM) + +add_custom_target( + generate_operator_thunks ALL + DEPENDS "${XYZ_PROTOCOL_OPERATOR_THUNKS_HEADER}") xyz_add_library( NAME protocol ALIAS xyz_protocol::protocol) +add_dependencies(protocol generate_operator_thunks) # One header list drives the build tree, the export and the install: a # header missing here is missing from the installed package too. target_sources( @@ -127,14 +148,21 @@ target_sources( xyz/detail/conformance.hh xyz/detail/conversion_thunks.hh xyz/detail/member_function_thunks.hh - xyz/detail/operator_thunks.hh xyz/detail/overload_spec.hh xyz/detail/owning_vtable.hh xyz/detail/protocol_traits.hh xyz/detail/protocol_wrappers.hh xyz/detail/small_buffer.hh xyz/detail/vtable.hh - xyz/detail/name_mangling.hh) + xyz/detail/name_mangling.hh + FILE_SET + generated_headers + TYPE + HEADERS + BASE_DIRS + "${XYZ_PROTOCOL_GENERATED_INCLUDE_DIRECTORY}" + FILES + "${XYZ_PROTOCOL_OPERATOR_THUNKS_HEADER}") # Consumers need the reflection flags of whichever compiler they build with, # so the options are generator expressions evaluated at their configure time # rather than the flags of the compiler that installed the package. @@ -206,7 +234,8 @@ if(XYZ_PROTOCOL_IS_NOT_SUBPROJECT) install( TARGETS protocol EXPORT xyz_protocol-targets - FILE_SET HEADERS DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") + FILE_SET HEADERS DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" + FILE_SET generated_headers DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") install( EXPORT xyz_protocol-targets diff --git a/MODULE.bazel b/MODULE.bazel index 426b4026..6b8b9383 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -8,3 +8,10 @@ bazel_dep(name = "googletest", version = "1.18.0") # Only for the empty xcode_config in BUILD.bazel that build:macos selects. bazel_dep(name = "apple_support", version = "1.24.2") +bazel_dep(name = "rules_python", version = "1.9.3") + +python = use_extension("@rules_python//python/extensions:python.bzl", "python") + +# Python below is used in bazel for a generator, without deps. +# It does not need keeping in sync with pyproject.toml. +python.toolchain(python_version = "3.13") diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index ce38d7ba..6630ca76 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -41,7 +41,8 @@ "https://bcr.bazel.build/modules/bazel_features/1.42.1/MODULE.bazel": "275a59b5406ff18c01739860aa70ad7ccb3cfb474579411decca11c93b951080", "https://bcr.bazel.build/modules/bazel_features/1.43.0/MODULE.bazel": "defa2226f06ba20550d6548c3a2ea2a7929634437a52973869c20c225450eb91", "https://bcr.bazel.build/modules/bazel_features/1.50.0/MODULE.bazel": "2083ef9c7a469f520890483ccf8e0189d6e71e2117e7752e15e6554433d5ae3e", - "https://bcr.bazel.build/modules/bazel_features/1.50.0/source.json": "e0ee3debde2789ff56e4452e612d126925ba9ab64d4bde79c67f099d2902df9b", + "https://bcr.bazel.build/modules/bazel_features/1.55.0/MODULE.bazel": "6cd2e9a25e1f28957c87c94ebf7a5a730d2312582d97c24ec1e1e9a5e6aca596", + "https://bcr.bazel.build/modules/bazel_features/1.55.0/source.json": "0bc67827e4a293029523788d7c0099a14fd6e55ec44f539731dad00edf9c5ddc", "https://bcr.bazel.build/modules/bazel_features/1.9.1/MODULE.bazel": "8f679097876a9b609ad1f60249c49d68bfab783dd9be012faf9d82547b14815a", "https://bcr.bazel.build/modules/bazel_skylib/1.0.3/MODULE.bazel": "bcb0fd896384802d1ad283b4e4eb4d718eebd8cb820b0a2c3a347fb971afd9d8", "https://bcr.bazel.build/modules/bazel_skylib/1.1.1/MODULE.bazel": "1add3e7d93ff2e6998f9e118022c84d163917d912f5afafb3058e3d2f1545b5e", @@ -189,7 +190,8 @@ "https://bcr.bazel.build/modules/rules_python/1.6.0/MODULE.bazel": "7e04ad8f8d5bea40451cf80b1bd8262552aa73f841415d20db96b7241bd027d8", "https://bcr.bazel.build/modules/rules_python/1.6.3/MODULE.bazel": "a7b80c42cb3de5ee2a5fa1abc119684593704fcd2fec83165ebe615dec76574f", "https://bcr.bazel.build/modules/rules_python/1.7.0/MODULE.bazel": "d01f995ecd137abf30238ad9ce97f8fc3ac57289c8b24bd0bf53324d937a14f8", - "https://bcr.bazel.build/modules/rules_python/1.7.0/source.json": "028a084b65dcf8f4dc4f82f8778dbe65df133f234b316828a82e060d81bdce32", + "https://bcr.bazel.build/modules/rules_python/1.9.3/MODULE.bazel": "3d69b3b436a973f3319277831985f5d58e492c9cc77ddee755ae9908e8accb79", + "https://bcr.bazel.build/modules/rules_python/1.9.3/source.json": "bf2211987d34bda32e1294a9a34135b702cdf40942cda00e8e21bf718076c188", "https://bcr.bazel.build/modules/rules_shell/0.2.0/MODULE.bazel": "fda8a652ab3c7d8fee214de05e7a9916d8b28082234e8d2c0094505c5268ed3c", "https://bcr.bazel.build/modules/rules_shell/0.3.0/MODULE.bazel": "de4402cd12f4cc8fda2354fce179fdb068c0b9ca1ec2d2b17b3e21b24c1a937b", "https://bcr.bazel.build/modules/rules_shell/0.6.1/MODULE.bazel": "72e76b0eea4e81611ef5452aa82b3da34caca0c8b7b5c0c9584338aa93bae26b", @@ -273,178 +275,10 @@ } } }, - "@@rules_python+//python/extensions:config.bzl%config": { - "general": { - "bzlTransitiveDigest": "dzD8Q2YmrP3fz8saWLHPmlwPLO91ImtTmP/c9JKTStM=", - "usagesDigest": "ZVSXMAGpD+xzVNPuvF1IoLBkty7TROO0+akMapt1pAg=", - "recordedInputs": [ - "REPO_MAPPING:rules_python+,bazel_tools bazel_tools", - "REPO_MAPPING:rules_python+,pypi__build rules_python++config+pypi__build", - "REPO_MAPPING:rules_python+,pypi__click rules_python++config+pypi__click", - "REPO_MAPPING:rules_python+,pypi__colorama rules_python++config+pypi__colorama", - "REPO_MAPPING:rules_python+,pypi__importlib_metadata rules_python++config+pypi__importlib_metadata", - "REPO_MAPPING:rules_python+,pypi__installer rules_python++config+pypi__installer", - "REPO_MAPPING:rules_python+,pypi__more_itertools rules_python++config+pypi__more_itertools", - "REPO_MAPPING:rules_python+,pypi__packaging rules_python++config+pypi__packaging", - "REPO_MAPPING:rules_python+,pypi__pep517 rules_python++config+pypi__pep517", - "REPO_MAPPING:rules_python+,pypi__pip rules_python++config+pypi__pip", - "REPO_MAPPING:rules_python+,pypi__pip_tools rules_python++config+pypi__pip_tools", - "REPO_MAPPING:rules_python+,pypi__pyproject_hooks rules_python++config+pypi__pyproject_hooks", - "REPO_MAPPING:rules_python+,pypi__setuptools rules_python++config+pypi__setuptools", - "REPO_MAPPING:rules_python+,pypi__tomli rules_python++config+pypi__tomli", - "REPO_MAPPING:rules_python+,pypi__wheel rules_python++config+pypi__wheel", - "REPO_MAPPING:rules_python+,pypi__zipp rules_python++config+pypi__zipp" - ], - "generatedRepoSpecs": { - "rules_python_internal": { - "repoRuleId": "@@rules_python+//python/private:internal_config_repo.bzl%internal_config_repo", - "attributes": { - "transition_setting_generators": {}, - "transition_settings": [] - } - }, - "pypi__build": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", - "attributes": { - "url": "https://files.pythonhosted.org/packages/e2/03/f3c8ba0a6b6e30d7d18c40faab90807c9bb5e9a1e3b2fe2008af624a9c97/build-1.2.1-py3-none-any.whl", - "sha256": "75e10f767a433d9a86e50d83f418e83efc18ede923ee5ff7df93b6cb0306c5d4", - "type": "zip", - "build_file_content": "package(default_visibility = [\"//visibility:public\"])\n\nload(\"@rules_python//python:py_library.bzl\", \"py_library\")\n\npy_library(\n name = \"lib\",\n srcs = glob([\"**/*.py\"]),\n data = glob([\"**/*\"], exclude=[\n # These entries include those put into user-installed dependencies by\n # data_exclude to avoid non-determinism.\n \"**/*.py\",\n \"**/*.pyc\",\n \"**/*.pyc.*\", # During pyc creation, temp files named *.pyc.NNN are created\n \"**/*.dist-info/RECORD\",\n \"BUILD\",\n \"WORKSPACE\",\n ]),\n # This makes this directory a top-level in the python import\n # search path for anything that depends on this.\n imports = [\".\"],\n)\n" - } - }, - "pypi__click": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", - "attributes": { - "url": "https://files.pythonhosted.org/packages/00/2e/d53fa4befbf2cfa713304affc7ca780ce4fc1fd8710527771b58311a3229/click-8.1.7-py3-none-any.whl", - "sha256": "ae74fb96c20a0277a1d615f1e4d73c8414f5a98db8b799a7931d1582f3390c28", - "type": "zip", - "build_file_content": "package(default_visibility = [\"//visibility:public\"])\n\nload(\"@rules_python//python:py_library.bzl\", \"py_library\")\n\npy_library(\n name = \"lib\",\n srcs = glob([\"**/*.py\"]),\n data = glob([\"**/*\"], exclude=[\n # These entries include those put into user-installed dependencies by\n # data_exclude to avoid non-determinism.\n \"**/*.py\",\n \"**/*.pyc\",\n \"**/*.pyc.*\", # During pyc creation, temp files named *.pyc.NNN are created\n \"**/*.dist-info/RECORD\",\n \"BUILD\",\n \"WORKSPACE\",\n ]),\n # This makes this directory a top-level in the python import\n # search path for anything that depends on this.\n imports = [\".\"],\n)\n" - } - }, - "pypi__colorama": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", - "attributes": { - "url": "https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl", - "sha256": "4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6", - "type": "zip", - "build_file_content": "package(default_visibility = [\"//visibility:public\"])\n\nload(\"@rules_python//python:py_library.bzl\", \"py_library\")\n\npy_library(\n name = \"lib\",\n srcs = glob([\"**/*.py\"]),\n data = glob([\"**/*\"], exclude=[\n # These entries include those put into user-installed dependencies by\n # data_exclude to avoid non-determinism.\n \"**/*.py\",\n \"**/*.pyc\",\n \"**/*.pyc.*\", # During pyc creation, temp files named *.pyc.NNN are created\n \"**/*.dist-info/RECORD\",\n \"BUILD\",\n \"WORKSPACE\",\n ]),\n # This makes this directory a top-level in the python import\n # search path for anything that depends on this.\n imports = [\".\"],\n)\n" - } - }, - "pypi__importlib_metadata": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", - "attributes": { - "url": "https://files.pythonhosted.org/packages/2d/0a/679461c511447ffaf176567d5c496d1de27cbe34a87df6677d7171b2fbd4/importlib_metadata-7.1.0-py3-none-any.whl", - "sha256": "30962b96c0c223483ed6cc7280e7f0199feb01a0e40cfae4d4450fc6fab1f570", - "type": "zip", - "build_file_content": "package(default_visibility = [\"//visibility:public\"])\n\nload(\"@rules_python//python:py_library.bzl\", \"py_library\")\n\npy_library(\n name = \"lib\",\n srcs = glob([\"**/*.py\"]),\n data = glob([\"**/*\"], exclude=[\n # These entries include those put into user-installed dependencies by\n # data_exclude to avoid non-determinism.\n \"**/*.py\",\n \"**/*.pyc\",\n \"**/*.pyc.*\", # During pyc creation, temp files named *.pyc.NNN are created\n \"**/*.dist-info/RECORD\",\n \"BUILD\",\n \"WORKSPACE\",\n ]),\n # This makes this directory a top-level in the python import\n # search path for anything that depends on this.\n imports = [\".\"],\n)\n" - } - }, - "pypi__installer": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", - "attributes": { - "url": "https://files.pythonhosted.org/packages/e5/ca/1172b6638d52f2d6caa2dd262ec4c811ba59eee96d54a7701930726bce18/installer-0.7.0-py3-none-any.whl", - "sha256": "05d1933f0a5ba7d8d6296bb6d5018e7c94fa473ceb10cf198a92ccea19c27b53", - "type": "zip", - "build_file_content": "package(default_visibility = [\"//visibility:public\"])\n\nload(\"@rules_python//python:py_library.bzl\", \"py_library\")\n\npy_library(\n name = \"lib\",\n srcs = glob([\"**/*.py\"]),\n data = glob([\"**/*\"], exclude=[\n # These entries include those put into user-installed dependencies by\n # data_exclude to avoid non-determinism.\n \"**/*.py\",\n \"**/*.pyc\",\n \"**/*.pyc.*\", # During pyc creation, temp files named *.pyc.NNN are created\n \"**/*.dist-info/RECORD\",\n \"BUILD\",\n \"WORKSPACE\",\n ]),\n # This makes this directory a top-level in the python import\n # search path for anything that depends on this.\n imports = [\".\"],\n)\n" - } - }, - "pypi__more_itertools": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", - "attributes": { - "url": "https://files.pythonhosted.org/packages/50/e2/8e10e465ee3987bb7c9ab69efb91d867d93959095f4807db102d07995d94/more_itertools-10.2.0-py3-none-any.whl", - "sha256": "686b06abe565edfab151cb8fd385a05651e1fdf8f0a14191e4439283421f8684", - "type": "zip", - "build_file_content": "package(default_visibility = [\"//visibility:public\"])\n\nload(\"@rules_python//python:py_library.bzl\", \"py_library\")\n\npy_library(\n name = \"lib\",\n srcs = glob([\"**/*.py\"]),\n data = glob([\"**/*\"], exclude=[\n # These entries include those put into user-installed dependencies by\n # data_exclude to avoid non-determinism.\n \"**/*.py\",\n \"**/*.pyc\",\n \"**/*.pyc.*\", # During pyc creation, temp files named *.pyc.NNN are created\n \"**/*.dist-info/RECORD\",\n \"BUILD\",\n \"WORKSPACE\",\n ]),\n # This makes this directory a top-level in the python import\n # search path for anything that depends on this.\n imports = [\".\"],\n)\n" - } - }, - "pypi__packaging": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", - "attributes": { - "url": "https://files.pythonhosted.org/packages/49/df/1fceb2f8900f8639e278b056416d49134fb8d84c5942ffaa01ad34782422/packaging-24.0-py3-none-any.whl", - "sha256": "2ddfb553fdf02fb784c234c7ba6ccc288296ceabec964ad2eae3777778130bc5", - "type": "zip", - "build_file_content": "package(default_visibility = [\"//visibility:public\"])\n\nload(\"@rules_python//python:py_library.bzl\", \"py_library\")\n\npy_library(\n name = \"lib\",\n srcs = glob([\"**/*.py\"]),\n data = glob([\"**/*\"], exclude=[\n # These entries include those put into user-installed dependencies by\n # data_exclude to avoid non-determinism.\n \"**/*.py\",\n \"**/*.pyc\",\n \"**/*.pyc.*\", # During pyc creation, temp files named *.pyc.NNN are created\n \"**/*.dist-info/RECORD\",\n \"BUILD\",\n \"WORKSPACE\",\n ]),\n # This makes this directory a top-level in the python import\n # search path for anything that depends on this.\n imports = [\".\"],\n)\n" - } - }, - "pypi__pep517": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", - "attributes": { - "url": "https://files.pythonhosted.org/packages/25/6e/ca4a5434eb0e502210f591b97537d322546e4833dcb4d470a48c375c5540/pep517-0.13.1-py3-none-any.whl", - "sha256": "31b206f67165b3536dd577c5c3f1518e8fbaf38cbc57efff8369a392feff1721", - "type": "zip", - "build_file_content": "package(default_visibility = [\"//visibility:public\"])\n\nload(\"@rules_python//python:py_library.bzl\", \"py_library\")\n\npy_library(\n name = \"lib\",\n srcs = glob([\"**/*.py\"]),\n data = glob([\"**/*\"], exclude=[\n # These entries include those put into user-installed dependencies by\n # data_exclude to avoid non-determinism.\n \"**/*.py\",\n \"**/*.pyc\",\n \"**/*.pyc.*\", # During pyc creation, temp files named *.pyc.NNN are created\n \"**/*.dist-info/RECORD\",\n \"BUILD\",\n \"WORKSPACE\",\n ]),\n # This makes this directory a top-level in the python import\n # search path for anything that depends on this.\n imports = [\".\"],\n)\n" - } - }, - "pypi__pip": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", - "attributes": { - "url": "https://files.pythonhosted.org/packages/8a/6a/19e9fe04fca059ccf770861c7d5721ab4c2aebc539889e97c7977528a53b/pip-24.0-py3-none-any.whl", - "sha256": "ba0d021a166865d2265246961bec0152ff124de910c5cc39f1156ce3fa7c69dc", - "type": "zip", - "build_file_content": "package(default_visibility = [\"//visibility:public\"])\n\nload(\"@rules_python//python:py_library.bzl\", \"py_library\")\n\npy_library(\n name = \"lib\",\n srcs = glob([\"**/*.py\"]),\n data = glob([\"**/*\"], exclude=[\n # These entries include those put into user-installed dependencies by\n # data_exclude to avoid non-determinism.\n \"**/*.py\",\n \"**/*.pyc\",\n \"**/*.pyc.*\", # During pyc creation, temp files named *.pyc.NNN are created\n \"**/*.dist-info/RECORD\",\n \"BUILD\",\n \"WORKSPACE\",\n ]),\n # This makes this directory a top-level in the python import\n # search path for anything that depends on this.\n imports = [\".\"],\n)\n" - } - }, - "pypi__pip_tools": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", - "attributes": { - "url": "https://files.pythonhosted.org/packages/0d/dc/38f4ce065e92c66f058ea7a368a9c5de4e702272b479c0992059f7693941/pip_tools-7.4.1-py3-none-any.whl", - "sha256": "4c690e5fbae2f21e87843e89c26191f0d9454f362d8acdbd695716493ec8b3a9", - "type": "zip", - "build_file_content": "package(default_visibility = [\"//visibility:public\"])\n\nload(\"@rules_python//python:py_library.bzl\", \"py_library\")\n\npy_library(\n name = \"lib\",\n srcs = glob([\"**/*.py\"]),\n data = glob([\"**/*\"], exclude=[\n # These entries include those put into user-installed dependencies by\n # data_exclude to avoid non-determinism.\n \"**/*.py\",\n \"**/*.pyc\",\n \"**/*.pyc.*\", # During pyc creation, temp files named *.pyc.NNN are created\n \"**/*.dist-info/RECORD\",\n \"BUILD\",\n \"WORKSPACE\",\n ]),\n # This makes this directory a top-level in the python import\n # search path for anything that depends on this.\n imports = [\".\"],\n)\n" - } - }, - "pypi__pyproject_hooks": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", - "attributes": { - "url": "https://files.pythonhosted.org/packages/ae/f3/431b9d5fe7d14af7a32340792ef43b8a714e7726f1d7b69cc4e8e7a3f1d7/pyproject_hooks-1.1.0-py3-none-any.whl", - "sha256": "7ceeefe9aec63a1064c18d939bdc3adf2d8aa1988a510afec15151578b232aa2", - "type": "zip", - "build_file_content": "package(default_visibility = [\"//visibility:public\"])\n\nload(\"@rules_python//python:py_library.bzl\", \"py_library\")\n\npy_library(\n name = \"lib\",\n srcs = glob([\"**/*.py\"]),\n data = glob([\"**/*\"], exclude=[\n # These entries include those put into user-installed dependencies by\n # data_exclude to avoid non-determinism.\n \"**/*.py\",\n \"**/*.pyc\",\n \"**/*.pyc.*\", # During pyc creation, temp files named *.pyc.NNN are created\n \"**/*.dist-info/RECORD\",\n \"BUILD\",\n \"WORKSPACE\",\n ]),\n # This makes this directory a top-level in the python import\n # search path for anything that depends on this.\n imports = [\".\"],\n)\n" - } - }, - "pypi__setuptools": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", - "attributes": { - "url": "https://files.pythonhosted.org/packages/90/99/158ad0609729111163fc1f674a5a42f2605371a4cf036d0441070e2f7455/setuptools-78.1.1-py3-none-any.whl", - "sha256": "c3a9c4211ff4c309edb8b8c4f1cbfa7ae324c4ba9f91ff254e3d305b9fd54561", - "type": "zip", - "build_file_content": "package(default_visibility = [\"//visibility:public\"])\n\nload(\"@rules_python//python:py_library.bzl\", \"py_library\")\n\npy_library(\n name = \"lib\",\n srcs = glob([\"**/*.py\"]),\n data = glob([\"**/*\"], exclude=[\n # These entries include those put into user-installed dependencies by\n # data_exclude to avoid non-determinism.\n \"**/*.py\",\n \"**/*.pyc\",\n \"**/*.pyc.*\", # During pyc creation, temp files named *.pyc.NNN are created\n \"**/*.dist-info/RECORD\",\n \"BUILD\",\n \"WORKSPACE\",\n ]),\n # This makes this directory a top-level in the python import\n # search path for anything that depends on this.\n imports = [\".\"],\n)\n" - } - }, - "pypi__tomli": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", - "attributes": { - "url": "https://files.pythonhosted.org/packages/97/75/10a9ebee3fd790d20926a90a2547f0bf78f371b2f13aa822c759680ca7b9/tomli-2.0.1-py3-none-any.whl", - "sha256": "939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc", - "type": "zip", - "build_file_content": "package(default_visibility = [\"//visibility:public\"])\n\nload(\"@rules_python//python:py_library.bzl\", \"py_library\")\n\npy_library(\n name = \"lib\",\n srcs = glob([\"**/*.py\"]),\n data = glob([\"**/*\"], exclude=[\n # These entries include those put into user-installed dependencies by\n # data_exclude to avoid non-determinism.\n \"**/*.py\",\n \"**/*.pyc\",\n \"**/*.pyc.*\", # During pyc creation, temp files named *.pyc.NNN are created\n \"**/*.dist-info/RECORD\",\n \"BUILD\",\n \"WORKSPACE\",\n ]),\n # This makes this directory a top-level in the python import\n # search path for anything that depends on this.\n imports = [\".\"],\n)\n" - } - }, - "pypi__wheel": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", - "attributes": { - "url": "https://files.pythonhosted.org/packages/7d/cd/d7460c9a869b16c3dd4e1e403cce337df165368c71d6af229a74699622ce/wheel-0.43.0-py3-none-any.whl", - "sha256": "55c570405f142630c6b9f72fe09d9b67cf1477fcf543ae5b8dcb1f5b7377da81", - "type": "zip", - "build_file_content": "package(default_visibility = [\"//visibility:public\"])\n\nload(\"@rules_python//python:py_library.bzl\", \"py_library\")\n\npy_library(\n name = \"lib\",\n srcs = glob([\"**/*.py\"]),\n data = glob([\"**/*\"], exclude=[\n # These entries include those put into user-installed dependencies by\n # data_exclude to avoid non-determinism.\n \"**/*.py\",\n \"**/*.pyc\",\n \"**/*.pyc.*\", # During pyc creation, temp files named *.pyc.NNN are created\n \"**/*.dist-info/RECORD\",\n \"BUILD\",\n \"WORKSPACE\",\n ]),\n # This makes this directory a top-level in the python import\n # search path for anything that depends on this.\n imports = [\".\"],\n)\n" - } - }, - "pypi__zipp": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", - "attributes": { - "url": "https://files.pythonhosted.org/packages/da/55/a03fd7240714916507e1fcf7ae355bd9d9ed2e6db492595f1a67f61681be/zipp-3.18.2-py3-none-any.whl", - "sha256": "dce197b859eb796242b0622af1b8beb0a722d52aa2f57133ead08edd5bf5374e", - "type": "zip", - "build_file_content": "package(default_visibility = [\"//visibility:public\"])\n\nload(\"@rules_python//python:py_library.bzl\", \"py_library\")\n\npy_library(\n name = \"lib\",\n srcs = glob([\"**/*.py\"]),\n data = glob([\"**/*\"], exclude=[\n # These entries include those put into user-installed dependencies by\n # data_exclude to avoid non-determinism.\n \"**/*.py\",\n \"**/*.pyc\",\n \"**/*.pyc.*\", # During pyc creation, temp files named *.pyc.NNN are created\n \"**/*.dist-info/RECORD\",\n \"BUILD\",\n \"WORKSPACE\",\n ]),\n # This makes this directory a top-level in the python import\n # search path for anything that depends on this.\n imports = [\".\"],\n)\n" - } - } - } - } - }, "@@rules_python+//python/uv:uv.bzl%uv": { "general": { - "bzlTransitiveDigest": "ijW9KS7qsIY+yBVvJ+Nr1mzwQox09j13DnE3iIwaeTM=", - "usagesDigest": "H8dQoNZcoqP+Mu0tHZTi4KHATzvNkM5ePuEqoQdklIU=", + "bzlTransitiveDigest": "yG9F6L2IZXKRbD/aIUa6sU7uITLUTBKOMWPbIvl1VdM=", + "usagesDigest": "OsokGRv4YC8TUDKRHnmDaAxWhcrvLj0OOH4bo3kcCyQ=", "recordedInputs": [ "REPO_MAPPING:rules_python+,bazel_tools bazel_tools", "REPO_MAPPING:rules_python+,platforms platforms" diff --git a/scripts/bazel.py b/scripts/bazel.py index c4ac94ea..3d7c85e9 100644 --- a/scripts/bazel.py +++ b/scripts/bazel.py @@ -69,7 +69,7 @@ def log_message(message_content: Any) -> None: log_message(f"Running: {' '.join(clean_command)}") subprocess.check_call(clean_command, cwd=SOURCE_ROOT, env=bazel_environment) - bazel_command = ["bazel", target_mode] + bazel_command = ["bazel", target_mode, "--keep_going"] # Each sanitizer is a named config in .bazelrc; `bazel test --config=...` # applies the build config to the test build as well. diff --git a/scripts/consteval_coverage.py b/scripts/consteval_coverage.py index 343dd4dc..de20080e 100644 --- a/scripts/consteval_coverage.py +++ b/scripts/consteval_coverage.py @@ -61,6 +61,7 @@ import sys from compiler_discovery import find_reflection_compilers +from generate_operator_thunks import generate_header SOURCE_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) @@ -531,6 +532,15 @@ def populate_work_dir( for header, lines in instrumented_by_header.items(): with open(os.path.join(work_dir, header), "w") as out: out.write("\n".join(lines) + "\n") + # Generated headers are excluded from instrumentation (no consteval code), + # but must exist in `work_dir` so translation units including protocol.hh + # compile. + generated_operator_thunks = os.path.join( + work_dir, "xyz", "detail", "operator_thunks.hh" + ) + os.makedirs(os.path.dirname(generated_operator_thunks), exist_ok=True) + with open(generated_operator_thunks, "w", encoding="utf-8") as out: + out.write(generate_header()) def compile_batch( diff --git a/scripts/generate_operator_thunks.py b/scripts/generate_operator_thunks.py new file mode 100644 index 00000000..eab4f153 --- /dev/null +++ b/scripts/generate_operator_thunks.py @@ -0,0 +1,256 @@ +#!/usr/bin/env python3 +"""Generate xyz/detail/operator_thunks.hh to an output file.""" + +import argparse +from dataclasses import dataclass +from pathlib import Path + + +@dataclass(frozen=True) +class OperatorDefinition: + """Description of one overloadable C++ member operator.""" + + meta_enum_name: str + symbol: str + unary_only: bool = False + + +OPERATORS: tuple[OperatorDefinition, ...] = ( + OperatorDefinition("op_parentheses", "()"), + OperatorDefinition("op_square_brackets", "[]"), + OperatorDefinition("op_arrow", "->", unary_only=True), + OperatorDefinition("op_star", "*"), + OperatorDefinition("op_arrow_star", "->*"), + OperatorDefinition("op_tilde", "~", unary_only=True), + OperatorDefinition("op_exclamation", "!", unary_only=True), + OperatorDefinition("op_plus", "+"), + OperatorDefinition("op_minus", "-"), + OperatorDefinition("op_slash", "/"), + OperatorDefinition("op_percent", "%"), + OperatorDefinition("op_caret", "^"), + OperatorDefinition("op_ampersand", "&"), + OperatorDefinition("op_pipe", "|"), + OperatorDefinition("op_plus_equals", "+="), + OperatorDefinition("op_minus_equals", "-="), + OperatorDefinition("op_star_equals", "*="), + OperatorDefinition("op_slash_equals", "/="), + OperatorDefinition("op_percent_equals", "%="), + OperatorDefinition("op_caret_equals", "^="), + OperatorDefinition("op_ampersand_equals", "&="), + OperatorDefinition("op_pipe_equals", "|="), + OperatorDefinition("op_ampersand_ampersand", "&&"), + OperatorDefinition("op_pipe_pipe", "||"), + OperatorDefinition("op_less_less", "<<"), + OperatorDefinition("op_greater_greater", ">>"), + OperatorDefinition("op_less_less_equals", "<<="), + OperatorDefinition("op_greater_greater_equals", ">>="), + OperatorDefinition("op_plus_plus", "++"), + OperatorDefinition("op_minus_minus", "--"), + OperatorDefinition("op_comma", ","), + OperatorDefinition("op_equals_equals", "=="), + OperatorDefinition("op_exclamation_equals", "!="), + OperatorDefinition("op_less", "<"), + OperatorDefinition("op_less_equals", "<="), + OperatorDefinition("op_greater", ">"), + OperatorDefinition("op_greater_equals", ">="), + OperatorDefinition("op_spaceship", "<=>"), +) + +HEADER_PROLOGUE = """\ +/* Copyright (c) 2025 The XYZ Protocol Authors. All Rights Reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +==============================================================================*/ +// Generated by scripts/generate_operator_thunks.py. Do not edit by hand. +#ifndef XYZ_PROTOCOL_OPERATOR_THUNKS_HH_ +#define XYZ_PROTOCOL_OPERATOR_THUNKS_HH_ + +#include +#include + +#include "xyz/detail/overload_spec.hh" +#include "xyz/detail/vtable.hh" + +namespace xyz::detail { + +// Thunk for one overload of a synthesised operator. Operators can't be reached +// through a named member, so `xyz_protocol_operator_overload_set` derives from +// this thunk directly instead of holding it as a data member, letting +// `ProtocolType` be recovered with a plain static_cast. +template +struct xyz_protocol_operator_thunk { + static_assert( + false, + "Unspecialized xyz_protocol_operator_thunk cannot be instantiated."); +}; + +// The overload set for a synthesised operator X inheriting from an +// `xyz_protocol_operator_thunk` for each overload. +template +struct xyz_protocol_operator_overload_set { + static_assert(false, + "Unspecialized xyz_protocol_operator_overload_set cannot be " + "instantiated."); +}; + +// The `xyz_protocol_operator_thunk` specialisation for an `overload_spec`. +template +struct operator_thunk_for; + +template +struct operator_thunk_for, ProtocolType, + Vtable> { + // clang-format off + using type = + typename[:substitute(^^xyz_protocol_operator_thunk, + { + std::meta::reflect_constant(operator_of(Member)), + function_pointer_type_of(Member), + ^^ProtocolType, ^^Vtable, + std::meta::reflect_constant(Member), + std::meta::reflect_constant(MemberQualifiers) + }):]; + // clang-format on +}; + +template +using operator_thunk_t = + operator_thunk_for::type; +""" + +HEADER_EPILOGUE = """\ +} // namespace xyz::detail + +#endif // XYZ_PROTOCOL_OPERATOR_THUNKS_HH_ +""" + + +def render_operator_block(operator_definition: OperatorDefinition) -> str: + """Render the thunk and overload-set specializations for one operator.""" + meta_enum_name = operator_definition.meta_enum_name + symbol = operator_definition.symbol + if operator_definition.unary_only: + template_parameters = ( + "typename R, bool IsNoexcept, typename ProtocolType,\n" + " typename Vtable, std::meta::info Member,\n" + " member_qualifiers MemberQualifiers" + ) + function_pointer_type = "R (*)() noexcept(IsNoexcept)" + parameter_list = "" + forwarded_arguments = "" + else: + template_parameters = ( + "typename R, typename... Args, bool IsNoexcept, typename ProtocolType,\n" + " typename Vtable, std::meta::info Member,\n" + " member_qualifiers MemberQualifiers" + ) + function_pointer_type = "R (*)(Args...) noexcept(IsNoexcept)" + parameter_list = "Args... args" + forwarded_arguments = ",\n std::forward(args)..." + + using_operator_name = f"operator{symbol} " if symbol == "," else f"operator{symbol}" + + return f"""\ +// operator{symbol} +template <{template_parameters}> +struct xyz_protocol_operator_thunk< + std::meta::operators::{meta_enum_name}, + {function_pointer_type}, + ProtocolType, Vtable, Member, MemberQualifiers> {{ + R operator{symbol}({parameter_list}) noexcept(IsNoexcept) + requires(MemberQualifiers == member_qualifiers::unqualified) + {{ + auto* protocol_object = static_cast(this); + return call_through_vtable( + protocol_object, protocol_object->xyz_protocol_vtable_, + protocol_object->xyz_protocol_erased_object(){forwarded_arguments}); + }} + + R operator{symbol}({parameter_list}) const noexcept(IsNoexcept) + requires(MemberQualifiers == member_qualifiers::const_qualified) + {{ + const auto* protocol_object = static_cast(this); + return call_through_vtable( + protocol_object, protocol_object->xyz_protocol_vtable_, + protocol_object->xyz_protocol_erased_object(){forwarded_arguments}); + }} + + protected: + xyz_protocol_operator_thunk() = default; + ~xyz_protocol_operator_thunk() = default; + xyz_protocol_operator_thunk(const xyz_protocol_operator_thunk&) = default; + xyz_protocol_operator_thunk(xyz_protocol_operator_thunk&&) = default; + xyz_protocol_operator_thunk& operator=(const xyz_protocol_operator_thunk&) = + default; + xyz_protocol_operator_thunk& operator=(xyz_protocol_operator_thunk&&) = + default; +}}; + +template +struct xyz_protocol_operator_overload_set< + std::meta::operators::{meta_enum_name}, ProtocolType, Vtable, + OverloadSpecs...> + : operator_thunk_t... {{ + using operator_thunk_t::{using_operator_name}...; + + protected: + xyz_protocol_operator_overload_set() = default; + ~xyz_protocol_operator_overload_set() = default; + xyz_protocol_operator_overload_set( + const xyz_protocol_operator_overload_set&) = default; + xyz_protocol_operator_overload_set(xyz_protocol_operator_overload_set&&) = + default; + xyz_protocol_operator_overload_set& operator=( + const xyz_protocol_operator_overload_set&) = default; + xyz_protocol_operator_overload_set& operator=( + xyz_protocol_operator_overload_set&&) = default; +}}; +""" + + +def generate_header() -> str: + """Return the full contents of xyz/detail/operator_thunks.hh.""" + sections = [HEADER_PROLOGUE] + sections.extend(render_operator_block(operator) for operator in OPERATORS) + sections.append(HEADER_EPILOGUE) + return "\n".join(sections) + + +def main() -> None: + """Write the generated operator thunks header to the requested output path.""" + argument_parser = argparse.ArgumentParser( + description="Generate xyz/detail/operator_thunks.hh." + ) + argument_parser.add_argument( + "--output", + type=Path, + required=True, + help="Output file path.", + ) + parsed_arguments = argument_parser.parse_args() + output_path: Path = parsed_arguments.output + output_path.parent.mkdir(parents=True, exist_ok=True) + output_path.write_text(generate_header(), encoding="utf-8") + + +if __name__ == "__main__": + main() diff --git a/xyz/detail/conformance.hh b/xyz/detail/conformance.hh index c6b76d7a..92d7c69c 100644 --- a/xyz/detail/conformance.hh +++ b/xyz/detail/conformance.hh @@ -325,10 +325,6 @@ consteval std::vector protocol_interface_function_infos() { if (has_reserved_member_name(member)) { reject_interface_member("reserved member name", member); } - if (is_lvalue_reference_qualified(member) || - is_rvalue_reference_qualified(member)) { - reject_interface_member("ref-qualified member function", member); - } std::vector params = parameters_of(member); if (!params.empty() && is_explicit_object_parameter(params.front())) { reject_interface_member("explicit-object member function", member); diff --git a/xyz/detail/operator_thunks.hh b/xyz/detail/operator_thunks.hh deleted file mode 100644 index f9d14bc6..00000000 --- a/xyz/detail/operator_thunks.hh +++ /dev/null @@ -1,2269 +0,0 @@ -/* Copyright (c) 2025 The XYZ Protocol Authors. All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -==============================================================================*/ -#ifndef XYZ_PROTOCOL_OPERATOR_THUNKS_HH_ -#define XYZ_PROTOCOL_OPERATOR_THUNKS_HH_ - -#include -#include - -#include "xyz/detail/overload_spec.hh" -#include "xyz/detail/vtable.hh" - -namespace xyz::detail { - -// Thunk for one overload of a synthesised call operator. `operator()` can't -// be reached through a named member, so `xyz_protocol_operator_overload_set` -// derives from this thunk directly instead of holding it as a data member, -// letting `ProtocolType` be recovered with a plain static_cast. -template -struct xyz_protocol_operator_thunk { - static_assert( - false, - "Unspecialized xyz_protocol_operator_thunk cannot be instantiated."); -}; - -// The overload set for a synthesised operator X inheriting from an -// `xyz_protocol_operator_thunk` for each overload. -template -struct xyz_protocol_operator_overload_set { - static_assert(false, - "Unspecialized xyz_protocol_operator_overload_set cannot be " - "instantiated."); -}; - -// The `xyz_protocol_operator_thunk` specialisation for an `overload_spec`. -template -struct operator_thunk_for; - -template -struct operator_thunk_for, ProtocolType, - Vtable> { - // clang-format off - using type = - typename[:substitute(^^xyz_protocol_operator_thunk, - { - std::meta::reflect_constant(operator_of(Member)), - function_pointer_type_of(Member), - ^^ProtocolType, ^^Vtable, - std::meta::reflect_constant(Member), - std::meta::reflect_constant(MemberQualifiers) - }):]; - // clang-format on -}; - -template -using operator_thunk_t = - operator_thunk_for::type; - -// operator() -template -struct xyz_protocol_operator_thunk< - std::meta::operators::op_parentheses, R (*)(Args...) noexcept(IsNoexcept), - ProtocolType, Vtable, Member, MemberQualifiers> { - R operator()(Args... args) noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::unqualified) - { - auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - R operator()(Args... args) const noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::const_qualified) - { - const auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - protected: - xyz_protocol_operator_thunk() = default; - ~xyz_protocol_operator_thunk() = default; - xyz_protocol_operator_thunk(const xyz_protocol_operator_thunk&) = default; - xyz_protocol_operator_thunk(xyz_protocol_operator_thunk&&) = default; - xyz_protocol_operator_thunk& operator=(const xyz_protocol_operator_thunk&) = - default; - xyz_protocol_operator_thunk& operator=(xyz_protocol_operator_thunk&&) = - default; -}; - -template -struct xyz_protocol_operator_overload_set - : operator_thunk_t... { - using operator_thunk_t::operator()...; - - protected: - xyz_protocol_operator_overload_set() = default; - ~xyz_protocol_operator_overload_set() = default; - xyz_protocol_operator_overload_set( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set(xyz_protocol_operator_overload_set&&) = - default; - xyz_protocol_operator_overload_set& operator=( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set& operator=( - xyz_protocol_operator_overload_set&&) = default; -}; - -// operator [] -template -struct xyz_protocol_operator_thunk { - R operator[](Args... args) noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::unqualified) - { - auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - R operator[](Args... args) const noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::const_qualified) - { - const auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - protected: - xyz_protocol_operator_thunk() = default; - ~xyz_protocol_operator_thunk() = default; - xyz_protocol_operator_thunk(const xyz_protocol_operator_thunk&) = default; - xyz_protocol_operator_thunk(xyz_protocol_operator_thunk&&) = default; - xyz_protocol_operator_thunk& operator=(const xyz_protocol_operator_thunk&) = - default; - xyz_protocol_operator_thunk& operator=(xyz_protocol_operator_thunk&&) = - default; -}; - -template -struct xyz_protocol_operator_overload_set< - std::meta::operators::op_square_brackets, ProtocolType, Vtable, - OverloadSpecs...> - : operator_thunk_t... { - using operator_thunk_t::operator[]...; - - protected: - xyz_protocol_operator_overload_set() = default; - ~xyz_protocol_operator_overload_set() = default; - xyz_protocol_operator_overload_set( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set(xyz_protocol_operator_overload_set&&) = - default; - xyz_protocol_operator_overload_set& operator=( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set& operator=( - xyz_protocol_operator_overload_set&&) = default; -}; - -// operator -> -template -struct xyz_protocol_operator_thunk< - std::meta::operators::op_arrow, R (*)(Args...) noexcept(IsNoexcept), - ProtocolType, Vtable, Member, MemberQualifiers> { - R operator->() noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::unqualified) - { - auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object()); - } - - R operator->() const noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::const_qualified) - { - const auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object()); - } - - protected: - xyz_protocol_operator_thunk() = default; - ~xyz_protocol_operator_thunk() = default; - xyz_protocol_operator_thunk(const xyz_protocol_operator_thunk&) = default; - xyz_protocol_operator_thunk(xyz_protocol_operator_thunk&&) = default; - xyz_protocol_operator_thunk& operator=(const xyz_protocol_operator_thunk&) = - default; - xyz_protocol_operator_thunk& operator=(xyz_protocol_operator_thunk&&) = - default; -}; - -template -struct xyz_protocol_operator_overload_set< - std::meta::operators::op_arrow, ProtocolType, Vtable, OverloadSpecs...> - : operator_thunk_t... { - using operator_thunk_t::operator->...; - - protected: - xyz_protocol_operator_overload_set() = default; - ~xyz_protocol_operator_overload_set() = default; - xyz_protocol_operator_overload_set( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set(xyz_protocol_operator_overload_set&&) = - default; - xyz_protocol_operator_overload_set& operator=( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set& operator=( - xyz_protocol_operator_overload_set&&) = default; -}; - -// operator * -template -struct xyz_protocol_operator_thunk< - std::meta::operators::op_star, R (*)(Args...) noexcept(IsNoexcept), - ProtocolType, Vtable, Member, MemberQualifiers> { - R operator*(Args... args) noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::unqualified) - { - auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - R operator*(Args... args) const noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::const_qualified) - { - const auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - protected: - xyz_protocol_operator_thunk() = default; - ~xyz_protocol_operator_thunk() = default; - xyz_protocol_operator_thunk(const xyz_protocol_operator_thunk&) = default; - xyz_protocol_operator_thunk(xyz_protocol_operator_thunk&&) = default; - xyz_protocol_operator_thunk& operator=(const xyz_protocol_operator_thunk&) = - default; - xyz_protocol_operator_thunk& operator=(xyz_protocol_operator_thunk&&) = - default; -}; - -template -struct xyz_protocol_operator_overload_set< - std::meta::operators::op_star, ProtocolType, Vtable, OverloadSpecs...> - : operator_thunk_t... { - using operator_thunk_t::operator*...; - - protected: - xyz_protocol_operator_overload_set() = default; - ~xyz_protocol_operator_overload_set() = default; - xyz_protocol_operator_overload_set( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set(xyz_protocol_operator_overload_set&&) = - default; - xyz_protocol_operator_overload_set& operator=( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set& operator=( - xyz_protocol_operator_overload_set&&) = default; -}; - -// operator->* -template -struct xyz_protocol_operator_thunk< - std::meta::operators::op_arrow_star, R (*)(Args...) noexcept(IsNoexcept), - ProtocolType, Vtable, Member, MemberQualifiers> { - R operator->*(Args... args) noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::unqualified) - { - auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - R operator->*(Args... args) const noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::const_qualified) - { - const auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - protected: - xyz_protocol_operator_thunk() = default; - ~xyz_protocol_operator_thunk() = default; - xyz_protocol_operator_thunk(const xyz_protocol_operator_thunk&) = default; - xyz_protocol_operator_thunk(xyz_protocol_operator_thunk&&) = default; - xyz_protocol_operator_thunk& operator=(const xyz_protocol_operator_thunk&) = - default; - xyz_protocol_operator_thunk& operator=(xyz_protocol_operator_thunk&&) = - default; -}; - -template -struct xyz_protocol_operator_overload_set< - std::meta::operators::op_arrow_star, ProtocolType, Vtable, OverloadSpecs...> - : operator_thunk_t... { - using operator_thunk_t::operator->*...; - - protected: - xyz_protocol_operator_overload_set() = default; - ~xyz_protocol_operator_overload_set() = default; - xyz_protocol_operator_overload_set( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set(xyz_protocol_operator_overload_set&&) = - default; - xyz_protocol_operator_overload_set& operator=( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set& operator=( - xyz_protocol_operator_overload_set&&) = default; -}; - -// operator~: always unary as a member (the language forbids a parameter), -// so this uses a fixed R(*)() rather than the generic R(*)(Args...) shape. -template -struct xyz_protocol_operator_thunk { - R operator~() noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::unqualified) - { - auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object()); - } - - R operator~() const noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::const_qualified) - { - const auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object()); - } - - protected: - xyz_protocol_operator_thunk() = default; - ~xyz_protocol_operator_thunk() = default; - xyz_protocol_operator_thunk(const xyz_protocol_operator_thunk&) = default; - xyz_protocol_operator_thunk(xyz_protocol_operator_thunk&&) = default; - xyz_protocol_operator_thunk& operator=(const xyz_protocol_operator_thunk&) = - default; - xyz_protocol_operator_thunk& operator=(xyz_protocol_operator_thunk&&) = - default; -}; - -template -struct xyz_protocol_operator_overload_set< - std::meta::operators::op_tilde, ProtocolType, Vtable, OverloadSpecs...> - : operator_thunk_t... { - using operator_thunk_t::operator~...; - - protected: - xyz_protocol_operator_overload_set() = default; - ~xyz_protocol_operator_overload_set() = default; - xyz_protocol_operator_overload_set( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set(xyz_protocol_operator_overload_set&&) = - default; - xyz_protocol_operator_overload_set& operator=( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set& operator=( - xyz_protocol_operator_overload_set&&) = default; -}; - -// operator!: always unary as a member, for the same reason as operator~. -template -struct xyz_protocol_operator_thunk { - R operator!() noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::unqualified) - { - auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object()); - } - - R operator!() const noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::const_qualified) - { - const auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object()); - } - - protected: - xyz_protocol_operator_thunk() = default; - ~xyz_protocol_operator_thunk() = default; - xyz_protocol_operator_thunk(const xyz_protocol_operator_thunk&) = default; - xyz_protocol_operator_thunk(xyz_protocol_operator_thunk&&) = default; - xyz_protocol_operator_thunk& operator=(const xyz_protocol_operator_thunk&) = - default; - xyz_protocol_operator_thunk& operator=(xyz_protocol_operator_thunk&&) = - default; -}; - -template -struct xyz_protocol_operator_overload_set - : operator_thunk_t... { - using operator_thunk_t::operator!...; - - protected: - xyz_protocol_operator_overload_set() = default; - ~xyz_protocol_operator_overload_set() = default; - xyz_protocol_operator_overload_set( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set(xyz_protocol_operator_overload_set&&) = - default; - xyz_protocol_operator_overload_set& operator=( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set& operator=( - xyz_protocol_operator_overload_set&&) = default; -}; - -// operator+ -template -struct xyz_protocol_operator_thunk< - std::meta::operators::op_plus, R (*)(Args...) noexcept(IsNoexcept), - ProtocolType, Vtable, Member, MemberQualifiers> { - R operator+(Args... args) noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::unqualified) - { - auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - R operator+(Args... args) const noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::const_qualified) - { - const auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - protected: - xyz_protocol_operator_thunk() = default; - ~xyz_protocol_operator_thunk() = default; - xyz_protocol_operator_thunk(const xyz_protocol_operator_thunk&) = default; - xyz_protocol_operator_thunk(xyz_protocol_operator_thunk&&) = default; - xyz_protocol_operator_thunk& operator=(const xyz_protocol_operator_thunk&) = - default; - xyz_protocol_operator_thunk& operator=(xyz_protocol_operator_thunk&&) = - default; -}; - -template -struct xyz_protocol_operator_overload_set< - std::meta::operators::op_plus, ProtocolType, Vtable, OverloadSpecs...> - : operator_thunk_t... { - using operator_thunk_t::operator+...; - - protected: - xyz_protocol_operator_overload_set() = default; - ~xyz_protocol_operator_overload_set() = default; - xyz_protocol_operator_overload_set( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set(xyz_protocol_operator_overload_set&&) = - default; - xyz_protocol_operator_overload_set& operator=( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set& operator=( - xyz_protocol_operator_overload_set&&) = default; -}; - -// operator- -template -struct xyz_protocol_operator_thunk< - std::meta::operators::op_minus, R (*)(Args...) noexcept(IsNoexcept), - ProtocolType, Vtable, Member, MemberQualifiers> { - R operator-(Args... args) noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::unqualified) - { - auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - R operator-(Args... args) const noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::const_qualified) - { - const auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - protected: - xyz_protocol_operator_thunk() = default; - ~xyz_protocol_operator_thunk() = default; - xyz_protocol_operator_thunk(const xyz_protocol_operator_thunk&) = default; - xyz_protocol_operator_thunk(xyz_protocol_operator_thunk&&) = default; - xyz_protocol_operator_thunk& operator=(const xyz_protocol_operator_thunk&) = - default; - xyz_protocol_operator_thunk& operator=(xyz_protocol_operator_thunk&&) = - default; -}; - -template -struct xyz_protocol_operator_overload_set< - std::meta::operators::op_minus, ProtocolType, Vtable, OverloadSpecs...> - : operator_thunk_t... { - using operator_thunk_t::operator-...; - - protected: - xyz_protocol_operator_overload_set() = default; - ~xyz_protocol_operator_overload_set() = default; - xyz_protocol_operator_overload_set( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set(xyz_protocol_operator_overload_set&&) = - default; - xyz_protocol_operator_overload_set& operator=( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set& operator=( - xyz_protocol_operator_overload_set&&) = default; -}; - -// operator/ -template -struct xyz_protocol_operator_thunk< - std::meta::operators::op_slash, R (*)(Args...) noexcept(IsNoexcept), - ProtocolType, Vtable, Member, MemberQualifiers> { - R operator/(Args... args) noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::unqualified) - { - auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - R operator/(Args... args) const noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::const_qualified) - { - const auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - protected: - xyz_protocol_operator_thunk() = default; - ~xyz_protocol_operator_thunk() = default; - xyz_protocol_operator_thunk(const xyz_protocol_operator_thunk&) = default; - xyz_protocol_operator_thunk(xyz_protocol_operator_thunk&&) = default; - xyz_protocol_operator_thunk& operator=(const xyz_protocol_operator_thunk&) = - default; - xyz_protocol_operator_thunk& operator=(xyz_protocol_operator_thunk&&) = - default; -}; - -template -struct xyz_protocol_operator_overload_set< - std::meta::operators::op_slash, ProtocolType, Vtable, OverloadSpecs...> - : operator_thunk_t... { - using operator_thunk_t::operator/...; - - protected: - xyz_protocol_operator_overload_set() = default; - ~xyz_protocol_operator_overload_set() = default; - xyz_protocol_operator_overload_set( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set(xyz_protocol_operator_overload_set&&) = - default; - xyz_protocol_operator_overload_set& operator=( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set& operator=( - xyz_protocol_operator_overload_set&&) = default; -}; - -// operator% -template -struct xyz_protocol_operator_thunk< - std::meta::operators::op_percent, R (*)(Args...) noexcept(IsNoexcept), - ProtocolType, Vtable, Member, MemberQualifiers> { - R operator%(Args... args) noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::unqualified) - { - auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - R operator%(Args... args) const noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::const_qualified) - { - const auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - protected: - xyz_protocol_operator_thunk() = default; - ~xyz_protocol_operator_thunk() = default; - xyz_protocol_operator_thunk(const xyz_protocol_operator_thunk&) = default; - xyz_protocol_operator_thunk(xyz_protocol_operator_thunk&&) = default; - xyz_protocol_operator_thunk& operator=(const xyz_protocol_operator_thunk&) = - default; - xyz_protocol_operator_thunk& operator=(xyz_protocol_operator_thunk&&) = - default; -}; - -template -struct xyz_protocol_operator_overload_set< - std::meta::operators::op_percent, ProtocolType, Vtable, OverloadSpecs...> - : operator_thunk_t... { - using operator_thunk_t::operator%...; - - protected: - xyz_protocol_operator_overload_set() = default; - ~xyz_protocol_operator_overload_set() = default; - xyz_protocol_operator_overload_set( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set(xyz_protocol_operator_overload_set&&) = - default; - xyz_protocol_operator_overload_set& operator=( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set& operator=( - xyz_protocol_operator_overload_set&&) = default; -}; - -// operator^ -template -struct xyz_protocol_operator_thunk< - std::meta::operators::op_caret, R (*)(Args...) noexcept(IsNoexcept), - ProtocolType, Vtable, Member, MemberQualifiers> { - R operator^(Args... args) noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::unqualified) - { - auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - R operator^(Args... args) const noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::const_qualified) - { - const auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - protected: - xyz_protocol_operator_thunk() = default; - ~xyz_protocol_operator_thunk() = default; - xyz_protocol_operator_thunk(const xyz_protocol_operator_thunk&) = default; - xyz_protocol_operator_thunk(xyz_protocol_operator_thunk&&) = default; - xyz_protocol_operator_thunk& operator=(const xyz_protocol_operator_thunk&) = - default; - xyz_protocol_operator_thunk& operator=(xyz_protocol_operator_thunk&&) = - default; -}; - -template -struct xyz_protocol_operator_overload_set< - std::meta::operators::op_caret, ProtocolType, Vtable, OverloadSpecs...> - : operator_thunk_t... { - using operator_thunk_t::operator^...; - - protected: - xyz_protocol_operator_overload_set() = default; - ~xyz_protocol_operator_overload_set() = default; - xyz_protocol_operator_overload_set( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set(xyz_protocol_operator_overload_set&&) = - default; - xyz_protocol_operator_overload_set& operator=( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set& operator=( - xyz_protocol_operator_overload_set&&) = default; -}; - -// operator& -template -struct xyz_protocol_operator_thunk< - std::meta::operators::op_ampersand, R (*)(Args...) noexcept(IsNoexcept), - ProtocolType, Vtable, Member, MemberQualifiers> { - R operator&(Args... args) noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::unqualified) - { - auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - R operator&(Args... args) const noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::const_qualified) - { - const auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - protected: - xyz_protocol_operator_thunk() = default; - ~xyz_protocol_operator_thunk() = default; - xyz_protocol_operator_thunk(const xyz_protocol_operator_thunk&) = default; - xyz_protocol_operator_thunk(xyz_protocol_operator_thunk&&) = default; - xyz_protocol_operator_thunk& operator=(const xyz_protocol_operator_thunk&) = - default; - xyz_protocol_operator_thunk& operator=(xyz_protocol_operator_thunk&&) = - default; -}; - -template -struct xyz_protocol_operator_overload_set< - std::meta::operators::op_ampersand, ProtocolType, Vtable, OverloadSpecs...> - : operator_thunk_t... { - using operator_thunk_t::operator&...; - - protected: - xyz_protocol_operator_overload_set() = default; - ~xyz_protocol_operator_overload_set() = default; - xyz_protocol_operator_overload_set( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set(xyz_protocol_operator_overload_set&&) = - default; - xyz_protocol_operator_overload_set& operator=( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set& operator=( - xyz_protocol_operator_overload_set&&) = default; -}; - -// operator| -template -struct xyz_protocol_operator_thunk< - std::meta::operators::op_pipe, R (*)(Args...) noexcept(IsNoexcept), - ProtocolType, Vtable, Member, MemberQualifiers> { - R operator|(Args... args) noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::unqualified) - { - auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - R operator|(Args... args) const noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::const_qualified) - { - const auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - protected: - xyz_protocol_operator_thunk() = default; - ~xyz_protocol_operator_thunk() = default; - xyz_protocol_operator_thunk(const xyz_protocol_operator_thunk&) = default; - xyz_protocol_operator_thunk(xyz_protocol_operator_thunk&&) = default; - xyz_protocol_operator_thunk& operator=(const xyz_protocol_operator_thunk&) = - default; - xyz_protocol_operator_thunk& operator=(xyz_protocol_operator_thunk&&) = - default; -}; - -template -struct xyz_protocol_operator_overload_set< - std::meta::operators::op_pipe, ProtocolType, Vtable, OverloadSpecs...> - : operator_thunk_t... { - using operator_thunk_t::operator|...; - - protected: - xyz_protocol_operator_overload_set() = default; - ~xyz_protocol_operator_overload_set() = default; - xyz_protocol_operator_overload_set( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set(xyz_protocol_operator_overload_set&&) = - default; - xyz_protocol_operator_overload_set& operator=( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set& operator=( - xyz_protocol_operator_overload_set&&) = default; -}; - -// operator+= -template -struct xyz_protocol_operator_thunk< - std::meta::operators::op_plus_equals, R (*)(Args...) noexcept(IsNoexcept), - ProtocolType, Vtable, Member, MemberQualifiers> { - R operator+=(Args... args) noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::unqualified) - { - auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - R operator+=(Args... args) const noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::const_qualified) - { - const auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - protected: - xyz_protocol_operator_thunk() = default; - ~xyz_protocol_operator_thunk() = default; - xyz_protocol_operator_thunk(const xyz_protocol_operator_thunk&) = default; - xyz_protocol_operator_thunk(xyz_protocol_operator_thunk&&) = default; - xyz_protocol_operator_thunk& operator=(const xyz_protocol_operator_thunk&) = - default; - xyz_protocol_operator_thunk& operator=(xyz_protocol_operator_thunk&&) = - default; -}; - -template -struct xyz_protocol_operator_overload_set - : operator_thunk_t... { - using operator_thunk_t::operator+=...; - - protected: - xyz_protocol_operator_overload_set() = default; - ~xyz_protocol_operator_overload_set() = default; - xyz_protocol_operator_overload_set( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set(xyz_protocol_operator_overload_set&&) = - default; - xyz_protocol_operator_overload_set& operator=( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set& operator=( - xyz_protocol_operator_overload_set&&) = default; -}; - -// operator-= -template -struct xyz_protocol_operator_thunk< - std::meta::operators::op_minus_equals, R (*)(Args...) noexcept(IsNoexcept), - ProtocolType, Vtable, Member, MemberQualifiers> { - R operator-=(Args... args) noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::unqualified) - { - auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - R operator-=(Args... args) const noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::const_qualified) - { - const auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - protected: - xyz_protocol_operator_thunk() = default; - ~xyz_protocol_operator_thunk() = default; - xyz_protocol_operator_thunk(const xyz_protocol_operator_thunk&) = default; - xyz_protocol_operator_thunk(xyz_protocol_operator_thunk&&) = default; - xyz_protocol_operator_thunk& operator=(const xyz_protocol_operator_thunk&) = - default; - xyz_protocol_operator_thunk& operator=(xyz_protocol_operator_thunk&&) = - default; -}; - -template -struct xyz_protocol_operator_overload_set - : operator_thunk_t... { - using operator_thunk_t::operator-=...; - - protected: - xyz_protocol_operator_overload_set() = default; - ~xyz_protocol_operator_overload_set() = default; - xyz_protocol_operator_overload_set( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set(xyz_protocol_operator_overload_set&&) = - default; - xyz_protocol_operator_overload_set& operator=( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set& operator=( - xyz_protocol_operator_overload_set&&) = default; -}; - -// operator*= -template -struct xyz_protocol_operator_thunk< - std::meta::operators::op_star_equals, R (*)(Args...) noexcept(IsNoexcept), - ProtocolType, Vtable, Member, MemberQualifiers> { - R operator*=(Args... args) noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::unqualified) - { - auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - R operator*=(Args... args) const noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::const_qualified) - { - const auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - protected: - xyz_protocol_operator_thunk() = default; - ~xyz_protocol_operator_thunk() = default; - xyz_protocol_operator_thunk(const xyz_protocol_operator_thunk&) = default; - xyz_protocol_operator_thunk(xyz_protocol_operator_thunk&&) = default; - xyz_protocol_operator_thunk& operator=(const xyz_protocol_operator_thunk&) = - default; - xyz_protocol_operator_thunk& operator=(xyz_protocol_operator_thunk&&) = - default; -}; - -template -struct xyz_protocol_operator_overload_set - : operator_thunk_t... { - using operator_thunk_t::operator*=...; - - protected: - xyz_protocol_operator_overload_set() = default; - ~xyz_protocol_operator_overload_set() = default; - xyz_protocol_operator_overload_set( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set(xyz_protocol_operator_overload_set&&) = - default; - xyz_protocol_operator_overload_set& operator=( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set& operator=( - xyz_protocol_operator_overload_set&&) = default; -}; - -// operator/= -template -struct xyz_protocol_operator_thunk< - std::meta::operators::op_slash_equals, R (*)(Args...) noexcept(IsNoexcept), - ProtocolType, Vtable, Member, MemberQualifiers> { - R operator/=(Args... args) noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::unqualified) - { - auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - R operator/=(Args... args) const noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::const_qualified) - { - const auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - protected: - xyz_protocol_operator_thunk() = default; - ~xyz_protocol_operator_thunk() = default; - xyz_protocol_operator_thunk(const xyz_protocol_operator_thunk&) = default; - xyz_protocol_operator_thunk(xyz_protocol_operator_thunk&&) = default; - xyz_protocol_operator_thunk& operator=(const xyz_protocol_operator_thunk&) = - default; - xyz_protocol_operator_thunk& operator=(xyz_protocol_operator_thunk&&) = - default; -}; - -template -struct xyz_protocol_operator_overload_set - : operator_thunk_t... { - using operator_thunk_t::operator/=...; - - protected: - xyz_protocol_operator_overload_set() = default; - ~xyz_protocol_operator_overload_set() = default; - xyz_protocol_operator_overload_set( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set(xyz_protocol_operator_overload_set&&) = - default; - xyz_protocol_operator_overload_set& operator=( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set& operator=( - xyz_protocol_operator_overload_set&&) = default; -}; - -// operator%= -template -struct xyz_protocol_operator_thunk { - R operator%=(Args... args) noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::unqualified) - { - auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - R operator%=(Args... args) const noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::const_qualified) - { - const auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - protected: - xyz_protocol_operator_thunk() = default; - ~xyz_protocol_operator_thunk() = default; - xyz_protocol_operator_thunk(const xyz_protocol_operator_thunk&) = default; - xyz_protocol_operator_thunk(xyz_protocol_operator_thunk&&) = default; - xyz_protocol_operator_thunk& operator=(const xyz_protocol_operator_thunk&) = - default; - xyz_protocol_operator_thunk& operator=(xyz_protocol_operator_thunk&&) = - default; -}; - -template -struct xyz_protocol_operator_overload_set< - std::meta::operators::op_percent_equals, ProtocolType, Vtable, - OverloadSpecs...> - : operator_thunk_t... { - using operator_thunk_t::operator%=...; - - protected: - xyz_protocol_operator_overload_set() = default; - ~xyz_protocol_operator_overload_set() = default; - xyz_protocol_operator_overload_set( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set(xyz_protocol_operator_overload_set&&) = - default; - xyz_protocol_operator_overload_set& operator=( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set& operator=( - xyz_protocol_operator_overload_set&&) = default; -}; - -// operator^= -template -struct xyz_protocol_operator_thunk< - std::meta::operators::op_caret_equals, R (*)(Args...) noexcept(IsNoexcept), - ProtocolType, Vtable, Member, MemberQualifiers> { - R operator^=(Args... args) noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::unqualified) - { - auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - R operator^=(Args... args) const noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::const_qualified) - { - const auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - protected: - xyz_protocol_operator_thunk() = default; - ~xyz_protocol_operator_thunk() = default; - xyz_protocol_operator_thunk(const xyz_protocol_operator_thunk&) = default; - xyz_protocol_operator_thunk(xyz_protocol_operator_thunk&&) = default; - xyz_protocol_operator_thunk& operator=(const xyz_protocol_operator_thunk&) = - default; - xyz_protocol_operator_thunk& operator=(xyz_protocol_operator_thunk&&) = - default; -}; - -template -struct xyz_protocol_operator_overload_set - : operator_thunk_t... { - using operator_thunk_t::operator^=...; - - protected: - xyz_protocol_operator_overload_set() = default; - ~xyz_protocol_operator_overload_set() = default; - xyz_protocol_operator_overload_set( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set(xyz_protocol_operator_overload_set&&) = - default; - xyz_protocol_operator_overload_set& operator=( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set& operator=( - xyz_protocol_operator_overload_set&&) = default; -}; - -// operator&= -template -struct xyz_protocol_operator_thunk { - R operator&=(Args... args) noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::unqualified) - { - auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - R operator&=(Args... args) const noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::const_qualified) - { - const auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - protected: - xyz_protocol_operator_thunk() = default; - ~xyz_protocol_operator_thunk() = default; - xyz_protocol_operator_thunk(const xyz_protocol_operator_thunk&) = default; - xyz_protocol_operator_thunk(xyz_protocol_operator_thunk&&) = default; - xyz_protocol_operator_thunk& operator=(const xyz_protocol_operator_thunk&) = - default; - xyz_protocol_operator_thunk& operator=(xyz_protocol_operator_thunk&&) = - default; -}; - -template -struct xyz_protocol_operator_overload_set< - std::meta::operators::op_ampersand_equals, ProtocolType, Vtable, - OverloadSpecs...> - : operator_thunk_t... { - using operator_thunk_t::operator&=...; - - protected: - xyz_protocol_operator_overload_set() = default; - ~xyz_protocol_operator_overload_set() = default; - xyz_protocol_operator_overload_set( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set(xyz_protocol_operator_overload_set&&) = - default; - xyz_protocol_operator_overload_set& operator=( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set& operator=( - xyz_protocol_operator_overload_set&&) = default; -}; - -// operator|= -template -struct xyz_protocol_operator_thunk< - std::meta::operators::op_pipe_equals, R (*)(Args...) noexcept(IsNoexcept), - ProtocolType, Vtable, Member, MemberQualifiers> { - R operator|=(Args... args) noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::unqualified) - { - auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - R operator|=(Args... args) const noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::const_qualified) - { - const auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - protected: - xyz_protocol_operator_thunk() = default; - ~xyz_protocol_operator_thunk() = default; - xyz_protocol_operator_thunk(const xyz_protocol_operator_thunk&) = default; - xyz_protocol_operator_thunk(xyz_protocol_operator_thunk&&) = default; - xyz_protocol_operator_thunk& operator=(const xyz_protocol_operator_thunk&) = - default; - xyz_protocol_operator_thunk& operator=(xyz_protocol_operator_thunk&&) = - default; -}; - -template -struct xyz_protocol_operator_overload_set - : operator_thunk_t... { - using operator_thunk_t::operator|=...; - - protected: - xyz_protocol_operator_overload_set() = default; - ~xyz_protocol_operator_overload_set() = default; - xyz_protocol_operator_overload_set( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set(xyz_protocol_operator_overload_set&&) = - default; - xyz_protocol_operator_overload_set& operator=( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set& operator=( - xyz_protocol_operator_overload_set&&) = default; -}; - -// operator&& -template -struct xyz_protocol_operator_thunk { - R operator&&(Args... args) noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::unqualified) - { - auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - R operator&&(Args... args) const noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::const_qualified) - { - const auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - protected: - xyz_protocol_operator_thunk() = default; - ~xyz_protocol_operator_thunk() = default; - xyz_protocol_operator_thunk(const xyz_protocol_operator_thunk&) = default; - xyz_protocol_operator_thunk(xyz_protocol_operator_thunk&&) = default; - xyz_protocol_operator_thunk& operator=(const xyz_protocol_operator_thunk&) = - default; - xyz_protocol_operator_thunk& operator=(xyz_protocol_operator_thunk&&) = - default; -}; - -template -struct xyz_protocol_operator_overload_set< - std::meta::operators::op_ampersand_ampersand, ProtocolType, Vtable, - OverloadSpecs...> - : operator_thunk_t... { - using operator_thunk_t::operator&&...; - - protected: - xyz_protocol_operator_overload_set() = default; - ~xyz_protocol_operator_overload_set() = default; - xyz_protocol_operator_overload_set( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set(xyz_protocol_operator_overload_set&&) = - default; - xyz_protocol_operator_overload_set& operator=( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set& operator=( - xyz_protocol_operator_overload_set&&) = default; -}; - -// operator|| -template -struct xyz_protocol_operator_thunk< - std::meta::operators::op_pipe_pipe, R (*)(Args...) noexcept(IsNoexcept), - ProtocolType, Vtable, Member, MemberQualifiers> { - R operator||(Args... args) noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::unqualified) - { - auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - R operator||(Args... args) const noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::const_qualified) - { - const auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - protected: - xyz_protocol_operator_thunk() = default; - ~xyz_protocol_operator_thunk() = default; - xyz_protocol_operator_thunk(const xyz_protocol_operator_thunk&) = default; - xyz_protocol_operator_thunk(xyz_protocol_operator_thunk&&) = default; - xyz_protocol_operator_thunk& operator=(const xyz_protocol_operator_thunk&) = - default; - xyz_protocol_operator_thunk& operator=(xyz_protocol_operator_thunk&&) = - default; -}; - -template -struct xyz_protocol_operator_overload_set< - std::meta::operators::op_pipe_pipe, ProtocolType, Vtable, OverloadSpecs...> - : operator_thunk_t... { - using operator_thunk_t::operator||...; - - protected: - xyz_protocol_operator_overload_set() = default; - ~xyz_protocol_operator_overload_set() = default; - xyz_protocol_operator_overload_set( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set(xyz_protocol_operator_overload_set&&) = - default; - xyz_protocol_operator_overload_set& operator=( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set& operator=( - xyz_protocol_operator_overload_set&&) = default; -}; - -// operator<< -template -struct xyz_protocol_operator_thunk< - std::meta::operators::op_less_less, R (*)(Args...) noexcept(IsNoexcept), - ProtocolType, Vtable, Member, MemberQualifiers> { - R operator<<(Args... args) noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::unqualified) - { - auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - R operator<<(Args... args) const noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::const_qualified) - { - const auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - protected: - xyz_protocol_operator_thunk() = default; - ~xyz_protocol_operator_thunk() = default; - xyz_protocol_operator_thunk(const xyz_protocol_operator_thunk&) = default; - xyz_protocol_operator_thunk(xyz_protocol_operator_thunk&&) = default; - xyz_protocol_operator_thunk& operator=(const xyz_protocol_operator_thunk&) = - default; - xyz_protocol_operator_thunk& operator=(xyz_protocol_operator_thunk&&) = - default; -}; - -template -struct xyz_protocol_operator_overload_set< - std::meta::operators::op_less_less, ProtocolType, Vtable, OverloadSpecs...> - : operator_thunk_t... { - using operator_thunk_t::operator<<...; - - protected: - xyz_protocol_operator_overload_set() = default; - ~xyz_protocol_operator_overload_set() = default; - xyz_protocol_operator_overload_set( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set(xyz_protocol_operator_overload_set&&) = - default; - xyz_protocol_operator_overload_set& operator=( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set& operator=( - xyz_protocol_operator_overload_set&&) = default; -}; - -// operator>> -template -struct xyz_protocol_operator_thunk { - R operator>>(Args... args) noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::unqualified) - { - auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - R operator>>(Args... args) const noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::const_qualified) - { - const auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - protected: - xyz_protocol_operator_thunk() = default; - ~xyz_protocol_operator_thunk() = default; - xyz_protocol_operator_thunk(const xyz_protocol_operator_thunk&) = default; - xyz_protocol_operator_thunk(xyz_protocol_operator_thunk&&) = default; - xyz_protocol_operator_thunk& operator=(const xyz_protocol_operator_thunk&) = - default; - xyz_protocol_operator_thunk& operator=(xyz_protocol_operator_thunk&&) = - default; -}; - -template -struct xyz_protocol_operator_overload_set< - std::meta::operators::op_greater_greater, ProtocolType, Vtable, - OverloadSpecs...> - : operator_thunk_t... { - using operator_thunk_t::operator>>...; - - protected: - xyz_protocol_operator_overload_set() = default; - ~xyz_protocol_operator_overload_set() = default; - xyz_protocol_operator_overload_set( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set(xyz_protocol_operator_overload_set&&) = - default; - xyz_protocol_operator_overload_set& operator=( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set& operator=( - xyz_protocol_operator_overload_set&&) = default; -}; - -// operator<<= -template -struct xyz_protocol_operator_thunk { - R operator<<=(Args... args) noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::unqualified) - { - auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - R operator<<=(Args... args) const noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::const_qualified) - { - const auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - protected: - xyz_protocol_operator_thunk() = default; - ~xyz_protocol_operator_thunk() = default; - xyz_protocol_operator_thunk(const xyz_protocol_operator_thunk&) = default; - xyz_protocol_operator_thunk(xyz_protocol_operator_thunk&&) = default; - xyz_protocol_operator_thunk& operator=(const xyz_protocol_operator_thunk&) = - default; - xyz_protocol_operator_thunk& operator=(xyz_protocol_operator_thunk&&) = - default; -}; - -template -struct xyz_protocol_operator_overload_set< - std::meta::operators::op_less_less_equals, ProtocolType, Vtable, - OverloadSpecs...> - : operator_thunk_t... { - using operator_thunk_t::operator<<=...; - - protected: - xyz_protocol_operator_overload_set() = default; - ~xyz_protocol_operator_overload_set() = default; - xyz_protocol_operator_overload_set( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set(xyz_protocol_operator_overload_set&&) = - default; - xyz_protocol_operator_overload_set& operator=( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set& operator=( - xyz_protocol_operator_overload_set&&) = default; -}; - -// operator>>= -template -struct xyz_protocol_operator_thunk< - std::meta::operators::op_greater_greater_equals, - R (*)(Args...) noexcept(IsNoexcept), ProtocolType, Vtable, Member, - MemberQualifiers> { - R operator>>=(Args... args) noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::unqualified) - { - auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - R operator>>=(Args... args) const noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::const_qualified) - { - const auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - protected: - xyz_protocol_operator_thunk() = default; - ~xyz_protocol_operator_thunk() = default; - xyz_protocol_operator_thunk(const xyz_protocol_operator_thunk&) = default; - xyz_protocol_operator_thunk(xyz_protocol_operator_thunk&&) = default; - xyz_protocol_operator_thunk& operator=(const xyz_protocol_operator_thunk&) = - default; - xyz_protocol_operator_thunk& operator=(xyz_protocol_operator_thunk&&) = - default; -}; - -template -struct xyz_protocol_operator_overload_set< - std::meta::operators::op_greater_greater_equals, ProtocolType, Vtable, - OverloadSpecs...> - : operator_thunk_t... { - using operator_thunk_t::operator>>=...; - - protected: - xyz_protocol_operator_overload_set() = default; - ~xyz_protocol_operator_overload_set() = default; - xyz_protocol_operator_overload_set( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set(xyz_protocol_operator_overload_set&&) = - default; - xyz_protocol_operator_overload_set& operator=( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set& operator=( - xyz_protocol_operator_overload_set&&) = default; -}; - -// operator++ -template -struct xyz_protocol_operator_thunk< - std::meta::operators::op_plus_plus, R (*)(Args...) noexcept(IsNoexcept), - ProtocolType, Vtable, Member, MemberQualifiers> { - R operator++(Args... args) noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::unqualified) - { - auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - R operator++(Args... args) const noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::const_qualified) - { - const auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - protected: - xyz_protocol_operator_thunk() = default; - ~xyz_protocol_operator_thunk() = default; - xyz_protocol_operator_thunk(const xyz_protocol_operator_thunk&) = default; - xyz_protocol_operator_thunk(xyz_protocol_operator_thunk&&) = default; - xyz_protocol_operator_thunk& operator=(const xyz_protocol_operator_thunk&) = - default; - xyz_protocol_operator_thunk& operator=(xyz_protocol_operator_thunk&&) = - default; -}; - -template -struct xyz_protocol_operator_overload_set< - std::meta::operators::op_plus_plus, ProtocolType, Vtable, OverloadSpecs...> - : operator_thunk_t... { - using operator_thunk_t::operator++...; - - protected: - xyz_protocol_operator_overload_set() = default; - ~xyz_protocol_operator_overload_set() = default; - xyz_protocol_operator_overload_set( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set(xyz_protocol_operator_overload_set&&) = - default; - xyz_protocol_operator_overload_set& operator=( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set& operator=( - xyz_protocol_operator_overload_set&&) = default; -}; - -// operator-- -template -struct xyz_protocol_operator_thunk< - std::meta::operators::op_minus_minus, R (*)(Args...) noexcept(IsNoexcept), - ProtocolType, Vtable, Member, MemberQualifiers> { - R operator--(Args... args) noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::unqualified) - { - auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - R operator--(Args... args) const noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::const_qualified) - { - const auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - protected: - xyz_protocol_operator_thunk() = default; - ~xyz_protocol_operator_thunk() = default; - xyz_protocol_operator_thunk(const xyz_protocol_operator_thunk&) = default; - xyz_protocol_operator_thunk(xyz_protocol_operator_thunk&&) = default; - xyz_protocol_operator_thunk& operator=(const xyz_protocol_operator_thunk&) = - default; - xyz_protocol_operator_thunk& operator=(xyz_protocol_operator_thunk&&) = - default; -}; - -template -struct xyz_protocol_operator_overload_set - : operator_thunk_t... { - using operator_thunk_t::operator--...; - - protected: - xyz_protocol_operator_overload_set() = default; - ~xyz_protocol_operator_overload_set() = default; - xyz_protocol_operator_overload_set( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set(xyz_protocol_operator_overload_set&&) = - default; - xyz_protocol_operator_overload_set& operator=( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set& operator=( - xyz_protocol_operator_overload_set&&) = default; -}; - -// operator, -template -struct xyz_protocol_operator_thunk< - std::meta::operators::op_comma, R (*)(Args...) noexcept(IsNoexcept), - ProtocolType, Vtable, Member, MemberQualifiers> { - R operator,(Args... args) noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::unqualified) - { - auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - R operator,(Args... args) const noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::const_qualified) - { - const auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - protected: - xyz_protocol_operator_thunk() = default; - ~xyz_protocol_operator_thunk() = default; - xyz_protocol_operator_thunk(const xyz_protocol_operator_thunk&) = default; - xyz_protocol_operator_thunk(xyz_protocol_operator_thunk&&) = default; - xyz_protocol_operator_thunk& operator=(const xyz_protocol_operator_thunk&) = - default; - xyz_protocol_operator_thunk& operator=(xyz_protocol_operator_thunk&&) = - default; -}; - -template -struct xyz_protocol_operator_overload_set< - std::meta::operators::op_comma, ProtocolType, Vtable, OverloadSpecs...> - : operator_thunk_t... { - using operator_thunk_t::operator, ...; - - protected: - xyz_protocol_operator_overload_set() = default; - ~xyz_protocol_operator_overload_set() = default; - xyz_protocol_operator_overload_set( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set(xyz_protocol_operator_overload_set&&) = - default; - xyz_protocol_operator_overload_set& operator=( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set& operator=( - xyz_protocol_operator_overload_set&&) = default; -}; - -// operator== -template -struct xyz_protocol_operator_thunk< - std::meta::operators::op_equals_equals, R (*)(Args...) noexcept(IsNoexcept), - ProtocolType, Vtable, Member, MemberQualifiers> { - R operator==(Args... args) noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::unqualified) - { - auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - R operator==(Args... args) const noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::const_qualified) - { - const auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - protected: - xyz_protocol_operator_thunk() = default; - ~xyz_protocol_operator_thunk() = default; - xyz_protocol_operator_thunk(const xyz_protocol_operator_thunk&) = default; - xyz_protocol_operator_thunk(xyz_protocol_operator_thunk&&) = default; - xyz_protocol_operator_thunk& operator=(const xyz_protocol_operator_thunk&) = - default; - xyz_protocol_operator_thunk& operator=(xyz_protocol_operator_thunk&&) = - default; -}; - -template -struct xyz_protocol_operator_overload_set< - std::meta::operators::op_equals_equals, ProtocolType, Vtable, - OverloadSpecs...> - : operator_thunk_t... { - using operator_thunk_t::operator==...; - - protected: - xyz_protocol_operator_overload_set() = default; - ~xyz_protocol_operator_overload_set() = default; - xyz_protocol_operator_overload_set( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set(xyz_protocol_operator_overload_set&&) = - default; - xyz_protocol_operator_overload_set& operator=( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set& operator=( - xyz_protocol_operator_overload_set&&) = default; -}; - -// operator!= -template -struct xyz_protocol_operator_thunk { - R operator!=(Args... args) noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::unqualified) - { - auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - R operator!=(Args... args) const noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::const_qualified) - { - const auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - protected: - xyz_protocol_operator_thunk() = default; - ~xyz_protocol_operator_thunk() = default; - xyz_protocol_operator_thunk(const xyz_protocol_operator_thunk&) = default; - xyz_protocol_operator_thunk(xyz_protocol_operator_thunk&&) = default; - xyz_protocol_operator_thunk& operator=(const xyz_protocol_operator_thunk&) = - default; - xyz_protocol_operator_thunk& operator=(xyz_protocol_operator_thunk&&) = - default; -}; - -template -struct xyz_protocol_operator_overload_set< - std::meta::operators::op_exclamation_equals, ProtocolType, Vtable, - OverloadSpecs...> - : operator_thunk_t... { - using operator_thunk_t::operator!=...; - - protected: - xyz_protocol_operator_overload_set() = default; - ~xyz_protocol_operator_overload_set() = default; - xyz_protocol_operator_overload_set( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set(xyz_protocol_operator_overload_set&&) = - default; - xyz_protocol_operator_overload_set& operator=( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set& operator=( - xyz_protocol_operator_overload_set&&) = default; -}; - -// operator< -template -struct xyz_protocol_operator_thunk< - std::meta::operators::op_less, R (*)(Args...) noexcept(IsNoexcept), - ProtocolType, Vtable, Member, MemberQualifiers> { - R operator<(Args... args) noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::unqualified) - { - auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - R operator<(Args... args) const noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::const_qualified) - { - const auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - protected: - xyz_protocol_operator_thunk() = default; - ~xyz_protocol_operator_thunk() = default; - xyz_protocol_operator_thunk(const xyz_protocol_operator_thunk&) = default; - xyz_protocol_operator_thunk(xyz_protocol_operator_thunk&&) = default; - xyz_protocol_operator_thunk& operator=(const xyz_protocol_operator_thunk&) = - default; - xyz_protocol_operator_thunk& operator=(xyz_protocol_operator_thunk&&) = - default; -}; - -template -struct xyz_protocol_operator_overload_set< - std::meta::operators::op_less, ProtocolType, Vtable, OverloadSpecs...> - : operator_thunk_t... { - using operator_thunk_t::operator<...; - - protected: - xyz_protocol_operator_overload_set() = default; - ~xyz_protocol_operator_overload_set() = default; - xyz_protocol_operator_overload_set( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set(xyz_protocol_operator_overload_set&&) = - default; - xyz_protocol_operator_overload_set& operator=( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set& operator=( - xyz_protocol_operator_overload_set&&) = default; -}; - -// operator<= -template -struct xyz_protocol_operator_thunk< - std::meta::operators::op_less_equals, R (*)(Args...) noexcept(IsNoexcept), - ProtocolType, Vtable, Member, MemberQualifiers> { - R operator<=(Args... args) noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::unqualified) - { - auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - R operator<=(Args... args) const noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::const_qualified) - { - const auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - protected: - xyz_protocol_operator_thunk() = default; - ~xyz_protocol_operator_thunk() = default; - xyz_protocol_operator_thunk(const xyz_protocol_operator_thunk&) = default; - xyz_protocol_operator_thunk(xyz_protocol_operator_thunk&&) = default; - xyz_protocol_operator_thunk& operator=(const xyz_protocol_operator_thunk&) = - default; - xyz_protocol_operator_thunk& operator=(xyz_protocol_operator_thunk&&) = - default; -}; - -template -struct xyz_protocol_operator_overload_set - : operator_thunk_t... { - using operator_thunk_t::operator<=...; - - protected: - xyz_protocol_operator_overload_set() = default; - ~xyz_protocol_operator_overload_set() = default; - xyz_protocol_operator_overload_set( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set(xyz_protocol_operator_overload_set&&) = - default; - xyz_protocol_operator_overload_set& operator=( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set& operator=( - xyz_protocol_operator_overload_set&&) = default; -}; - -// operator> -template -struct xyz_protocol_operator_thunk< - std::meta::operators::op_greater, R (*)(Args...) noexcept(IsNoexcept), - ProtocolType, Vtable, Member, MemberQualifiers> { - R operator>(Args... args) noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::unqualified) - { - auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - R operator>(Args... args) const noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::const_qualified) - { - const auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - protected: - xyz_protocol_operator_thunk() = default; - ~xyz_protocol_operator_thunk() = default; - xyz_protocol_operator_thunk(const xyz_protocol_operator_thunk&) = default; - xyz_protocol_operator_thunk(xyz_protocol_operator_thunk&&) = default; - xyz_protocol_operator_thunk& operator=(const xyz_protocol_operator_thunk&) = - default; - xyz_protocol_operator_thunk& operator=(xyz_protocol_operator_thunk&&) = - default; -}; - -template -struct xyz_protocol_operator_overload_set< - std::meta::operators::op_greater, ProtocolType, Vtable, OverloadSpecs...> - : operator_thunk_t... { - using operator_thunk_t::operator>...; - - protected: - xyz_protocol_operator_overload_set() = default; - ~xyz_protocol_operator_overload_set() = default; - xyz_protocol_operator_overload_set( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set(xyz_protocol_operator_overload_set&&) = - default; - xyz_protocol_operator_overload_set& operator=( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set& operator=( - xyz_protocol_operator_overload_set&&) = default; -}; - -// operator>= -template -struct xyz_protocol_operator_thunk { - R operator>=(Args... args) noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::unqualified) - { - auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - R operator>=(Args... args) const noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::const_qualified) - { - const auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - protected: - xyz_protocol_operator_thunk() = default; - ~xyz_protocol_operator_thunk() = default; - xyz_protocol_operator_thunk(const xyz_protocol_operator_thunk&) = default; - xyz_protocol_operator_thunk(xyz_protocol_operator_thunk&&) = default; - xyz_protocol_operator_thunk& operator=(const xyz_protocol_operator_thunk&) = - default; - xyz_protocol_operator_thunk& operator=(xyz_protocol_operator_thunk&&) = - default; -}; - -template -struct xyz_protocol_operator_overload_set< - std::meta::operators::op_greater_equals, ProtocolType, Vtable, - OverloadSpecs...> - : operator_thunk_t... { - using operator_thunk_t::operator>=...; - - protected: - xyz_protocol_operator_overload_set() = default; - ~xyz_protocol_operator_overload_set() = default; - xyz_protocol_operator_overload_set( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set(xyz_protocol_operator_overload_set&&) = - default; - xyz_protocol_operator_overload_set& operator=( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set& operator=( - xyz_protocol_operator_overload_set&&) = default; -}; - -// operator<=> -template -struct xyz_protocol_operator_thunk< - std::meta::operators::op_spaceship, R (*)(Args...) noexcept(IsNoexcept), - ProtocolType, Vtable, Member, MemberQualifiers> { - R operator<=>(Args... args) noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::unqualified) - { - auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - R operator<=>(Args... args) const noexcept(IsNoexcept) - requires(MemberQualifiers == member_qualifiers::const_qualified) - { - const auto* protocol_object = static_cast(this); - return call_through_vtable( - protocol_object, protocol_object->xyz_protocol_vtable_, - protocol_object->xyz_protocol_erased_object(), - std::forward(args)...); - } - - protected: - xyz_protocol_operator_thunk() = default; - ~xyz_protocol_operator_thunk() = default; - xyz_protocol_operator_thunk(const xyz_protocol_operator_thunk&) = default; - xyz_protocol_operator_thunk(xyz_protocol_operator_thunk&&) = default; - xyz_protocol_operator_thunk& operator=(const xyz_protocol_operator_thunk&) = - default; - xyz_protocol_operator_thunk& operator=(xyz_protocol_operator_thunk&&) = - default; -}; - -template -struct xyz_protocol_operator_overload_set< - std::meta::operators::op_spaceship, ProtocolType, Vtable, OverloadSpecs...> - : operator_thunk_t... { - using operator_thunk_t::operator<=>...; - - protected: - xyz_protocol_operator_overload_set() = default; - ~xyz_protocol_operator_overload_set() = default; - xyz_protocol_operator_overload_set( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set(xyz_protocol_operator_overload_set&&) = - default; - xyz_protocol_operator_overload_set& operator=( - const xyz_protocol_operator_overload_set&) = default; - xyz_protocol_operator_overload_set& operator=( - xyz_protocol_operator_overload_set&&) = default; -}; - -} // namespace xyz::detail - -#endif // XYZ_PROTOCOL_OPERATOR_THUNKS_HH_ diff --git a/xyz/detail/overload_spec.hh b/xyz/detail/overload_spec.hh index d821a880..b309c176 100644 --- a/xyz/detail/overload_spec.hh +++ b/xyz/detail/overload_spec.hh @@ -52,19 +52,21 @@ consteval std::meta::info function_pointer_type_of( enum class member_qualifiers { unqualified, const_qualified, - // TODO(jbcoe): Add const and non-const rvalue and lvalue qualifiers. + lvalue_qualified, + const_lvalue_qualified, + rvalue_qualified, + const_rvalue_qualified, }; consteval member_qualifiers member_qualifiers_of(std::meta::info member) { - // TODO(jbcoe): Remove this check once reference-qualified member functions - // are supported. - if (is_lvalue_reference_qualified(member) || - is_rvalue_reference_qualified(member)) { - throw std::runtime_error( - "lvalue or rvalue qualified member functions are not currently " - "supported"); + if (is_lvalue_reference_qualified(member)) { + return is_const(member) ? member_qualifiers::const_lvalue_qualified + : member_qualifiers::lvalue_qualified; + } + if (is_rvalue_reference_qualified(member)) { + return is_const(member) ? member_qualifiers::const_rvalue_qualified + : member_qualifiers::rvalue_qualified; } - return is_const(member) ? member_qualifiers::const_qualified : member_qualifiers::unqualified; } diff --git a/xyz/detail/protocol_wrappers.hh b/xyz/detail/protocol_wrappers.hh index 0ccb1982..c7c78b6a 100644 --- a/xyz/detail/protocol_wrappers.hh +++ b/xyz/detail/protocol_wrappers.hh @@ -42,9 +42,9 @@ enum class const_policy { propagate, // `protocol_view`: every wrapper is const-qualified regardless of `I` // (shallow const, as for `std::span`). - all_const, + constify, // `protocol_view`: only the const member functions of `I`. - const_only, + only_const, }; // Returns `true` if `member` if forwarded under `ConstPolicy`. @@ -56,11 +56,11 @@ consteval bool is_forwarded_member_function( // `protocol` propagates const through forwarded member function calls // so supports const and non-const qualified member functions. return true; - case const_policy::const_only: + case const_policy::only_const: // `protocol_view` forwards only const-qualified member // functions. return is_const(member); - case const_policy::all_const: + case const_policy::constify: // `protocol_view` is a view type: overload resolution through // a const and non-const access path must yield the same result. // A const-qualified member function is only given a forwarding wrapper if @@ -88,8 +88,8 @@ consteval void reject_conversion_functions_of_mixed_constness( std::meta::info first = {}; for (std::meta::info member : members) { if (!is_conversion_function(member) || - !is_forwarded_member_function(member, - members)) { + !is_forwarded_member_function(member, + members)) { continue; } if (first == std::meta::info{}) { @@ -156,7 +156,7 @@ template members = protocol_interface_functions_of; - if (ConstPolicy == const_policy::all_const) { + if (ConstPolicy == const_policy::constify) { reject_conversion_functions_of_mixed_constness(members); } std::vector member_base_types; diff --git a/xyz/protocol.hh b/xyz/protocol.hh index 86e9b763..0dac1e78 100644 --- a/xyz/protocol.hh +++ b/xyz/protocol.hh @@ -557,7 +557,7 @@ template class protocol_view : public detail::protocol_wrappers_t, detail::vtable_t, - detail::const_policy::all_const> { + detail::const_policy::constify> { public: // The default constructor is deleted as a default constructed // `protocol_view` would be empty. @@ -669,7 +669,7 @@ template class protocol_view : public detail::protocol_wrappers_t, detail::vtable_t, - detail::const_policy::const_only> { + detail::const_policy::only_const> { public: // The default constructor is deleted as a default constructed // `protocol_view` would be empty. diff --git a/xyz/tests/conformance_tests.cc b/xyz/tests/conformance_tests.cc index a2cdee68..4a23db5e 100644 --- a/xyz/tests/conformance_tests.cc +++ b/xyz/tests/conformance_tests.cc @@ -207,39 +207,6 @@ TEST(ConformsToTest, NonNoexceptInterfaceAcceptsNoexceptCandidate) { static_assert(is_protocol_conformant()); } -TEST(ConformsToTest, RefQualifiedInterfaceMembersAreRejected) { - struct LvalueRefInterface { - void f() &; - }; - - struct RvalueRefInterface { - void f() &&; - }; - - struct MatchingLvalueRefCandidate { - void f() &; - }; - - struct MatchingRvalueRefCandidate { - void f() &&; - }; - - struct UnqualifiedCandidate { - void f(); - }; - -#ifdef __cpp_constexpr_exceptions - static_assert(conformance_check_rejects()); - static_assert( - conformance_check_rejects()); - static_assert(conformance_check_rejects()); - static_assert( - conformance_check_rejects()); -#endif // __cpp_constexpr_exceptions -} - TEST(ConformsToTest, UnsupportedOperatorsAreRejected) { struct EqualsInterface { EqualsInterface& operator=(int); @@ -878,10 +845,6 @@ TEST(ConformsToTest, InternalNamesOfProtocolArePrefixed) { } TEST(ConformsToTest, RejectionMessageNamesTheMember) { - struct RefQualifiedInterface { - void named_function() &; - }; - struct ExplicitObjectInterface { void named_function(this ExplicitObjectInterface&); }; @@ -900,9 +863,6 @@ TEST(ConformsToTest, RejectionMessageNamesTheMember) { struct Candidate {}; #ifdef __cpp_constexpr_exceptions - static_assert( - conformance_rejection_message_contains( - "ref-qualified member function 'named_function'")); static_assert(conformance_rejection_message_contains( "explicit-object member function 'named_function'")); @@ -942,25 +902,6 @@ TEST(ConformsToTest, RejectionMessageNamesTheOverload) { #endif // __cpp_constexpr_exceptions } -TEST(ConformsToTest, RejectedOperatorIsNamedTheSameWayByEveryCheck) { - // Ref-qualified and an unsupported operator: whichever check fires, the - // member is named by its display string. - struct Interface { - bool operator==(const FirstOperand&) const&; - }; - - struct Candidate {}; - -#ifdef __cpp_constexpr_exceptions - static_assert(conformance_rejection_message_contains( - "ref-qualified member function '")); - static_assert(conformance_rejection_message_contains( - "operator==")); - static_assert(conformance_rejection_message_contains( - "FirstOperand")); -#endif // __cpp_constexpr_exceptions -} - TEST(ConformsToTest, UnqualifiedInterfaceDoesNotMatchRefQualifiedCandidate) { struct Interface { void f(); @@ -1156,20 +1097,6 @@ TEST(ConformsToTest, StaticCandidateConformsToNonConstMember) { static_assert(is_protocol_conformant()); } -TEST(ConformsToTest, RefQualifiedInterfaceMemberRejectedForStaticCandidate) { - struct Interface { - int take() &&; - }; - - struct Conforming { - static int take(); - }; - -#ifdef __cpp_constexpr_exceptions - static_assert(conformance_check_rejects()); -#endif // __cpp_constexpr_exceptions -} - TEST(ConformsToTest, StaticCandidateWithWrongSignatureDoesNotConform) { struct Interface { int value(int x) const; diff --git a/xyz/tests/feature_tests.cc b/xyz/tests/feature_tests.cc new file mode 100644 index 00000000..0cc9c57e --- /dev/null +++ b/xyz/tests/feature_tests.cc @@ -0,0 +1,73 @@ +// Development tests for faster rebuild-run cycles. + +#include + +#include +#include +#include +#include +#include +#include + +#include "xyz/protocol.hh" + +using xyz::detail::is_protocol_v; +using xyz::detail::is_protocol_view_v; +using xyz::detail::is_valid_interface; + +namespace xyz::tests { +namespace { + +enum class ReferenceQualifier { + None, + Const, + LValue, + ConstLValue, + RValue, + ConstRValue, +}; + +TEST(ReflectionProtocolTest, ReferenceQualifers_NoneAndConst) { + struct Interface { + ReferenceQualifier fn(); + ReferenceQualifier fn() const; + }; + + struct Conforming { + ReferenceQualifier fn() { return ReferenceQualifier::None; } + + ReferenceQualifier fn() const { return ReferenceQualifier::Const; } + }; + + protocol p(Conforming{}); + EXPECT_EQ(p.fn(), ReferenceQualifier::None); + EXPECT_EQ(std::as_const(p).fn(), ReferenceQualifier::Const); +} + +TEST(ReflectionProtocolTest, ReferenceQualifers_LValueAndRValue) { + struct Interface { + ReferenceQualifier fn() &; + ReferenceQualifier fn() const &; + ReferenceQualifier fn() &&; + ReferenceQualifier fn() const &&; + }; + + struct Conforming { + ReferenceQualifier fn() & { return ReferenceQualifier::LValue; } + + ReferenceQualifier fn() const & { return ReferenceQualifier::ConstLValue; } + + ReferenceQualifier fn() && { return ReferenceQualifier::RValue; } + + ReferenceQualifier fn() const && { return ReferenceQualifier::ConstRValue; } + }; + + protocol p(Conforming{}); + EXPECT_EQ(p.fn(), ReferenceQualifier::LValue); + EXPECT_EQ(std::as_const(p).fn(), ReferenceQualifier::ConstLValue); + EXPECT_EQ(std::move(p).fn(), ReferenceQualifier::RValue); + EXPECT_EQ(std::move(std::as_const(p)).fn(), ReferenceQualifier::ConstRValue); +} + +} // namespace +} // namespace xyz::tests diff --git a/xyz/tests/protocol_operator_tests.cc b/xyz/tests/protocol_operator_tests.cc index 0d256ddd..68161d3d 100644 --- a/xyz/tests/protocol_operator_tests.cc +++ b/xyz/tests/protocol_operator_tests.cc @@ -590,7 +590,7 @@ consteval bool view_wrappers_reject() { try { (void)xyz::detail::generate_member_bases_wrapper< ^^Interface, protocol_view, xyz::detail::vtable_t, - xyz::detail::const_policy::all_const>(); + xyz::detail::const_policy::constify>(); } catch (const std::runtime_error&) { return true; }