BlueBrain / HighFive

HighFive - Header-only C++ HDF5 interface
https://bluebrain.github.io/HighFive/
Boost Software License 1.0
687 stars 161 forks source link

Review anonymous file mode enum. #902

Open 1uc opened 10 months ago

1uc commented 10 months ago

https://github.com/BlueBrain/HighFive/blob/76382329c47c94924eb97a2100a0116494456bee/include/highfive/H5File.hpp#L28-L45

and then here: https://github.com/BlueBrain/HighFive/blob/76382329c47c94924eb97a2100a0116494456bee/include/highfive/H5File.hpp#L54-L56

isn't particularly type safe. One option is:

class File {
  enum class FileMode {
    ReadOnly,
  };

  static constexpr ReadOnly = FileMode::ReadOnly;

};

and a lot of boiler plate to allow it to work properly as a bitset. Or use:

using FileMode = std::bitset<?>;

class File {
  static constexpr FileMode ReadOnly = {...};
};