Skip to content

Conversation

@ozars
Copy link

@ozars ozars commented Dec 30, 2025

Tested: On x86_64-pc-linux-gnu, with gcc 15.2.1 and clang 21.1.6, with libstdc++ for both, with build types Debug and Release, with C++ standards 17, 20 and 23.

Ad-hoc test script is given below.

#!/bin/bash

set -o errexit
set -o nounset
set -o pipefail

function check() {
  local cc="$1"
  local cxx="$2"
  local build_type="$3"
  local std="$4"
  local build_dir="build_${cc}_${build_type}_${std}"
  echo -e "\033[1m"
  echo "=== Building with $cc/$cxx, type=$build_type, std=$std ==="
  echo -e "\033[0m"
  rm -rf "$build_dir"
  mkdir -p "$build_dir"
  CC="$cc" CXX="$cxx" \
    cmake \
      -S . \
      -B "$build_dir" \
      -G "Ninja" \
      -Dgtest_build_tests=ON \
      -Dgmock_build_tests=ON \
      -DCMAKE_BUILD_TYPE="$build_type" \
      -DCMAKE_CXX_STANDARD="$std" \
      -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
  cmake --build "$build_dir" -- -j$(nproc)
  cmake --build "$build_dir" --target test
}

check "gcc" "g++" "Debug" "17"
check "gcc" "g++" "Release" "17"
check "gcc" "g++" "Debug" "20"
check "gcc" "g++" "Release" "20"
check "gcc" "g++" "Debug" "23"
check "gcc" "g++" "Release" "23"

check "clang" "clang++" "Debug" "17"
check "clang" "clang++" "Release" "17"
check "clang" "clang++" "Debug" "20"
check "clang" "clang++" "Release" "20"
check "clang" "clang++" "Debug" "23"
check "clang" "clang++" "Release" "23"

- Add feature flags for `std::ranges` and `std::views::as_const`
  detection.
- Extend `StlContainerView` with a `std::ranges::view` specialization.
- Introduce `internal::ValueType` to deduce element/value type for both
  STL containers and ranges, while keeping backward-compatibility for
  the existing behavior.
- Update container matchers to use `internal::ValueType` instead of
  assuming nested `value_type`.
- Add coverage for common matchers against `std::ranges` views (e.g.
  `ElementsAre`, `ElementsAreArray`, `Contains`, `Pointwise`,
  `UnorderedPointwise`, `Pointee`).
- Resolves google#3403.
- Resolves google#4512.
- Resolves google#4534.

Tested: On x86_64-pc-linux-gnu, with gcc 15.2.1 and clang 21.1.6, with
libstdc++ for both, with build types Debug and Release, with C++
standards 17, 20 and 23.

Ad-hoc test script is given below.

```bash
#!/bin/bash

set -o errexit
set -o nounset
set -o pipefail

function check() {
  local cc="$1"
  local cxx="$2"
  local build_type="$3"
  local std="$4"
  local build_dir="build_${cc}_${build_type}_${std}"
  echo -e "\033[1m"
  echo "=== Building with $cc/$cxx, type=$build_type, std=$std ==="
  echo -e "\033[0m"
  rm -rf "$build_dir"
  mkdir -p "$build_dir"
  CC="$cc" CXX="$cxx" \
    cmake \
      -S . \
      -B "$build_dir" \
      -G "Ninja" \
      -Dgtest_build_tests=ON \
      -Dgmock_build_tests=ON \
      -DCMAKE_BUILD_TYPE="$build_type" \
      -DCMAKE_CXX_STANDARD="$std" \
      -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
  cmake --build "$build_dir" -- -j$(nproc)
  cmake --build "$build_dir" --target test
}

check "gcc" "g++" "Debug" "17"
check "gcc" "g++" "Release" "17"
check "gcc" "g++" "Debug" "20"
check "gcc" "g++" "Release" "20"
check "gcc" "g++" "Debug" "23"
check "gcc" "g++" "Release" "23"

check "clang" "clang++" "Debug" "17"
check "clang" "clang++" "Release" "17"
check "clang" "clang++" "Debug" "20"
check "clang" "clang++" "Release" "20"
check "clang" "clang++" "Debug" "23"
check "clang" "clang++" "Release" "23"
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FR]: Loosen restrictions on what types are considered containers for matchers Matchers for C++20 ranges support ranges with Container Matchers

1 participant