Skip to content
Draft
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
2 changes: 2 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Checks: |
modernize-avoid-bind,
modernize-loop-convert,
modernize-make-shared,
modernize-make-unique,
modernize-redundant-void-arg,
modernize-replace-auto-ptr,
modernize-replace-disallow-copy-and-assign-macro,
Expand All @@ -35,6 +36,7 @@ Checks: |
modernize-use-noexcept,
modernize-use-nullptr,
modernize-use-override,
modernize-use-transparent-functors,
modernize-use-using,
readability-avoid-const-params-in-decls,
readability-braces-around-statements,
Expand Down
80 changes: 29 additions & 51 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ jobs:
cmake-args: -DCMAKE_CXX_STANDARD=14
- runs-on: macos-15-intel
python-version: '3.13'
cmake-args: -DCMAKE_CXX_STANDARD=11
cmake-args: -DCMAKE_CXX_STANDARD=14
- runs-on: macos-latest
python-version: '3.12'
cmake-args: -DCMAKE_CXX_STANDARD=17 -DPYBIND11_DISABLE_HANDLE_TYPE_NAME_DEFAULT_IMPLEMENTATION=ON
Expand Down Expand Up @@ -152,7 +152,7 @@ jobs:
python-version: ${{ matrix.python-version }}
cmake-args: ${{ matrix.cmake-args }}

# This checks inplace builds with C++11
# This checks inplace builds with C++14
inplace:
if: github.event.pull_request.draft == false
strategy:
Expand Down Expand Up @@ -254,12 +254,15 @@ jobs:
run: uv tool install ninja

- name: Configure via preset
run: cmake --preset venv -DPYBIND11_CREATE_WITH_UV="${{ matrix.python-version }}"
run: >
cmake --preset venv
-DPYBIND11_CREATE_WITH_UV="${{ matrix.python-version }}"
-DCMAKE_CXX_STANDARD=14

- name: Build C++11
- name: Build C++14
run: cmake --build --preset venv

- name: Python tests C++11
- name: Python tests C++14
run: cmake --build --preset testsvenv -t pytest

# Testing on clang using the excellent silkeh clang docker images
Expand Down Expand Up @@ -536,43 +539,43 @@ jobs:
set +e; source /opt/intel/oneapi/setvars.sh; set -e
python3 -m pip install -r tests/requirements.txt

- name: Configure C++11
- name: Configure C++14
run: |
set +e; source /opt/intel/oneapi/setvars.sh; set -e
cmake -S . -B build-11 \
cmake -S . -B build-14 \
-DPYBIND11_WERROR=ON \
-DDOWNLOAD_CATCH=ON \
-DDOWNLOAD_EIGEN=OFF \
-DCMAKE_CXX_STANDARD=11 \
-DCMAKE_CXX_STANDARD=14 \
-DCMAKE_CXX_COMPILER=$(which icpc) \
-DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)")

- name: Build C++11
- name: Build C++14
run: |
set +e; source /opt/intel/oneapi/setvars.sh; set -e
cmake --build build-11 -j 2 -v
cmake --build build-14 -j 2 -v

- name: Python tests C++11
- name: Python tests C++14
run: |
set +e; source /opt/intel/oneapi/setvars.sh; set -e
sudo service apport stop
cmake --build build-11 --target check
cmake --build build-14 --target check

- name: C++ tests C++11
- name: C++ tests C++14
timeout-minutes: 3
run: |
set +e; source /opt/intel/oneapi/setvars.sh; set -e
cmake --build build-11 --target cpptest
cmake --build build-14 --target cpptest

- name: Interface test C++11
- name: Interface test C++14
run: |
set +e; source /opt/intel/oneapi/setvars.sh; set -e
cmake --build build-11 --target test_cmake_build
cmake --build build-14 --target test_cmake_build

- name: Visibility test
run: |
set +e; source /opt/intel/oneapi/setvars.sh; set -e
cmake --build build-11 --target test_cross_module_rtti
cmake --build build-14 --target test_cross_module_rtti

- name: Configure C++17
run: |
Expand Down Expand Up @@ -659,7 +662,7 @@ jobs:
-DPYBIND11_WERROR=ON
-DDOWNLOAD_CATCH=ON
-DDOWNLOAD_EIGEN=ON
-DCMAKE_CXX_STANDARD=11
-DCMAKE_CXX_STANDARD=14
-DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)")

- name: Build
Expand Down Expand Up @@ -810,7 +813,7 @@ jobs:
-DDOWNLOAD_CATCH=ON
-DDOWNLOAD_EIGEN=ON
${{ matrix.args }}
- name: Build C++11
- name: Build C++14
run: cmake --build build -j 2

- name: Python tests
Expand Down Expand Up @@ -859,7 +862,7 @@ jobs:
-DDOWNLOAD_CATCH=ON
-DDOWNLOAD_EIGEN=ON
${{ matrix.args }}
- name: Build C++11
- name: Build C++14
run: cmake --build build --config Debug -j 2

- name: Python tests
Expand Down Expand Up @@ -969,25 +972,25 @@ jobs:

- uses: actions/checkout@v7

- name: Configure C++11
- name: Configure C++14
# LTO leads to many undefined reference like
# `pybind11::detail::function_call::function_call(pybind11::detail::function_call&&)
run: >-
cmake -G "MinGW Makefiles" -DCMAKE_CXX_STANDARD=11 -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON
cmake -G "MinGW Makefiles" -DCMAKE_CXX_STANDARD=14 -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON
-DPYTHON_EXECUTABLE=$(python -c "import sys; print(sys.executable)")
-S . -B build

- name: Build C++11
- name: Build C++14
run: cmake --build build -j 2

- name: Python tests C++11
- name: Python tests C++14
run: cmake --build build --target pytest -j 2

- name: C++11 tests
- name: C++14 tests
timeout-minutes: 3
run: PYTHONHOME=/${{matrix.sys}} PYTHONPATH=/${{matrix.sys}} cmake --build build --target cpptest -j 2

- name: Interface test C++11
- name: Interface test C++14
run: PYTHONHOME=/${{matrix.sys}} PYTHONPATH=/${{matrix.sys}} cmake --build build --target test_cmake_build

- name: Visibility test
Expand All @@ -996,31 +999,6 @@ jobs:
- name: Clean directory
run: git clean -fdx

- name: Configure C++14
run: >-
cmake -G "MinGW Makefiles" -DCMAKE_CXX_STANDARD=14 -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON
-DPYTHON_EXECUTABLE=$(python -c "import sys; print(sys.executable)")
-S . -B build2

- name: Build C++14
run: cmake --build build2 -j 2

- name: Python tests C++14
run: cmake --build build2 --target pytest -j 2

- name: C++14 tests
timeout-minutes: 3
run: PYTHONHOME=/${{matrix.sys}} PYTHONPATH=/${{matrix.sys}} cmake --build build2 --target cpptest -j 2

- name: Interface test C++14
run: PYTHONHOME=/${{matrix.sys}} PYTHONPATH=/${{matrix.sys}} cmake --build build2 --target test_cmake_build

- name: Visibility test
run: PYTHONHOME=/${{matrix.sys}} PYTHONPATH=/${{matrix.sys}} cmake --build build2 --target test_cross_module_rtti

- name: Clean directory
run: git clean -fdx

- name: Configure C++17
run: >-
cmake -G "MinGW Makefiles" -DCMAKE_CXX_STANDARD=17 -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON
Expand Down
24 changes: 12 additions & 12 deletions .github/workflows/upstream.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,28 +49,28 @@ jobs:
cmake --version
pip list

# First build - C++11 mode and inplace
- name: Configure C++11
# First build - C++14 mode and inplace
- name: Configure C++14
run: >
cmake -S . -B build11
cmake -S . -B build14
-DPYBIND11_WERROR=ON
-DDOWNLOAD_CATCH=ON
-DDOWNLOAD_EIGEN=ON
-DCMAKE_CXX_STANDARD=11
-DCMAKE_CXX_STANDARD=14
-DCMAKE_BUILD_TYPE=Debug

- name: Build C++11
run: cmake --build build11 -j 2
- name: Build C++14
run: cmake --build build14 -j 2

- name: Python tests C++11
run: cmake --build build11 --target pytest -j 2
- name: Python tests C++14
run: cmake --build build14 --target pytest -j 2

- name: C++11 tests
- name: C++14 tests
timeout-minutes: 3
run: cmake --build build11 --target cpptest -j 2
run: cmake --build build14 --target cpptest -j 2

- name: Interface test C++11
run: cmake --build build11 --target test_cmake_build
- name: Interface test C++14
run: cmake --build build14 --target test_cmake_build

# Second build - C++17 mode and in a build directory
- name: Configure C++17
Expand Down
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,7 @@ if(NOT TARGET pybind11_headers)
pybind11_headers ${pybind11_system} INTERFACE $<BUILD_INTERFACE:${pybind11_INCLUDE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)

target_compile_features(pybind11_headers INTERFACE cxx_inheriting_constructors cxx_user_literals
cxx_right_angle_brackets)
target_compile_features(pybind11_headers INTERFACE cxx_std_14)
if(NOT "${PYBIND11_INTERNALS_VERSION}" STREQUAL "")
target_compile_definitions(
pybind11_headers INTERFACE "PYBIND11_INTERNALS_VERSION=${PYBIND11_INTERNALS_VERSION}")
Expand Down
4 changes: 2 additions & 2 deletions docs/advanced/deprecated.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
Deprecated
##########

Support for C++11 is deprecated and will be removed in a future version. Please
use at least C++14.
Support for C++11 was removed in pybind11 3.1. Please use at least C++14;
C++17 or newer is recommended.

Support for FindPythonLibs (not available in CMake 3.26+ mode) is deprecated
and will be removed in a future version. The default mode is also going to
Expand Down
2 changes: 1 addition & 1 deletion docs/basics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ On Linux, the above example can be compiled using the following command:

.. code-block:: bash

$ c++ -O3 -Wall -shared -std=c++11 -fPIC $(python3 -m pybind11 --includes) example.cpp -o example$(python3 -m pybind11 --extension-suffix)
$ c++ -O3 -Wall -shared -std=c++14 -fPIC $(python3 -m pybind11 --includes) example.cpp -o example$(python3 -m pybind11 --extension-suffix)

.. note::

Expand Down
17 changes: 1 addition & 16 deletions docs/classes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -414,8 +414,7 @@ The overload signatures are also visible in the method's docstring:
|
| Set the pet's name

If you have a C++14 compatible compiler [#cpp14]_, you can use an alternative
syntax to cast the overloaded function:
You can also use an alternative syntax to cast the overloaded function:

.. code-block:: cpp

Expand All @@ -439,20 +438,6 @@ on constness, the ``py::const_`` tag should be used:
.def("foo_mutable", py::overload_cast<int, float>(&Widget::foo))
.def("foo_const", py::overload_cast<int, float>(&Widget::foo, py::const_));

If you prefer the ``py::overload_cast`` syntax but have a C++11 compatible compiler only,
you can use ``py::detail::overload_cast_impl`` with an additional set of parentheses:

.. code-block:: cpp

template <typename... Args>
using overload_cast_ = pybind11::detail::overload_cast_impl<Args...>;

py::class_<Pet>(m, "Pet")
.def("set", overload_cast_<int>()(&Pet::set), "Set the pet's age")
.def("set", overload_cast_<const std::string &>()(&Pet::set), "Set the pet's name");

.. [#cpp14] A compiler which supports the ``-std=c++14`` flag.

.. note::

To define multiple overloaded constructors, simply declare one after the
Expand Down
6 changes: 3 additions & 3 deletions docs/compiling.rst
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ that. Your ``meson.build`` file would look something like this:
'cpp',
version: '0.1.0',
default_options: [
'cpp_std=c++11',
'cpp_std=c++14',
],
)

Expand Down Expand Up @@ -649,7 +649,7 @@ On Linux, you can compile an example such as the one given in

.. code-block:: bash

$ c++ -O3 -Wall -shared -std=c++11 -fPIC $(python3 -m pybind11 --includes) example.cpp -o example$(python3-config --extension-suffix)
$ c++ -O3 -Wall -shared -std=c++14 -fPIC $(python3 -m pybind11 --includes) example.cpp -o example$(python3-config --extension-suffix)

The ``python3 -m pybind11 --includes`` command fetches the include paths for
both pybind11 and Python headers. This assumes that pybind11 has been installed
Expand All @@ -663,7 +663,7 @@ building the module:

.. code-block:: bash

$ c++ -O3 -Wall -shared -std=c++11 -undefined dynamic_lookup $(python3 -m pybind11 --includes) example.cpp -o example$(python3-config --extension-suffix)
$ c++ -O3 -Wall -shared -std=c++14 -undefined dynamic_lookup $(python3 -m pybind11 --includes) example.cpp -o example$(python3-config --extension-suffix)

For quick tests, the command line tool can also produce the full set of flags
for you, based on ``python-config``:
Expand Down
12 changes: 4 additions & 8 deletions include/pybind11/attr.h
Original file line number Diff line number Diff line change
Expand Up @@ -677,28 +677,24 @@ struct process_attributes {
PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(r);
PYBIND11_WORKAROUND_INCORRECT_GCC_UNUSED_BUT_SET_PARAMETER(r);
using expander = int[];
(void) expander{
0, ((void) process_attribute<typename std::decay<Args>::type>::init(args, r), 0)...};
(void) expander{0, ((void) process_attribute<std::decay_t<Args>>::init(args, r), 0)...};
}
static void init(const Args &...args, type_record *r) {
PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(r);
PYBIND11_WORKAROUND_INCORRECT_GCC_UNUSED_BUT_SET_PARAMETER(r);
using expander = int[];
(void) expander{0,
(process_attribute<typename std::decay<Args>::type>::init(args, r), 0)...};
(void) expander{0, (process_attribute<std::decay_t<Args>>::init(args, r), 0)...};
}
static void precall(function_call &call) {
PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(call);
using expander = int[];
(void) expander{0,
(process_attribute<typename std::decay<Args>::type>::precall(call), 0)...};
(void) expander{0, (process_attribute<std::decay_t<Args>>::precall(call), 0)...};
}
static void postcall(function_call &call, handle fn_ret) {
PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(call, fn_ret);
PYBIND11_WORKAROUND_INCORRECT_GCC_UNUSED_BUT_SET_PARAMETER(fn_ret);
using expander = int[];
(void) expander{
0, (process_attribute<typename std::decay<Args>::type>::postcall(call, fn_ret), 0)...};
(void) expander{0, (process_attribute<std::decay_t<Args>>::postcall(call, fn_ret), 0)...};
}
};

Expand Down
Loading
Loading