Removed potentially unsafe conversion

This commit is contained in:
Daniel Wolf 2016-09-23 21:15:34 +02:00
parent 18aa0f9e20
commit 2fdd98f5b3
2 changed files with 2 additions and 7 deletions

View File

@ -56,11 +56,6 @@ public:
class ReferenceWrapper { class ReferenceWrapper {
public: public:
operator boost::optional<const T&>() const {
auto optional = timeline.get(time);
return optional ? optional->getValue() : boost::optional<const T&>();
}
operator boost::optional<T>() const { operator boost::optional<T>() const {
auto optional = timeline.get(time); auto optional = timeline.get(time);
return optional ? optional->getValue() : boost::optional<T>(); return optional ? optional->getValue() : boost::optional<T>();

View File

@ -222,7 +222,7 @@ void testSetter(std::function<void(const Timed<int>&, Timeline<int>&)> set) {
// Check timeline via indexer // Check timeline via indexer
for (centiseconds t = 0_cs; t < 10_cs; ++t) { for (centiseconds t = 0_cs; t < 10_cs; ++t) {
optional<const int&> actual = timeline[t]; optional<int> actual = timeline[t];
EXPECT_EQ(expectedValues[t.count()], actual ? optional<int>(*actual) : none); EXPECT_EQ(expectedValues[t.count()], actual ? optional<int>(*actual) : none);
} }
@ -268,7 +268,7 @@ TEST(Timeline, indexer_get) {
vector<optional<int>> expectedValues{ none, 1, 2, 2, none, none, 3, 3, 3 }; vector<optional<int>> expectedValues{ none, 1, 2, 2, none, none, 3, 3, 3 };
for (centiseconds t = 0_cs; t < 9_cs; ++t) { for (centiseconds t = 0_cs; t < 9_cs; ++t) {
{ {
optional<const int&> actual = timeline[t]; optional<int> actual = timeline[t];
EXPECT_EQ(expectedValues[t.count()], actual ? optional<int>(*actual) : none); EXPECT_EQ(expectedValues[t.count()], actual ? optional<int>(*actual) : none);
} }
{ {