22 #ifndef __utl_dev_inbuf_dev_h__ 23 #define __utl_dev_inbuf_dev_h__ 54 template <
typename impl_t,
typename data_t,
size_t streamsize =0>
82 size_t get_ (data_t& data) {
return impl().get_(data); }
83 size_t get_ (data_t* data,
size_t n) {
return impl().get_ (data, n); }
108 size_t get (data_t& data) {
120 size_t get (data_t* data,
size_t n) {
121 return get_ (data, n);
139 template <
typename _Dst_t>
141 static_assert ((
sizeof (_Dst_t)%
sizeof(data_t) == 0),
142 "Target size must be an integer multiple of device's data size");
143 get_ (reinterpret_cast<data_t*>(&dst),
sizeof(_Dst_t)/
sizeof(data_t));
147 template <
typename _Dst_t>
187 template <
typename data_t,
size_t streamsize>
232 virtual size_t get_ (data_t& data) = 0;
242 virtual size_t get_ (data_t* data,
size_t n) = 0;
251 size_t get (data_t& data) {
return get_ (data); }
252 size_t get (data_t* data,
size_t n) {
return get_ (data, n); }
268 template <
typename _Dst_t>
270 static_assert ((
sizeof (_Dst_t)%
sizeof(data_t) == 0),
271 "Target size must be an integer multiple of device's data size");
272 get_ (reinterpret_cast<data_t*>(&dst),
sizeof(_Dst_t)/
sizeof(data_t));
276 template <
typename _Dst_t>
309 #if defined _utl_have_concepts 311 template <
typename _Tp>
312 concept
bool Inbuf_dev = requires (_Tp t,
const _Tp ct,
typename _Tp::data_type v) {
315 requires !std::is_copy_constructible<_Tp>::value;
316 requires !std::is_copy_assignable<_Tp>::value;
319 {t.get(&v, 1, 0)} ->
size_t;
323 typename _Tp::const_iterator;
324 requires Indev_it<typename _Tp::iterator>;
326 { t.begin() } ->
typename _Tp::iterator;
329 { t.end() } ->
typename _Tp::iterator;
334 namespace inbuf_dev_details {
338 template <
class _Tp>
using try_get1_t = decltype (declval<_Tp>().
get (declval<typename _Tp::data_type&>()));
339 template <
class _Tp>
using try_get2_t = decltype (declval<_Tp>().
get (declval<typename _Tp::data_type*>(), declval<size_t>()));
343 template <
class _Tp>
using try_begin_t = decltype (declval<_Tp>().begin());
344 template <
class _Tp>
using tryc_begin_t = decltype (declval<const _Tp>().begin());
345 template <
class _Tp>
using try_cbegin_t = decltype (declval<const _Tp>().cbegin());
346 template <
class _Tp>
using try_end_t = decltype (declval<_Tp>().begin());
347 template <
class _Tp>
using tryc_end_t = decltype (declval<const _Tp>().begin());
348 template <
class _Tp>
using try_cend_t = decltype (declval<const _Tp>().cend());
351 template <
typename _Tp,
typename =
void>
355 template <
typename _Tp>
358 typename _Tp::data_type,
359 typename _Tp::pointer_type,
360 typename _Tp::iterator,
361 typename _Tp::const_iterator,
366 use_if_same_t <tryc_begin_t<_Tp>, typename _Tp::const_iterator>,
367 use_if_same_t <try_cbegin_t<_Tp>, typename _Tp::const_iterator>,
369 use_if_same_t <tryc_end_t<_Tp>, typename _Tp::const_iterator>,
370 use_if_same_t <try_cend_t<_Tp>, typename _Tp::const_iterator>
379 template <
typename _Tp>
inbuf_dev< impl_t, data_t, streamsize > inbuf_dev_t
class type syntactic sugar
size_t get_(data_t &data)
decltype(declval< const _Tp >().cend()) try_cend_t
void void_t
void_t type alias
const_iterator begin() const noexcept
const_iterator end() const noexcept
const_iterator cend() const noexcept
decltype(declval< const _Tp >().begin()) tryc_begin_t
iterator begin() noexcept
.begin implementation
meta::eval< meta::enable_if< meta::same_< _T1, _T2 >::value, _Ret > > use_if_same_t
inbuf_dev()=default
A default constructor from derived only.
size_t get_(data_t *data, size_t n)
decltype(declval< _Tp >().get(declval< typename _Tp::data_type * >(), declval< size_t >())) try_get2_t
const_iterator cbegin() const noexcept
decltype(declval< _Tp >().get(declval< typename _Tp::data_type & >())) try_get1_t
decltype(declval< const _Tp >().begin()) tryc_end_t
~inbuf_dev()=default
Allow destructor from derived only.
decltype(declval< _Tp >().begin()) try_end_t
indev_it< inbuf_dev_t, const data_t *, streamsize > const_iterator
Const iterator.
STL's core language concepts.
indev_it< inbuf_dev_t, data_t *, streamsize > iterator
Iterator.
Input device iterator type. We "future call" interface methods from owner class to provide iterator f...
decltype(declval< _Tp >().begin()) try_begin_t
Primary template to catch any non input device types.
inbuf_dev_t & operator>>(_Dst_t &dst)
Template operator >> implementation for for all by value/ref parameters.
const_iterator cend() const noexcept
decltype(declval< const _Tp >().cbegin()) try_cbegin_t
const_iterator end() const noexcept
iterator begin() noexcept
.begin implementation
Iterator collection for devices.
inbuf_dev_t & operator=(const inbuf_dev_t &)=delete
const_iterator begin() const noexcept
A virtual base class specialization.
Abstract base class for input buffered devices.
const_iterator cbegin() const noexcept
Implementation detail main forward header.