Skip to content

Commit

Permalink
Add MSVC support
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickroberts committed Jan 12, 2025
1 parent 88bda2e commit d3af2bd
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 10 deletions.
19 changes: 12 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,18 @@ add_library(patrickroberts INTERFACE)
target_compile_features(patrickroberts INTERFACE cxx_std_23)
target_compile_options(
patrickroberts
INTERFACE
-Wall
-Werror
-Wextra
-pedantic
$<$<CXX_COMPILER_ID:Clang>:$<$<BOOL:${PATRICK_ROBERTS_USE_LIBCXX}>:-stdlib=libc++>
-D_GLIBCXX_DO_NOT_USE_BUILTIN_TRAITS>)
INTERFACE $<$<CXX_COMPILER_ID:MSVC>:
/W4
/WX
/std:c++latest>
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:
-Wall
-Werror
-Wextra
-pedantic>
$<$<CXX_COMPILER_ID:Clang>:
$<$<BOOL:${PATRICK_ROBERTS_USE_LIBCXX}>:-stdlib=libc++>
-D_GLIBCXX_DO_NOT_USE_BUILTIN_TRAITS>)
target_include_directories(patrickroberts
INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/include")

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ static_assert([] {
```
## Features:
- C++23 implementation (uses `if consteval`, `std::unreachable()`, and `auto`-cast)
- C++23 implementation
- Fully constexpr and SFINAE-friendly
- Supports:
* Ranges of any iterator category including `contiguous_range<R>`
Expand Down
4 changes: 4 additions & 0 deletions cmake/pre-commit.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ find_package(Python3 REQUIRED COMPONENTS Interpreter)
set(VIRTUAL_ENV "${PROJECT_SOURCE_DIR}/.venv")
set(VIRTUAL_ENV_BIN "${VIRTUAL_ENV}/bin")

if(WIN32)
set(VIRTUAL_ENV_BIN "${VIRTUAL_ENV}/Scripts")
endif()

if(NOT EXISTS "${VIRTUAL_ENV}")
execute_process(COMMAND "${Python3_EXECUTABLE}" -m venv "${VIRTUAL_ENV}"
COMMAND_ERROR_IS_FATAL ANY)
Expand Down
3 changes: 2 additions & 1 deletion include/pr/any_iterator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ class any_iterator : public detail::iterator_concept_trait<KindV> {
template <class IteratorT, class SentinelT>
constexpr any_iterator(IteratorT &&iterator, SentinelT &&sentinel)
: iterator_ptr_(in_place_iterator_type_<IteratorT, SentinelT>,
auto(iterator), auto(sentinel)) {}
static_cast<std::decay_t<IteratorT>>(iterator),
static_cast<std::decay_t<SentinelT>>(sentinel)) {}

any_iterator() = delete;

Expand Down
2 changes: 1 addition & 1 deletion include/pr/detail/intrusive_small_ptr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class intrusive_small_ptr {
if constexpr (sizeof(AdaptorT) <= sizeof(InplaceT) and
alignof(AdaptorT) <= alignof(InplaceT)) {
// placement new is not allowed in a constant expression
if not consteval {
if (not std::is_constant_evaluated()) {
::new (&inplace_) AdaptorT(static_cast<ArgsT &&>(args)...);
index_ = index_type::is_inplace;
return;
Expand Down
2 changes: 2 additions & 0 deletions include/pr/detail/iterator_interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#include <pr/detail/intrusive_small_ptr.hpp>

#include <typeinfo>

namespace pr::detail {

template <class ElementT, any_kind KindV, class ReferenceT, class DifferenceT>
Expand Down

0 comments on commit d3af2bd

Please sign in to comment.