Comments (7)
Move constructors would be very nice anyway to use it with the auto keyword
auto file = netcdf::ncFile(fname, netcdf::ncFile::read);
Currently this code fails because the copy constructor is private and no move constructor is generated.
from netcdf-cxx4.
I agree that move constructors would be a nice feature. However, your code example could easily be rewritten to work without them:
...
NcIO(std::string const &filePath, netCDF::NcFile::FileMode fMode) :
_mync(filePath, fMode) {}
};
from netcdf-cxx4.
I should know better, that was embarrassing...
On Fri, Jan 8, 2016 at 3:37 AM, Jarle Ladstein [email protected]
wrote:
I agree that move constructors would be a nice feature. However, your code
example could easily be rewritten to work without them:...
NcIO(std::string const &filePath, netCDF::NcFile::FileMode fMode) :
_mync(filePath, fMode) {}
};—
Reply to this email directly or view it on GitHub
#25 (comment).
from netcdf-cxx4.
I'd be quite happy to work on this feature if it's still wanted. I'm currently using this in a C++17 environment and this, among other modern c++ niceties, is near the top of my wishlist.
from netcdf-cxx4.
@htmlboss that would be fantastic, we'd welcome the contribution :).
from netcdf-cxx4.
Finally have some time to attack this...I see 2 ways of going about this thing:
- Test against the
__cplusplus
macro:
#if __cplusplus >= 201103L
#define HAS_CXX11
#endif
and then:
#ifdef HAS_CXX11
// Move constructor
NcFile(NcFile&&) = default;
// Move assignment
NcFile& operator=(NcFile&&) = default;
#endif
That's your move-semantics 😸
This is really quick and easy, but some compilers may not adhere to correctly setting the __cplusplus
macro, although it's defined in the c++ standard.
- Doing some magic with autotools. Not really familiar with it but I quickly found out it can reliably test for specific c++ versions.
@WardF what's your opinion?
from netcdf-cxx4.
I'm concerned about accidentally boxing out some developers because of a compiler they're using, but I think most modern compilers support setting the __cplusplus
macro. Lets go with option 1
since it should be the easiest way forward. If we receive a complaint, it should be easy enough for us to move the check into autotools
and cmake
; I found the cmake
info here: https://stackoverflow.com/questions/10984442/how-to-detect-c11-support-of-a-compiler-with-cmake
Thanks again for your help with this!
from netcdf-cxx4.
Related Issues (20)
- Errors building 4.3.1 tag on macOS with Clang 12.0.5
- libnetcdf_c++4 vs. libnetcdf-cxx4 HOT 1
- Get attributes in the original order
- compile failure ncVar.cpp:630:11 error: 'nc_def_var_filter' was not declared in this scope (on static build) HOT 1
- header file is right? HOT 2
- Erroneous condition always evaluating true HOT 2
- Minimum required C++ standard?
- How to load data into a std::vector HOT 4
- 2 * field not copied in copy constructor ? HOT 1
- Does netcdf-cxx4 support parallel IO?
- netCDF::exceptions::NcHdfErr after calling getVar too often HOT 1
- CMake uninstall target conflicts with other previously registered uninstall targets
- Inconsistent constructor signatures
- HDF 1.14 + netcdf-c 4.9 Support? HOT 3
- Cmake modernization
- Testing: cxx4_test_filter (10/18) - Failed HOT 2
- [feature-request] `netcdfcpp_meta.h` file HOT 1
- updating a variable in a netcdf file
- adding a variable to an existing nc file
- Please clarify H5Free HOT 4
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 netcdf-cxx4.