diff --git a/CMakeLists.txt b/CMakeLists.txt index 5a835df..37de36f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.20) include(cmake/color.cmake) -set(BLT_VERSION 0.20.17) +set(BLT_VERSION 0.20.18) set(BLT_TEST_VERSION 0.0.1) set(BLT_TARGET BLT) diff --git a/include/blt/meta/meta.h b/include/blt/meta/meta.h index 57cd624..e7619a0 100644 --- a/include/blt/meta/meta.h +++ b/include/blt/meta/meta.h @@ -188,6 +188,38 @@ namespace blt::meta using reference_t = decltype(detail::reference_type_helper::template get(0)); template using const_reference_t = decltype(detail::const_reference_type_helper::template get(0)); + + template + struct arrow_return + { + using type = typename std::result_of)(T*)>::type; + }; + + template + struct arrow_return + { + using type = T*; + }; + + // gets the return type for arrow operator + template + using arrow_return_t = typename arrow_return::type; + + template + struct deref_return + { + using type = typename std::result_of::type; + }; + + template + struct deref_return + { + using type = T&; + }; + + // gets the return type for the reference operator + template + using deref_return_t = typename deref_return::type; #define BLT_META_MAKE_FUNCTION_CHECK(FUNC, ...)\ template \ diff --git a/include/blt/std/ranges.h b/include/blt/std/ranges.h index de1facc..4898666 100644 --- a/include/blt/std/ranges.h +++ b/include/blt/std/ranges.h @@ -82,23 +82,24 @@ namespace blt return current != other.current; } - std::pair operator*() const + std::pair> operator*() const { return {index, *current}; }; - std::pair operator*() + std::pair> operator*() { return {index, *current}; }; }; + // TODO: cleanup! all of this! add support for reversing template class pair_iterator { public: - using c1_ref = typename std::iterator_traits::reference; - using c2_ref = typename std::iterator_traits::reference; + using c1_ref = blt::meta::deref_return_t; + using c2_ref = blt::meta::deref_return_t; using iterator_category = std::forward_iterator_tag; using value_type = std::pair;