-
Notifications
You must be signed in to change notification settings - Fork 61
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
Backport of some concepts from util to C++17 #1741
base: master
Are you sure you want to change the base?
Backport of some concepts from util to C++17 #1741
Conversation
e50ec72
to
0949690
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1741 +/- ##
==========================================
- Coverage 90.04% 88.63% -1.42%
==========================================
Files 396 396
Lines 37928 37865 -63
Branches 4262 4261 -1
==========================================
- Hits 34154 33563 -591
- Misses 2477 3012 +535
+ Partials 1297 1290 -7 ☔ View full report in Codecov by Sentry. |
Thank you very much, I update your branch, so make sure to git pull and have a look at my changes first:
I have fixed the I hope that with these changes and suggestions you can continue, please let me know when there is additional trouble, then we can communicate further (probably next week). |
Thank you! For reference, I build the whole engine just to make sure that everything still builds especially since I'm currently working on the utility library which is used throughout a good portion of the codebase. Will let you know if I spot more problems. |
Hello @joka921 , |
@gpicciuca
TLDR: In general you should work on changing one thing, and then making sure that it compiles in both modes, currently I am doing a lot of cleanup in different places where it would be possible to discuss the occuring problems in advance, but we are all just learning to use these macros and their limitations (I have also learned several things about template metaprogramming in the past week). |
A bit more verbose, but it works.
|
@joka921 The changes in Will continue working on this next week. Feel free to have a look in the meantime if you have time. |
Okay, I have brought this back to compilation in both modes, but it took me quite a lot of time. Please continue as follows:
At some point, contact me again with the list of concepts where issues remain (the ones from point 3.) such that I can have a look at the more advanced techniques that we might need there. Let me know, if I can be of assistance or if there are additional questions. |
8878380
to
1770f2c
Compare
Ignore the force-push I just did please. Rebase went wrong. Working on it. |
1770f2c
to
5a83a04
Compare
Rebase solved. Both modes build just fine with this last commit. Tackling each concept now individually to not end up in a dead-end again. |
@gpicciuca |
I'm going through those enable_if_t templates again. One thing worth mentioning is that with the v3-ranges macros, you cannot have variadic arguments there. For example:
In these cases (and there are quite a few), we cannot even apply the normal C++17 sfinae techniques as you'd have to specify the Another example, although just a test:
The |
Signed-off-by: Johannes Kalmbach <[email protected]>
Signed-off-by: Johannes Kalmbach <[email protected]>
Signed-off-by: Johannes Kalmbach <[email protected]>
Signed-off-by: Johannes Kalmbach <[email protected]>
Signed-off-by: Johannes Kalmbach <[email protected]>
dc60f38
to
8b2f5f5
Compare
Conformance check passed ✅No test result changes. |
|
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.
I have made a thorough pass. I have marked some nasty details which I will look at myself first. Thanks for the tedious work so far,
I'll get back to you once I have addressed the things I want to change myself.
@@ -53,3 +55,25 @@ using namespace std; | |||
|
|||
} // namespace concepts | |||
} // namespace ql | |||
|
|||
// A template with a requires clause | |||
/// INTERNAL ONLY |
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.
I have updated versions of those, I will merge them in here myself later today or tomorrow.
@@ -71,6 +72,40 @@ struct CompactStringVectorWriter; | |||
|
|||
} | |||
|
|||
// TODO<joka921, picciuca> : The following doesn't work if there is no `begin()` |
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.
Just noting this TODO for later, s.t. I can have a look at it again.
decltype(sizeOfQueueWord)>( | ||
0.8 * memoryToUse, generators, lessThanForQueue); | ||
0.8 * memoryToUse, std::move(generators), lessThanForQueue); |
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.
Marking this for later to have a look at it.
template <typename U = void> | ||
std::enable_if_t<WatchDogEnabled, U> startWatchDogInternal(); |
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.
I'll have a look at how we can implement those withouth std::enable_if_t
, we'll need some of my new macros probably.
// TODO<joka921> play with a better solution for defaulting constructors. | ||
CPP_template(typename X = void)( | ||
requires std::is_default_constructible_v<Accessor>) | ||
IteratorForAccessOperator() {} |
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.
Pointing out this TODO for later.
// Note: The following code can not be written with a single declaration in | ||
// the `std::enable_if_t` world, because of the following bug in GCC 11: | ||
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105268 | ||
// TODO<joka921> Figure out whether this is also an issue on older GCC | ||
// versions for which we need this port. | ||
template <typename HandlerSupplier> | ||
static constexpr bool isValidConstructorArgument = | ||
ad_utility::InvocableWithConvertibleReturnType< | ||
HandlerSupplier, WebSocketHandler, net::io_context&>; | ||
template < | ||
typename HandlerSupplier, | ||
std::enable_if_t<isValidConstructorArgument<HandlerSupplier>, int> = 0> |
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.
Also a thing which I'll have a look at
@@ -37,6 +37,7 @@ Convenience header for Nlohmann::Json that sets the default options. Also | |||
#include "util/SourceLocation.h" | |||
|
|||
// For higher flexibility of the custom json helper functions. | |||
// TODO<joka921, gpicciuca> Make `CPP_concept` again. |
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.
Maybe we can address this right now:)
@@ -42,8 +42,13 @@ | |||
|
|||
using namespace std::string_literals; | |||
|
|||
// TODO<joka921, gpicciuca>, some of those currently don't compile, but we first | |||
// take care of more important things. | |||
#if false |
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.
I'll have a look at those
static_assert(!std::is_copy_assignable_v<decltype(hallo)>); | ||
// TODO<joka921> This has to be changed, because some concept checks here are | ||
// currently disabled. | ||
// static_assert(!std::is_copy_assignable_v<decltype(hallo)>); |
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.
Another TODO
@@ -91,8 +91,13 @@ TEST(Parameters, ParameterConcept) { | |||
IsParameter<DurationParameter<std::chrono::seconds, "Seconds">>); | |||
|
|||
// Test some other random types. | |||
// TODO<joka921, gpicciuca> This constrained is currently deactivated. | |||
static_assert(IsParameter<std::string>); |
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.
Same here
Proposing a first bulk of changes aiming to backport some of the concepts used throughout the util module. (Not ready for merging)
There are some places where things are quite intricate and complicated, so feedback would be appreciated.
Problematic areas:
SerializeVector.h ends up with an incomplete type when building with C++17 flagConfigOptionProxy.h seems to not forward the underlying type correctly, causing the ValidatorFunction constraints to fail when using theaddValidator
method fromConfigOption.h
(See commented code in BenchmarkExamples.cpp)A solution has to be found for theisInstantiation
constraints imposed in some parts ofConfigOption.h
, which I currently had to remove to make it build with v3-ranges.Update:
I have a working cpp20 util module so far with all concepts rewritten using the v3-range macros.
cpp17 version is in progress.
Couple of remarks which I found on the way:
StringUtils.h
implements different compile-time string concatenation methods by leveraging the new c++20 template value feature. This is not supported in C++17 and may need some rework. The same goes for theProgramOptionsHelpers.h
which is used inRuntimeConfiguration
.LambdaHelpers.h
I had to resort toQL_CONCEPT_OR_NOTHING
, just like inIterators.h
otherwise I'd end up with compile-time errors due to copy and move semantics being deleted (due to the default constructor/methods, which cannot be templated otherwise they need to be explicitly implemented)TypeTraits.h
we have the type-aliasTupleCat
which takes variadic template arguments. Problem is that the v3-range concept macros append other stuff at the end of the template<> definition and therefore make the compiler complain abouttypename... Tuples
not being the last element of the list. Edit: Was an easy fix for the TypeTraits.h, but in ConstexprUtils.h we also have cases with variadic arguments which are also causing issues here.