DNAOp: Make use of template keyword for dependent templates

Prevents potential ambiguities from occurring.
This commit is contained in:
Lioncash 2020-04-18 03:54:22 -04:00
parent f5ad22ecf4
commit 25d3ed0f33
1 changed files with 36 additions and 25 deletions

View File

@ -147,18 +147,20 @@ struct BinarySize {
} }
template <class T, Endian DNAE> template <class T, Endian DNAE>
static std::enable_if_t<std::is_array_v<T>> Do(const PropId& id, T& var, StreamT& s) { static std::enable_if_t<std::is_array_v<T>> Do(const PropId& id, T& var, StreamT& s) {
for (auto& v : var) for (auto& v : var) {
BinarySize<PropOp>::Do<std::remove_reference_t<decltype(v)>, DNAE>(id, v, s); BinarySize<PropOp>::template Do<std::remove_reference_t<decltype(v)>, DNAE>(id, v, s);
}
} }
template <class T, Endian DNAE> template <class T, Endian DNAE>
static void DoSize(const PropId& id, T& var, StreamT& s) { static void DoSize(const PropId& id, T& var, StreamT& s) {
BinarySize<PropOp>::Do<T, DNAE>(id, var, s); BinarySize<PropOp>::template Do<T, DNAE>(id, var, s);
} }
template <class T, class S, Endian DNAE> template <class T, class S, Endian DNAE>
static std::enable_if_t<!std::is_same_v<T, bool>> Do(const PropId& id, std::vector<T>& vector, const S& count, static std::enable_if_t<!std::is_same_v<T, bool>> Do(const PropId& id, std::vector<T>& vector, const S& count,
StreamT& s) { StreamT& s) {
for (T& v : vector) for (T& v : vector) {
BinarySize<PropOp>::Do<T, DNAE>(id, v, s); BinarySize<PropOp>::template Do<T, DNAE>(id, v, s);
}
} }
template <class T, class S, Endian DNAE> template <class T, class S, Endian DNAE>
static std::enable_if_t<std::is_same_v<T, bool>> Do(const PropId& id, std::vector<T>& vector, const S& count, static std::enable_if_t<std::is_same_v<T, bool>> Do(const PropId& id, std::vector<T>& vector, const S& count,
@ -255,7 +257,7 @@ struct PropCount {
} }
template <class T, Endian DNAE> template <class T, Endian DNAE>
static void DoSize(const PropId& id, T& var, StreamT& s) { static void DoSize(const PropId& id, T& var, StreamT& s) {
PropCount<PropOp>::Do<T, DNAE>(id, var, s); PropCount<PropOp>::template Do<T, DNAE>(id, var, s);
} }
template <class T, class S, Endian DNAE> template <class T, class S, Endian DNAE>
static void Do(const PropId& id, std::vector<T>& vector, const S& count, StreamT& s) { static void Do(const PropId& id, std::vector<T>& vector, const S& count, StreamT& s) {
@ -327,12 +329,13 @@ struct Read {
} }
template <class T, Endian DNAE> template <class T, Endian DNAE>
static std::enable_if_t<std::is_array_v<T>> Do(const PropId& id, T& var, StreamT& s) { static std::enable_if_t<std::is_array_v<T>> Do(const PropId& id, T& var, StreamT& s) {
for (auto& v : var) for (auto& v : var) {
Read<PropOp>::Do<std::remove_reference_t<decltype(v)>, DNAE>(id, v, s); Read<PropOp>::template Do<std::remove_reference_t<decltype(v)>, DNAE>(id, v, s);
}
} }
template <class T, Endian DNAE> template <class T, Endian DNAE>
static void DoSize(const PropId& id, T& var, StreamT& s) { static void DoSize(const PropId& id, T& var, StreamT& s) {
Read<PropOp>::Do<T, DNAE>(id, var, s); Read<PropOp>::template Do<T, DNAE>(id, var, s);
} }
template <class T, class S, Endian DNAE> template <class T, class S, Endian DNAE>
static std::enable_if_t<!std::is_same_v<T, bool>> Do(const PropId& id, std::vector<T>& vector, const S& count, static std::enable_if_t<!std::is_same_v<T, bool>> Do(const PropId& id, std::vector<T>& vector, const S& count,
@ -341,7 +344,7 @@ struct Read {
vector.reserve(count); vector.reserve(count);
for (size_t i = 0; i < static_cast<size_t>(count); ++i) { for (size_t i = 0; i < static_cast<size_t>(count); ++i) {
vector.emplace_back(); vector.emplace_back();
Read<PropOp>::Do<T, DNAE>(id, vector.back(), r); Read<PropOp>::template Do<T, DNAE>(id, vector.back(), r);
} }
} }
template <class T, class S, Endian DNAE> template <class T, class S, Endian DNAE>
@ -483,18 +486,20 @@ struct Write {
} }
template <class T, Endian DNAE> template <class T, Endian DNAE>
static std::enable_if_t<std::is_array_v<T>> Do(const PropId& id, T& var, StreamT& s) { static std::enable_if_t<std::is_array_v<T>> Do(const PropId& id, T& var, StreamT& s) {
for (auto& v : var) for (auto& v : var) {
Write<PropOp>::Do<std::remove_reference_t<decltype(v)>, DNAE>(id, v, s); Write<PropOp>::template Do<std::remove_reference_t<decltype(v)>, DNAE>(id, v, s);
}
} }
template <class T, Endian DNAE> template <class T, Endian DNAE>
static void DoSize(const PropId& id, T& var, StreamT& s) { static void DoSize(const PropId& id, T& var, StreamT& s) {
Write<PropOp>::Do<T, DNAE>(id, var, s); Write<PropOp>::template Do<T, DNAE>(id, var, s);
} }
template <class T, class S, Endian DNAE> template <class T, class S, Endian DNAE>
static std::enable_if_t<!std::is_same_v<T, bool>> Do(const PropId& id, std::vector<T>& vector, const S& count, static std::enable_if_t<!std::is_same_v<T, bool>> Do(const PropId& id, std::vector<T>& vector, const S& count,
StreamT& w) { StreamT& w) {
for (T& v : vector) for (T& v : vector) {
Write<PropOp>::Do<T, DNAE>(id, v, w); Write<PropOp>::template Do<T, DNAE>(id, v, w);
}
} }
template <class T, class S, Endian DNAE> template <class T, class S, Endian DNAE>
static std::enable_if_t<std::is_same_v<T, bool>> Do(const PropId& id, std::vector<T>& vector, const S& count, static std::enable_if_t<std::is_same_v<T, bool>> Do(const PropId& id, std::vector<T>& vector, const S& count,
@ -596,9 +601,11 @@ struct ReadYaml {
template <class T, Endian DNAE> template <class T, Endian DNAE>
static std::enable_if_t<std::is_array_v<T>> Do(const PropId& id, T& var, StreamT& r) { static std::enable_if_t<std::is_array_v<T>> Do(const PropId& id, T& var, StreamT& r) {
size_t _count; size_t _count;
if (auto __v = r.enterSubVector(id.name, _count)) if (auto __v = r.enterSubVector(id.name, _count)) {
for (size_t i = 0; i < _count && i < std::extent_v<T>; ++i) for (size_t i = 0; i < _count && i < std::extent_v<T>; ++i) {
ReadYaml<PropOp>::Do<std::remove_reference_t<decltype(var[i])>, DNAE>({}, var[i], r); ReadYaml<PropOp>::template Do<std::remove_reference_t<decltype(var[i])>, DNAE>({}, var[i], r);
}
}
} }
template <class T, Endian DNAE> template <class T, Endian DNAE>
static void DoSize(const PropId& id, T& var, StreamT& s) { static void DoSize(const PropId& id, T& var, StreamT& s) {
@ -613,7 +620,7 @@ struct ReadYaml {
vector.reserve(_count); vector.reserve(_count);
for (size_t i = 0; i < _count; ++i) { for (size_t i = 0; i < _count; ++i) {
vector.emplace_back(); vector.emplace_back();
ReadYaml<PropOp>::Do<T, DNAE>({}, vector.back(), r); ReadYaml<PropOp>::template Do<T, DNAE>({}, vector.back(), r);
} }
} }
/* Horrible reference abuse (but it works) */ /* Horrible reference abuse (but it works) */
@ -712,9 +719,11 @@ struct WriteYaml {
} }
template <class T, Endian DNAE> template <class T, Endian DNAE>
static std::enable_if_t<std::is_array_v<T>> Do(const PropId& id, T& var, StreamT& w) { static std::enable_if_t<std::is_array_v<T>> Do(const PropId& id, T& var, StreamT& w) {
if (auto __v = w.enterSubVector(id.name)) if (auto __v = w.enterSubVector(id.name)) {
for (auto& v : var) for (auto& v : var) {
WriteYaml<PropOp>::Do<std::remove_reference_t<decltype(v)>, DNAE>({}, v, w); WriteYaml<PropOp>::template Do<std::remove_reference_t<decltype(v)>, DNAE>({}, v, w);
}
}
} }
template <class T, Endian DNAE> template <class T, Endian DNAE>
static void DoSize(const PropId& id, T& var, StreamT& s) { static void DoSize(const PropId& id, T& var, StreamT& s) {
@ -723,9 +732,11 @@ struct WriteYaml {
template <class T, class S, Endian DNAE> template <class T, class S, Endian DNAE>
static std::enable_if_t<!std::is_same_v<T, bool>> Do(const PropId& id, std::vector<T>& vector, const S& count, static std::enable_if_t<!std::is_same_v<T, bool>> Do(const PropId& id, std::vector<T>& vector, const S& count,
StreamT& w) { StreamT& w) {
if (auto __v = w.enterSubVector(id.name)) if (auto __v = w.enterSubVector(id.name)) {
for (T& v : vector) for (T& v : vector) {
WriteYaml<PropOp>::Do<T, DNAE>(id, v, w); WriteYaml<PropOp>::template Do<T, DNAE>(id, v, w);
}
}
} }
template <class T, class S, Endian DNAE> template <class T, class S, Endian DNAE>
static std::enable_if_t<std::is_same_v<T, bool>> Do(const PropId& id, std::vector<T>& vector, const S& count, static std::enable_if_t<std::is_same_v<T, bool>> Do(const PropId& id, std::vector<T>& vector, const S& count,