9 #ifndef LARCOREALG_COREUTILS_CONTAINERMETA_H 10 #define LARCOREALG_COREUTILS_CONTAINERMETA_H 20 #include <type_traits> 60 template <
typename Coll>
64 template <
typename Coll>
70 template <
typename Coll>
74 template <
typename Coll>
81 template <
typename Coll>
85 template <
typename Coll>
105 template <
typename Coll>
109 template <
typename Coll>
127 template <
typename Coll>
143 template <
typename Cont>
147 template <
typename Cont>
165 template <
typename CollRef>
185 template <
typename Ptr>
188 template <
typename T>
194 template <
typename T>
200 template <
typename T, std::
size_t N>
207 template <
typename Ptr,
typename =
void>
213 template <
typename Coll,
typename =
void>
215 using type =
typename Coll::value_type;
219 template <
typename Coll>
221 <Coll,
std::enable_if_t<std::is_pointer_v<std::decay_t<Coll>>>>
225 template <
typename Coll>
227 <Coll, std::enable_if_t<util::is_unique_ptr_v<std::decay_t<Coll>>>>
233 template <
typename Coll,
typename =
void>
240 using type = decltype(*getBegin(std::declval<Coll>()));
245 template <
typename T>
247 using type = decltype(*(std::declval<T*>()));
252 template <
typename Ptr>
254 <Ptr, std::enable_if_t<util::is_unique_ptr_v<std::decay_t<Ptr>>>>
256 <std::remove_reference_t<typename Ptr::pointer>>
261 template <
typename Coll,
typename =
void>
268 using type = decltype(*getCBegin(std::declval<Coll>()));
273 template <
typename T>
275 using type = decltype(*(std::declval<std::add_const_t<T>*>()));
279 template <
typename Ptr>
281 <Ptr, std::enable_if_t<util::is_unique_ptr_v<std::decay_t<Ptr>>>>
283 <std::remove_reference_t<typename Ptr::pointer>>
290 template <
typename Coll,
typename =
void>
292 using type = std::reference_wrapper<Coll>;
293 static auto make(Coll& coll) {
return std::ref(coll); }
296 template <
typename Coll>
298 <Coll, std::enable_if_t<util::is_reference_wrapper_v<Coll>>>
300 using type = std::remove_cv_t<Coll>;
304 template <
typename Coll>
306 <Coll, std::enable_if_t<util::is_unique_ptr_v<Coll>>>
308 using type =
typename Coll::pointer;
309 static type make(Coll& uptr) {
return uptr.get(); }
312 template <
typename Ptr>
314 <Ptr, std::enable_if_t<std::is_pointer_v<std::decay_t<Ptr>>>>
318 std::remove_all_extents_t<
319 std::remove_pointer_t<std::decay_t<Ptr>>
322 static type
make(Ptr& ptr) {
return ptr; }
329 template <
typename CollRef,
typename =
void>
332 = std::add_lvalue_reference_t<std::remove_reference_t<CollRef>>;
333 static CollRef&
get(CollRef& coll) {
return coll; }
336 template <
typename CollRef>
338 <CollRef, std::enable_if_t<util::is_reference_wrapper_v<CollRef>>>
340 using type = std::add_lvalue_reference_t<typename CollRef::type>;
341 static type get(CollRef& refw) {
return refw.get(); }
344 template <
typename CollRef>
346 <CollRef, std::enable_if_t<util::is_unique_ptr_v<CollRef>>>
348 using type =
typename CollRef::pointer;
349 static type get(CollRef& uptr) {
return uptr.get(); }
352 template <
typename T>
355 static type get(
T* ptr) {
return ptr; }
358 template <
typename T>
361 static type get(
T ptr[]) {
return ptr; }
364 template <
typename T, std::
size_t N>
367 static type get(
T ptr[
N]) {
return ptr; }
377 template <
typename Coll>
390 template <
typename Coll>
393 <util::strip_referenceness_t<Coll>>
398 template <
typename Coll>
401 <util::strip_referenceness_t<Coll>>
406 template <
typename Coll>
412 template <
typename Coll>
420 template <
typename CollRef>
426 template <
typename CollRef>
437 #endif // LARCOREALG_COREUTILS_CONTAINERMETA_H
static CollRef & get(CollRef &coll)
util::strip_referenceness_t< typename details::collection_value_type_impl< util::strip_referenceness_t< Coll >>::type > type
Namespace for general, non-LArSoft-specific utilities.
collection_value_t< Coll > value_type
Trait of type obtained by constant access to element of collection Coll.
std::add_lvalue_reference_t< std::remove_reference_t< std::remove_reference_t< CollRef > >> type
static auto getCBegin(Coll &&coll)
Trait with the type of collection referenced by collRef.
Trait of type obtained by access to element of collection Coll.
collection_value_t< Coll > value_type
Trait of a type that can be used to reference the collection Coll.
static type make(Coll &uptr)
static type make(Coll &refw)
std::add_const_t< T > value_type
std::reference_wrapper< std::remove_reference_t< Coll > > type
static auto getBegin(Coll &&coll)
static type make(Ptr &ptr)
decltype(auto) constexpr cbegin(T &&obj)
ADL-aware version of std::cbegin.
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Trait of value contained in the template collection Coll.
static auto make(Coll &coll)