Comments (5)
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.
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.
π 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.
from ads.
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)
- ADS-sum command: Read or Write a list of variables with one single ADS-command HOT 1
- impossible to compile under ubuntu 20.04.5 HOT 1
- CMake Error at CMakeLists.txt:40 (install): install TARGETS given target "ads" which does not exist in this directory. HOT 3
- Unreachable PLC Blocks All Other Operations During Timeout Period HOT 2
- Reading route using `adstool`
- Will beckhoff officially launch the golang version of the ADS API HOT 2
- SymbolAccess for Bool HOT 5
- ADS Server HOT 1
- Async WriteReqEx HOT 5
- AdsNotification cycle time deviation HOT 2
- RGB Image over ADS HOT 1
- Port: 30000 already in used as 0x7ffe55930ed0 terminate called after throwing an instance of 'AdsException'
- Passing IP from terminal
- ADS Connection Error With Docker Container HOT 1
- CMake build failing HOT 2
- ADS READ for TwinCAT Motion
- Info: connection closed by remote in sockets.cpp HOT 2
- twincat3 - ubuntu error code 6 HOT 2
- ADS from Local to AmsNetID Fails HOT 1
- VS2019 64bit Compile ErrorοΌstd::numeric_limits<uint32_t>::max()
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 ads.