-
Notifications
You must be signed in to change notification settings - Fork 40
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
Storage types fixed #32
Conversation
…manually. This deals with local storage (future SBO and other) properly - All storages define copy semantics AND move semantics. If the underlying (erased) type is not copy constructible, then an exception is thrown at runtime if a copy is attempted. Similar thing for move semantics. - defined custom exchange() as std::exchange() is not constexpr in C++17
…ype is nothrow constructible with forwarding reference - added small buffer optimization (SBO) storage
@krzysztof-jusiak I've also added |
nice, can we add some more tests please to ensure that functionality won't get removed in the future |
Yep no problem |
…e want te::poly to be default constructible in the future. No reason why not. - bug: If a copy assign or move assign throws, the pointer won't be reset so you could get a double free. fix: null pointers after deletion - added tests for sbo_storage and shared_storage
I added some tests. I don't think the tests are as complete as they should be. But we could add more in future PRs |
- enhancing should_support_dynamic_storage()
- testing value semantics more thoroughly based on storage type
@krzysztof-jusiak OK, i've added a few more tests, specifically that test value semantics more closely depending on the storage type. If everything passes, I would be keen for you to review. Thanks |
Fantastic, thanks |
I've added bug fixes and tests for self-assignment :) |
Hmm, with the fixes and noexcept-correctness, the library generates a lot more assembly. So the whole "better inlining" argument goes out the window. Maybe there are some optimizations possible |
Compiler explorer experiments hint that's because I've removed loads of |
Like, |
I don't understand what Codacy is chatting about |
I've tried so many different compilers, and it always works fine. So I really don't know what Codacy is talking about. It doesn't make sense to have an explicit templated constructor with a universal reference. I'm not even sure that would be valid C++. @krzysztof-jusiak any ideas? |
… not correct but let's make Github happy
I give up fighting Codacy. I would love it if someone showed me what I'm doing wrong. The code builds everywhere (everywhere i've been bothered to try) |
…happy - function pointers for copy, move etc need to have arguments with correct names, i.e. whether the pointers refer to 'self' or 'other' objects
@pfeatherstone Perhaps I don't understand the problem, but is there any reason you don't want to make the |
- removed default constructors. I re-added them at some point because I thought that would somehow trigger some C++ rule that would make Codacy happy - added // cppcheck-suppress noExplicitConstructor to one of the poly constructors
I have a few more ideas for another PR. For example, the storage policies should have additional policies that dictate whether or not they should be copyable, moveable, noexcept copyable or noexcept moveable. At the moment, all of them are copyable and moveable. If the underlying erased type is not copyable say, then the copy constructor or copy assign operator of the poly throws. Which means we can't mark the copy constructor or copy assignment operators as noexcept. Similar thing for move semantics. Or depending on the policy, we may want to delete copy or move semantics. these types of things will chip away lines of assembly. The default behavior before was to mark everything as noexcept which I think is incorrect because your program will always terminate. i don't think that's desirable. |
@krzysztof-jusiak Do you mind reviewing when you get the chance? |
@pfeatherstone very nice, thank you 👏 I think it just need rebasing and it's good to go 👍 |
@krzysztof-jusiak Sorry, I'm not a git expert. Do you mind giving some instructions? This branch is ahead of boost-ext/te anyway so not sure what rebasing would do. Do you mean squashing commits? |
@pfeatherstone see #19 regarding compilation errors with GCC |
@hgkjshegfskef Thanks. Now i know what name to put to that |
@pfeatherstone if you understand how that "ADL magic" works (I unfortunately do not), perhaps you can borrow the implementation from Anton Polukhin's Boost.PFR, which works under c++17 and even c++14, which, as far as I understand, needs to do something similar. That issue is 4 years old, and nobody suggested a patch yet, so good luck :) |
I think Boost.PFR uses something different. It has to do with aggregate initialization. |
I think we need @krzysztof-jusiak to lay out his opinion on this. Making this work on gcc without changing the API would be nice. I'm not a fan of the Dyno interface which requires you to define several things. This is super clean. But if it can't be done with gcc then it can't be done. Sy Brand did something really great using the old metaclasses proposal. I'm sure something equivalent with reflection will be possible soon and all problems will go away. In the mean time, we make this a Clang only library. |
hmm, it seems that the soution has been broken for g++8+ borefe these changes either way. I think we can proceeed with the PR as it's a great improvement and figure out whether there is a valuable wknd or g++8+. I do remember seeing a workable solution somewhere at some point. Will try to dig it in. |
Regardin the MR conficts
|
This reverts commit cd872c1.
I don't quite understand what you want me to do with the rebase. Can't we just do a squash and merge? I made my changes on master. When I run your commands I just get messages like "Already up-to-date". I'm really sorry if I'm being dumb. |
It also doesn't work for certain versions of Clang, for example 11.0.0, 10.0.1, 9.0.1, 8.0.1. https://godbolt.org/z/TdTKaah18 |
merged, thanks @pfeatherstone, @hgkjshegfskef |
Awesome. Now we just need it to work on gcc and other versions of clang. |
@krzysztof-jusiak Is this relevant to fixing the implementation such that it works with g++ and some version of clang? |
Problem:
Solution:
void_ptr
Issue: #31
Reviewers:
@krzysztof-jusiak