Much more efficient generation of function signatures, updated docs
This modification taps into some newer C++14 features (if present) to
generate function signatures considerably more efficiently at compile
time rather than at run time.
With this change, pybind11 binaries are now *2.1 times* smaller compared
to the Boost.Python baseline in the benchmark. Compilation times get a
nice improvement as well.
Visual Studio 2015 unfortunately doesn't implement 'constexpr' well
enough yet to support this change and uses a runtime fallback.
diff --git a/docs/cmake.rst b/docs/cmake.rst
index 348c54a..c44366f 100644
--- a/docs/cmake.rst
+++ b/docs/cmake.rst
@@ -39,8 +39,16 @@
# find_package(PythonInterp ${PYTHONLIBS_VERSION_STRING} EXACT REQUIRED)
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
- # Enable C++11 mode on C++ / Clang
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
+ CHECK_CXX_COMPILER_FLAG("-std=c++14" HAS_CPP14_FLAG)
+ CHECK_CXX_COMPILER_FLAG("-std=c++11" HAS_CPP11_FLAG)
+
+ if (HAS_CPP14_FLAG)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
+ elseif (HAS_CPP11_FLAG)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
+ else()
+ message(FATAL_ERROR "Unsupported compiler -- at least C++11 support is needed!")
+ endif()
# Enable link time optimization and set the default symbol
# visibility to hidden (very important to obtain small binaries)