Comments (6)
It seems disambiguating the constructors will fix the issue is VS2015:
MutableIfNotReference() = default;
-template<typename... Args>
-explicit MutableIfNotReference(Args&&... args):
-get(std::forward<Args>(args)...)
+template<typename Arg0, typename... Args>
+explicit MutableIfNotReference(Arg0&& arg0, Args&&... args) :
+ get(std::forward<Arg0>(arg0), std::forward<Args>(args)...)
{}
from safe.
Hey, I'm not sure to understand the issue. In the attached file, the line that should construct a value is commented out. But I guess this is the one that has a different behavior under VS2017 and VS2015 ? If it is so, then truly the correct output is "Mutex constructed Value constructed" and VS2015 is wrong.
I don't understand why VS2015 gets it wrong (do you ?) but I guess I see what your fix does. Looking at the code, though, I realize that the variadic constructor covers the default construction and we simply don't need the default constructor statement.
Can you answer these two questions for me, and we'll see how we go along with this:
- Do the tests pass on VS2015, when the issue happens ?
- Since we don't need the default constructor, can you tell me what happens if you remove it (see attached file) ? Does it solve the problem ?
Thanks for taking the time to share this with me,
Cheers!
L-C
from safe.
Hi @LouisCharlesC , thank you for the rapid response.
I am very sorry for the confusion, indeed the wrong lines are commented out in the code example. The main
function should be, as you correctly inferred,
int main()
{
safe::Safe<FTestValueType, FTestMutexType> X;
return 0;
}
I have tested simply removing the default constructor, and that seems to have the same effect. This is also a much cleaner fix. :)
- MutableIfNotReference() = default;
template<typename... Args>
explicit MutableIfNotReference(Args&&... args) :
get(std::forward<Args>(args)...)
{}
I have not had the opportunity to run the tests yet.
from safe.
Stupid C++, if you don't default (or delete) the default constructor, then the type becomes non-trivial. Who knows what else can happen if we don't do exactly the right thing. Solution: do as little as possible. Here's another mutableref.h.txt, could you try it out ?
from safe.
Blimey! This file alone isn't going to work.
Just pull my last commit and check out if it fixes your problem. If so, we're all set!
from safe.
Tests on Windows added.
Also I confirmed that the tests detected this bug on VS2015. Bug was already fixed by previous commit.
from safe.
Related Issues (17)
- Why is the access class not movable? HOT 2
- Simplification HOT 3
- Some questions about library HOT 3
- It isn't working in my sample HOT 4
- Do not use unnamed namespace in header HOT 3
- Naming scheme nitpicking: letter case HOT 3
- Suggestions HOT 1
- Make type names more intuitive / closer to the standard library HOT 5
- Upgradable shared_lock/shared_mutex with safe. HOT 2
- License questions HOT 9
- Early release of access object? HOT 6
- [Debian] Please change dependency import for .deb packaging HOT 4
- help with enforcing read-only access HOT 9
- Packaging HOT 1
- More recent CMake possible? HOT 2
- Semantics of safe::Safe::operator=() do not feel right HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from safe.