From b86d2ab7d0cfc373a3ae57006f25ae6aad123b3b Mon Sep 17 00:00:00 2001 From: Francisco Date: Thu, 10 Dec 2020 17:56:44 +0000 Subject: [PATCH] move choice_type to adt folder --- .../srslte/{common => adt}/choice_type.h | 2 +- .../srslte/adt/detail/index_sequence.h | 34 +++++++++++++++++++ .../{common => adt/detail}/type_utils.h | 6 ++-- lib/include/srslte/adt/interval.h | 2 +- lib/include/srslte/common/basic_pnf.h | 2 +- lib/include/srslte/common/fsm.h | 2 +- lib/test/common/choice_type_test.cc | 2 +- 7 files changed, 43 insertions(+), 7 deletions(-) rename lib/include/srslte/{common => adt}/choice_type.h (99%) create mode 100644 lib/include/srslte/adt/detail/index_sequence.h rename lib/include/srslte/{common => adt/detail}/type_utils.h (98%) diff --git a/lib/include/srslte/common/choice_type.h b/lib/include/srslte/adt/choice_type.h similarity index 99% rename from lib/include/srslte/common/choice_type.h rename to lib/include/srslte/adt/choice_type.h index 19294744a..9e21584ce 100644 --- a/lib/include/srslte/common/choice_type.h +++ b/lib/include/srslte/adt/choice_type.h @@ -10,7 +10,7 @@ * */ -#include "type_utils.h" +#include "srslte/adt/detail/type_utils.h" #ifndef SRSLTE_CHOICE_TYPE_H #define SRSLTE_CHOICE_TYPE_H diff --git a/lib/include/srslte/adt/detail/index_sequence.h b/lib/include/srslte/adt/detail/index_sequence.h new file mode 100644 index 000000000..35af029f0 --- /dev/null +++ b/lib/include/srslte/adt/detail/index_sequence.h @@ -0,0 +1,34 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2020 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +#ifndef CPP_TESTS_INDEX_SEQUENCE_H +#define CPP_TESTS_INDEX_SEQUENCE_H + +namespace srslte { + +template +struct index_sequence {}; + +template +struct index_sequence_helper : public index_sequence_helper {}; + +template +struct index_sequence_helper<0U, Next...> { + using type = index_sequence; +}; + +template +using make_index_sequence = typename index_sequence_helper::type; + +} // namespace srslte + +#endif // CPP_TESTS_INDEX_SEQUENCE_H diff --git a/lib/include/srslte/common/type_utils.h b/lib/include/srslte/adt/detail/type_utils.h similarity index 98% rename from lib/include/srslte/common/type_utils.h rename to lib/include/srslte/adt/detail/type_utils.h index 56c26efa2..3efaa7861 100644 --- a/lib/include/srslte/common/type_utils.h +++ b/lib/include/srslte/adt/detail/type_utils.h @@ -287,7 +287,8 @@ const T& get(const TypeContainer& c) } template class TypeContainer, + template + class TypeContainer, typename... Args, typename T = typename get_index_type::type> T& get(TypeContainer& c) @@ -296,7 +297,8 @@ T& get(TypeContainer& c) } template class TypeContainer, + template + class TypeContainer, typename... Args, typename T = typename get_index_type::type> const T& get(const TypeContainer& c) diff --git a/lib/include/srslte/adt/interval.h b/lib/include/srslte/adt/interval.h index 20c9cfaa1..3f29b4722 100644 --- a/lib/include/srslte/adt/interval.h +++ b/lib/include/srslte/adt/interval.h @@ -39,7 +39,7 @@ public: bool empty() const { return stop_ == start_; } - T length() const { return stop_ - start_; } + auto length() -> decltype(std::declval() - std::declval()) const { return stop_ - start_; } void set(T start_point, T stop_point) { diff --git a/lib/include/srslte/common/basic_pnf.h b/lib/include/srslte/common/basic_pnf.h index 147b97caa..5db0e32f8 100644 --- a/lib/include/srslte/common/basic_pnf.h +++ b/lib/include/srslte/common/basic_pnf.h @@ -15,9 +15,9 @@ #include "basic_vnf_api.h" #include "common.h" +#include "srslte/adt/choice_type.h" #include "srslte/common/block_queue.h" #include "srslte/common/buffer_pool.h" -#include "srslte/common/choice_type.h" #include "srslte/common/logmap.h" #include #include diff --git a/lib/include/srslte/common/fsm.h b/lib/include/srslte/common/fsm.h index 8af4dfeb5..e01382da3 100644 --- a/lib/include/srslte/common/fsm.h +++ b/lib/include/srslte/common/fsm.h @@ -13,9 +13,9 @@ #ifndef SRSLTE_FSM_H #define SRSLTE_FSM_H +#include "srslte/adt/detail/type_utils.h" #include "srslte/adt/move_callback.h" #include "srslte/common/logmap.h" -#include "type_utils.h" #include #include #include diff --git a/lib/test/common/choice_type_test.cc b/lib/test/common/choice_type_test.cc index a259e1739..1687cef16 100644 --- a/lib/test/common/choice_type_test.cc +++ b/lib/test/common/choice_type_test.cc @@ -10,7 +10,7 @@ * */ -#include "srslte/common/choice_type.h" +#include "srslte/adt/choice_type.h" #include "srslte/common/test_common.h" struct C {