diff --git a/GaudiFunctional/include/Gaudi/Functional/MergingTransformer.h b/GaudiFunctional/include/Gaudi/Functional/MergingTransformer.h index 552a0906b9ae95657ec6419a7f978d563384d4f1..4ae7bafe9359952fd8c07f2bcc986c661e17e42f 100644 --- a/GaudiFunctional/include/Gaudi/Functional/MergingTransformer.h +++ b/GaudiFunctional/include/Gaudi/Functional/MergingTransformer.h @@ -1,5 +1,5 @@ /***********************************************************************************\ -* (c) Copyright 1998-2024 CERN for the benefit of the LHCb and ATLAS collaborations * +* (c) Copyright 1998-2025 CERN for the benefit of the LHCb and ATLAS collaborations * * * * This software is distributed under the terms of the Apache version 2 licence, * * copied verbatim in the file "LICENSE". * @@ -38,11 +38,11 @@ namespace Gaudi::Functional { } template <typename Sig> - struct is_void_fun : std::false_type {}; + constexpr bool is_void_fun_v = false; template <typename... Args> - struct is_void_fun<void( Args... )> : std::true_type {}; + constexpr bool is_void_fun_v<void( Args... )> = true; template <typename Sig> - inline constexpr bool is_void_fun_v = is_void_fun<Sig>::value; + concept is_void_fun = is_void_fun_v<Sig>; template <typename Signature, typename Traits_, bool isLegacy> struct MergingTransformer; @@ -234,8 +234,7 @@ namespace Gaudi::Functional { using MergingTransformer = details::MergingTransformer<Signature, Traits_, details::isLegacy<Traits_>>; // more meaningful alias for cases where the return type in Signature is void - template <typename Signature, typename Traits_ = Traits::useDefaults, - typename = std::enable_if_t<details::is_void_fun_v<Signature>>> + template <details::is_void_fun Signature, typename Traits_ = Traits::useDefaults> using MergingConsumer = details::MergingTransformer<Signature, Traits_, details::isLegacy<Traits_>>; // M vectors of the same -> N diff --git a/GaudiFunctional/include/Gaudi/Functional/details.h b/GaudiFunctional/include/Gaudi/Functional/details.h index c7c6f5f2f3d1f059baeafc646c4bf774e365c9da..d1a77f8413f579ae5808959cc7c08e4aba2bdd39 100644 --- a/GaudiFunctional/include/Gaudi/Functional/details.h +++ b/GaudiFunctional/include/Gaudi/Functional/details.h @@ -1,5 +1,5 @@ /***********************************************************************************\ -* (c) Copyright 1998-2024 CERN for the benefit of the LHCb and ATLAS collaborations * +* (c) Copyright 1998-2025 CERN for the benefit of the LHCb and ATLAS collaborations * * * * This software is distributed under the terms of the Apache version 2 licence, * * copied verbatim in the file "LICENSE". * @@ -131,22 +131,18 @@ namespace Gaudi::Functional::details { template <typename Arg> constexpr bool is_optional_v = Gaudi::cpp17::is_detected_v<details2::is_optional_, Arg>; - template <typename Arg> - using require_is_optional = std::enable_if_t<is_optional_v<Arg>>; - - template <typename Arg> - using require_is_not_optional = std::enable_if_t<!is_optional_v<Arg>>; - template <typename T> using remove_optional_t = std::conditional_t<is_optional_v<T>, Gaudi::cpp17::detected_t<details2::value_type_of_t, T>, T>; constexpr struct invoke_optionally_t { - template <typename F, typename Arg, typename = require_is_not_optional<Arg>> + template <typename F, typename Arg> + requires( !is_optional_v<Arg> ) decltype( auto ) operator()( F&& f, Arg&& arg ) const { return std::invoke( std::forward<F>( f ), std::forward<Arg>( arg ) ); } - template <typename F, typename Arg, typename = require_is_optional<Arg>> + template <typename F, typename Arg> + requires( is_optional_v<Arg> ) void operator()( F&& f, Arg&& arg ) const { if ( arg ) std::invoke( std::forward<F>( f ), *std::forward<Arg>( arg ) ); } @@ -162,20 +158,19 @@ namespace Gaudi::Functional::details { using RepeatValues_ = decltype( get_values_helper<Value>( std::make_index_sequence<N>() ) ); ///////////////////////////////////////// - - template <typename Out1, typename Out2, - typename = std::enable_if_t<std::is_constructible_v<Out1, Out2> && std::is_base_of_v<DataObject, Out1>>> + template <std::derived_from<DataObject> Out1, std::convertible_to<Out1> Out2> auto put( const DataObjectHandle<Out1>& out_handle, Out2&& out ) { return out_handle.put( std::make_unique<Out1>( std::forward<Out2>( out ) ) ); } - template <typename Out1, typename Out2, typename = std::enable_if_t<std::is_constructible_v<Out1, Out2>>> + template <typename Out1, std::convertible_to<Out1> Out2> auto put( const DataObjectHandle<AnyDataWrapper<Out1>>& out_handle, Out2&& out ) { return out_handle.put( std::forward<Out2>( out ) ); } // optional put - template <typename OutHandle, typename OptOut, typename = require_is_optional<OptOut>> + template <typename OutHandle, typename OptOut> + requires( is_optional_v<OptOut> ) void put( const OutHandle& out_handle, OptOut&& out ) { if ( out ) put( out_handle, *std::forward<OptOut>( out ) ); } @@ -201,9 +196,9 @@ namespace Gaudi::Functional::details { } // Container<T*> with T&& as argument - template <typename Container, typename Value, - typename = std::enable_if_t<std::is_pointer_v<typename Container::value_type>>, - typename = std::enable_if_t<std::is_convertible_v<Value, c_remove_ptr_t<Container>>>> + template <typename Container, typename Value> + requires( std::is_pointer_v<typename Container::value_type> && + std::is_convertible_v<Value, c_remove_ptr_t<Container>> ) auto operator()( Container& c, Value&& v ) const { return operator()( c, new c_remove_ptr_t<Container>{ std::forward<Value>( v ) } ); } @@ -213,12 +208,14 @@ namespace Gaudi::Functional::details { ///////////////////////////////////////// constexpr struct deref_t { - template <typename In, typename = std::enable_if_t<!std::is_pointer_v<In>>> + template <typename In> + requires( !std::is_pointer_v<In> ) const In& operator()( const In& in ) const { return in; } - template <typename In, typename = std::enable_if_t<!std::is_pointer_v<std::decay_t<In>>>> + template <typename In> + requires( !std::is_pointer_v<std::decay_t<In>> ) In operator()( In&& in ) const { return std::forward<In>( in ); } @@ -234,19 +231,16 @@ namespace Gaudi::Functional::details { // if Container is a pointer, then we're optional items namespace details2 { template <typename T> - struct is_gaudi_range : std::false_type {}; + constexpr static bool is_gaudi_range_v = false; - template <typename T, typename IT> - struct is_gaudi_range<Gaudi::Range_<T, IT>> : std::true_type {}; - - template <typename T, typename IT> - struct is_gaudi_range<Gaudi::NamedRange_<T, IT>> : std::true_type {}; + template <typename T> + constexpr static bool is_gaudi_range_v<Gaudi::Range_<T>> = true; - template <typename T, typename IT> - struct is_gaudi_range<std::optional<Gaudi::NamedRange_<T, IT>>> : std::true_type {}; + template <typename T> + constexpr static bool is_gaudi_range_v<Gaudi::NamedRange_<T>> = true; template <typename T> - constexpr static bool is_gaudi_range_v = is_gaudi_range<T>::value; + constexpr static bool is_gaudi_range_v<std::optional<Gaudi::NamedRange_<T>>> = true; template <typename Container, typename Value> void push_back( Container& c, const Value& v, std::true_type ) { @@ -259,24 +253,24 @@ namespace Gaudi::Functional::details { template <typename In> struct get_from_handle { - template <template <typename> class Handle, typename I, typename = std::enable_if_t<std::is_convertible_v<I, In>>> + template <template <typename> class Handle, std::convertible_to<In> I> auto operator()( const Handle<I>& h ) -> const In& { return *h.get(); } - template <template <typename> class Handle, typename I, typename IT> - auto operator()( const Handle<Gaudi::Range_<I, IT>>& h ) -> const In { + template <template <typename> class Handle, typename I> + auto operator()( const Handle<Gaudi::Range_<I>>& h ) -> const In { return h.get(); } - template <template <typename> class Handle, typename I, typename IT> - auto operator()( const Handle<Gaudi::NamedRange_<I, IT>>& h ) -> const In { + template <template <typename> class Handle, typename I> + auto operator()( const Handle<Gaudi::NamedRange_<I>>& h ) -> const In { return h.get(); } - template <template <typename> class Handle, typename I, typename IT> - auto operator()( const Handle<std::optional<Gaudi::NamedRange_<I, IT>>>& h ) -> const In { + template <template <typename> class Handle, typename I> + auto operator()( const Handle<std::optional<Gaudi::NamedRange_<I>>>& h ) -> const In { return h.get(); } - template <template <typename> class Handle, typename I, - typename = std::enable_if_t<std::is_convertible_v<I*, In>>> + template <template <typename> class Handle, typename I> + requires( std::is_convertible_v<I*, In> ) auto operator()( const Handle<I>& h ) -> const In { return h.getIfExists(); } // In is-a pointer @@ -352,38 +346,50 @@ namespace Gaudi::Functional::details { size_type size() const { return m_containers.size(); } template <typename X = Container> - std::enable_if_t<!std::is_pointer_v<X>, ref_t> front() const { + requires( !std::is_pointer_v<X> ) + ref_t front() const { return *m_containers.front(); } + template <typename X = Container> - std::enable_if_t<std::is_pointer_v<X>, ptr_t> front() const { + requires( std::is_pointer_v<X> ) + ptr_t front() const { return m_containers.front(); } template <typename X = Container> - std::enable_if_t<!std::is_pointer_v<X>, ref_t> back() const { + requires( !std::is_pointer_v<X> ) + ref_t back() const { return *m_containers.back(); } + template <typename X = Container> - std::enable_if_t<std::is_pointer_v<X>, ptr_t> back() const { + requires( std::is_pointer_v<X> ) + ptr_t back() const { return m_containers.back(); } template <typename X = Container> - std::enable_if_t<!std::is_pointer_v<X>, ref_t> operator[]( size_type i ) const { + requires( !std::is_pointer_v<X> ) + ref_t operator[]( size_type i ) const { return *m_containers[i]; } + template <typename X = Container> - std::enable_if_t<std::is_pointer_v<X>, ptr_t> operator[]( size_type i ) const { + requires( std::is_pointer_v<X> ) + ptr_t operator[]( size_type i ) const { return m_containers[i]; } template <typename X = Container> - std::enable_if_t<!std::is_pointer_v<X>, ref_t> at( size_type i ) const { + requires( !std::is_pointer_v<X> ) + ref_t at( size_type i ) const { return *m_containers[i]; } + template <typename X = Container> - std::enable_if_t<std::is_pointer_v<X>, ptr_t> at( size_type i ) const { + requires( std::is_pointer_v<X> ) + ptr_t at( size_type i ) const { return m_containers[i]; } diff --git a/GaudiFunctional/include/Gaudi/Functional/utilities.h b/GaudiFunctional/include/Gaudi/Functional/utilities.h index cdd4c32160400c30266ff4ddf52f60d5ce8b108a..bd2cf3bde07e38526f9ff5702d9c417ebb44af75 100644 --- a/GaudiFunctional/include/Gaudi/Functional/utilities.h +++ b/GaudiFunctional/include/Gaudi/Functional/utilities.h @@ -1,5 +1,5 @@ /***********************************************************************************\ -* (c) Copyright 1998-2024 CERN for the benefit of the LHCb and ATLAS collaborations * +* (c) Copyright 1998-2025 CERN for the benefit of the LHCb and ATLAS collaborations * * * * This software is distributed under the terms of the Apache version 2 licence, * * copied verbatim in the file "LICENSE". * @@ -53,8 +53,8 @@ namespace Gaudi::Functional { template <typename Data, typename View> struct writeViewFor { - template <typename T> - using OutputHandle = std::enable_if_t<std::is_same_v<T, Data>, DataObjectWriteHandle<View, Data>>; + template <std::same_as<Data> T> + using OutputHandle = DataObjectWriteHandle<View, Data>; }; // add support for objects that should reside in the TES for lifetime management, but should not @@ -67,8 +67,8 @@ namespace Gaudi::Functional { OpaqueView( T const& ) {} }; - template <typename T> - using OutputHandle = std::enable_if_t<std::is_same_v<T, Data>, DataObjectWriteHandle<OpaqueView, Data>>; + template <std::same_as<Data> T> + using OutputHandle = DataObjectWriteHandle<OpaqueView, Data>; }; // this uses the defaults -- and it itself is the default ;-) diff --git a/GaudiKernel/include/Gaudi/Accumulators/CounterArray.h b/GaudiKernel/include/Gaudi/Accumulators/CounterArray.h index 971d01dd36b2f6d7f85aec9ba1da41835b3eedce..391da8738aeaee60cd02de6d57a8557c190c6333 100644 --- a/GaudiKernel/include/Gaudi/Accumulators/CounterArray.h +++ b/GaudiKernel/include/Gaudi/Accumulators/CounterArray.h @@ -1,5 +1,5 @@ /***********************************************************************************\ -* (c) Copyright 1998-2022 CERN for the benefit of the LHCb and ATLAS collaborations * +* (c) Copyright 1998-2025 CERN for the benefit of the LHCb and ATLAS collaborations * * * * This software is distributed under the terms of the Apache version 2 licence, * * copied verbatim in the file "LICENSE". * @@ -36,8 +36,7 @@ namespace Gaudi::Accumulators { template <typename Counter, std::size_t N> struct CounterArrayInternal : std::array<Counter, N> { /// constructor with callables for FormatName - template <typename OWNER, typename FormatName, std::size_t... Ns, - typename = typename std::enable_if_t<std::is_invocable_v<FormatName, int>>> + template <typename OWNER, std::invocable<int> FormatName, std::size_t... Ns> CounterArrayInternal( OWNER* owner, FormatName&& fname, std::integer_sequence<std::size_t, Ns...> ) : std::array<Counter, N>{ Counter{ owner, fname( Ns ) }... } { static_assert( sizeof...( Ns ) < 1000, "Using CounterArray with 1000 arrays or more is prohibited. This " diff --git a/GaudiKernel/include/Gaudi/Accumulators/HistogramArray.h b/GaudiKernel/include/Gaudi/Accumulators/HistogramArray.h index e796ad0c1ad136d3e5586cba5711eae00ab01b24..072690be637a057445059e893230f5cc1cf6d5b4 100644 --- a/GaudiKernel/include/Gaudi/Accumulators/HistogramArray.h +++ b/GaudiKernel/include/Gaudi/Accumulators/HistogramArray.h @@ -1,5 +1,5 @@ /***********************************************************************************\ -* (c) Copyright 1998-2024 CERN for the benefit of the LHCb and ATLAS collaborations * +* (c) Copyright 1998-2025 CERN for the benefit of the LHCb and ATLAS collaborations * * * * This software is distributed under the terms of the Apache version 2 licence, * * copied verbatim in the file "LICENSE". * @@ -42,9 +42,7 @@ namespace Gaudi::Accumulators { template <typename Histo, std::size_t N> struct HistogramArrayInternal : boost::container::static_vector<Histo, N> { /// constructor with callables for FormatName and FormatTitle - template <typename OWNER, typename FormatName, typename FormatTitle, - typename = typename std::enable_if_t<std::is_invocable_v<FormatName, int>>, - typename = typename std::enable_if_t<std::is_invocable_v<FormatTitle, int>>> + template <typename OWNER, std::invocable<int> FormatName, std::invocable<int> FormatTitle> HistogramArrayInternal( OWNER* owner, FormatName&& fname, FormatTitle&& ftitle, typename Histo::AxisTupleType&& allAxis ) { for ( std::size_t i = 0; i < N; i++ ) { this->emplace_back( owner, fname( i ), ftitle( i ), allAxis ); } diff --git a/GaudiKernel/include/Gaudi/Accumulators/StaticHistogram.h b/GaudiKernel/include/Gaudi/Accumulators/StaticHistogram.h index 950c93142e48046d5df0c9c158e3bfea72803425..3120a6862404eae0beafe76a4be3a180407be58c 100644 --- a/GaudiKernel/include/Gaudi/Accumulators/StaticHistogram.h +++ b/GaudiKernel/include/Gaudi/Accumulators/StaticHistogram.h @@ -1,5 +1,5 @@ /***********************************************************************************\ -* (c) Copyright 1998-2024 CERN for the benefit of the LHCb and ATLAS collaborations * +* (c) Copyright 1998-2025 CERN for the benefit of the LHCb and ATLAS collaborations * * * * This software is distributed under the terms of the Apache version 2 licence, * * copied verbatim in the file "LICENSE". * @@ -347,16 +347,19 @@ namespace Gaudi::Accumulators { using InternalType = std::tuple<Elements...>; using ValueType = HistoInputType<SubTuple_t<InternalType, NIndex>, NIndex>; using std::tuple<Elements...>::tuple; - template <class... AxisType, typename = typename std::enable_if_t<( sizeof...( AxisType ) == NIndex )>> + template <class... AxisType> + requires( sizeof...( AxisType ) == NIndex ) unsigned int computeIndex( std::tuple<AxisType...> const& axis ) const { return computeIndexInternal<0, std::tuple<AxisType...>>( axis ); } - template <class... AxisType, typename = typename std::enable_if_t<( sizeof...( AxisType ) == NIndex )>> + template <class... AxisType> + requires( sizeof...( AxisType ) == NIndex ) static unsigned int computeTotNBins( std::tuple<AxisType...> const& axis ) { return computeTotNBinsInternal<0, std::tuple<AxisType...>>( axis ); } auto forInternalCounter() const { return 1ul; } - template <class... AxisType, typename = typename std::enable_if_t<( sizeof...( AxisType ) == NIndex )>> + template <class... AxisType> + requires( sizeof...( AxisType ) == NIndex ) bool inAcceptance( std::tuple<AxisType...> const& axis ) const { return inAcceptanceInternal<0, std::tuple<AxisType...>>( axis ); } @@ -401,16 +404,19 @@ namespace Gaudi::Accumulators { struct WeightedHistoInputType : std::pair<HistoInputType<ArithmeticTuple, NIndex>, WArithmetic> { using ValueType = typename HistoInputType<ArithmeticTuple, NIndex>::ValueType; using std::pair<HistoInputType<ArithmeticTuple, NIndex>, WArithmetic>::pair; - template <class... AxisType, typename = typename std::enable_if_t<( sizeof...( AxisType ) == NIndex )>> + template <class... AxisType> + requires( sizeof...( AxisType ) == NIndex ) unsigned int computeIndex( std::tuple<AxisType...> const& axis ) const { return this->first.computeIndex( axis ); } - template <class... AxisType, typename = typename std::enable_if_t<( sizeof...( AxisType ) == NIndex )>> + template <class... AxisType> + requires( sizeof...( AxisType ) == NIndex ) static unsigned int computeTotNBins( std::tuple<AxisType...> const& axis ) { return HistoInputType<ArithmeticTuple, NIndex>::computeTotNBins( axis ); } auto forInternalCounter() const { return std::pair( this->first.forInternalCounter(), this->second ); } - template <class... AxisType, typename = typename std::enable_if_t<( sizeof...( AxisType ) == NIndex )>> + template <class... AxisType> + requires( sizeof...( AxisType ) == NIndex ) bool inAcceptance( std::tuple<AxisType...> const& axis ) const { return this->first.inAcceptance( axis ); } @@ -534,7 +540,8 @@ namespace Gaudi::Accumulators { throw std::logic_error( fmt::format( "Retrieving axis {} in Histogram of dimension {}", i, std::tuple_size_v<AxisTupleType> ) ); } - template <size_t N, typename = std::enable_if_t<std::tuple_size_v<AxisTupleType> != N>> + template <size_t N> + requires( std::tuple_size_v<AxisTupleType> != N ) auto& _getAxis( size_t i, std::integral_constant<size_t, N> ) const { if ( i == N ) return std::get<N>( m_axis ); return _getAxis( i, std::integral_constant<size_t, N + 1>() ); diff --git a/GaudiKernel/include/Gaudi/Allocator/Arena.h b/GaudiKernel/include/Gaudi/Allocator/Arena.h index ac05e127bc82a0a55ecfe7d7b8165e9baf46a872..346a144594f339f6efffa742613fa1bf9c8f39b4 100644 --- a/GaudiKernel/include/Gaudi/Allocator/Arena.h +++ b/GaudiKernel/include/Gaudi/Allocator/Arena.h @@ -40,7 +40,8 @@ namespace Gaudi::Allocator { * This constructor is only enabled if an instance of DefaultResource can be invoked * with no arguments and yields Resource*. */ - template <typename D = void, typename = std::enable_if_t<std::is_invocable_r_v<Resource*, DefaultResource>, D>> + template <typename D = void> + requires( std::is_invocable_r_v<Resource*, DefaultResource> ) Arena() : Arena( std::invoke( DefaultResource{} ) ) {} /** Converting copy constructor, rebinding U -> T. diff --git a/GaudiKernel/include/Gaudi/Parsers/Grammars.h b/GaudiKernel/include/Gaudi/Parsers/Grammars.h index 17abf3dd93d00158a50a6878467277f20c2476f1..6f21852c4271798ff9adbb529947d6975685f670 100644 --- a/GaudiKernel/include/Gaudi/Parsers/Grammars.h +++ b/GaudiKernel/include/Gaudi/Parsers/Grammars.h @@ -1,5 +1,5 @@ /***********************************************************************************\ -* (c) Copyright 1998-2024 CERN for the benefit of the LHCb and ATLAS collaborations * +* (c) Copyright 1998-2025 CERN for the benefit of the LHCb and ATLAS collaborations * * * * This software is distributed under the terms of the Apache version 2 licence, * * copied verbatim in the file "LICENSE". * @@ -145,8 +145,8 @@ namespace Gaudi { // ---------------------------------------------------------------------------- // Register IntGrammar: // ---------------------------------------------------------------------------- - template <typename Iterator, typename T, typename Skipper> - struct Grammar_<Iterator, T, Skipper, std::enable_if_t<std::is_integral_v<T>>> { + template <typename Iterator, std::integral T, typename Skipper> + struct Grammar_<Iterator, T, Skipper> { typedef IntGrammar<Iterator, T, Skipper> Grammar; }; //============================================================================== @@ -159,8 +159,8 @@ namespace Gaudi { // ---------------------------------------------------------------------------- // Register RealGrammar: // ---------------------------------------------------------------------------- - template <typename Iterator, typename T, typename Skipper> - struct Grammar_<Iterator, T, Skipper, std::enable_if_t<std::is_floating_point_v<T>>> { + template <typename Iterator, std::floating_point T, typename Skipper> + struct Grammar_<Iterator, T, Skipper> { typedef RealGrammar<Iterator, T, Skipper> Grammar; }; //============================================================================== diff --git a/GaudiKernel/include/Gaudi/Property.h b/GaudiKernel/include/Gaudi/Property.h index fcc45b8d8ffeeef4fc914879cae19dc9b8cc97bf..5422da49e8344c84534e2a6b87357d635a52bde2 100644 --- a/GaudiKernel/include/Gaudi/Property.h +++ b/GaudiKernel/include/Gaudi/Property.h @@ -1,5 +1,5 @@ /***********************************************************************************\ -* (c) Copyright 1998-2024 CERN for the benefit of the LHCb and ATLAS collaborations * +* (c) Copyright 1998-2025 CERN for the benefit of the LHCb and ATLAS collaborations * * * * This software is distributed under the terms of the Apache version 2 licence, * * copied verbatim in the file "LICENSE". * @@ -49,13 +49,7 @@ namespace Gaudi { StorageType m_value; VerifierType m_verifier; HandlersType m_handlers; - /// helper typedefs for SFINAE - /// @{ - template <class T> - static inline constexpr bool is_this_type_v = std::is_same_v<Property, std::remove_reference_t<T>>; - template <class T> - using not_copying = std::enable_if_t<!is_this_type_v<T>>; - /// @} + public: // ========================================================================== /// the constructor with property name, value and documentation. @@ -66,17 +60,17 @@ namespace Gaudi { m_verifier( m_value ); } /// Autodeclaring constructor with property name, value and documentation. - /// @note the use std::enable_if is required to avoid ambiguities - template <typename OWNER, typename T = ValueType, typename = std::enable_if_t<std::is_base_of_v<IProperty, OWNER>>, - typename = std::enable_if_t<std::is_default_constructible_v<T>>> + /// @note the use of requires is required to avoid ambiguities + template <std::derived_from<IProperty> OWNER, typename T = ValueType> + requires( std::is_default_constructible_v<T> ) Property( OWNER* owner, std::string name ) : Property( std::move( name ), ValueType{}, "" ) { owner->declareProperty( *this ); setOwnerType<OWNER>(); } /// Autodeclaring constructor with property name, value and documentation. - /// @note the use std::enable_if is required to avoid ambiguities - template <class OWNER, class T = StorageType, typename = std::enable_if_t<std::is_base_of_v<IProperty, OWNER>>> + /// @note the use of requires is required to avoid ambiguities + template <std::derived_from<IProperty> OWNER, class T = StorageType> Property( OWNER* owner, std::string name, T&& value, std::string doc = "", std::string semantics = "" ) : Property( std::move( name ), std::forward<T>( value ), std::move( doc ), std::move( semantics ) ) { owner->declareProperty( *this ); @@ -84,8 +78,8 @@ namespace Gaudi { } /// Autodeclaring constructor with property name, value, updateHandler and documentation. - /// @note the use std::enable_if is required to avoid ambiguities - template <class OWNER, class T = StorageType, typename = std::enable_if_t<std::is_base_of_v<IProperty, OWNER>>> + /// @note the use of requires is required to avoid ambiguities + template <std::derived_from<IProperty> OWNER, class T = StorageType> Property( OWNER* owner, std::string name, T&& value, std::function<void( PropertyBase& )> handler, std::string doc = "", std::string semantics = "" ) : Property( owner, std::move( name ), std::forward<T>( value ), std::move( doc ), std::move( semantics ) ) { @@ -93,8 +87,8 @@ namespace Gaudi { } /// Autodeclaring constructor with property name, value, pointer to member function updateHandler and documentation. - /// @note the use std::enable_if is required to avoid ambiguities - template <class OWNER, class T = StorageType, typename = std::enable_if_t<std::is_base_of_v<IProperty, OWNER>>> + /// @note the use of requires is required to avoid ambiguities + template <std::derived_from<IProperty> OWNER, class T = StorageType> Property( OWNER* owner, std::string name, T&& value, void ( OWNER::*handler )( PropertyBase& ), std::string doc = "", std::string semantics = "" ) : Property( @@ -102,8 +96,8 @@ namespace Gaudi { [owner, handler]( PropertyBase& p ) { ( owner->*handler )( p ); }, std::move( doc ), std::move( semantics ) ) {} /// Autodeclaring constructor with property name, value, pointer to member function updateHandler and documentation. - /// @note the use std::enable_if is required to avoid ambiguities - template <class OWNER, class T = StorageType, typename = std::enable_if_t<std::is_base_of_v<IProperty, OWNER>>> + /// @note the use of requires is required to avoid ambiguities + template <std::derived_from<IProperty> OWNER, class T = StorageType> Property( OWNER* owner, std::string name, T&& value, void ( OWNER::*handler )(), std::string doc = "", std::string semantics = "" ) : Property( @@ -112,8 +106,8 @@ namespace Gaudi { } /// Autodeclaring constructor with property name, value, updateHandler and documentation. - /// @note the use std::enable_if is required to avoid ambiguities - template <class OWNER, class T = StorageType, typename = std::enable_if_t<std::is_base_of_v<IProperty, OWNER>>> + /// @note the use of requires is required to avoid ambiguities + template <std::derived_from<IProperty> OWNER, class T = StorageType> Property( OWNER* owner, std::string name, T&& value, std::function<void( PropertyBase& )> handler, Details::Property::ImmediatelyInvokeHandler invoke, std::string doc = "", std::string semantics = "" ) : Property( owner, std::move( name ), std::forward<T>( value ), std::move( handler ), std::move( doc ), @@ -124,12 +118,14 @@ namespace Gaudi { /// Construct an anonymous property from a value. /// This constructor is not generated if T is the current type, so that the /// compiler picks up the copy constructor instead of this one. - template <typename T, typename = not_copying<T>> + template <typename T> + requires( !std::is_same_v<Property, std::remove_reference_t<T>> ) Property( T&& v ) : Details::PropertyBase( typeid( ValueType ), "", "", "" ), m_value( std::forward<T>( v ) ) {} /// Construct an anonymous property with default constructed value. /// Can be used only if StorageType is default constructible. - template <typename T = StorageType, typename = std::enable_if_t<!std::is_reference_v<T>>> + template <typename T = StorageType> + requires( !std::is_reference_v<T> ) Property() : Details::PropertyBase( typeid( ValueType ), "", "", "" ), m_value() {} using Details::PropertyBase::declareReadHandler; @@ -172,7 +168,8 @@ namespace Gaudi { // return m_value; // } - template <typename Dummy = TYPE, typename = std::enable_if_t<std::is_constructible_v<std::string_view, Dummy>>> + template <typename Dummy = TYPE> + requires( std::is_constructible_v<std::string_view, Dummy> ) operator std::string_view() const { m_handlers.useReadHandler( *this ); return m_value; diff --git a/GaudiKernel/include/Gaudi/cxx/SynchronizedValue.h b/GaudiKernel/include/Gaudi/cxx/SynchronizedValue.h index 00a5a781a0abbf09130f150ee97480c4034f1d3e..764b9e9b8a343dc07d2019601a1346fd8440f5be 100644 --- a/GaudiKernel/include/Gaudi/cxx/SynchronizedValue.h +++ b/GaudiKernel/include/Gaudi/cxx/SynchronizedValue.h @@ -1,5 +1,5 @@ /***********************************************************************************\ -* (c) Copyright 1998-2023 CERN for the benefit of the LHCb and ATLAS collaborations * +* (c) Copyright 1998-2025 CERN for the benefit of the LHCb and ATLAS collaborations * * * * This software is distributed under the terms of the Apache version 2 licence, * * copied verbatim in the file "LICENSE". * @@ -78,15 +78,14 @@ namespace Gaudi::cxx { return *this; } - template <typename F, typename... Args, - typename = std::enable_if_t<std::is_invocable_v<F, Value&, Args...> && - !std::is_invocable_v<F, const Value&, Args...>>> + template <typename... Args, std::invocable<Value&, Args...> F> + requires( !std::is_invocable_v<F, const Value&, Args...> ) decltype( auto ) with_lock( F&& f, Args&&... args ) { WriteLock _{ m_mtx }; return std::invoke( std::forward<F>( f ), m_obj, std::forward<Args>( args )... ); } - template <typename F, typename... Args, typename = std::enable_if_t<std::is_invocable_v<F, const Value&, Args...>>> + template <typename... Args, std::invocable<const Value&, Args...> F> decltype( auto ) with_lock( F&& f, Args&&... args ) const { ReadLock _{ m_mtx }; return std::invoke( std::forward<F>( f ), m_obj, std::forward<Args>( args )... ); diff --git a/GaudiKernel/include/GaudiKernel/DataObjectHandle.h b/GaudiKernel/include/GaudiKernel/DataObjectHandle.h index 550dfbb62b39f099b0d438ecbc13d06a48add33c..6e306c410bf0df9fede5f9c30a063193f09b2292 100644 --- a/GaudiKernel/include/GaudiKernel/DataObjectHandle.h +++ b/GaudiKernel/include/GaudiKernel/DataObjectHandle.h @@ -455,8 +455,8 @@ public: : ::details::ReadHandle<T>{ k, Gaudi::DataHandle::Reader, owner } {} /// Autodeclaring constructor with property name, mode, key and documentation. - /// @note the use std::enable_if is required to avoid ambiguities - template <typename OWNER, typename K, typename = std::enable_if_t<std::is_base_of_v<IProperty, OWNER>>> + /// @note the use of requires is required to avoid ambiguities + template <std::derived_from<IProperty> OWNER, typename K> DataObjectReadHandle( OWNER* owner, std::string propertyName, K key = {}, std::string doc = "" ) : ::details::ReadHandle<T>( owner, Gaudi::DataHandle::Reader, std::move( propertyName ), std::move( key ), std::move( doc ) ) {} @@ -477,8 +477,8 @@ public: : ::details::WriteHandle<T, U>{ k, Gaudi::DataHandle::Writer, owner } {} /// Autodeclaring constructor with property name, mode, key and documentation. - /// @note the use std::enable_if is required to avoid ambiguities - template <typename OWNER, typename K, typename = std::enable_if_t<std::is_base_of_v<IProperty, OWNER>>> + /// @note the use of requires is required to avoid ambiguities + template <std::derived_from<IProperty> OWNER, typename K> DataObjectWriteHandle( OWNER* owner, std::string propertyName, K key = {}, std::string doc = "" ) : ::details::WriteHandle<T, U>( owner, Gaudi::DataHandle::Writer, std::move( propertyName ), std::move( key ), std::move( doc ) ) {} diff --git a/GaudiKernel/include/GaudiKernel/DataObjectHandleBase.h b/GaudiKernel/include/GaudiKernel/DataObjectHandleBase.h index 234f3932397b696be946018c3f98ee7a48e03b24..657da050133c6395d47f7d55ecbd133f5c9ff4d2 100644 --- a/GaudiKernel/include/GaudiKernel/DataObjectHandleBase.h +++ b/GaudiKernel/include/GaudiKernel/DataObjectHandleBase.h @@ -1,5 +1,5 @@ /***********************************************************************************\ -* (c) Copyright 1998-2024 CERN for the benefit of the LHCb and ATLAS collaborations * +* (c) Copyright 1998-2025 CERN for the benefit of the LHCb and ATLAS collaborations * * * * This software is distributed under the terms of the Apache version 2 licence, * * copied verbatim in the file "LICENSE". * @@ -44,8 +44,8 @@ public: DataObjectHandleBase& operator=( const DataObjectHandleBase& ); /// Autodeclaring constructor with property name, mode, key and documentation. - /// @note the use std::enable_if is required to avoid ambiguities - template <class OWNER, class K, typename = std::enable_if_t<std::is_base_of_v<IProperty, OWNER>>> + /// @note the use of requires is required to avoid ambiguities + template <std::derived_from<IProperty> OWNER, class K> inline DataObjectHandleBase( OWNER* owner, Gaudi::DataHandle::Mode m, std::string name, K key = {}, std::string doc = "" ) : DataObjectHandleBase( std::move( key ), m, owner ) { diff --git a/GaudiKernel/include/GaudiKernel/IBinder.h b/GaudiKernel/include/GaudiKernel/IBinder.h index 34f5c8bc4f5c71f17358a8515111a049f1043421..ba7bc791cca4c41a0521bac2c31b80b4406b5cf0 100644 --- a/GaudiKernel/include/GaudiKernel/IBinder.h +++ b/GaudiKernel/include/GaudiKernel/IBinder.h @@ -1,5 +1,5 @@ /*****************************************************************************\ -* (c) Copyright 2021-2024 CERN for the benefit of the LHCb Collaboration * +* (c) Copyright 2021-2025 CERN for the benefit of the LHCb Collaboration * * * * This software is distributed under the terms of the GNU General Public * * Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * @@ -29,7 +29,7 @@ namespace Gaudi::Interface::Bind { // identity binding: no actual binding is required... Box( IFace const* ptr ) : m_ptr{ ptr } { assert( m_ptr != nullptr ); } // bind the arguments... - template <typename Ret, typename... Args, typename = std::enable_if_t<std::is_base_of_v<IFace, Ret>>> + template <std::derived_from<IFace> Ret, typename... Args> Box( std::in_place_type_t<Ret>, Args&&... args ) { if constexpr ( sizeof( Ret ) <= sizeof( m_storage ) ) { m_ptr = new ( &m_storage ) Ret{ std::forward<Args>( args )... }; diff --git a/GaudiKernel/include/GaudiKernel/IDataManagerSvc.h b/GaudiKernel/include/GaudiKernel/IDataManagerSvc.h index 5720dc402d58810d760c840d9828df53b5ab44dc..1e5fac22b9d65d8d9941aa310d49bc0258653d1e 100644 --- a/GaudiKernel/include/GaudiKernel/IDataManagerSvc.h +++ b/GaudiKernel/include/GaudiKernel/IDataManagerSvc.h @@ -1,5 +1,5 @@ /***********************************************************************************\ -* (c) Copyright 1998-2024 CERN for the benefit of the LHCb and ATLAS collaborations * +* (c) Copyright 1998-2025 CERN for the benefit of the LHCb and ATLAS collaborations * * * * This software is distributed under the terms of the Apache version 2 licence, * * copied verbatim in the file "LICENSE". * @@ -136,7 +136,8 @@ struct GAUDI_API IDataManagerSvc : extend_interfaces<IInterface> { it should have the signature bool(IRegistry*,int level) @return Status code indicating success or failure. */ - template <typename F, typename = std::enable_if_t<!std::is_convertible_v<F, IDataStoreAgent*>>> + template <typename F> + requires( !std::is_convertible_v<F, IDataStoreAgent*> ) StatusCode traverseSubTree( std::string_view sub_path, F&& f ) { auto agent = makeDataStoreAgent( std::forward<F>( f ) ); return traverseSubTree( sub_path, &agent ); @@ -157,7 +158,8 @@ struct GAUDI_API IDataManagerSvc : extend_interfaces<IInterface> { it should have the signature bool(IRegistry*,int level) @return Status code indicating success or failure */ - template <typename F, typename = std::enable_if_t<!std::is_convertible_v<F, IDataStoreAgent*>>> + template <typename F> + requires( !std::is_convertible_v<F, IDataStoreAgent*> ) StatusCode traverseSubTree( DataObject* pObject, F&& f ) { auto agent = makeDataStoreAgent( std::forward<F>( f ) ); return traverseSubTree( pObject, &agent ); @@ -173,7 +175,8 @@ struct GAUDI_API IDataManagerSvc : extend_interfaces<IInterface> { it should have the signature bool(IRegistry*,int level) @return Status code indicating success or failure */ - template <typename F, typename = std::enable_if_t<!std::is_convertible_v<F, IDataStoreAgent*>>> + template <typename F> + requires( !std::is_convertible_v<F, IDataStoreAgent*> ) StatusCode traverseTree( F&& f ) { auto agent = makeDataStoreAgent( std::forward<F>( f ) ); return traverseTree( &agent ); diff --git a/GaudiKernel/include/GaudiKernel/Range.h b/GaudiKernel/include/GaudiKernel/Range.h index f3faad94f2f936175223033ae08c12e4f1dd03ab..acb2fd02a7aa98c242b95d9237cdd8ff73ec1fb9 100644 --- a/GaudiKernel/include/GaudiKernel/Range.h +++ b/GaudiKernel/include/GaudiKernel/Range.h @@ -1,5 +1,5 @@ /***********************************************************************************\ -* (c) Copyright 1998-2024 CERN for the benefit of the LHCb and ATLAS collaborations * +* (c) Copyright 1998-2025 CERN for the benefit of the LHCb and ATLAS collaborations * * * * This software is distributed under the terms of the Apache version 2 licence, * * copied verbatim in the file "LICENSE". * @@ -92,6 +92,9 @@ namespace Gaudi { */ template <class CONTAINER, class ITERATOR = typename Gaudi::details::container<CONTAINER>::Iterator> class Range_ : public RangeBase_ { + // FIXME: prepare for removal of ITERATOR argument: check whether the default is _always_ used + static_assert( std::is_same_v<ITERATOR, typename Gaudi::details::container<CONTAINER>::Iterator> ); + public: // ======================================================================== typedef std::pair<ITERATOR, ITERATOR> Base; diff --git a/GaudiKernel/include/GaudiKernel/ServiceHandle.h b/GaudiKernel/include/GaudiKernel/ServiceHandle.h index 20c4aea33a2c70741f87313c3cfa152f2fcc0dad..802e71932ecac7dba4257863153210d37de2aef5 100644 --- a/GaudiKernel/include/GaudiKernel/ServiceHandle.h +++ b/GaudiKernel/include/GaudiKernel/ServiceHandle.h @@ -1,5 +1,5 @@ /***********************************************************************************\ -* (c) Copyright 1998-2024 CERN for the benefit of the LHCb and ATLAS collaborations * +* (c) Copyright 1998-2025 CERN for the benefit of the LHCb and ATLAS collaborations * * * * This software is distributed under the terms of the Apache version 2 licence, * * copied verbatim in the file "LICENSE". * @@ -54,13 +54,13 @@ public: : GaudiHandle<T>( serviceName, "Service", theParentName ) {} /** Copy constructor from a non const T to const T service handle */ - template <typename CT = T, typename NCT = std::remove_const_t<T>, - typename = std::enable_if_t<std::is_const_v<CT> && !std::is_same_v<CT, NCT>>> + template <typename CT = T, typename NCT = std::remove_const_t<T>> + requires( std::is_const_v<CT> && !std::is_same_v<CT, NCT> ) ServiceHandle( const ServiceHandle<NCT>& other ) : GaudiHandle<CT>( other ) {} /// Autodeclaring constructor with property name, service type/name and documentation. - /// @note the use std::enable_if is required to avoid ambiguities - template <class OWNER, typename = std::enable_if_t<std::is_base_of_v<IProperty, OWNER>>> + /// @note the use of requires is required to avoid ambiguities + template <std::derived_from<IProperty> OWNER> inline ServiceHandle( OWNER* owner, std::string PropName, const std::string& svcName, std::string doc = "" ) : ServiceHandle( svcName, owner->name() ) { auto p = owner->OWNER::PropertyHolderImpl::declareProperty( std::move( PropName ), *this, std::move( doc ) ); diff --git a/GaudiKernel/include/GaudiKernel/StatusCode.h b/GaudiKernel/include/GaudiKernel/StatusCode.h index d35678070a954d4b40be560d9ca3ba365fbaec60..419c02de657afb10631627cdc32fa565133e248b 100644 --- a/GaudiKernel/include/GaudiKernel/StatusCode.h +++ b/GaudiKernel/include/GaudiKernel/StatusCode.h @@ -1,5 +1,5 @@ /***********************************************************************************\ -* (c) Copyright 1998-2024 CERN for the benefit of the LHCb and ATLAS collaborations * +* (c) Copyright 1998-2025 CERN for the benefit of the LHCb and ATLAS collaborations * * * * This software is distributed under the terms of the Apache version 2 licence, * * copied verbatim in the file "LICENSE". * @@ -105,7 +105,8 @@ public: StatusCode() = default; /// Constructor from enum type (allowing implicit conversion) - template <typename T, typename = std::enable_if_t<is_StatusCode_enum<T>::value>> + template <typename T> + requires( is_StatusCode_enum<T>::value ) StatusCode( T sc ) noexcept : StatusCode{ static_cast<StatusCode::code_t>( sc ), is_StatusCode_enum<T>::instance } {} /// Constructor from code_t and category (explicit conversion only) @@ -265,7 +266,7 @@ private: [[noreturn]] void i_doThrow( std::string_view message, std::string_view tag ) const; /// Helper to invoke a callable and return the resulting StatusCode or this, if the callable returns void. - template <typename F, typename... ARGS, typename = std::enable_if_t<std::is_invocable_v<F, ARGS...>>> + template <typename... ARGS, std::invocable<ARGS...> F> // requires ( std::is_invocable_v<F, ARGS...> ) StatusCode i_invoke( F&& f, ARGS&&... args ) const { if constexpr ( std::is_invocable_r_v<StatusCode, F, ARGS...> ) { return std::invoke( std::forward<F>( f ), std::forward<ARGS>( args )... ); diff --git a/GaudiKernel/include/GaudiKernel/ToolHandle.h b/GaudiKernel/include/GaudiKernel/ToolHandle.h index 829f9c5c3b6dff2f3cf6583339c594dd21d920a0..1983005fff12967046386a0cab6bbb1a8af2abc0 100644 --- a/GaudiKernel/include/GaudiKernel/ToolHandle.h +++ b/GaudiKernel/include/GaudiKernel/ToolHandle.h @@ -1,5 +1,5 @@ /***********************************************************************************\ -* (c) Copyright 1998-2024 CERN for the benefit of the LHCb and ATLAS collaborations * +* (c) Copyright 1998-2025 CERN for the benefit of the LHCb and ATLAS collaborations * * * * This software is distributed under the terms of the Apache version 2 licence, * * copied verbatim in the file "LICENSE". * @@ -149,8 +149,8 @@ public: , m_pToolSvc( "ToolSvc", GaudiHandleBase::parentName() ) {} /** Copy constructor from a non const T to const T tool handle */ - template <typename CT = T, typename NCT = std::remove_const_t<T>, - typename = std::enable_if_t<std::is_const_v<CT> && !std::is_same_v<CT, NCT>>> + template <typename CT = T, typename NCT = std::remove_const_t<T>> + requires( std::is_const_v<CT> && !std::is_same_v<CT, NCT> ) ToolHandle( const ToolHandle<NCT>& other ) : BaseToolHandle( other.parent(), other.createIf() ) , GaudiHandle<CT>( other ) @@ -194,8 +194,8 @@ public: } /// Autodeclaring constructor with property propName, tool type/name and documentation. - /// @note the use std::enable_if is required to avoid ambiguities - template <class OWNER, typename = std::enable_if_t<std::is_base_of_v<IProperty, OWNER>>> + /// @note the use of requires is required to avoid ambiguities + template <std::derived_from<IProperty> OWNER> ToolHandle( OWNER* owner, std::string propName, std::string toolType, std::string doc = "" ) : ToolHandle( owner ) { // convert name and type to a valid type/name string // - if type does not contain '/' use type/type @@ -364,13 +364,13 @@ public: /// Copy constructor from a non const T to const T tool handle template <typename CT = T, typename NCT = std::remove_const_t<T>> - PublicToolHandle( const PublicToolHandle<NCT>& other, - std::enable_if_t<std::is_const_v<CT> && !std::is_same_v<CT, NCT>>* = nullptr ) + requires( std::is_const_v<CT> && !std::is_same_v<CT, NCT> ) + PublicToolHandle( const PublicToolHandle<NCT>& other ) : ToolHandle<T>( static_cast<const ToolHandle<NCT>&>( other ) ) {} /// Autodeclaring constructor with property propName, tool type/name and documentation. - /// @note the use std::enable_if is required to avoid ambiguities - template <class OWNER, typename = std::enable_if_t<std::is_base_of_v<IProperty, OWNER>>> + /// @note the use of requires is required to avoid ambiguities + template <std::derived_from<IProperty> OWNER> inline PublicToolHandle( OWNER* owner, std::string propName, std::string toolType, std::string doc = "" ) : PublicToolHandle() { // convert name and type to a valid type/name string @@ -436,8 +436,8 @@ public: bool push_back( const ToolHandle<T>& myHandle ) override { return push_back( myHandle.typeAndName() ); } /// Autodeclaring constructor with property name, tool type/name and documentation. - /// @note the use std::enable_if is required to avoid ambiguities - template <class OWNER, typename = std::enable_if_t<std::is_base_of_v<IProperty, OWNER>>> + /// @note the use of requires is required to avoid ambiguities + template <std::derived_from<IProperty> OWNER> inline ToolHandleArray( OWNER* owner, std::string name, const std::vector<std::string>& typesAndNames = {}, std::string doc = "" ) : ToolHandleArray( owner ) { @@ -463,8 +463,8 @@ public: : ToolHandleArray<T>( typesAndNames, nullptr, createIf ) {} /// Autodeclaring constructor with property name, tool type/name and documentation. - /// @note the use std::enable_if is required to avoid ambiguities - template <class OWNER, typename = std::enable_if_t<std::is_base_of_v<IProperty, OWNER>>> + /// @note the use of requires is required to avoid ambiguities + template <std::derived_from<IProperty> OWNER> PublicToolHandleArray( OWNER* owner, std::string name, const std::vector<std::string>& typesAndNames = {}, std::string doc = "" ) : PublicToolHandleArray() { diff --git a/GaudiKernel/include/GaudiKernel/ToolVisitor.h b/GaudiKernel/include/GaudiKernel/ToolVisitor.h index beca5e6a665cb2d9f43cf51042cbaadb5a6764a4..c4b50305967a621d02a6f721a17e68fa771f9f55 100644 --- a/GaudiKernel/include/GaudiKernel/ToolVisitor.h +++ b/GaudiKernel/include/GaudiKernel/ToolVisitor.h @@ -1,5 +1,5 @@ /***********************************************************************************\ -* (c) Copyright 1998-2024 CERN for the benefit of the LHCb and ATLAS collaborations * +* (c) Copyright 1998-2025 CERN for the benefit of the LHCb and ATLAS collaborations * * * * This software is distributed under the terms of the Apache version 2 licence, * * copied verbatim in the file "LICENSE". * @@ -36,7 +36,8 @@ public: * ToolVisitor::visit(tools(), visitor); * @verbatim */ - template <typename Callable, typename = std::enable_if_t<std::is_invocable_r_v<void, Callable, IAlgTool*>>> + template <std::invocable<IAlgTool*> Callable> + requires( std::is_invocable_r_v<void, Callable, IAlgTool*> ) static void visit( const std::vector<IAlgTool*>& tools, Callable& callable, const std::regex& reject_filter = s_noFilter ) { class Visitor final : public IVisitor { diff --git a/GaudiKernel/include/GaudiKernel/TypeNameString.h b/GaudiKernel/include/GaudiKernel/TypeNameString.h index 787081b975967191117d85a9d5cae0adc8fe8725..2a10e20ac0513200009b776fe747f8299b935299 100644 --- a/GaudiKernel/include/GaudiKernel/TypeNameString.h +++ b/GaudiKernel/include/GaudiKernel/TypeNameString.h @@ -1,5 +1,5 @@ /***********************************************************************************\ -* (c) Copyright 1998-2024 CERN for the benefit of the LHCb and ATLAS collaborations * +* (c) Copyright 1998-2025 CERN for the benefit of the LHCb and ATLAS collaborations * * * * This software is distributed under the terms of the Apache version 2 licence, * * copied verbatim in the file "LICENSE". * @@ -41,8 +41,8 @@ namespace Gaudi { // support passing a Gaudi::Property<std::string> without having to include Property.h // require that prop.value() can be used to construct a TypeNameString... - template <class T, typename = std::enable_if_t<std::is_constructible< - TypeNameString, decltype( std::declval<const T&>().value() )>::value>> + template <class T> + requires( std::is_constructible_v<TypeNameString, decltype( std::declval<const T&>().value() )> ) TypeNameString( const T& prop ) : TypeNameString( prop.value() ) {} const std::string& type() const { return m_type; } diff --git a/GaudiKernel/tests/src/LogHistogram.h b/GaudiKernel/tests/src/LogHistogram.h index 68a412096f7913281f5b66b701244358a0318b1e..e66f54258f7e1bc53893ae90f211ad43cde7458d 100644 --- a/GaudiKernel/tests/src/LogHistogram.h +++ b/GaudiKernel/tests/src/LogHistogram.h @@ -1,5 +1,5 @@ /***********************************************************************************\ -* (c) Copyright 1998-2024 CERN for the benefit of the LHCb and ATLAS collaborations * +* (c) Copyright 1998-2025 CERN for the benefit of the LHCb and ATLAS collaborations * * * * This software is distributed under the terms of the Apache version 2 licence, * * copied verbatim in the file "LICENSE". * @@ -33,12 +33,14 @@ namespace Gaudi::Accumulators { template <class... ARGS> LogInputType( ARGS... args ) : std::array<Arithmetic, ND>{ static_cast<Arithmetic>( args )... } {} using ValueType = LogInputType<Arithmetic, ND>; - template <class... AxisType, typename = typename std::enable_if_t<( sizeof...( AxisType ) == ND )>> + template <class... AxisType> + requires( sizeof...( AxisType ) == ND ) unsigned int computeIndex( std::tuple<AxisType...> const& axis ) const { return computeIndexInternal<0, std::tuple<AxisType...>>( axis ); } auto forInternalCounter() { return 1ul; } - template <class... AxisType, typename = typename std::enable_if_t<( sizeof...( AxisType ) == ND )>> + template <class... AxisType> + requires( sizeof...( AxisType ) == ND ) static unsigned int computeTotNBins( std::tuple<AxisType...> const& axis ) { return computeTotNBinsInternal<0, std::tuple<AxisType...>>( axis ); }