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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ def _feature_compatibility(self):
"compiler": {
"gcc": "14",
"clang": "18",
"apple-clang": "",
"msvc": "195",
"apple-clang": "17",
"msvc": "194",
},
},
}
Expand Down
4 changes: 3 additions & 1 deletion docs/getting_started/cpp_compiler_support.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ C++ feature:
| **`std::format`** | 20 | 13+ | 17+ | 16+ | 194+ |
| **C++ modules** | 20 | None | 17+ | None | None |
| **`import std;`** | 23 | None | 18+ | None | None |
| **Explicit `this` parameter** | 23 | 14+ | 18+ | None | 195+ |
| **Explicit `this` parameter** | 23 | 14+ | 18+ | 17+ | 194+ |

??? note "clang-19 unfixable bug"

Expand Down Expand Up @@ -97,6 +97,8 @@ C++ feature:
- To write code with wide compatibility
a [dedicated macro may be used](../users_guide/use_cases/wide_compatibility.md#QUANTITY_SPEC).
- Tested with `__cpp_explicit_this_parameter` [feature test macro](https://en.cppreference.com/w/cpp/feature_test).
- Note that some compiler versions do not implement this macro even though they do support the
feature well enough. In such cases, compilation with explicit `this` is enforced.
- Related build options:
- Conan: [no_crtp](installation_and_usage.md#no_crtp)
- CMake: [MP_UNITS_API_NO_CRTP](installation_and_usage.md#MP_UNITS_API_NO_CRTP)
Expand Down
22 changes: 15 additions & 7 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,21 @@ endif()

# clang++-18 supports explicit `this` parameter
# https://github.com/llvm/llvm-project/issues/82780
if(NOT ${projectPrefix}EXPLICIT_THIS_PARAMETER_SUPPORTED
AND CMAKE_CXX_STANDARD GREATER_EQUAL 23
AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang"
AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "18"
)
message(STATUS "Clang 18+ detected, overriding `no CRTP` support")
set(${projectPrefix}EXPLICIT_THIS_PARAMETER_SUPPORTED ON)
# AppleClang 17 also supports explicit `this` parameter (feature check macro unimplemented)
# https://developer.apple.com/documentation/xcode-release-notes/xcode-16_3-release-notes
# MSVC 19.32 also supports explicit `this` parameter (feature check macro unimplemented in this version)
# https://learn.microsoft.com/en-us/visualstudio/releases/2022/release-notes-v17.2
if(NOT ${projectPrefix}EXPLICIT_THIS_PARAMETER_SUPPORTED AND CMAKE_CXX_STANDARD GREATER_EQUAL 23)
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "18")
message(STATUS "Clang 18+ detected, overriding `no CRTP` support")
set(${projectPrefix}EXPLICIT_THIS_PARAMETER_SUPPORTED ON)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "17")
message(STATUS "AppleClang 17+ detected, overriding `no CRTP` support")
set(${projectPrefix}EXPLICIT_THIS_PARAMETER_SUPPORTED ON)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "19.32")
message(STATUS "MSVC 19.32+ detected, overriding `no CRTP` support")
set(${projectPrefix}EXPLICIT_THIS_PARAMETER_SUPPORTED ON)
endif()
endif()

# project API settings
Expand Down
Loading