Skip to content

Errors with rvalue references in C++11 mode #17

@Luthaf

Description

@Luthaf

The following code throw a NcBadId exception at the auto attr = wrap.file.getAtt("Conventions"); line.

#include <string>
#include <netcdf>

using namespace std;
using namespace netCDF;

class Wrapper {
public:
    Wrapper(string name, string mode) {
        if (mode == "r")
            file = NcFile(name, NcFile::read);
        else if (mode == "w")
            file = NcFile(name, NcFile::write);
    }
    NcFile file;
};

int main(int argc, char** argv) {
    Wrapper wrap("file.nc", "r");
    auto attr = wrap.file.getAtt("Conventions");
    return 0;
}

While when I use direct initialisation for the file member, everything works.

class Wrapper {
public:
     Wrapper(string name, string mode) : file(name, NcFile::read) {}
    NcFile file;
};

Maybe the library is using the default generated operator=(const NcFile&), and this one is not correct. My compiler is clang based on LLVM 3.5.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions