21 #ifndef __utl_dev_in_dev_h__ 22 #define __utl_dev_in_dev_h__ 53 template <
typename impl_t,
typename data_t,
size_t streamsize =0>
79 size_t get_ (data_t& data) {
return impl().get_ (data); }
80 size_t get_ (data_t* data,
size_t n) {
return impl().get (data, n); }
97 size_t get (data_t& data) {
109 size_t get (data_t* data,
size_t n) {
110 return get_ (data, n);
128 template <
typename _Dst_t>
130 static_assert ((
sizeof (_Dst_t)%
sizeof(data_t) == 0),
131 "Target size must be an integer multiple of device's data size");
132 get_ (reinterpret_cast<data_t*>(&dst),
sizeof(_Dst_t)/
sizeof(data_t));
136 template <
typename _Dst_t>
173 template <
typename data_t,
size_t streamsize>
212 virtual size_t get_ (data_t& data) = 0;
222 virtual size_t get_ (data_t* data,
size_t n) = 0;
230 size_t get (data_t& data) {
return get_ (data); }
231 size_t get (data_t* data,
size_t n) {
return get_ (data, n); }
248 template <
typename _Dst_t>
250 static_assert ((
sizeof (_Dst_t)%
sizeof(data_t) == 0),
251 "Target size must be an integer multiple of device's data size");
252 get_ (reinterpret_cast<data_t*>(&dst),
sizeof(_Dst_t)/
sizeof(data_t));
256 template <
typename _Dst_t>
289 namespace in_dev_details {
293 template <
class _Tp>
using try_get1_t = decltype (declval<_Tp>().
get (declval<typename _Tp::data_type&>()));
294 template <
class _Tp>
using try_get2_t = decltype (declval<_Tp>().
get (declval<typename _Tp::data_type*>(), declval<size_t>()));
298 template <
class _Tp>
using try_begin_t = decltype (declval<_Tp>().begin());
299 template <
class _Tp>
using tryc_begin_t = decltype (declval<const _Tp>().begin());
300 template <
class _Tp>
using try_cbegin_t = decltype (declval<const _Tp>().cbegin());
301 template <
class _Tp>
using try_end_t = decltype (declval<_Tp>().begin());
302 template <
class _Tp>
using tryc_end_t = decltype (declval<const _Tp>().begin());
303 template <
class _Tp>
using try_cend_t = decltype (declval<const _Tp>().cend());
306 template <
typename _Tp,
typename =
void>
310 template <
typename _Tp>
313 typename _Tp::data_type,
314 typename _Tp::pointer_type,
315 typename _Tp::iterator,
316 typename _Tp::const_iterator,
321 use_if_same_t <tryc_begin_t<_Tp>, typename _Tp::const_iterator>,
322 use_if_same_t <try_cbegin_t<_Tp>, typename _Tp::const_iterator>,
324 use_if_same_t <tryc_end_t<_Tp>, typename _Tp::const_iterator>,
325 use_if_same_t <try_cend_t<_Tp>, typename _Tp::const_iterator>
334 template <
typename _Tp>
in_dev_t & operator=(const in_dev_t &)=delete
const_iterator cbegin() const noexcept
void void_t
void_t type alias
Primary template to catch any non input device types.
const_iterator cend() const noexcept
decltype(declval< const _Tp >().cbegin()) try_cbegin_t
decltype(declval< const _Tp >().cend()) try_cend_t
decltype(declval< _Tp >().get(declval< typename _Tp::data_type & >())) try_get1_t
~in_dev()=default
Allow destructor from derived only.
meta::eval< meta::enable_if< meta::same_< _T1, _T2 >::value, _Ret > > use_if_same_t
decltype(declval< _Tp >().begin()) try_end_t
const_iterator begin() const noexcept
in_dev_t & operator>>(_Dst_t &dst)
Template operator >> implementation for for all by value/ref parameters.
const_iterator end() const noexcept
indev_it< in_dev_t, data_t *, streamsize > iterator
Iterator.
iterator begin() noexcept
.begin implementation
STL's core language concepts.
decltype(declval< _Tp >().begin()) try_begin_t
const_iterator begin() const noexcept
in_dev< impl_t, data_t, streamsize > in_dev_t
class type syntactic sugar
Input device iterator type. We "future call" interface methods from owner class to provide iterator f...
indev_it< in_dev_t, const data_t *, streamsize > const_iterator
Const iterator.
decltype(declval< _Tp >().get(declval< typename _Tp::data_type * >(), declval< size_t >())) try_get2_t
Abstract base class for input devices.
in_dev()=default
A default constructor from derived only.
Iterator collection for devices.
decltype(declval< const _Tp >().begin()) tryc_begin_t
size_t get_(data_t *data, size_t n)
const_iterator end() const noexcept
A virtual base class specialization.
size_t get_(data_t &data)
const_iterator cend() const noexcept
decltype(declval< const _Tp >().begin()) tryc_end_t
const_iterator cbegin() const noexcept
iterator begin() noexcept
.begin implementation
Implementation detail main forward header.