I have a problem and can not figure it out on my own. I am describing it and want you to give me ideas about it, please.
I need to define a bitset with dynamic size:
int x = fileparser.read("value"); // This fileparser is a custom class that reads .ini files.
std::bitset<x> myBitset;
but this bitset's size should be read from the file. So as you know, bitset can not handle runtime parameters cause of template arguments.
- I wrote a file parser class but I can not convert it to constexpr because it is a singleton and should return a static instance in one of its methods.
- I don't want to use the boost library.
- Also C++11 has a defect in constexpr classes and I'm facing it (ref: https://stackoverflow.com/a/36489493/12347681)
So, how can I handle it? I want to read a value from the file and use it as a constexpr.
Thanks in advance.
EDIT: When I convert my reader class to constexpr, I am facing the above defect from C++11. Is there a way to use my file reader class to determine the size of the bitset?
Aucun commentaire:
Enregistrer un commentaire