File indexing completed on 2024-04-06 12:13:12
0001 #ifndef FWCore_Utilities_get_underlying_safe_h
0002 #define FWCore_Utilities_get_underlying_safe_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028 #include <memory>
0029
0030
0031
0032 #include "FWCore/Utilities/interface/propagate_const.h"
0033 #include "FWCore/Utilities/interface/propagate_const_array.h"
0034
0035
0036
0037 namespace edm {
0038
0039
0040 template <typename T>
0041 constexpr std::shared_ptr<T>& get_underlying_safe(propagate_const<std::shared_ptr<T>>& iP) {
0042 return get_underlying(iP);
0043 }
0044 template <typename T>
0045 constexpr std::shared_ptr<T const> get_underlying_safe(propagate_const<std::shared_ptr<T>> const& iP) {
0046 std::shared_ptr<T const> copy = get_underlying(iP);
0047 return copy;
0048 }
0049
0050 template <typename T>
0051 constexpr std::shared_ptr<T[]>& get_underlying_safe(propagate_const_array<std::shared_ptr<T[]>>& iP) {
0052 return get_underlying(iP);
0053 }
0054 template <typename T>
0055 constexpr std::shared_ptr<T const[]> get_underlying_safe(propagate_const_array<std::shared_ptr<T[]>> const& iP) {
0056 std::shared_ptr<T const[]> copy = get_underlying(iP);
0057 return copy;
0058 }
0059
0060
0061 template <typename T>
0062 constexpr T*& get_underlying_safe(propagate_const<T*>& iP) {
0063 return get_underlying(iP);
0064 }
0065 template <typename T>
0066 constexpr T const* get_underlying_safe(propagate_const<T*> const& iP) {
0067 T const* copy = get_underlying(iP);
0068 return copy;
0069 }
0070
0071 template <typename T>
0072 constexpr T* get_underlying_safe(propagate_const_array<T[]>& iP) {
0073 return get_underlying(iP);
0074 }
0075 template <typename T>
0076 constexpr T const* get_underlying_safe(propagate_const_array<T[]> const& iP) {
0077 T const* copy = get_underlying(iP);
0078 return copy;
0079 }
0080
0081
0082 template <typename T>
0083 constexpr std::unique_ptr<T>& get_underlying_safe(propagate_const<std::unique_ptr<T>>& iP) {
0084 return get_underlying(iP);
0085 }
0086
0087 template <typename T>
0088 constexpr std::unique_ptr<T const> get_underlying_safe(propagate_const<std::unique_ptr<T>> const& iP) {
0089 std::unique_ptr<T const> copy = get_underlying(iP);
0090 return copy;
0091 }
0092
0093 template <typename T>
0094 constexpr std::unique_ptr<T[]>& get_underlying_safe(propagate_const_array<std::unique_ptr<T[]>>& iP) {
0095 return get_underlying(iP);
0096 }
0097
0098 template <typename T>
0099 constexpr std::unique_ptr<T const[]> get_underlying_safe(propagate_const_array<std::unique_ptr<T[]>> const& iP) {
0100 std::unique_ptr<T const[]> copy = get_underlying(iP);
0101 return copy;
0102 }
0103
0104 }
0105
0106 #endif