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 {};
101 struct has_trace<T, decltype((void)T::trace)> : std::true_type {};
103 template<
typename Trait>
108 call_trace(
int& _call_depth) : call_depth(_call_depth) { ++call_depth; }
109 ~call_trace() noexcept { --call_depth; }
111 void call(std::false_type, const ::mdds::mtv::trace_method_properties_t&)
const
116 void call(std::true_type, const ::mdds::mtv::trace_method_properties_t& props)
const
123 void operator()(const ::mdds::mtv::trace_method_properties_t& props)
const
125 call(has_trace<Trait>{}, props);
131 inline void throw_block_position_not_found(
132 const char* method_sig,
int line,
size_t pos,
size_t block_size,
size_t container_size)
134 std::ostringstream os;
135 os << method_sig <<
"#" << line <<
": block position not found! (logical pos="
136 << pos <<
", block size=" << block_size <<
", logical size=" << container_size <<
")";
137 throw std::out_of_range(os.str());
158 template<
typename _T,
typename _SizeT>
159 std::pair<_SizeT, bool> calc_input_end_position(
160 const _T& it_begin,
const _T& it_end, _SizeT pos, _SizeT total_size)
162 using ret_type = std::pair<_SizeT, bool>;
164 _SizeT length = std::distance(it_begin, it_end);
167 return ret_type(0,
false);
169 _SizeT end_pos = pos + length - 1;
170 if (end_pos >= total_size)
171 throw std::out_of_range(
"Input data sequence is too long.");
173 return ret_type(end_pos,
true);
177 T advance_position(
const T& pos,
int steps)
185 if (ret.second + steps < ret.first->size)
193 steps -=
static_cast<int>(ret.first->size - ret.second);
203 if (
static_cast<int>(ret.second) >= -steps)
210 steps +=
static_cast<int>(ret.second + 1);
212 ret.second = ret.first->size - 1;
220 template<
typename _Blk>
223 return _Blk::at(data, offset);
226 #ifndef MDDS_MULTI_TYPE_VECTOR_USE_DEQUE
231 auto it = mdds::mtv::boolean_element_block::cbegin(data);
232 std::advance(it, offset);
242 #ifdef MDDS_MULTI_TYPE_VECTOR_DEBUG
244 #define MDDS_MTV_TRACE(method_type) \
245 ::mdds::detail::mtv::call_trace<Trait> mdds_mtv_ct(m_trace_call_depth); \
247 { trace_method_t::method_type, this, __func__, "", __FILE__, __LINE__ } \
250 #define MDDS_MTV_TRACE_ARGS(method_type, stream) \
251 ::mdds::detail::mtv::call_trace<Trait> mdds_mtv_ct(m_trace_call_depth); \
254 std::ostringstream _os_; \
257 { trace_method_t::method_type, this, __func__, _os_.str(), __FILE__, __LINE__ } \
263 #define MDDS_MTV_TRACE(...)
265 #define MDDS_MTV_TRACE_ARGS(...)
Definition: types.hpp:173
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