29 #ifndef INCLUDED_MDDS_MULTI_TYPE_VECTOR_DIR_UTIL_HPP
30 #define INCLUDED_MDDS_MULTI_TYPE_VECTOR_DIR_UTIL_HPP
32 #include "./types.hpp"
93 namespace detail {
namespace mtv {
95 #ifdef MDDS_MULTI_TYPE_VECTOR_DEBUG
97 template<
typename T,
typename =
void>
98 struct has_trace : std::false_type
103 struct has_trace<T, decltype((void)T::trace)> : std::true_type
107 template<
typename Trait>
112 call_trace(
int& _call_depth) : call_depth(_call_depth)
116 ~call_trace() noexcept
121 void call(std::false_type, const ::mdds::mtv::trace_method_properties_t&)
const
126 void call(std::true_type, const ::mdds::mtv::trace_method_properties_t& props)
const
133 void operator()(const ::mdds::mtv::trace_method_properties_t& props)
const
135 call(has_trace<Trait>{}, props);
141 inline void throw_block_position_not_found(
142 const char* method_sig,
int line,
size_t pos,
size_t block_size,
size_t container_size)
144 std::ostringstream os;
145 os << method_sig <<
"#" << line <<
": block position not found! (logical pos=" << pos
146 <<
", block size=" << block_size <<
", logical size=" << container_size <<
")";
147 throw std::out_of_range(os.str());
168 template<
typename _T,
typename _SizeT>
169 std::pair<_SizeT, bool> calc_input_end_position(
const _T& it_begin,
const _T& it_end, _SizeT pos, _SizeT total_size)
171 using ret_type = std::pair<_SizeT, bool>;
173 _SizeT length = std::distance(it_begin, it_end);
176 return ret_type(0,
false);
178 _SizeT end_pos = pos + length - 1;
179 if (end_pos >= total_size)
180 throw std::out_of_range(
"Input data sequence is too long.");
182 return ret_type(end_pos,
true);
186 T advance_position(
const T& pos,
int steps)
194 if (ret.second + steps < ret.first->size)
202 steps -=
static_cast<int>(ret.first->size - ret.second);
212 if (
static_cast<int>(ret.second) >= -steps)
219 steps +=
static_cast<int>(ret.second + 1);
221 ret.second = ret.first->size - 1;
229 template<
typename _Blk>
232 return _Blk::at(data, offset);
235 #ifndef MDDS_MULTI_TYPE_VECTOR_USE_DEQUE
238 inline bool get_block_element_at<mdds::mtv::boolean_element_block>(
241 auto it = mdds::mtv::boolean_element_block::cbegin(data);
242 std::advance(it, offset);
252 #ifdef MDDS_MULTI_TYPE_VECTOR_DEBUG
254 #define MDDS_MTV_TRACE(method_type) \
255 ::mdds::detail::mtv::call_trace<Trait> mdds_mtv_ct(m_trace_call_depth); \
256 mdds_mtv_ct({trace_method_t::method_type, this, __func__, "", __FILE__, __LINE__})
258 #define MDDS_MTV_TRACE_ARGS(method_type, stream) \
259 ::mdds::detail::mtv::call_trace<Trait> mdds_mtv_ct(m_trace_call_depth); \
262 std::ostringstream _os_; \
264 mdds_mtv_ct({trace_method_t::method_type, this, __func__, _os_.str(), __FILE__, __LINE__}); \
269 #define MDDS_MTV_TRACE(...)
271 #define MDDS_MTV_TRACE_ARGS(...)
Definition: types.hpp:174
static constexpr lu_factor_t loop_unrolling
Definition: util.hpp:88
void element_block_acquired(const base_element_block *block)
Definition: util.hpp:54
void element_block_released(const base_element_block *block)
Definition: util.hpp:67