Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v31r0 (aeb156f0)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
AnyDataWrapper.h
Go to the documentation of this file.
1 #ifndef GAUDIKERNEL_ANYDATAWRAPPER_H
2 #define GAUDIKERNEL_ANYDATAWRAPPER_H
3 
4 // Include files
6 #include "boost/optional.hpp"
7 #include <cstddef>
8 #include <iterator>
9 
10 namespace details {
11 #if __cplusplus < 201703L
12  template <typename C>
13  constexpr auto size( const C& c ) noexcept( noexcept( c.size() ) ) -> decltype( c.size() ) {
14  return c.size();
15  }
16 
17  template <typename T, std::size_t N>
18  constexpr auto size( const T ( &array )[N] ) noexcept {
19  return N;
20  }
21 #else
22  using std::size;
23 #endif
24 
25  template <typename T, typename... Args>
26  constexpr auto size( const T&, Args&&... ) noexcept {
27  static_assert( sizeof...( Args ) == 0, "No extra args please" );
28  return boost::none;
29  }
30 } // namespace details
31 
32 // ugly hack to circumvent the usage of boost::any
34  // TODO: C++17: replace with 'std::optional<std::size_t>'
35  virtual boost::optional<std::size_t> size() const = 0;
36 };
37 
38 template <class T>
40 public:
41  AnyDataWrapper( T&& data ) : m_data( std::move( data ) ){};
42 
44  : AnyDataWrapperBase( std::move( other ) ), m_data( std::move( other.m_data ) ){};
45 
46  const T& getData() const { return m_data; }
47  T& getData() { return m_data; }
48 
49  boost::optional<std::size_t> size() const override {
50  // TODO: C++17: add 'using std::size' and remove the first two implementations in details...
52  return size( m_data );
53  }
54 
55 private:
56  T m_data;
57 };
58 
59 #endif
constexpr auto size(const T &, Args &&...) noexcept
boost::optional< std::size_t > size() const override
STL namespace.
const T & getData() const
AnyDataWrapper(AnyDataWrapper &&other)
constexpr auto size(const C &c) noexcept(noexcept(c.size())) -> decltype(c.size())
int N
Definition: IOTest.py:99
struct GAUDI_API array
Parametrisation class for redirection array - like implementation.
AnyDataWrapper(T &&data)
#define GAUDI_API
Definition: Kernel.h:71
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30