9 İşlemeler 5d15ee0404 ... a6969b647a

Yazar SHA1 Mesaj Tarih
  namark a6969b647a allinclude 2 ay önce
  namark ea4a2f539e Unit tests for tuple relational operators and vector mismatch algorithm. 2 ay önce
  namark 22a4cedbcf Vector iterator mismatch algorithm. 2 ay önce
  namark 0cf7b193e6 Relational tuple operators. 2 ay önce
  namark ac56b3d549 Improved array operators SFINAE. 2 ay önce
  namark 17da9c8282 Separated the mismatch algorithm and made it move-only friendly. 2 ay önce
  namark 4da90af1f1 Minor comment fix. 2 ay önce
  namark 52315bc8a2 Made literals namespace inline. 2 ay önce
  namark 2da7b0163f Improved some includes. 2 ay önce

+ 2 - 0
source/simple/support/algorithm.hpp

@@ -1,5 +1,6 @@
 // this is an auto-generated allinclude
 #include "algorithm/advance_vector.hpp"
+#include "algorithm/mismatch.hpp"
 #include "algorithm/numeric.hpp"
 #include "algorithm/pick_unique.hpp"
 #include "algorithm/range_wrappers.hpp"
@@ -8,3 +9,4 @@
 #include "algorithm/traits.hpp"
 #include "algorithm/utils.hpp"
 #include "algorithm/variance.hpp"
+#include "algorithm/vmismatch.hpp"

+ 43 - 0
source/simple/support/algorithm/mismatch.hpp

@@ -0,0 +1,43 @@
+#ifndef SIMPLE_SUPPORT_ALGORITHM_MISMATCH_HPP
+#define SIMPLE_SUPPORT_ALGORITHM_MISMATCH_HPP
+
+#include <utility> // std::pair std::move
+#include <type_traits> // std::enable_if_t
+#include "traits.hpp" // is_iterable_v
+
+namespace simple::support
+{
+
+	// cause can't even count on libstdc++ devs to implement a mismatch without
+	// copying the iterator bajillion times... simple rule - pass by const ref,
+	// is it that hard? your own compiler can't short circuit a simple and/or
+	// functors if they accept value instead of const ref, and you are here
+	// copying user defined types willy nilly, for no good reason... "but
+	// standard requires, bhaahaa"... standard does not require you to be a
+	// dick, ffs...
+	// i don't care how regular you wish the world to be, input iterators are move only, deal with it
+	template <typename It, typename It2,
+		std::enable_if_t<is_iterable_v<It> && is_iterable_v<It2>>* = nullptr>
+	[[nodiscard]] constexpr
+	std::pair<It,It2> mismatch(It begin, const It& end, It2 begin2)
+	// TODO: noexcept(...)
+	{
+		while(begin != end && *begin == *begin2)
+			++begin, ++begin2;
+		return {std::move(begin),std::move(begin2)};
+	}
+
+	template <typename It, typename It2,
+		std::enable_if_t<is_iterable_v<It> && is_iterable_v<It2>>* = nullptr>
+	[[nodiscard]] constexpr
+	std::pair<It,It2> mismatch(It begin, const It& end, It2 begin2, const It2& end2)
+	// TODO: noexcept(...)
+	{
+		while(begin != end && begin2 != end2 && *begin == *begin2)
+			++begin, ++begin2;
+		return {std::move(begin),std::move(begin2)};
+	}
+
+} // namespace simple::support
+
+#endif /* end of include guard */

+ 1 - 25
source/simple/support/algorithm/split.hpp

@@ -1,38 +1,14 @@
 #ifndef SIMPLE_SUPPORT_ALGORITHM_SPLIT_HPP
 #define SIMPLE_SUPPORT_ALGORITHM_SPLIT_HPP
 #include <type_traits> // std::enable_if_t
-#include <utility> // std::pair
 #include <iterator> // std::begin std::end
 
 #include "traits.hpp" // is_range_v is_iterable_v
+#include "mismatch.hpp" // mismatch
 #include "../range.hpp" // range
 
 namespace simple::support
 {
-	// cause can't even count on libstdc++ devs to implement a mismatch without
-	// copying the iterator bajillion times... simple rule - pass by const ref,
-	// is it that hard? your own compiler can't short circuit a simple and/or
-	// functors if they accept value instead of const ref, and you are here
-	// copying user defined types willy nilly, for no good reason... "but
-	// standard requires, bhaahaa"... standard does not require you to be a
-	// dick, ffs...
-	template <typename It, typename It2>
-	[[nodiscard]] constexpr
-	auto mismatch(It begin, It end, It2 begin2)
-	{
-		while(begin != end && *begin == *begin2)
-			++begin, ++begin2;
-		return std::pair{begin,begin2};
-	}
-	template <typename It, typename It2>
-	[[nodiscard]] constexpr
-	auto mismatch(It begin, It end, It2 begin2, It2 end2)
-	{
-		while(begin != end && begin2 != end2 && *begin == *begin2)
-			++begin, ++begin2;
-		return std::pair{begin,begin2};
-	}
-
 	// cause we don't get a proper standard search until c++20, and even then it depends on super experimental ranges library
 	// (how does stuff like that even get in i wonder -_-)
 	template <typename It, typename NeedleIt>

+ 5 - 1
source/simple/support/algorithm/traits.hpp

@@ -1,6 +1,10 @@
 #ifndef SIMPLE_SUPPORT_ALGORITHM_TRAITS_HPP
 #define SIMPLE_SUPPORT_ALGORITHM_TRAITS_HPP
-#include <iterator>
+
+#include <iterator> // std::begin std::end
+#include <type_traits> // std::true_type std::false_type
+#include <utility> // std::declval
+#include <cstddef> // std::nullptr_t
 
 namespace simple::support
 {

+ 43 - 0
source/simple/support/algorithm/vmismatch.hpp

@@ -0,0 +1,43 @@
+#ifndef SIMPLE_SUPPORT_ALGORITHM_VMISMATCH_HPP
+#define SIMPLE_SUPPORT_ALGORITHM_VMISMATCH_HPP
+
+#include <type_traits> // std::enable_if_t
+#include <tuple> // std::apply
+
+#include "traits.hpp" // is_iterable_v
+
+namespace simple::support
+{
+
+	template <typename It,
+		std::enable_if_t<is_iterable_v<It>>* = nullptr>
+	[[nodiscard]] constexpr
+	auto reaches(const It& begin, const It& end)
+	noexcept(noexcept(begin == end))
+	-> decltype(begin == end)
+	{ return begin == end; }
+
+	// if tuples were not just an afterthought
+	template <typename Vit,
+		std::enable_if_t<is_iterable_v<Vit>>* = nullptr>
+		// TODO: is tuple-like *begin, tuple_size != 0
+	[[nodiscard]] constexpr
+	auto mismatch(Vit begin, const Vit& end)
+	// TODO: noexcept(...)
+	{
+		auto all_the_same = [](auto&& tuple)
+		{
+			return std::apply([](auto&& first, auto&& ... rest)
+			{
+				return ((rest == first) && ...);
+			}, tuple);
+		};
+
+		while(not reaches(begin, end) && all_the_same(*begin))
+			++begin;
+		return begin;
+	}
+
+} // namespace simple::support
+
+#endif /* end of include guard */

+ 9 - 7
source/simple/support/array_operators.hpp

@@ -461,13 +461,15 @@ template <typename Array, typename Other, \
 	typename OtherElement = simple::support::AOps_Details::array_element_t<OtherOperatorDef, Other>, \
 	typename OtherElOpDef = simple::support::define_array_operators<OtherElement>, \
 	bool ops_defined = OperatorDef::enabled_right_element_operators && simple::support::array_operator::op_type, \
+	std::enable_if_t<ops_defined>* = nullptr, \
+	std::enable_if_t<std::is_invocable_v<op_fun, Element, Other>>* = nullptr, \
 	typename Result = typename OperatorDef::template result<std::conditional_t<ops_defined, std::invoke_result_t<op_fun,Element,Other>, Element>, simple::support::array_operator::op_type, Other, true>, \
 	typename ResultOpDef = simple::support::define_array_operators<Result>, \
-	std::enable_if_t<(ops_defined) \
-		&& !std::is_same_v< \
+	std::enable_if_t< \
+		not std::is_same_v< \
 			typename OperatorDef::compatibility_tag, \
 			typename OtherOperatorDef::compatibility_tag> \
-		&& !std::is_same_v< \
+		&& not std::is_same_v< \
 			typename OperatorDef::compatibility_tag, \
 			typename OtherElOpDef::compatibility_tag> \
 		&& (std::is_same_v< \
@@ -476,7 +478,6 @@ template <typename Array, typename Other, \
 			|| std::is_same_v< \
 			typename ResultOpDef::compatibility_tag, \
 			typename OperatorDef::compatibility_tag>) \
-		&& std::is_invocable_v<op_fun, Element, Other>\
 	>* = nullptr \
 > \
 [[nodiscard]] constexpr auto operator op_symbol \
@@ -502,10 +503,12 @@ template <typename Array, typename Other, \
 	typename OtherElement = simple::support::AOps_Details::array_element_t<OtherOperatorDef, Other>, \
 	typename OtherElOpDef = simple::support::define_array_operators<OtherElement>, \
 	bool ops_defined = OperatorDef::enabled_left_element_operators && simple::support::array_operator::op_type, \
+	std::enable_if_t<ops_defined>* = nullptr, \
+	std::enable_if_t<std::is_invocable_v<op_fun, Other, Element>>* = nullptr, \
 	typename Result = typename OperatorDef::template result<std::conditional_t<ops_defined, std::invoke_result_t<op_fun,Other,Element>, Element>, simple::support::array_operator::op_type, Other, true>, \
 	typename ResultOpDef = simple::support::define_array_operators<Result>, \
-	std::enable_if_t<(ops_defined) \
-		&& !std::is_same_v< \
+	std::enable_if_t< \
+		!std::is_same_v< \
 			typename OperatorDef::compatibility_tag, \
 			typename OtherOperatorDef::compatibility_tag> \
 		&& !std::is_same_v< \
@@ -517,7 +520,6 @@ template <typename Array, typename Other, \
 			|| std::is_same_v< \
 			typename ResultOpDef::compatibility_tag, \
 			typename OperatorDef::compatibility_tag>) \
-		&& std::is_invocable_v<op_fun, Other, Element>\
 	>* = nullptr \
 > \
 [[nodiscard]] constexpr auto operator op_symbol \

+ 2 - 2
source/simple/support/int_literals.hpp

@@ -5,7 +5,7 @@
 #include <type_traits>
 #include <limits>
 
-namespace simple::support::literals
+namespace simple::support{ inline namespace literals
 {
 
 namespace details
@@ -79,6 +79,6 @@ SIMPLE_SUPPORT_DEFINE_UNSIGNED_INT_LITERAL_OPERATOR(unsigned short, _ush);
 
 #undef SIMPLE_SUPPORT_DEFINE_UNSIGNED_INT_LITERAL_OPERATOR
 
-} // namespace literals
+}} // namespace simple::support::literals
 
 #endif /* end of include guard */

+ 1 - 1
source/simple/support/math/abs.hpp

@@ -14,6 +14,6 @@ namespace simple::support
 		else return n;
 	}
 
-} // namespace simple::support::math
+} // namespace simple::support
 
 #endif /* end of include guard */

+ 1 - 0
source/simple/support/tuple_utils.hpp

@@ -3,5 +3,6 @@
 #include "tuple_utils/carcdr.hpp"
 #include "tuple_utils/common.hpp"
 #include "tuple_utils/operators.hpp"
+#include "tuple_utils/reduction.hpp"
 #include "tuple_utils/subtuple.hpp"
 #include "tuple_utils/transform.hpp"

+ 0 - 0
source/simple/support/tuple_utils/operators.hpp


Bu fark içinde çok fazla dosya değişikliği olduğu için bazı dosyalar gösterilmiyor