From a889c5708f6f9d6edcf7732321b523539b14b90d Mon Sep 17 00:00:00 2001 From: Jonas Rembser Date: Mon, 29 Sep 2025 11:32:28 +0200 Subject: [PATCH 1/5] [RF] Remove unimplemented `RooWorkspace::merge()` function --- roofit/roofitcore/inc/RooWorkspace.h | 2 -- roofit/roofitcore/src/ModelConfig.cxx | 8 ++------ 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/roofit/roofitcore/inc/RooWorkspace.h b/roofit/roofitcore/inc/RooWorkspace.h index dc7f044737191..e6d20338f9d86 100644 --- a/roofit/roofitcore/inc/RooWorkspace.h +++ b/roofit/roofitcore/inc/RooWorkspace.h @@ -99,8 +99,6 @@ class RooWorkspace : public TNamed { // Retrieve list of parameter snapshots RooLinkedList const& getSnapshots() const { return _snapshots; } - void merge(const RooWorkspace& /*other*/) {} ; - // Accessor functions RooAbsPdf* pdf(RooStringView name) const ; RooAbsReal* function(RooStringView name) const ; diff --git a/roofit/roofitcore/src/ModelConfig.cxx b/roofit/roofitcore/src/ModelConfig.cxx index 578ef871c0659..94e8a7ec6a70a 100644 --- a/roofit/roofitcore/src/ModelConfig.cxx +++ b/roofit/roofitcore/src/ModelConfig.cxx @@ -191,18 +191,14 @@ void ModelConfig::Print(Option_t *) const } //////////////////////////////////////////////////////////////////////////////// -/// If a workspace already exists in this ModelConfig, RooWorkspace::merge(ws) will be called -/// on the existing workspace. +/// If a workspace already exists in this ModelConfig, this function will do nothing. void ModelConfig::SetWS(RooWorkspace &ws) { if (!fRefWS) { fRefWS = &ws; } else { - RooFit::MsgLevel level = RooMsgService::instance().globalKillBelow(); - RooMsgService::instance().setGlobalKillBelow(RooFit::ERROR); - GetWS()->merge(ws); - RooMsgService::instance().setGlobalKillBelow(level); + coutE(ObjectHandling) << "ModelConfig::SetWS(): workspace already set, not doing anything" << std::endl; } } From cffea8ea05ee914e2b3b92c3976bcf2ad48ec6fa Mon Sep 17 00:00:00 2001 From: Jonas Rembser Date: Mon, 29 Sep 2025 13:57:16 +0200 Subject: [PATCH 2/5] [cppyy] Remove checks for C++ standard As ROOT requires C++17 for a long time now, cppyy also requires it and we can remove the checks for C++17 or lower standards from the code. --- .../pyroot/cppyy/CPyCppyy/src/Converters.cxx | 13 +--- .../cppyy/CPyCppyy/src/DeclareConverters.h | 4 -- .../cppyy/CPyCppyy/src/DeclareExecutors.h | 4 -- .../pyroot/cppyy/CPyCppyy/src/Executors.cxx | 6 -- .../cppyy/CPyCppyy/src/LowLevelViews.cxx | 4 -- .../pyroot/cppyy/CPyCppyy/src/LowLevelViews.h | 4 -- .../pyroot/cppyy/cppyy/test/cpp11features.cxx | 4 -- .../pyroot/cppyy/cppyy/test/cpp11features.h | 4 -- .../pyroot/cppyy/cppyy/test/datatypes.cxx | 34 --------- bindings/pyroot/cppyy/cppyy/test/datatypes.h | 32 --------- bindings/pyroot/cppyy/cppyy/test/stltypes.cxx | 2 - bindings/pyroot/cppyy/cppyy/test/stltypes.h | 4 -- bindings/pyroot/cppyy/cppyy/test/templates.h | 2 - .../cppyy/cppyy/test/test_cpp11features.py | 50 +++++++------ .../pyroot/cppyy/cppyy/test/test_datatypes.py | 70 +++++++------------ .../pyroot/cppyy/cppyy/test/test_fragile.py | 8 +-- .../pyroot/cppyy/cppyy/test/test_lowlevel.py | 6 -- .../cppyy/cppyy/test/test_regression.py | 19 +++-- .../pyroot/cppyy/cppyy/test/test_stltypes.py | 6 -- .../pyroot/cppyy/cppyy/test/test_templates.py | 32 +++------ 20 files changed, 69 insertions(+), 239 deletions(-) diff --git a/bindings/pyroot/cppyy/CPyCppyy/src/Converters.cxx b/bindings/pyroot/cppyy/CPyCppyy/src/Converters.cxx index e651c2a29228f..639d08c3a3d2e 100644 --- a/bindings/pyroot/cppyy/CPyCppyy/src/Converters.cxx +++ b/bindings/pyroot/cppyy/CPyCppyy/src/Converters.cxx @@ -26,10 +26,9 @@ #include #include #include -#if (__cplusplus > 201402L) || (defined(_MSC_VER) && _MSVC_LANG > 201402L) #include #include -#endif + // codecvt does not exist for gcc4.8.5 and is in principle deprecated; it is // only used in py2 for char -> wchar_t conversion for std::wstring; if not // available, the conversion is done through Python (requires an extra copy) @@ -1777,9 +1776,7 @@ bool CPyCppyy::name##ArrayConverter::ToMemory( \ CPPYY_IMPL_ARRAY_CONVERTER(Bool, c_bool, bool, '?', ) CPPYY_IMPL_ARRAY_CONVERTER(SChar, c_char, signed char, 'b', ) CPPYY_IMPL_ARRAY_CONVERTER(UChar, c_ubyte, unsigned char, 'B', ) -#if (__cplusplus > 201402L) || (defined(_MSC_VER) && _MSVC_LANG > 201402L) CPPYY_IMPL_ARRAY_CONVERTER(Byte, c_ubyte, std::byte, 'B', ) -#endif CPPYY_IMPL_ARRAY_CONVERTER(Int8, c_byte, int8_t, 'b', _i8) CPPYY_IMPL_ARRAY_CONVERTER(Int16, c_int16, int16_t, 'h', _i16) CPPYY_IMPL_ARRAY_CONVERTER(Int32, c_int32, int32_t, 'i', _i32) @@ -2032,7 +2029,6 @@ bool CPyCppyy::STLWStringConverter::ToMemory(PyObject* value, void* address, PyO } -#if (__cplusplus > 201402L) || (defined(_MSC_VER) && _MSVC_LANG > 201402L) CPyCppyy::STLStringViewConverter::STLStringViewConverter(bool keepControl) : InstanceConverter(Cppyy::GetScope("std::string_view"), keepControl) {} @@ -2112,7 +2108,6 @@ bool CPyCppyy::STLStringViewConverter::ToMemory( return false; } -#endif bool CPyCppyy::STLStringMoveConverter::SetArg( @@ -3563,9 +3558,7 @@ static struct InitConvFactories_t { gf["SCharAsInt[]"] = gf["signed char ptr"]; gf["UCharAsInt*"] = gf["unsigned char ptr"]; gf["UCharAsInt[]"] = gf["unsigned char ptr"]; -#if (__cplusplus > 201402L) || (defined(_MSC_VER) && _MSVC_LANG > 201402L) gf["std::byte ptr"] = (cf_t)+[](cdims_t d) { return new ByteArrayConverter{d}; }; -#endif gf["int8_t ptr"] = (cf_t)+[](cdims_t d) { return new Int8ArrayConverter{d}; }; gf["int16_t ptr"] = (cf_t)+[](cdims_t d) { return new Int16ArrayConverter{d}; }; gf["int32_t ptr"] = (cf_t)+[](cdims_t d) { return new Int32ArrayConverter{d}; }; @@ -3590,14 +3583,12 @@ static struct InitConvFactories_t { // aliases gf["signed char"] = gf["char"]; gf["const signed char&"] = gf["const char&"]; -#if (__cplusplus > 201402L) || (defined(_MSC_VER) && _MSVC_LANG > 201402L) gf["std::byte"] = gf["uint8_t"]; gf["byte"] = gf["uint8_t"]; gf["const std::byte&"] = gf["const uint8_t&"]; gf["const byte&"] = gf["const uint8_t&"]; gf["std::byte&"] = gf["uint8_t&"]; gf["byte&"] = gf["uint8_t&"]; -#endif gf["std::int8_t"] = gf["int8_t"]; gf["const std::int8_t&"] = gf["const int8_t&"]; gf["std::int8_t&"] = gf["int8_t&"]; @@ -3651,13 +3642,11 @@ static struct InitConvFactories_t { gf["const string&"] = gf["std::string"]; gf["std::string&&"] = (cf_t)+[](cdims_t) { return new STLStringMoveConverter{}; }; gf["string&&"] = gf["std::string&&"]; -#if (__cplusplus > 201402L) || (defined(_MSC_VER) && _MSVC_LANG > 201402L) gf["std::string_view"] = (cf_t)+[](cdims_t) { return new STLStringViewConverter{}; }; gf[STRINGVIEW] = gf["std::string_view"]; gf["std::string_view&"] = gf["std::string_view"]; gf["const std::string_view&"] = gf["std::string_view"]; gf["const " STRINGVIEW "&"] = gf["std::string_view"]; -#endif gf["std::wstring"] = (cf_t)+[](cdims_t) { return new STLWStringConverter{}; }; gf[WSTRING1] = gf["std::wstring"]; gf[WSTRING2] = gf["std::wstring"]; diff --git a/bindings/pyroot/cppyy/CPyCppyy/src/DeclareConverters.h b/bindings/pyroot/cppyy/CPyCppyy/src/DeclareConverters.h index 2f7f0a25e6920..f8932cd295209 100644 --- a/bindings/pyroot/cppyy/CPyCppyy/src/DeclareConverters.h +++ b/bindings/pyroot/cppyy/CPyCppyy/src/DeclareConverters.h @@ -215,9 +215,7 @@ class CString32Converter : public Converter { CPPYY_DECLARE_ARRAY_CONVERTER(Bool); CPPYY_DECLARE_ARRAY_CONVERTER(SChar); CPPYY_DECLARE_ARRAY_CONVERTER(UChar); -#if (__cplusplus > 201402L) || (defined(_MSC_VER) && _MSVC_LANG > 201402L) CPPYY_DECLARE_ARRAY_CONVERTER(Byte); -#endif CPPYY_DECLARE_ARRAY_CONVERTER(Int8); CPPYY_DECLARE_ARRAY_CONVERTER(Int16); CPPYY_DECLARE_ARRAY_CONVERTER(Int32); @@ -384,9 +382,7 @@ protected: \ CPPYY_DECLARE_STRING_CONVERTER(STLString, std::string); CPPYY_DECLARE_STRING_CONVERTER(STLWString, std::wstring); -#if (__cplusplus > 201402L) || (defined(_MSC_VER) && _MSVC_LANG > 201402L) CPPYY_DECLARE_STRING_CONVERTER(STLStringView, std::string_view); -#endif class STLStringMoveConverter : public STLStringConverter { public: diff --git a/bindings/pyroot/cppyy/CPyCppyy/src/DeclareExecutors.h b/bindings/pyroot/cppyy/CPyCppyy/src/DeclareExecutors.h index ff6cb18cdc5c9..888f63be96e63 100644 --- a/bindings/pyroot/cppyy/CPyCppyy/src/DeclareExecutors.h +++ b/bindings/pyroot/cppyy/CPyCppyy/src/DeclareExecutors.h @@ -7,9 +7,7 @@ #include "Dimensions.h" // Standard -#if (__cplusplus > 201402L) || (defined(_MSC_VER) && _MSVC_LANG > 201402L) #include -#endif namespace CPyCppyy { @@ -65,9 +63,7 @@ CPPYY_ARRAY_DECL_EXEC(Void); CPPYY_ARRAY_DECL_EXEC(Bool); CPPYY_ARRAY_DECL_EXEC(SChar); CPPYY_ARRAY_DECL_EXEC(UChar); -#if (__cplusplus > 201402L) || (defined(_MSC_VER) && _MSVC_LANG > 201402L) CPPYY_ARRAY_DECL_EXEC(Byte); -#endif CPPYY_ARRAY_DECL_EXEC(Int8); CPPYY_ARRAY_DECL_EXEC(UInt8); CPPYY_ARRAY_DECL_EXEC(Short); diff --git a/bindings/pyroot/cppyy/CPyCppyy/src/Executors.cxx b/bindings/pyroot/cppyy/CPyCppyy/src/Executors.cxx index 954be578485b0..531db2af36234 100644 --- a/bindings/pyroot/cppyy/CPyCppyy/src/Executors.cxx +++ b/bindings/pyroot/cppyy/CPyCppyy/src/Executors.cxx @@ -510,9 +510,7 @@ PyObject* CPyCppyy::name##ArrayExecutor::Execute( \ CPPYY_IMPL_ARRAY_EXEC(Bool, bool, ) CPPYY_IMPL_ARRAY_EXEC(SChar, signed char, ) CPPYY_IMPL_ARRAY_EXEC(UChar, unsigned char, ) -#if (__cplusplus > 201402L) || (defined(_MSC_VER) && _MSVC_LANG > 201402L) CPPYY_IMPL_ARRAY_EXEC(Byte, std::byte, ) -#endif CPPYY_IMPL_ARRAY_EXEC(Int8, int8_t, _i8) CPPYY_IMPL_ARRAY_EXEC(UInt8, uint8_t, _i8) CPPYY_IMPL_ARRAY_EXEC(Short, short, ) @@ -1019,12 +1017,10 @@ struct InitExecFactories_t { gf["bool ptr"] = (ef_t)+[](cdims_t d) { return new BoolArrayExecutor{d}; }; gf["unsigned char ptr"] = (ef_t)+[](cdims_t d) { return new UCharArrayExecutor{d}; }; gf["const unsigned char ptr"] = gf["unsigned char ptr"]; -#if (__cplusplus > 201402L) || (defined(_MSC_VER) && _MSVC_LANG > 201402L) gf["std::byte ptr"] = (ef_t)+[](cdims_t d) { return new ByteArrayExecutor{d}; }; gf["const std::byte ptr"] = gf["std::byte ptr"]; gf["byte ptr"] = gf["std::byte ptr"]; gf["const byte ptr"] = gf["std::byte ptr"]; -#endif gf["int8_t ptr"] = (ef_t)+[](cdims_t d) { return new Int8ArrayExecutor{d}; }; gf["uint8_t ptr"] = (ef_t)+[](cdims_t d) { return new UInt8ArrayExecutor{d}; }; gf["short ptr"] = (ef_t)+[](cdims_t d) { return new ShortArrayExecutor{d}; }; @@ -1046,14 +1042,12 @@ struct InitExecFactories_t { gf["internal_enum_type_t"] = gf["int"]; gf["internal_enum_type_t&"] = gf["int&"]; gf["internal_enum_type_t ptr"] = gf["int ptr"]; -#if (__cplusplus > 201402L) || (defined(_MSC_VER) && _MSVC_LANG > 201402L) gf["std::byte"] = gf["uint8_t"]; gf["byte"] = gf["uint8_t"]; gf["std::byte&"] = gf["uint8_t&"]; gf["byte&"] = gf["uint8_t&"]; gf["const std::byte&"] = gf["const uint8_t&"]; gf["const byte&"] = gf["const uint8_t&"]; -#endif gf["std::int8_t"] = gf["int8_t"]; gf["std::int8_t&"] = gf["int8_t&"]; gf["const std::int8_t&"] = gf["const int8_t&"]; diff --git a/bindings/pyroot/cppyy/CPyCppyy/src/LowLevelViews.cxx b/bindings/pyroot/cppyy/CPyCppyy/src/LowLevelViews.cxx index 3b0d48e9f1c7c..40a8d23f3f344 100644 --- a/bindings/pyroot/cppyy/CPyCppyy/src/LowLevelViews.cxx +++ b/bindings/pyroot/cppyy/CPyCppyy/src/LowLevelViews.cxx @@ -1001,10 +1001,8 @@ template<> struct typecode_traits { static constexpr const char* format = "b"; static constexpr const char* name = "SCharAsInt"; }; template<> struct typecode_traits { static constexpr const char* format = "B"; static constexpr const char* name = "UCharAsInt"; }; -#if (__cplusplus > 201402L) || (defined(_MSC_VER) && _MSVC_LANG > 201402L) template<> struct typecode_traits { static constexpr const char* format = "B"; static constexpr const char* name = "UCharAsInt"; }; -#endif template<> struct typecode_traits { static constexpr const char* format = "b"; static constexpr const char* name = "char*"; }; template<> struct typecode_traits { @@ -1142,9 +1140,7 @@ PyObject* CPyCppyy::CreateLowLevelView(type** address, cdims_t shape) { \ CPPYY_IMPL_VIEW_CREATOR(bool); CPPYY_IMPL_VIEW_CREATOR(signed char); CPPYY_IMPL_VIEW_CREATOR(unsigned char); -#if (__cplusplus > 201402L) || (defined(_MSC_VER) && _MSVC_LANG > 201402L) CPPYY_IMPL_VIEW_CREATOR(std::byte); -#endif CPPYY_IMPL_VIEW_CREATOR(short); CPPYY_IMPL_VIEW_CREATOR(unsigned short); CPPYY_IMPL_VIEW_CREATOR(int); diff --git a/bindings/pyroot/cppyy/CPyCppyy/src/LowLevelViews.h b/bindings/pyroot/cppyy/CPyCppyy/src/LowLevelViews.h index 811af69e2787f..b3b6c8daa16ca 100644 --- a/bindings/pyroot/cppyy/CPyCppyy/src/LowLevelViews.h +++ b/bindings/pyroot/cppyy/CPyCppyy/src/LowLevelViews.h @@ -7,9 +7,7 @@ // Standard #include #include -#if (__cplusplus > 201402L) || (defined(_MSC_VER) && _MSVC_LANG > 201402L) #include -#endif namespace CPyCppyy { @@ -49,9 +47,7 @@ CPPYY_DECL_VIEW_CREATOR(bool); CPPYY_DECL_VIEW_CREATOR(char); CPPYY_DECL_VIEW_CREATOR(signed char); CPPYY_DECL_VIEW_CREATOR(unsigned char); -#if (__cplusplus > 201402L) || (defined(_MSC_VER) && _MSVC_LANG > 201402L) CPPYY_DECL_VIEW_CREATOR(std::byte); -#endif PyObject* CreateLowLevelView_i8(int8_t*, cdims_t shape); PyObject* CreateLowLevelView_i8(int8_t**, cdims_t shape); PyObject* CreateLowLevelView_i8(uint8_t*, cdims_t shape); diff --git a/bindings/pyroot/cppyy/cppyy/test/cpp11features.cxx b/bindings/pyroot/cppyy/cppyy/test/cpp11features.cxx index 79fcb7fc65a2b..7319875c30e4e 100644 --- a/bindings/pyroot/cppyy/cppyy/test/cpp11features.cxx +++ b/bindings/pyroot/cppyy/cppyy/test/cpp11features.cxx @@ -1,5 +1,3 @@ -#if __cplusplus >= 201103L - #include "cpp11features.h" @@ -57,5 +55,3 @@ void implicit_converion_move(TestMoving2&&) { // for std::function testing std::function FNCreateTestStructFunc() { return [](const FNTestStruct& t) { return t.t; }; } std::function FunctionNS::FNCreateTestStructFunc() { return [](const FNTestStruct& t) { return t.t; }; } - -#endif // c++11 and later diff --git a/bindings/pyroot/cppyy/cppyy/test/cpp11features.h b/bindings/pyroot/cppyy/cppyy/test/cpp11features.h index aae0cc6ac5d3d..44d8a234af6ce 100644 --- a/bindings/pyroot/cppyy/cppyy/test/cpp11features.h +++ b/bindings/pyroot/cppyy/cppyy/test/cpp11features.h @@ -1,5 +1,3 @@ -#if __cplusplus >= 201103L - #include #include #include @@ -120,5 +118,3 @@ namespace std { size_t operator()(const StructWithHash&) const { return 17; } }; } // namespace std - -#endif // c++11 and later diff --git a/bindings/pyroot/cppyy/cppyy/test/datatypes.cxx b/bindings/pyroot/cppyy/cppyy/test/datatypes.cxx index b78b6b7d3112b..f2c4bf3424901 100644 --- a/bindings/pyroot/cppyy/cppyy/test/datatypes.cxx +++ b/bindings/pyroot/cppyy/cppyy/test/datatypes.cxx @@ -15,9 +15,7 @@ CppyyTestData::CppyyTestData() : m_const_int(17), m_owns_arrays(false) m_wchar = L'D'; m_char16 = u'\u00df'; m_char32 = U'\u00df'; -#if __cplusplus > 201402L m_byte = (std::byte)'d'; -#endif m_int8 = -9; m_uint8 = 9; m_short = -11; @@ -42,9 +40,7 @@ CppyyTestData::CppyyTestData() : m_const_int(17), m_owns_arrays(false) m_bool_array2 = new bool[N]; m_schar_array2 = new signed char[N]; m_uchar_array2 = new unsigned char[N]; -#if __cplusplus > 201402L m_byte_array2 = new std::byte[N]; -#endif m_int8_array2 = new int8_t[N]; m_uint8_array2 = new uint8_t[N]; m_short_array2 = new short[N]; @@ -64,10 +60,8 @@ CppyyTestData::CppyyTestData() : m_const_int(17), m_owns_arrays(false) m_bool_array2[i] = bool((i+1)%2); m_uchar_array[i] = 1u*i; m_uchar_array2[i] = 2u*i; -#if __cplusplus > 201402L m_byte_array[i] = (std::byte)(3u*i); m_byte_array2[i] = (std::byte)(4u*i); -#endif m_int8_array[i] = - 1*i; m_int8_array2[i] = - 2*i; m_uint8_array[i] = 3u*i; @@ -110,9 +104,7 @@ void CppyyTestData::destroy_arrays() { if (m_owns_arrays == true) { delete[] m_bool_array2; delete[] m_uchar_array2; -#if __cplusplus > 201402L delete[] m_byte_array2; -#endif delete[] m_int8_array2; delete[] m_uint8_array2; delete[] m_short_array2; @@ -139,9 +131,7 @@ unsigned char CppyyTestData::get_uchar() { return m_uchar; } wchar_t CppyyTestData::get_wchar() { return m_wchar; } char16_t CppyyTestData::get_char16() { return m_char16; } char32_t CppyyTestData::get_char32() { return m_char32; } -#if __cplusplus > 201402L std::byte CppyyTestData::get_byte() { return m_byte; } -#endif int8_t CppyyTestData::get_int8() { return m_int8; } uint8_t CppyyTestData::get_uint8() { return m_uint8; } short CppyyTestData::get_short() { return m_short; } @@ -170,10 +160,8 @@ signed char* CppyyTestData::get_schar_array() { return m_schar_array; } signed char* CppyyTestData::get_schar_array2() { return m_schar_array2; } unsigned char* CppyyTestData::get_uchar_array() { return m_uchar_array; } unsigned char* CppyyTestData::get_uchar_array2() { return m_uchar_array2; } -#if __cplusplus > 201402L std::byte* CppyyTestData::get_byte_array() { return m_byte_array; } std::byte* CppyyTestData::get_byte_array2() { return m_byte_array2; } -#endif int8_t* CppyyTestData::get_int8_array() { return m_int8_array; } int8_t* CppyyTestData::get_int8_array2() { return m_int8_array2; } uint8_t* CppyyTestData::get_uint8_array() { return m_uint8_array; } @@ -215,9 +203,7 @@ const unsigned char& CppyyTestData::get_uchar_cr() { return m_uchar; } const wchar_t& CppyyTestData::get_wchar_cr() { return m_wchar; } const char16_t& CppyyTestData::get_char16_cr() { return m_char16; } const char32_t& CppyyTestData::get_char32_cr() { return m_char32; } -#if __cplusplus > 201402L const std::byte& CppyyTestData::get_byte_cr() { return m_byte; } -#endif const int8_t& CppyyTestData::get_int8_cr() { return m_int8; } const uint8_t& CppyyTestData::get_uint8_cr() { return m_uint8; } const short& CppyyTestData::get_short_cr() { return m_short; } @@ -246,9 +232,7 @@ unsigned char& CppyyTestData::get_uchar_r() { return m_uchar; } wchar_t& CppyyTestData::get_wchar_r() { return m_wchar; } char16_t& CppyyTestData::get_char16_r() { return m_char16; } char32_t& CppyyTestData::get_char32_r() { return m_char32; } -#if __cplusplus > 201402L std::byte& CppyyTestData::get_byte_r() { return m_byte; } -#endif int8_t& CppyyTestData::get_int8_r() { return m_int8; } uint8_t& CppyyTestData::get_uint8_r() { return m_uint8; } short& CppyyTestData::get_short_r() { return m_short; } @@ -277,9 +261,7 @@ void CppyyTestData::set_uchar(unsigned char uc) { m_uchar = uc; } void CppyyTestData::set_wchar(wchar_t wc) { m_wchar = wc; } void CppyyTestData::set_char16(char16_t c16) { m_char16 = c16; } void CppyyTestData::set_char32(char32_t c32) { m_char32 = c32; } -#if __cplusplus > 201402L void CppyyTestData::set_byte(std::byte b) { m_byte = b; } -#endif void CppyyTestData::set_int8(int8_t s8) { m_int8 = s8; } void CppyyTestData::set_uint8(uint8_t u8) { m_uint8 = u8; } void CppyyTestData::set_short(short s) { m_short = s; } @@ -321,9 +303,7 @@ void CppyyTestData::set_uchar_cr(const unsigned char& uc) { m_uchar = void CppyyTestData::set_wchar_cr(const wchar_t& wc) { m_wchar = wc; } void CppyyTestData::set_char16_cr(const char16_t& c16) { m_char16 = c16; } void CppyyTestData::set_char32_cr(const char32_t& c32) { m_char32 = c32; } -#if __cplusplus > 201402L void CppyyTestData::set_byte_cr(const std::byte& b) { m_byte = b; } -#endif void CppyyTestData::set_int8_cr(const int8_t& s8) { m_int8 = s8; } void CppyyTestData::set_uint8_cr(const uint8_t& u8) { m_uint8 = u8; } void CppyyTestData::set_short_cr(const short& s) { m_short = s; } @@ -352,9 +332,7 @@ void CppyyTestData::set_char16_r(char16_t& c16) { c16 = u'\u6c24'; } void CppyyTestData::set_char32_r(char32_t& c32) { c32 = U'\U0001f34e'; } void CppyyTestData::set_schar_r(signed char& sc) { sc = 'c'; } void CppyyTestData::set_uchar_r(unsigned char& uc) { uc = 'd'; } -#if __cplusplus > 201402L void CppyyTestData::set_byte_r(std::byte& b) { b = (std::byte)'e'; } -#endif void CppyyTestData::set_short_r(short& s) { s = -1; } void CppyyTestData::set_ushort_r(unsigned short& us) { us = 2; } void CppyyTestData::set_int_r(int& i) { i = -3; } @@ -375,9 +353,7 @@ void CppyyTestData::set_char16_p(char16_t* c16) { *c16 = u'\u6c24'; } void CppyyTestData::set_char32_p(char32_t* c32) { *c32 = U'\U0001f34e'; } void CppyyTestData::set_schar_p(signed char* sc) { *sc = 'c'; } void CppyyTestData::set_uchar_p(unsigned char* uc) { *uc = 'd'; } -#if __cplusplus > 201402L void CppyyTestData::set_byte_p(std::byte* b) { *b = (std::byte)'e'; } -#endif void CppyyTestData::set_int8_p(int8_t* i8) { *i8 = -27; } void CppyyTestData::set_uint8_p(uint8_t* ui8) { *ui8 = 28; } void CppyyTestData::set_short_p(short* s) { *s = -1; } @@ -421,12 +397,10 @@ void CppyyTestData::set_uchar_ppa(unsigned char** uc) { (*uc) = new unsigned char[3]; (*uc)[0] = 'k'; (*uc)[1] = 'l'; (*uc)[2] = 'm'; } -#if __cplusplus > 201402L void CppyyTestData::set_byte_ppa(std::byte** b) { (*b) = new std::byte[3]; (*b)[0] = (std::byte)'n'; (*b)[1] = (std::byte)'o'; (*b)[2] = (std::byte)'p'; } -#endif void CppyyTestData::set_int8_ppa(int8_t** i8) { (*i8) = new int8_t[3]; (*i8)[0] = -27; (*i8)[1] = -28; (*i8)[2] = -29; @@ -531,9 +505,7 @@ void CppyyTestData::set_uchar_rv(unsigned char&& uc) { m_uchar = uc; } void CppyyTestData::set_wchar_rv(wchar_t&& wc) { m_wchar = wc; } void CppyyTestData::set_char16_rv(char16_t&& c16) { m_char16 = c16; } void CppyyTestData::set_char32_rv(char32_t&& c32) { m_char32 = c32; } -#if __cplusplus > 201402L void CppyyTestData::set_byte_rv(std::byte&& b) { m_byte = b; } -#endif void CppyyTestData::set_int8_rv(int8_t&& s8) { m_int8 = s8; } void CppyyTestData::set_uint8_rv(uint8_t&& u8) { m_uint8 = u8; } void CppyyTestData::set_short_rv(short&& s) { m_short = s; } @@ -575,9 +547,7 @@ unsigned char CppyyTestData::s_uchar = 'u'; wchar_t CppyyTestData::s_wchar = L'U'; char16_t CppyyTestData::s_char16 = u'\u6c29'; char32_t CppyyTestData::s_char32 = U'\U0001f34b'; -#if __cplusplus > 201402L std::byte CppyyTestData::s_byte = (std::byte)'b'; -#endif int8_t CppyyTestData::s_int8 = - 87; uint8_t CppyyTestData::s_uint8 = 87; short CppyyTestData::s_short = -101; @@ -637,9 +607,7 @@ unsigned char g_uchar = 'u'; wchar_t g_wchar = L'U'; char16_t g_char16 = u'\u6c21'; char32_t g_char32 = U'\u6c21'; -#if __cplusplus > 201402L std::byte g_byte = (std::byte)'x'; -#endif int8_t g_int8 = -66; uint8_t g_uint8 = 66; short g_short = -88; @@ -713,12 +681,10 @@ int64_t sum_uc_data(unsigned char* data, int size) return total; } -#if __cplusplus > 201402L int64_t sum_byte_data(std::byte* data, int size) { return sum_uc_data((unsigned char*)data, size); } -#endif //= function pointer passing ================================================ diff --git a/bindings/pyroot/cppyy/cppyy/test/datatypes.h b/bindings/pyroot/cppyy/cppyy/test/datatypes.h index e15fd9b8a4a3f..5f1a65556e398 100644 --- a/bindings/pyroot/cppyy/cppyy/test/datatypes.h +++ b/bindings/pyroot/cppyy/cppyy/test/datatypes.h @@ -106,9 +106,7 @@ class CppyyTestData { wchar_t get_wchar(); char16_t get_char16(); char32_t get_char32(); -#if __cplusplus > 201402L std::byte get_byte(); -#endif int8_t get_int8(); uint8_t get_uint8(); short get_short(); @@ -137,10 +135,8 @@ class CppyyTestData { signed char* get_schar_array2(); unsigned char* get_uchar_array(); unsigned char* get_uchar_array2(); -#if __cplusplus > 201402L std::byte* get_byte_array(); std::byte* get_byte_array2(); -#endif int8_t* get_int8_array(); int8_t* get_int8_array2(); uint8_t* get_uint8_array(); @@ -182,9 +178,7 @@ class CppyyTestData { const wchar_t& get_wchar_cr(); const char16_t& get_char16_cr(); const char32_t& get_char32_cr(); -#if __cplusplus > 201402L const std::byte& get_byte_cr(); -#endif const int8_t& get_int8_cr(); const uint8_t& get_uint8_cr(); const short& get_short_cr(); @@ -213,9 +207,7 @@ class CppyyTestData { wchar_t& get_wchar_r(); char16_t& get_char16_r(); char32_t& get_char32_r(); -#if __cplusplus > 201402L std::byte& get_byte_r(); -#endif int8_t& get_int8_r(); uint8_t& get_uint8_r(); short& get_short_r(); @@ -244,9 +236,7 @@ class CppyyTestData { void set_wchar(wchar_t); void set_char16(char16_t); void set_char32(char32_t); -#if __cplusplus > 201402L void set_byte(std::byte); -#endif void set_int8(int8_t); void set_uint8(uint8_t); void set_short(short); @@ -287,9 +277,7 @@ class CppyyTestData { void set_wchar_cr(const wchar_t&); void set_char16_cr(const char16_t&); void set_char32_cr(const char32_t&); -#if __cplusplus > 201402L void set_byte_cr(const std::byte&); -#endif void set_int8_cr(const int8_t&); void set_uint8_cr(const uint8_t&); void set_short_cr(const short&); @@ -318,9 +306,7 @@ class CppyyTestData { void set_char32_r(char32_t&); void set_schar_r(signed char&); void set_uchar_r(unsigned char&); -#if __cplusplus > 201402L void set_byte_r(std::byte&); -#endif void set_short_r(short&); void set_ushort_r(unsigned short&); void set_int_r(int&); @@ -341,9 +327,7 @@ class CppyyTestData { void set_char32_p(char32_t*); void set_schar_p(signed char*); void set_uchar_p(unsigned char*); -#if __cplusplus > 201402L void set_byte_p(std::byte*); -#endif void set_int8_p(int8_t*); void set_uint8_p(uint8_t*); void set_short_p(short*); @@ -366,9 +350,7 @@ class CppyyTestData { void set_char32_ppa(char32_t**); void set_schar_ppa(signed char**); void set_uchar_ppa(unsigned char**); -#if __cplusplus > 201402L void set_byte_ppa(std::byte**); -#endif void set_int8_ppa(int8_t**); void set_uint8_ppa(uint8_t**); void set_short_ppa(short**); @@ -403,9 +385,7 @@ class CppyyTestData { void set_wchar_rv(wchar_t&&); void set_char16_rv(char16_t&&); void set_char32_rv(char32_t&&); -#if __cplusplus > 201402L void set_byte_rv(std::byte&&); -#endif void set_int8_rv(int8_t&&); void set_uint8_rv(uint8_t&&); void set_short_rv(short&&); @@ -470,9 +450,7 @@ class CppyyTestData { wchar_t m_wchar; char16_t m_char16; char32_t m_char32; -#if __cplusplus > 201402L std::byte m_byte; -#endif int8_t m_int8; uint8_t m_uint8; short m_short; @@ -502,10 +480,8 @@ class CppyyTestData { signed char* m_schar_array2; unsigned char m_uchar_array[N]; unsigned char* m_uchar_array2; -#if __cplusplus > 201402L std::byte m_byte_array[N]; std::byte* m_byte_array2; -#endif int8_t m_int8_array[N]; int8_t* m_int8_array2; uint8_t m_uint8_array[N]; @@ -546,9 +522,7 @@ class CppyyTestData { static wchar_t s_wchar; static char16_t s_char16; static char32_t s_char32; -#if __cplusplus > 201402L static std::byte s_byte; -#endif static int8_t s_int8; static uint8_t s_uint8; static short s_short; @@ -591,9 +565,7 @@ extern unsigned char g_uchar; extern wchar_t g_wchar; extern char16_t g_char16; extern char32_t g_char32; -#if __cplusplus > 201402L extern std::byte g_byte; -#endif extern int8_t g_int8; extern uint8_t g_uint8; extern short g_short; @@ -622,9 +594,7 @@ static const unsigned char g_c_uchar = 'x'; static const wchar_t g_c_wchar = L'U'; static const char16_t g_c_char16 = u'\u6c34'; static const char32_t g_c_char32 = U'\U0001f34c'; -#if __cplusplus > 201402L static const std::byte g_c_byte = (std::byte)'u'; -#endif static const int8_t g_c_int8 = -12; static const uint8_t g_c_uint8 = 12; static const short g_c_short = -99; @@ -682,9 +652,7 @@ extern StorableData gData; //= special case of "byte" arrays =========================================== int64_t sum_uc_data(unsigned char* data, int size); -#if __cplusplus > 201402L int64_t sum_byte_data(std::byte* data, int size); -#endif //= function pointer passing ================================================ diff --git a/bindings/pyroot/cppyy/cppyy/test/stltypes.cxx b/bindings/pyroot/cppyy/cppyy/test/stltypes.cxx index 244d50056699e..970c83e7f05f8 100644 --- a/bindings/pyroot/cppyy/cppyy/test/stltypes.cxx +++ b/bindings/pyroot/cppyy/cppyy/test/stltypes.cxx @@ -54,7 +54,6 @@ std::wstring UnicodeAndSTL::get_string_wcr(const std::wstring& s) { return s; } // helpers for string_view testing -#if __cplusplus > 201402L std::string_view::size_type StringViewTest::count(const std::string_view arg) { return arg.size(); } @@ -62,7 +61,6 @@ std::string_view::size_type StringViewTest::count(const std::string_view arg) { std::string_view::size_type StringViewTest::count_cr(const std::string_view& arg) { return arg.size(); } -#endif // __cplusplus > 201402L // helper for exception base class testing int MyError::s_count = 0; diff --git a/bindings/pyroot/cppyy/cppyy/test/stltypes.h b/bindings/pyroot/cppyy/cppyy/test/stltypes.h index 6e613aee6ad6f..def1dad181089 100644 --- a/bindings/pyroot/cppyy/cppyy/test/stltypes.h +++ b/bindings/pyroot/cppyy/cppyy/test/stltypes.h @@ -6,9 +6,7 @@ #include #include #include -#if __cplusplus > 201402L #include -#endif #include #include @@ -209,12 +207,10 @@ namespace UnicodeAndSTL { // helpers for string_view testing -#if __cplusplus > 201402L namespace StringViewTest { std::string_view::size_type count(const std::string_view arg); std::string_view::size_type count_cr(const std::string_view& arg); } -#endif // helper for exception base class testing diff --git a/bindings/pyroot/cppyy/cppyy/test/templates.h b/bindings/pyroot/cppyy/cppyy/test/templates.h index 8d6f0d8ae3748..addded9bda085 100644 --- a/bindings/pyroot/cppyy/cppyy/test/templates.h +++ b/bindings/pyroot/cppyy/cppyy/test/templates.h @@ -257,7 +257,6 @@ struct Derived : public Base { // 'using' of templates template using DA_vector = std::vector; -#if __cplusplus > 201402L namespace using_problem { template @@ -280,7 +279,6 @@ template using make_vector = typename matryoshka::type; typedef make_vector iiv_t; }; -#endif namespace using_problem { diff --git a/bindings/pyroot/cppyy/cppyy/test/test_cpp11features.py b/bindings/pyroot/cppyy/cppyy/test/test_cpp11features.py index bcb12f25d93ed..99dd13c065e4c 100644 --- a/bindings/pyroot/cppyy/cppyy/test/test_cpp11features.py +++ b/bindings/pyroot/cppyy/cppyy/test/test_cpp11features.py @@ -313,41 +313,39 @@ def test09_lambda_calls(self): assert cppyy.gbl.gMyLambda(2) == 42 assert cppyy.gbl.gMyLambda(40) == 80 - if cppyy.gbl.gInterpreter.ProcessLine("__cplusplus;") >= 201402: - cppyy.cppdef("auto gime_a_lambda1() { return []() { return 42; }; }") - l1 = cppyy.gbl.gime_a_lambda1() - assert l1 - assert l1() == 42 - - cppyy.cppdef("auto gime_a_lambda2() { int a = 4; return [a](int b) { return 42+a+b; }; }") - l2 = cppyy.gbl.gime_a_lambda2() - assert l2 - assert l2(2) == 48 - - cppyy.cppdef("auto gime_a_lambda3(int a ) { return [a](int b) { return 42+a+b; }; }") - l3 = cppyy.gbl.gime_a_lambda3(4) - assert l3 - assert l3(2) == 48 + cppyy.cppdef("auto gime_a_lambda1() { return []() { return 42; }; }") + l1 = cppyy.gbl.gime_a_lambda1() + assert l1 + assert l1() == 42 + + cppyy.cppdef("auto gime_a_lambda2() { int a = 4; return [a](int b) { return 42+a+b; }; }") + l2 = cppyy.gbl.gime_a_lambda2() + assert l2 + assert l2(2) == 48 + + cppyy.cppdef("auto gime_a_lambda3(int a ) { return [a](int b) { return 42+a+b; }; }") + l3 = cppyy.gbl.gime_a_lambda3(4) + assert l3 + assert l3(2) == 48 def test10_optional(self): """Use of optional and nullopt""" import cppyy - if 201703 <= cppyy.gbl.gInterpreter.ProcessLine("__cplusplus;"): - assert cppyy.gbl.std.optional - assert cppyy.gbl.std.nullopt + assert cppyy.gbl.std.optional + assert cppyy.gbl.std.nullopt - cppyy.cppdef(""" - enum Enum { A = -1 }; - bool callopt(std::optional) { return true; } - """) + cppyy.cppdef(""" + enum Enum { A = -1 }; + bool callopt(std::optional) { return true; } + """) - a = cppyy.gbl.std.optional[cppyy.gbl.Enum]() - assert cppyy.gbl.callopt(a) + a = cppyy.gbl.std.optional[cppyy.gbl.Enum]() + assert cppyy.gbl.callopt(a) - c = cppyy.gbl.std.nullopt - assert cppyy.gbl.callopt(c) + c = cppyy.gbl.std.nullopt + assert cppyy.gbl.callopt(c) @mark.xfail(run = False, reason = "Crashes") def test11_chrono(self): diff --git a/bindings/pyroot/cppyy/cppyy/test/test_datatypes.py b/bindings/pyroot/cppyy/cppyy/test/test_datatypes.py index bcc7151314bdb..7cfc350ec59e8 100644 --- a/bindings/pyroot/cppyy/cppyy/test/test_datatypes.py +++ b/bindings/pyroot/cppyy/cppyy/test/test_datatypes.py @@ -14,10 +14,6 @@ def setup_class(cls): cls.datatypes = cppyy.load_reflection_info(cls.test_dct) cls.N = cppyy.gbl.N - at_least_17 = 201402 < cppyy.gbl.gInterpreter.ProcessLine("__cplusplus;") - cls.has_byte = at_least_17 - cls.has_optional = at_least_17 - @mark.skip() def test01_instance_data_read_access(self): """Read access to instance public data and verify values""" @@ -46,8 +42,7 @@ def test01_instance_data_read_access(self): # reading integer types assert c.m_int8 == - 9; assert c.get_int8_cr() == - 9; assert c.get_int8_r() == - 9 assert c.m_uint8 == 9; assert c.get_uint8_cr() == 9; assert c.get_uint8_r() == 9 - if self.has_byte: - assert c.m_byte == ord('d'); assert c.get_byte_cr() == ord('d'); assert c.get_byte_r() == ord('d') + assert c.m_byte == ord('d'); assert c.get_byte_cr() == ord('d'); assert c.get_byte_r() == ord('d') assert c.m_short == -11; assert c.get_short_cr() == -11; assert c.get_short_r() == -11 assert c.m_ushort == 11; assert c.get_ushort_cr() == 11; assert c.get_ushort_r() == 11 assert c.m_int == -22; assert c.get_int_cr() == -22; assert c.get_int_r() == -22 @@ -150,9 +145,8 @@ def test01_instance_data_read_access(self): assert c.get_bool_array2()[i] == bool((i+1)%2) # reading of integer array types - names = ['schar', 'uchar', 'int8', 'uint8', 'short', 'ushort', 'int', 'uint', 'long', 'ulong'] - alpha = [ (1, 2), (1, 2), (-1, -2), (3, 4), (-5, -6), (7, 8), (-9, -10), (11, 12), (-13, -14), (15, 16)] - if self.has_byte: names.append('byte'); alpha.append((3,4)) + names = ["schar", "uchar", "int8", "uint8", "short", "ushort", "int", "uint", "long", "ulong", "byte"] + alpha = [(1, 2), (1, 2), (-1, -2), (3, 4), (-5, -6), (7, 8), (-9, -10), (11, 12), (-13, -14), (15, 16), (3, 4)] for j in range(self.N): assert getattr(c, 'm_%s_array' % names[i])[i] == alpha[i][0]*i @@ -170,8 +164,7 @@ def test01_instance_data_read_access(self): # out-of-bounds checks raises(IndexError, c.m_schar_array.__getitem__, self.N) raises(IndexError, c.m_uchar_array.__getitem__, self.N) - if self.has_byte: - raises(IndexError, c.m_byte_array.__getitem__, self.N) + raises(IndexError, c.m_byte_array.__getitem__, self.N) raises(IndexError, c.m_int8_array.__getitem__, self.N) raises(IndexError, c.m_uint8_array.__getitem__, self.N) raises(IndexError, c.m_short_array.__getitem__, self.N) @@ -246,8 +239,7 @@ def test02_instance_data_write_access(self): raises(ValueError, c.set_char32, "string") # integer types - names = ['int8', 'uint8', 'short', 'ushort', 'int', 'uint', 'long', 'ulong', 'llong', 'ullong'] - if self.has_byte: names.append('byte') + names = ["int8", "uint8", "short", "ushort", "int", "uint", "long", "ulong", "llong", "ullong", "byte"] for i in range(len(names)): setattr(c, 'm_'+names[i], i) @@ -313,13 +305,11 @@ def test02_instance_data_write_access(self): c.destroy_arrays() # integer arrays (skip int8_t and uint8_t as these are presented as (unsigned) char still) - names = ['uchar', 'short', 'ushort', 'int', 'uint', 'long', 'ulong'] - if self.has_byte: names.append('byte') + names = ["uchar", "short", "ushort", "int", "uint", "long", "ulong", "byte"] import array a = range(self.N) - atypes = ['B', 'h', 'H', 'i', 'I', 'l', 'L'] - if self.has_byte: atypes.append('B') + atypes = ['B', 'h', 'H', 'i', 'I', 'l', 'L', 'B'] for j in range(len(names)): b = array.array(atypes[j], a) setattr(c, 'm_'+names[j]+'_array', b) # buffer copies @@ -407,9 +397,8 @@ def test04_class_read_access(self): assert type(CppyyTestData.s_char32) == pyunicode # integer types - if self.has_byte: - assert CppyyTestData.s_byte == ord('b') - assert c.s_byte == ord('b') + assert CppyyTestData.s_byte == ord('b') + assert c.s_byte == ord('b') assert CppyyTestData.s_int8 == - 87 assert c.s_int8 == - 87 assert CppyyTestData.s_uint8 == 87 @@ -475,11 +464,10 @@ def test05_class_data_write_access(self): assert CppyyTestData.s_char32 == u'\u00ef' # integer types - if self.has_byte: - c.s_byte = 66 - assert CppyyTestData.s_byte == 66 - CppyyTestData.s_byte = 66 - assert c.s_byte == 66 + c.s_byte = 66 + assert CppyyTestData.s_byte == 66 + CppyyTestData.s_byte = 66 + assert c.s_byte == 66 c.s_short = -102 assert CppyyTestData.s_short == -102 CppyyTestData.s_short = -203 @@ -1145,9 +1133,6 @@ def test23_buffer_reshaping(self): CppyyTestData = cppyy.gbl.CppyyTestData c = CppyyTestData() - byte_array_names = [] - if self.has_byte: - byte_array_names = ['get_byte_array', 'get_byte_array2'] for func in ['get_bool_array', 'get_bool_array2', 'get_uchar_array', 'get_uchar_array2', 'get_int8_array', 'get_int8_array2', @@ -1157,8 +1142,8 @@ def test23_buffer_reshaping(self): 'get_int_array', 'get_int_array2', 'get_uint_array', 'get_uint_array2', 'get_long_array', 'get_long_array2', - 'get_ulong_array', 'get_ulong_array2']+\ - byte_array_names: + 'get_ulong_array', 'get_ulong_array2', + 'get_byte_array', 'get_byte_array2']: arr = getattr(c, func)() arr.reshape((self.N,)) assert len(arr) == self.N @@ -1273,9 +1258,7 @@ def run(self, f, buf, total): assert f(pbuf, len(buf)) == total run(self, cppyy.gbl.sum_uc_data, buf, total) - - if self.has_byte: - run(self, cppyy.gbl.sum_byte_data, buf, total) + run(self, cppyy.gbl.sum_byte_data, buf, total) @mark.xfail(run=not IS_MAC_ARM, reason = "Crashes on OS X ARM with" \ "libc++abi: terminating due to uncaught exception") @@ -2045,19 +2028,18 @@ def test40_more_aggregates(self): r1 = ns.make_R1() assert r1.e == ns.E.A - if self.has_optional: - cppyy.cppdef("""\ - namespace AggregateTest { - struct R2 { - std::optional s = {}; - }; + cppyy.cppdef("""\ + namespace AggregateTest { + struct R2 { + std::optional s = {}; + }; - R2 make_R2() { - return {1}; - } }""") + R2 make_R2() { + return {1}; + } }""") - r2 = ns.make_R2() - assert r2.s.x == 1 + r2 = ns.make_R2() + assert r2.s.x == 1 @mark.xfail() def test41_complex_numpy_arrays(self): diff --git a/bindings/pyroot/cppyy/cppyy/test/test_fragile.py b/bindings/pyroot/cppyy/cppyy/test/test_fragile.py index c4108258b2b9f..25da1b5e5366f 100644 --- a/bindings/pyroot/cppyy/cppyy/test/test_fragile.py +++ b/bindings/pyroot/cppyy/cppyy/test/test_fragile.py @@ -787,19 +787,13 @@ def test01_abortive_signals(self): class TestSTDNOTINGLOBAL: - def setup_class(cls): - import cppyy - cls.has_byte = 201402 < cppyy.gbl.gInterpreter.ProcessLine("__cplusplus;") - @mark.xfail() def test01_stl_in_std(self): """STL classes should live in std:: only""" import cppyy - names = ['array', 'function', 'list', 'set', 'vector'] - if self.has_byte: - names.append('byte') + names = ["array", "function", "list", "set", "vector", "byte"] for name in names: getattr(cppyy.gbl.std, name) diff --git a/bindings/pyroot/cppyy/cppyy/test/test_lowlevel.py b/bindings/pyroot/cppyy/cppyy/test/test_lowlevel.py index da15f701de84c..be0c99be74119 100644 --- a/bindings/pyroot/cppyy/cppyy/test/test_lowlevel.py +++ b/bindings/pyroot/cppyy/cppyy/test/test_lowlevel.py @@ -15,9 +15,6 @@ def setup_class(cls): cls.datatypes = cppyy.load_reflection_info(cls.test_dct) cls.N = cppyy.gbl.N - at_least_17 = 201402 < cppyy.gbl.gInterpreter.ProcessLine("__cplusplus;") - cls.has_nested_namespace = at_least_17 - def test00_import_all(self): """Validity of `from cppyy.ll import *`""" @@ -497,9 +494,6 @@ def test14_templated_arrays(self): def test15_templated_arrays_gmpxx(self): """Use of gmpxx array types in templates""" - if not self.has_nested_namespace: - return - import cppyy try: diff --git a/bindings/pyroot/cppyy/cppyy/test/test_regression.py b/bindings/pyroot/cppyy/cppyy/test/test_regression.py index d5fc197536601..eae00fa47b1c0 100644 --- a/bindings/pyroot/cppyy/cppyy/test/test_regression.py +++ b/bindings/pyroot/cppyy/cppyy/test/test_regression.py @@ -1020,17 +1020,16 @@ def test35_filesytem(self): import cppyy - if cppyy.gbl.gInterpreter.ProcessLine("__cplusplus;") > 201402: - cppyy.cppdef("""\ - #include - std::string stack_std_path() { - std::filesystem::path p = "/usr"; - std::ostringstream os; - os << p; - return os.str(); - }""") + cppyy.cppdef("""\ + #include + std::string stack_std_path() { + std::filesystem::path p = "/usr"; + std::ostringstream os; + os << p; + return os.str(); + }""") - assert cppyy.gbl.stack_std_path() == '"/usr"' + assert cppyy.gbl.stack_std_path() == '"/usr"' def test36_ctypes_sizeof(self): """cppyy.sizeof forwards to ctypes.sizeof where necessary""" diff --git a/bindings/pyroot/cppyy/cppyy/test/test_stltypes.py b/bindings/pyroot/cppyy/cppyy/test/test_stltypes.py index c377df50e4f91..b121ac2f12222 100644 --- a/bindings/pyroot/cppyy/cppyy/test/test_stltypes.py +++ b/bindings/pyroot/cppyy/cppyy/test/test_stltypes.py @@ -1697,9 +1697,6 @@ def test01_string_through_string_view(self): """Usage of std::string_view as formal argument""" import cppyy - if cppyy.gbl.gInterpreter.ProcessLine("__cplusplus;") <= 201402: - # string_view exists as of C++17 - return countit = cppyy.gbl.StringViewTest.count countit_cr = cppyy.gbl.StringViewTest.count_cr @@ -1718,9 +1715,6 @@ def test02_string_view_from_unicode(self): """Life-time management of converted unicode strings""" import cppyy, gc - if cppyy.gbl.gInterpreter.ProcessLine("__cplusplus;") <= 201402: - # string_view exists as of C++17 - return # view on (converted) unicode text = cppyy.gbl.std.string_view('''\ diff --git a/bindings/pyroot/cppyy/cppyy/test/test_templates.py b/bindings/pyroot/cppyy/cppyy/test/test_templates.py index 429705e914594..8dddc7461d00c 100644 --- a/bindings/pyroot/cppyy/cppyy/test/test_templates.py +++ b/bindings/pyroot/cppyy/cppyy/test/test_templates.py @@ -13,11 +13,6 @@ def setup_class(cls): import cppyy cls.templates = cppyy.load_reflection_info(cls.test_dct) - at_least_17 = 201402 < cppyy.gbl.gInterpreter.ProcessLine("__cplusplus;") - cls.has_integral_v = at_least_17 - cls.has_disjunction_v = at_least_17 - cls.has_pack_fold = at_least_17 - def test00_template_back_reference(self): """Template reflection""" @@ -299,18 +294,16 @@ def test12_template_aliases(self): assert iavec[5] == 5 # with variadic template - if cppyy.gbl.gInterpreter.ProcessLine("__cplusplus;") > 201402: - assert nsup.matryoshka[int, 3].type - assert nsup.matryoshka[int, 3, 4].type - assert nsup.make_vector[int , 3] - assert nsup.make_vector[int , 3]().m_val == 3 - assert nsup.make_vector[int , 4]().m_val == 4 + assert nsup.matryoshka[int, 3].type + assert nsup.matryoshka[int, 3, 4].type + assert nsup.make_vector[int , 3] + assert nsup.make_vector[int , 3]().m_val == 3 + assert nsup.make_vector[int , 4]().m_val == 4 # with inner types using - if cppyy.gbl.gInterpreter.ProcessLine("__cplusplus;") > 201402: - assert cppyy.gbl.gInterpreter.CheckClassTemplate("using_problem::Bar::Foo") - assert nsup.Foo - assert nsup.Bar.Foo # used to fail + assert cppyy.gbl.gInterpreter.CheckClassTemplate("using_problem::Bar::Foo") + assert nsup.Foo + assert nsup.Bar.Foo # used to fail @mark.xfail() def test13_using_templated_method(self): @@ -503,9 +496,6 @@ class CustomVec { def test20_templated_ctor_with_defaults(self): """Templated constructor with defaults used to be ignored""" - if not self.has_integral_v: - return - import cppyy cppyy.cppdef("""\ @@ -741,9 +731,6 @@ def test26_partial_templates(self): def test27_variadic_constructor(self): """Use of variadic template function as contructor""" - if not self.has_disjunction_v: - return - import cppyy cppyy.cppdef("""\ @@ -1152,9 +1139,6 @@ def test33_using_template_argument(self): def test34_cstring_template_argument(self): """`const char*` use over std::string""" - if not self.has_pack_fold: - return - import cppyy import ctypes From 9d5190904c7eb03dc91760297edf6feeec9d874f Mon Sep 17 00:00:00 2001 From: Jonas Rembser Date: Mon, 29 Sep 2025 14:32:18 +0200 Subject: [PATCH 3/5] [RF] Implement RooLinkedList::contains() This mimics what is done in the newer C++ standards for multiple standard library classes, and also tells cppyy how to implement `__contains__` in the Python proxy. --- roofit/roofitcore/inc/RooLinkedList.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/roofit/roofitcore/inc/RooLinkedList.h b/roofit/roofitcore/inc/RooLinkedList.h index 3c94fca57609f..0ac8842367e54 100644 --- a/roofit/roofitcore/inc/RooLinkedList.h +++ b/roofit/roofitcore/inc/RooLinkedList.h @@ -95,6 +95,9 @@ class RooLinkedList : public TObject { return _first ? _first->_arg : nullptr ; } + // For checking if the list contains an element with a given name from Python. + bool contains(const char* name) const { return find(name); } + void RecursiveRemove(TObject *obj) override; void Print(const char* opt) const override ; From f71314e9be84bbd2165d0b0c67c3e53da9af0d7c Mon Sep 17 00:00:00 2001 From: Jonas Rembser Date: Mon, 29 Sep 2025 15:18:45 +0200 Subject: [PATCH 4/5] [RF] Add `RooAbsCollection::contains()` override for name argument This is to make all overloads for looking up elements available via the `contains()` pythonization. --- roofit/roofitcore/inc/RooAbsCollection.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/roofit/roofitcore/inc/RooAbsCollection.h b/roofit/roofitcore/inc/RooAbsCollection.h index 89d3db502c10c..e0f8c5d370a1e 100644 --- a/roofit/roofitcore/inc/RooAbsCollection.h +++ b/roofit/roofitcore/inc/RooAbsCollection.h @@ -216,6 +216,11 @@ class RooAbsCollection : public TObject, public RooPrintable { /// Find object in the collection, Note: matching by object name, like the find() method TObject* FindObject(const TObject* obj) const override { auto arg = dynamic_cast(obj); return (arg) ? find(*arg) : nullptr; } + /// Check if collection contains an argument with a specific name. + bool contains(const char* name) const { + return find(name); + } + /// Check if collection contains an argument with the same name as var. /// To check for a specific instance, use containsInstance(). bool contains(const RooAbsArg& var) const { From 3baa681708ec67c7b1a0ec1c61c0864180e22279 Mon Sep 17 00:00:00 2001 From: Jonas Rembser Date: Mon, 29 Sep 2025 14:27:08 +0200 Subject: [PATCH 5/5] [CPyCppyy] Don't re-implement `contains()` in Python if already present The newer C++ standards already implement a `contains()` method for multiple STL classes. We can just forward to these in the `__contains__` method for the Python proxy. Forwarding to `contains()` on the C++ side means also that it will become easier to implement classes that Pythonize nicely automatically. Just as happened already before with `size()` (that got used to automatically implement `__len__`), one just needs to implement `contains()` on the C++ side now to implicitly get the `__contains__` pythonization. --- .../pyroot/cppyy/CPyCppyy/src/PyStrings.cxx | 3 +++ bindings/pyroot/cppyy/CPyCppyy/src/PyStrings.h | 1 + .../pyroot/cppyy/CPyCppyy/src/Pythonize.cxx | 18 +++++++++++++++++- .../pyroot/cppyy/cppyy/test/test_stltypes.py | 7 +++++++ 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/bindings/pyroot/cppyy/CPyCppyy/src/PyStrings.cxx b/bindings/pyroot/cppyy/CPyCppyy/src/PyStrings.cxx index abbf16ece0049..2ea01910ca82b 100644 --- a/bindings/pyroot/cppyy/CPyCppyy/src/PyStrings.cxx +++ b/bindings/pyroot/cppyy/CPyCppyy/src/PyStrings.cxx @@ -7,6 +7,7 @@ PyObject* CPyCppyy::PyStrings::gAssign = nullptr; PyObject* CPyCppyy::PyStrings::gBases = nullptr; PyObject* CPyCppyy::PyStrings::gBase = nullptr; +PyObject* CPyCppyy::PyStrings::gContains = nullptr; PyObject* CPyCppyy::PyStrings::gCopy = nullptr; PyObject* CPyCppyy::PyStrings::gCppBool = nullptr; PyObject* CPyCppyy::PyStrings::gCppName = nullptr; @@ -88,6 +89,7 @@ bool CPyCppyy::CreatePyStrings() { CPPYY_INITIALIZE_STRING(gAssign, __assign__); CPPYY_INITIALIZE_STRING(gBases, __bases__); CPPYY_INITIALIZE_STRING(gBase, __base__); + CPPYY_INITIALIZE_STRING(gContains, contains); CPPYY_INITIALIZE_STRING(gCopy, copy); #if PY_VERSION_HEX < 0x03000000 CPPYY_INITIALIZE_STRING(gCppBool, __cpp_nonzero__); @@ -171,6 +173,7 @@ PyObject* CPyCppyy::DestroyPyStrings() { // Remove all cached python strings. Py_DECREF(PyStrings::gBases); PyStrings::gBases = nullptr; Py_DECREF(PyStrings::gBase); PyStrings::gBase = nullptr; + Py_DECREF(PyStrings::gContains); PyStrings::gContains = nullptr; Py_DECREF(PyStrings::gCopy); PyStrings::gCopy = nullptr; Py_DECREF(PyStrings::gCppBool); PyStrings::gCppBool = nullptr; Py_DECREF(PyStrings::gCppName); PyStrings::gCppName = nullptr; diff --git a/bindings/pyroot/cppyy/CPyCppyy/src/PyStrings.h b/bindings/pyroot/cppyy/CPyCppyy/src/PyStrings.h index 55eaef58273a3..61d37b3ffc1c9 100644 --- a/bindings/pyroot/cppyy/CPyCppyy/src/PyStrings.h +++ b/bindings/pyroot/cppyy/CPyCppyy/src/PyStrings.h @@ -10,6 +10,7 @@ namespace PyStrings { extern PyObject* gAssign; extern PyObject* gBases; extern PyObject* gBase; + extern PyObject* gContains; extern PyObject* gCopy; extern PyObject* gCppBool; extern PyObject* gCppName; diff --git a/bindings/pyroot/cppyy/CPyCppyy/src/Pythonize.cxx b/bindings/pyroot/cppyy/CPyCppyy/src/Pythonize.cxx index 70d0b22aa8c49..a50086dd67646 100644 --- a/bindings/pyroot/cppyy/CPyCppyy/src/Pythonize.cxx +++ b/bindings/pyroot/cppyy/CPyCppyy/src/Pythonize.cxx @@ -898,6 +898,7 @@ PyObject* MapInit(PyObject* self, PyObject* args, PyObject* /* kwds */) return nullptr; } +#if __cplusplus <= 202002L PyObject* STLContainsWithFind(PyObject* self, PyObject* obj) { // Implement python's __contains__ for std::map/std::set @@ -924,6 +925,7 @@ PyObject* STLContainsWithFind(PyObject* self, PyObject* obj) return result; } +#endif //- set behavior as primitives ------------------------------------------------ @@ -1266,6 +1268,7 @@ PyObject* STLStringDecode(CPPInstance* self, PyObject* args, PyObject* kwds) return PyUnicode_Decode(obj->data(), obj->size(), encoding, errors); } +#if __cplusplus <= 202302L PyObject* STLStringContains(CPPInstance* self, PyObject* pyobj) { std::string* obj = GetSTLString(self); @@ -1282,6 +1285,7 @@ PyObject* STLStringContains(CPPInstance* self, PyObject* pyobj) Py_RETURN_FALSE; } +#endif PyObject* STLStringReplace(CPPInstance* self, PyObject* args, PyObject* /*kwds*/) { @@ -1654,6 +1658,10 @@ bool CPyCppyy::Pythonize(PyObject* pyclass, const std::string& name) Utility::AddToClass(pyclass, "__len__", "size"); } + if (HasAttrDirect(pyclass, PyStrings::gContains)) { + Utility::AddToClass(pyclass, "__contains__", "contains"); + } + if (!IsTemplatedSTLClass(name, "vector") && // vector is dealt with below !((PyTypeObject*)pyclass)->tp_iter) { if (HasAttrDirect(pyclass, PyStrings::gBegin) && HasAttrDirect(pyclass, PyStrings::gEnd)) { @@ -1885,8 +1893,10 @@ bool CPyCppyy::Pythonize(PyObject* pyclass, const std::string& name) // constructor that takes python associative collections Utility::AddToClass(pyclass, "__real_init", "__init__"); Utility::AddToClass(pyclass, "__init__", (PyCFunction)MapInit, METH_VARARGS | METH_KEYWORDS); - +#if __cplusplus <= 202002L + // From C++20, std::map and std::unordered_map already implement a contains() method. Utility::AddToClass(pyclass, "__contains__", (PyCFunction)STLContainsWithFind, METH_O); +#endif } else if (IsTemplatedSTLClass(name, "set")) { @@ -1894,7 +1904,10 @@ bool CPyCppyy::Pythonize(PyObject* pyclass, const std::string& name) Utility::AddToClass(pyclass, "__real_init", "__init__"); Utility::AddToClass(pyclass, "__init__", (PyCFunction)SetInit, METH_VARARGS | METH_KEYWORDS); +#if __cplusplus <= 202002L + // From C++20, std::set already implements a contains() method. Utility::AddToClass(pyclass, "__contains__", (PyCFunction)STLContainsWithFind, METH_O); +#endif } else if (IsTemplatedSTLClass(name, "pair")) { @@ -1922,7 +1935,10 @@ bool CPyCppyy::Pythonize(PyObject* pyclass, const std::string& name) Utility::AddToClass(pyclass, "__cmp__", (PyCFunction)STLStringCompare, METH_O); Utility::AddToClass(pyclass, "__eq__", (PyCFunction)STLStringIsEqual, METH_O); Utility::AddToClass(pyclass, "__ne__", (PyCFunction)STLStringIsNotEqual, METH_O); +#if __cplusplus <= 202302L + // From C++23, std::sting already implements a contains() method. Utility::AddToClass(pyclass, "__contains__", (PyCFunction)STLStringContains, METH_O); +#endif Utility::AddToClass(pyclass, "decode", (PyCFunction)STLStringDecode, METH_VARARGS | METH_KEYWORDS); Utility::AddToClass(pyclass, "__cpp_find", "find"); Utility::AddToClass(pyclass, "find", (PyCFunction)STLStringFind, METH_VARARGS | METH_KEYWORDS); diff --git a/bindings/pyroot/cppyy/cppyy/test/test_stltypes.py b/bindings/pyroot/cppyy/cppyy/test/test_stltypes.py index b121ac2f12222..c10a1a0103b76 100644 --- a/bindings/pyroot/cppyy/cppyy/test/test_stltypes.py +++ b/bindings/pyroot/cppyy/cppyy/test/test_stltypes.py @@ -1868,6 +1868,13 @@ def test05_contains(self): for i in range(100): assert not (2**30 in S) + assert '__contains__' in cppyy.gbl.std.string.__dict__ + my_string = cppyy.gbl.std.string("hello world") + + assert "hello" in my_string + assert "world" in my_string + assert "bye" not in my_string + class TestSTLTUPLE: def setup_class(cls):