Skip to content

Commit b253ab1

Browse files
committed
changes to the typesafe ID class
1 parent aeb4fb0 commit b253ab1

File tree

3 files changed

+8
-13
lines changed

3 files changed

+8
-13
lines changed

inc/osvr/Common/SerializationTraits.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ namespace common {
516516
struct SimpleStructSerialization<StringID>
517517
: SimpleStructSerializationBase {
518518
template <typename F, typename T> static void apply(F &f, T &val) {
519-
f(val.m_val);
519+
f(val.value());
520520
}
521521
};
522522

inc/osvr/Util/ID.h

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,16 @@ template <class Tag, class impl> class ID {
4848
// Explicit constructor:
4949
explicit ID(impl val) : m_val(val) {}
5050

51-
// Explicit conversion to get back the impl:
52-
// explicit operator impl() const { return m_val; }
53-
54-
// Implicit conversion to get back the impl
55-
operator impl() const { return m_val; }
56-
5751
bool empty() const { return m_val == 0xffffffff ? true : false; }
5852

59-
// this messes with implicit conversion (type casting)
60-
/*
61-
friend bool operator>(ID a, impl b) { return a.m_val > b; }
62-
friend bool operator<(ID a, impl b) { return a.m_val < b; }
53+
operator impl & () {return m_val; }
6354
friend bool operator==(ID a, ID b) { return a.m_val == b.m_val; }
6455
friend bool operator!=(ID a, ID b) { return a.m_val != b.m_val; }
65-
*/
56+
57+
impl& value() { return m_val; }
58+
impl value() const { return m_val; }
59+
60+
private:
6661
impl m_val;
6762
};
6863

src/osvr/Common/RegisteredStringMap.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ namespace common {
6060

6161
for (auto &entry : m_regEntries) {
6262

63-
serializedMap[entry.first] = entry.second.m_val;
63+
serializedMap[entry.first] = entry.second.value();
6464
}
6565
return serializedMap;
6666
}

0 commit comments

Comments
 (0)