Skip to content
Snippets Groups Projects
Commit fe6e56d2 authored by Dominic Kempf's avatar Dominic Kempf
Browse files

[ParameterTreeParser] Add a template specialization of the parser for std::bitset

This specialization was missing and made it impossible to parse bitsets.
The implementation uses the specialization for bool. It was not possible
to reuse the parseRange method, because a bitset doesnt have begin() and end().
parent d26d2332
Branches
Tags
No related merge requests found
......@@ -19,6 +19,7 @@
#include <typeinfo>
#include <vector>
#include <algorithm>
#include <bitset>
#include <dune/common/array.hh>
#include <dune/common/exceptions.hh>
......@@ -315,6 +316,21 @@ namespace Dune {
}
};
template<std::size_t n>
struct ParameterTree::Parser<std::bitset<n> > {
static std::bitset<n>
parse(const std::string& str) {
std::bitset<n> val;
std::vector<std::string> sub = split(str);
if (sub.size() != n)
DUNE_THROW(RangeError, "cannot parse bitset because of unmatching sizes");
for (std::size_t i=0; i<n; ++i) {
val[i] = ParameterTree::Parser<bool>::parse(sub[i]);
}
return val;
}
};
template<typename T, typename A>
struct ParameterTree::Parser<std::vector<T, A> > {
static std::vector<T, A>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment