From 6e3259593a62bf8f12153745663541931c51ee22 Mon Sep 17 00:00:00 2001 From: Egor Pugin Date: Wed, 7 Apr 2021 00:29:07 +0300 Subject: [PATCH] Reorder list templates. --- src/ccutil/list.h | 54 +++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/src/ccutil/list.h b/src/ccutil/list.h index ac773c75c..631452104 100644 --- a/src/ccutil/list.h +++ b/src/ccutil/list.h @@ -18,34 +18,6 @@ namespace tesseract { -template -class X_LIST : public CONTAINER { -public: - X_LIST() = default; - X_LIST(const X_LIST &) = delete; - X_LIST &operator=(const X_LIST &) = delete; - ~X_LIST() { - clear(); - } - - /* delete elements */ - void clear() { - CONTAINER::internal_clear([](void *link) {delete reinterpret_cast(link);}); - } - - /* Become a deep copy of src_list */ - template - void deep_copy(const U *src_list, CLASSNAME *(*copier)(const CLASSNAME *)) { - static_assert(std::is_base_of_v); - - X_ITER from_it(const_cast(src_list)); - X_ITER to_it(this); - - for (from_it.mark_cycle_pt(); !from_it.cycled_list(); from_it.forward()) - to_it.add_after_then_move((*copier)(from_it.data())); - } -}; - template class X_ITER : public CONTAINER { public: @@ -67,6 +39,32 @@ public: } }; +template +class X_LIST : public CONTAINER { +public: + X_LIST() = default; + X_LIST(const X_LIST &) = delete; + X_LIST &operator=(const X_LIST &) = delete; + ~X_LIST() { + clear(); + } + + /* delete elements */ + void clear() { + CONTAINER::internal_clear([](void *link) {delete reinterpret_cast(link);}); + } + + /* Become a deep copy of src_list */ + template + void deep_copy(const U *src_list, CLASSNAME *(*copier)(const CLASSNAME *)) { + X_ITER from_it(const_cast(src_list)); + X_ITER to_it(this); + + for (from_it.mark_cycle_pt(); !from_it.cycled_list(); from_it.forward()) + to_it.add_after_then_move((*copier)(from_it.data())); + } +}; + } // namespace tesseract #endif