Comments (5)
Hello @amutamil,
thanks for your feedback!
Without a minimal working example, this is tough to say. In a quick example, I drafted (https://cppinsights.io/s/f4c0dc68), the transformation works as expected.
I'm happy to look at your example.
Andreas
from cppinsights.
Hello @andreasfertig ,
please refer this example https://cppinsights.io/s/647ccf1d,
Regards,
Amutamil E
from cppinsights.
Hello @amutamil,
thanks for sharing the code.
Please have a close look at our two different versions. My struct test
comes without a user-provided destructor. As a result, you can see that test
, in my case, uses a compiler-provided move constructor (line 5 in the transformed output). Due to the destructor's presence in your example, only a compiler-provided copy constructor exists. This is why there is a cast around the std::move
, which adds const
.
In short, C++ Insights does what it is supposed to do: show you what's actually happening.
I wrote about this in one of my blog posts: andreasfertig.blog/2023/11/why-you-shouldnt-provide-an-empty-destructor/.
Andreas
from cppinsights.
Hello @andreasfertig,
Sorry if I deviated you from the real bug. I saw that video, from that video only I found this bug,
the real question is after C++ insights translate move
into casting also why do we have std::move
still being part of the translated version
test(static_cast<const test &&>(std::move(t)));
here in last still why we have std::move(t)
. This can't be just test(static_cast<const test &&>(t));
?
Amutamil E
from cppinsights.
Hello @amutamil,
the real question is after C++ insights translate move into casting also why do we have std::move still being part of the translated version
C++ Insights doesn't translate move
. I leave STL functions as they are. One reason why I'm not keen to add special code for std::variant
. Whatever these functions internally do is part of their implementation.
test(static_cast<const test &&>(std::move(t)));
here in last still why we havestd::move(t)
. This can't be justtest(static_cast<const test &&>(t));
?
As I said above, std::move
is not transformed. The cast you see is there because your code is not doing what you expect it to do. The cast C++ Insights shows you is adding const
to the rvalue reference the inner std::move
returns. If C++ Insights would transform move to a cast, your code would look like this:
test(static_cast<const test &&>(static_cast<test&&>(t)));
Andreas
from cppinsights.
Related Issues (20)
- Pack expansion in ctor call transformed into invalid c++
- Class template argument deduction not working - cpp17 HOT 2
- Add support for `SourceLocExpr` HOT 4
- Build on visualstudio 2019 get ascii, utf errors HOT 1
- Variant initialization improvisation (suggestion) HOT 4
- crash when parse cpp file HOT 1
- different result from godbolt HOT 1
- Incorrect move-only lambda code generation HOT 1
- Superfluous parentheses in declarations are handled incorrectly HOT 4
- Show initialization of non-local variables
- explicit casting for const HOT 2
- NRVO translation is not NRVO eligible HOT 2
- Segmentation Fault: Stack dump without symbol names HOT 1
- structured binding with lambda reports 'Segmentation fault' HOT 1
- Structure binding variables is rvalue reference? HOT 2
- How do I use it with cmake project HOT 2
- can not open "libxml2s.lib" ??? what is "libxml2s.lib" ? from where? HOT 4
- Static casts missing with inherited classes
- Lambda Capture Variable Not Used in Generated Code
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 cppinsights.