The Gaudi Framework  v32r0 (3325bb39)
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  using std::size;
12 
13  template <typename T, typename... Args>
14  constexpr auto size( const T&, Args&&... ) noexcept {
15  static_assert( sizeof...( Args ) == 0, "No extra args please" );
16  return boost::none;
17  }
18 } // namespace details
19 
20 // ugly hack to circumvent the usage of boost::any
22  // TODO: C++17: replace with 'std::optional<std::size_t>'
23  virtual boost::optional<std::size_t> size() const = 0;
24 };
25 
26 template <class T>
28 public:
29  AnyDataWrapper( T&& data ) : m_data( std::move( data ) ){};
30 
32  : AnyDataWrapperBase( std::move( other ) ), m_data( std::move( other.m_data ) ){};
33 
34  const T& getData() const { return m_data; }
35  T& getData() { return m_data; }
36 
37  boost::optional<std::size_t> size() const override {
38  // TODO: C++17: add 'using std::size' and remove the first two implementations in details...
40  return size( m_data );
41  }
42 
43 private:
44  T m_data;
45 };
46 
47 #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)
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