-
Notifications
You must be signed in to change notification settings - Fork 295
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
refactor: towards plain struct flavor entities #3216
Merged
Merged
Changes from 46 commits
Commits
Show all changes
54 commits
Select commit
Hold shift + click to select a range
50a0aba
refactor(flavor): try to remove operator[]
ludamad0 a96aa39
REVERTME comment out all array usage of polynomials
ludamad0 061ccd2
Merge remote-tracking branch 'origin/master' into ad/chore/flavor-ref…
ludamad0 844c310
try to remove operator[]
ludamad0 a02ca70
try to remove operator[]
ludamad0 264dc18
try to remove operator[]
ludamad0 2444a59
try to remove operator[]
ludamad0 6ff2adb
try to remove operator[]
ludamad0 ad99141
Start of implementing
ludamad0 e57c811
Start of implementing
ludamad0 82bae80
Start of implementing
ludamad0 acf9c75
Start of implementing
ludamad0 fd819a8
Start of implementing
ludamad0 6616189
Start of implementing
ludamad0 9815845
more implementation
ludamad0 0831ddf
refactor: finish extend_edges
ludamad0 cd10687
refactor: finish extend_edges
ludamad0 414eb9a
comment
ludamad0 488a23f
more implementation
ludamad0 4d5ac93
more implementation
ludamad0 51690f8
more implementation
ludamad0 2c10140
fix
ludamad0 012cb5f
add zip_view utility
ludamad0 df2f1ff
renaming
ludamad0 12f72fe
more addressing TODOs
ludamad0 5649093
more addressing TODOs
ludamad0 82aa856
more addressing TODOs
ludamad0 ab62aa1
more addressing TODOs
ludamad0 c0bdb36
more addressing TODOs
ludamad0 a6346ac
more addressing TODOs
ludamad0 8f03269
more addressing TODOs
ludamad0 570a339
more addressing TODOs
ludamad0 8213351
more addressing TODOs
ludamad0 6d002b0
more addressing TODOs
ludamad0 67e4305
fix: rest
ludamad0 919a998
fix: rest
ludamad0 774a6d4
fix: the final operator[] eradication TODOs
ludamad0 7ecc83c
fix: cant remove typename. all well
ludamad0 4bfc72f
gdwarf
ludamad0 4332247
gdwarf
ludamad0 1ea9217
Fix bug in test
ludamad0 df79b8b
Fix bug in test
ludamad0 be5d158
fix: accidental extra EXPERCT_EQQ
ludamad0 6ba9030
fix: accidental extra EXPERCT_EQQ
ludamad0 bcf492b
Merge branch 'master' into ad/chore/flavor-refactor
ludamad d2827d9
Merge branch 'master' into ad/chore/flavor-refactor
ludamad a06ae1e
Update yarn-project
ludamad d1c0392
Merge branch 'master' into ad/chore/flavor-refactor
ludamad cb478b6
Merge remote-tracking branch 'origin/master' into ad/chore/flavor-ref…
ludamad 8bc9ba0
Merge remote-tracking branch 'origin/master' into ad/chore/flavor-ref…
ludamad fb15e90
Merge branch 'master' into ad/chore/flavor-refactor
ludamad 5cc1c97
Revert yarn-project
ludamad0 d70b08f
chore: assert sizes in define pointer view
ludamad0 a23c162
fix: size asserts
ludamad0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,190 @@ | ||
#pragma once | ||
/* ********************************* FILE ************************************/ | ||
/** \file mzip.hpp | ||
* | ||
* \brief This header contains the zip iterator class. | ||
* | ||
* WARNING this is a zip view, not a zip copy! | ||
* | ||
* \remark | ||
* - c++17 | ||
* - no dependencies | ||
* - header only | ||
* - tested by test_zip_iterator.cpp | ||
* - not thread safe | ||
* - view ! | ||
* - extends lifetime of rvalue inputs untill the end of the for loop | ||
* | ||
* \todo | ||
* - add algorithm tests, probably does not work at all... | ||
* | ||
* | ||
* \example | ||
* std::vector<int> as{1,2},bs{1,2,3}; | ||
* for(auto [index, a,b]: zip(as,bs)){ | ||
* a++; | ||
* } | ||
* cout<<as<<endl; // shows (2, 3) | ||
* works for any number | ||
* | ||
* zip returns tuples of references to the contents | ||
* | ||
* | ||
* | ||
* | ||
* | ||
* | ||
* | ||
* | ||
* | ||
* does not copy the containers | ||
* returns tuple of references to the containers content | ||
* iterates untill the first iterator hits end. | ||
* extends ownership to the end of the for loop, or untill zip goes out of scope. | ||
* | ||
* possibly risky behaviour on clang, gcc for fun(const zip& z) when called as fun(zip(a,b)) | ||
* | ||
* | ||
* Depends on the following behaviour for for loops: | ||
* | ||
* // in for(x:zip) | ||
* // equiv: | ||
* { // c++ 11+ | ||
* auto && __range = range_expression ; | ||
* for (auto __begin = begin_expr, __end = end_expr; __begin != __end; ++__begin) { | ||
* range_declaration = *__begin; | ||
* loop_statement | ||
* } | ||
* } | ||
* | ||
* { // in c++ 17 | ||
* auto && __range = range_expression ; | ||
* auto __begin = begin_expr ; | ||
* auto __end = end_expr ; | ||
* for ( ; __begin != __end; ++__begin) { | ||
* range_declaration = *__begin; | ||
* loop_statement | ||
* } | ||
* } | ||
* | ||
* | ||
* \author Mikael Persson | ||
* \date 2019-09-01 | ||
******************************************************************************/ | ||
|
||
static_assert(__cplusplus >= 201703L, | ||
" must be c++17 or greater"); // could be rewritten in c++11, but the features you must use will be buggy | ||
// in an older compiler anyways. | ||
#include <cassert> | ||
#include <functional> | ||
#include <iostream> | ||
#include <sstream> | ||
#include <tuple> | ||
#include <type_traits> | ||
#include <vector> | ||
|
||
template <class T> | ||
/** | ||
* @brief The zip_iterator class | ||
* | ||
* Provides a zip iterator which is at end when any is at end | ||
*/ | ||
class zip_iterator { | ||
public: | ||
// speeds up compilation a little bit... | ||
using tuple_indexes = std::make_index_sequence<std::tuple_size_v<std::remove_reference_t<T>>>; | ||
|
||
zip_iterator(T iter, T iter_end) | ||
: iter(iter) | ||
, iter_end(iter_end) | ||
{} | ||
// prefix, inc first, then return | ||
zip_iterator& operator++() | ||
{ | ||
for_each_in_tuple([](auto&& x) { return x++; }, iter); | ||
// then if any hit end, update all to point to end. | ||
auto end = apply2([](auto x, auto y) { return x == y; }, iter, iter_end); | ||
if (if_any_in(end)) { | ||
apply2([](auto& x, auto y) { return x = y; }, iter, iter_end); | ||
} | ||
index++; | ||
return *this; | ||
} | ||
// sufficient because ++ keeps track and sets all to end when any is | ||
bool operator!=(const zip_iterator& other) const { return other.iter != iter; } | ||
auto operator*() const | ||
{ | ||
return std::forward<decltype(get_refs(iter, tuple_indexes{}))>(get_refs(iter, tuple_indexes{})); | ||
} | ||
|
||
private: | ||
T iter, iter_end; | ||
std::size_t index = 0; | ||
|
||
template <std::size_t... I> auto get_refs(T t, std::index_sequence<I...>) const | ||
{ | ||
return std::make_tuple(std::ref(*std::get<I>(t))...); | ||
} | ||
|
||
template <class F, class A, std::size_t... I> auto apply2_impl(F&& f, A&& a, A&& b, std::index_sequence<I...>) | ||
{ | ||
return std::make_tuple(f(std::get<I>(a), std::get<I>(b))...); | ||
} | ||
template <class F, class A> auto apply2(F&& f, A&& a, A&& b) | ||
{ | ||
return apply2_impl(std::forward<F>(f), std::forward<A>(a), std::forward<A>(b), tuple_indexes{}); | ||
} | ||
template <class A, std::size_t... I> bool if_any_impl(const A& t, std::index_sequence<I...>) const | ||
{ | ||
return (... || std::get<I>(t)); // c++17 | ||
} | ||
|
||
// in general context we must enforce that these are tuples | ||
template <class A> bool if_any_in(A&& t) const { return if_any_impl(std::forward<A>(t), tuple_indexes{}); } | ||
|
||
template <class F, class Tuple, std::size_t... I> | ||
auto for_each_in_impl(F&& f, Tuple&& t, std::index_sequence<I...>) const | ||
{ | ||
return std::make_tuple(f(std::get<I>(t))...); | ||
} | ||
|
||
template <class F, class A> void for_each_in_tuple(F&& f, A&& t) const | ||
{ | ||
for_each_in_impl(std::forward<F>(f), std::forward<A>(t), tuple_indexes{}); | ||
} | ||
}; | ||
|
||
template <class... S> class zip_view { | ||
using arg_indexes = std::make_index_sequence<sizeof...(S)>; | ||
|
||
public: | ||
zip_view(S... args) | ||
: args(std::forward<S>(args)...) | ||
{} | ||
auto begin() const { return get_begins(arg_indexes{}); } | ||
auto end() const { return get_ends(arg_indexes{}); } | ||
[[nodiscard]] std::size_t size() const { return size_impl(arg_indexes{}); } | ||
|
||
private: | ||
std::tuple<S...> args; | ||
template <std::size_t... I> auto get_begins(std::index_sequence<I...>) const | ||
{ | ||
return zip_iterator(std::make_tuple(std::get<I>(args).begin()...), std::make_tuple(std::get<I>(args).end()...)); | ||
} | ||
template <std::size_t... I> auto get_ends(std::index_sequence<I...>) const | ||
{ | ||
return zip_iterator(std::make_tuple(std::get<I>(args).end()...), std::make_tuple(std::get<I>(args).end()...)); | ||
} | ||
template <std::size_t... I> auto size_impl(std::index_sequence<I...>) const | ||
{ | ||
return std::max({ std::size_t(std::get<I>(args).size())... }); | ||
} | ||
|
||
template <class A, std::size_t... I> bool if_any_impl(const A& t, std::index_sequence<I...>) const | ||
{ | ||
return (... || std::get<I>(t)); // c++17 | ||
} | ||
}; | ||
|
||
// deduction guide, | ||
template <class... S> zip_view(S&&...) -> zip_view<S...>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This was not building in its own folder, nor was it compatible with the gdb on mainframe