-
Notifications
You must be signed in to change notification settings - Fork 44
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
Rework Container Type Traits and GlobRef Conversion Rules #630
base: development
Are you sure you want to change the base?
Conversation
There are two different things: we need From https://en.cppreference.com/w/cpp/named_req/StandardLayoutType:
This restriction is important as we cannot copy vtables across process boundaries (unless we force things like ALSR to be disabled). Afaics, it doesn't include So, to amend your proposal: |
That is what I meant, actually. In other words, we want to keep compatibility to C, MPI, etc.
Correct. vtables shouldn't be allowed. But a standard layout gives a much stronger guarantee. We can include |
You're right, |
Minor change: We cannot rely on And after thinking again we do not really need trivial construction. All we need is default construction which gives us still the possiblity to construct elements while constructing the container, although we do not really consider this currently. So in summary: template <class T>
struct is_container_compatible :
public std::integral_constant<bool,
std::is_default_constructible<T>::value
&& std::is_trivially_copyable<T>::value
>
{ }; |
Codecov Report
@@ Coverage Diff @@
## development #630 +/- ##
===============================================
+ Coverage 84.83% 84.85% +0.01%
===============================================
Files 335 336 +1
Lines 24798 24856 +58
Branches 11249 11282 +33
===============================================
+ Hits 21038 21091 +53
Misses 3729 3729
- Partials 31 36 +5
|
For the record: default construction of elements in containers has been brought up in #479. |
Like always, such PR get larger than expected. I am documenting everything now with sweet While this approach demonstrates it for |
dash::GlobAsyncRef<int> agref3 = | ||
static_cast<dash::GlobAsyncRef<int>>(carr.async[0]); | ||
//dash::GlobAsyncRef<int> agref3 = | ||
// static_cast<dash::GlobAsyncRef<int>>(carr.async[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.
I guess I'm missing something here, but why do we disallow explicit const->non-const conversion?
Sorry, this PR completely slipped through. Just a minor question, seems fine to me otherwise |
Unfortunately, we cannot implement the following example:
AFAIK we chose these constraints because we want to be able to do a simple
memcpy
in DART by using Shared Memory Windows. Butstd::memcpy()
does not require a StandardLayoutType. A TrviallyCopyable type suffices as documented. So we should weaken our container requirements to allow adash::Array<Child>
.We reworked
GlobRef
some time ago and the relatively strict requirements lead to one consequence which we have to deal with. We should permit the following conversion:EDIT: My suggestion is to replace
is_standard_layout
withis_trivially_default_constructible
. Then, aChild
is container compatible and this should suffice for our requirements. Thoughts on this?