Git Product home page Git Product logo

Comments (5)

pbruenn avatar pbruenn commented on July 21, 2024

I will take a look on this one later. Maybe VC++ is missing some c++11 feature or my knowledge is smaller than you think and gcc is just doing magic with my code ;-).
Some years ago I attended "ESE Kongress" in Sindelfingen. The lecture of Prof. Peter Sommerlad opened my mind for C++11 and simple code. So I started to take a deeper look into STL and always try solve my problems using standard C++ library mechanisms.
Funny fact: he told me at the coffee table destructors are evil. At that time I didn't really understand what he meant. But now I "think" I figured out it is because of the "rule of five", so I try to implement "rule of zero".
At least AdsHandleGuard is my try to implement it. Comments and laughter of experts would be appreciated ;-).

Regards,
Patrick

from ads.

mwiarda avatar mwiarda commented on July 21, 2024

The ironic thing is that what prevents me from using the STL in my daily work is the limited subset of the STL that is supported by TwinCAT 3.1 C++ modules :-)
I try to keep myself up to date by listening to conference talks and reading a lot.
Whenever I work on a "non-kernel-mode" sideproject I test out everything I learned.

That rule of zero thing is a really clever idea. I already admired that solution in your code πŸ‘
Its beautiful - but it is not obvious. I like code to be straightforward and easy to read. This solution is neat but can throw off people quickly. You always stop to wonder if it really covers any remote case that can happen. Anyway, it probably outperforms any constructor/destructor/... implementation I could write.

I guess you are right with the rule of five idea. And then there is the "throwing in destructors"-problem and the issue with destructors of base classes.

Regards,
Michael

from ads.

pbruenn avatar pbruenn commented on July 21, 2024

πŸ˜† I will try to convince my colleagues of c++14 support in TwinCAT at the lunch table ;-).

I prefer easy to read code, too. But that lecture encouraged me "learn to master the tools you use".
In every profession you have to learn to handle your tools. Only in programming some guidelines force you to write stuff like this:

if (0 == error) {
    do_error_handling(error);
} else {
    // this is empty to be compliant with coding guideline...
}

Just to make sure anyone could read it. No one would tell a carpenter to always use a handsaw just because a circular saw will cut his finger faster.

from ads.

mwiarda avatar mwiarda commented on July 21, 2024

from ads.

pbruenn avatar pbruenn commented on July 21, 2024

I am absolutely with you. "Clever coding" is as stupid as "Clever cable handling". However if you want to be allowed to handle cables, you have_to learn the cable codings.

In commit a4f2064 you can see even clever "rule of zero" has its pitfalls ;-).

I still think there is some error in VC++2015 std::bind/placeholders/std::unique_ptr implementation. This article sounds promising but even with VS2015 Update 3 I got the same error so I rewrote AdsHandle in commit b1d306e

from ads.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.