-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Formatting/additions/etc #31
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"folders": | ||
[ | ||
{ | ||
"path": "." | ||
} | ||
], | ||
"settings": | ||
{ | ||
"ClangFormat": | ||
{ | ||
"binary": "clang-format", | ||
"format_on_save": true, | ||
"style": "file" | ||
}, | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"project": ".sublime-project" | ||
} |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,46 +36,31 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
#include <numeric> | ||
#include <algorithm> | ||
|
||
#include "mkn/kul/span.hpp" | ||
|
||
namespace mkn { | ||
namespace kul { | ||
|
||
#define PRINT_LINE() std::cout << __LINE__ << std::endl | ||
|
||
namespace func { | ||
template <typename...> | ||
using check = void; | ||
} | ||
|
||
template <typename T, typename data_fn = void, typename size_fn = void> | ||
struct is_span_like : std::false_type {}; | ||
|
||
template <typename T> | ||
struct is_span_like<T, func::check<decltype(std::declval<T>().data())>, | ||
func::check<decltype(std::declval<T>().size())>> : std::true_type {}; | ||
|
||
template <typename T> | ||
auto constexpr is_span_like_v = is_span_like<T>::value; | ||
|
||
template <typename Container, typename Function> | ||
void for_each(Container& container, Function && function) { | ||
void for_each(Container& container, Function&& function) { | ||
std::for_each(std::begin(container), std::end(container), function); | ||
} | ||
Comment on lines
44
to
47
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
|
||
template <typename Container, typename Function> | ||
bool any_of(Container const& container, Function && function) { | ||
bool any_of(Container const& container, Function&& function) { | ||
return std::any_of(std::begin(container), std::end(container), function); | ||
} | ||
template <typename Container, typename Function> | ||
bool any_of(Container && container, Function && function) { | ||
bool any_of(Container&& container, Function&& function) { | ||
return std::any_of(std::begin(container), std::end(container), function); | ||
} | ||
Comment on lines
49
to
56
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Comment on lines
+54
to
56
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The - return any_of(std::begin(container), std::end(container), function);
+ return std::any_of(std::begin(container), std::end(container), function); |
||
|
||
template <typename Container, typename Function> | ||
bool all_of(Container const& container, Function && function) { | ||
bool all_of(Container const& container, Function&& function) { | ||
return std::all_of(std::begin(container), std::end(container), function); | ||
} | ||
template <typename Container, typename Function> | ||
bool all_of(Container && container, Function && function) { | ||
bool all_of(Container&& container, Function&& function) { | ||
return all_of(container, function); | ||
} | ||
Comment on lines
+59
to
65
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to the
Comment on lines
+63
to
65
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The - return all_of(container, function);
+ return std::all_of(std::begin(container), std::end(container), function); |
||
|
||
|
@@ -90,7 +75,7 @@ bool compare_to(T const& t, OP const& op, Args const&... args) { | |
return ((op(args, t)) && ...); | ||
} | ||
template <typename T, typename OP, typename... Args> | ||
bool compare_to(T && t, OP && op, Args &&... args) { | ||
bool compare_to(T&& t, OP&& op, Args&&... args) { | ||
return compare_to(t, op, args...); | ||
} | ||
Comment on lines
+78
to
80
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The - return compare_to(t, op, args...);
+ return compare_to(static_cast<T const&>(t), op, args...); |
||
|
||
|
@@ -100,7 +85,7 @@ bool compare_to(T const& t, OP const& op, std::tuple<TupleElements...> const& tu | |
return std::apply([&](auto const&... args) { return compare_to(t, op, args...); }, tuple); | ||
} | ||
template <typename T, typename OP, typename... TupleElements> | ||
bool compare_to(T && t, OP && op, std::tuple<TupleElements...> && tuple) { | ||
bool compare_to(T&& t, OP&& op, std::tuple<TupleElements...>&& tuple) { | ||
return compare_to(t, op, tuple); | ||
} | ||
Comment on lines
+88
to
90
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The - return compare_to(t, op, tuple);
+ return compare_to(static_cast<T const&>(t), op, tuple); |
||
|
||
|
@@ -114,7 +99,7 @@ class All { | |
return are(t, std::equal_to<T>{}); | ||
} | ||
template <typename T> | ||
bool operator==(T && t) { | ||
bool operator==(T&& t) { | ||
return are(t, std::equal_to<T>{}); | ||
} | ||
|
||
|
@@ -123,7 +108,7 @@ class All { | |
return are(t, std::not_equal_to<T>{}); | ||
} | ||
template <typename T> | ||
bool operator!=(T && t) { | ||
bool operator!=(T&& t) { | ||
return are(t, std::not_equal_to<T>{}); | ||
} | ||
|
||
|
@@ -132,7 +117,7 @@ class All { | |
return are(t, std::greater<T>{}); | ||
} | ||
template <typename T> | ||
bool operator>(T && t) { | ||
bool operator>(T&& t) { | ||
return are(t, std::greater<T>{}); | ||
} | ||
|
||
|
@@ -141,7 +126,7 @@ class All { | |
return are(t, std::less<T>{}); | ||
} | ||
template <typename T> | ||
bool operator<(T && t) { | ||
bool operator<(T&& t) { | ||
return are(t, std::less<T>{}); | ||
} | ||
|
||
|
@@ -150,7 +135,7 @@ class All { | |
return are(t, std::greater_equal<T>{}); | ||
} | ||
template <typename T> | ||
bool operator>=(T && t) { | ||
bool operator>=(T&& t) { | ||
return are(t, std::greater_equal<T>{}); | ||
} | ||
|
||
|
@@ -159,7 +144,7 @@ class All { | |
return are(t, std::less_equal<T>{}); | ||
} | ||
template <typename T> | ||
bool operator<=(T && t) { | ||
bool operator<=(T&& t) { | ||
return are(t, std::less_equal<T>{}); | ||
} | ||
Comment on lines
144
to
149
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The operator overloads for
Comment on lines
+147
to
149
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The comparison operators ( - return are(t, std::equal_to<T>{});
+ return are(static_cast<T const&>(t), std::equal_to<T>{}); Repeat this change for all the comparison operators. |
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's less complicated as it has fewer parameters, and avoids needing to use begin/end, which is the point
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@PhilipDeegan, thank you for your explanation. I understand your point about reducing complexity and the need to explicitly call
std::begin
andstd::end
. This indeed makes the code cleaner and easier to read. I appreciate your approach to improving code readability and simplicity.