diff options
-rw-r--r-- | include/armnn/Optional.hpp | 51 | ||||
-rw-r--r-- | src/armnn/test/OptionalTest.cpp | 37 |
2 files changed, 1 insertions, 87 deletions
diff --git a/include/armnn/Optional.hpp b/include/armnn/Optional.hpp index e55702d915..cfe0d30610 100644 --- a/include/armnn/Optional.hpp +++ b/include/armnn/Optional.hpp @@ -59,28 +59,6 @@ protected: bool m_HasValue; }; -struct HasGetMemberFunction -{ - template <class T> - static auto Check(T* p) -> decltype(p->get(), std::true_type()); - - template <class T> - static auto Check(...) -> std::false_type; -}; - -// -// Predicate checking for boost::optional compatibility -// -template <typename T> -struct CheckBoostOptionalSignature -{ - using ResultType = decltype(HasGetMemberFunction::Check<T>(0)); - - static constexpr bool Result() { - return std::is_same<std::true_type, ResultType>::value; - } -}; - // // The default implementation is the non-reference case. This // has an unsigned char array for storing the optional value which @@ -107,16 +85,6 @@ public: *this = other; } - // enable construction from types that matches the CheckBoostOptionalSignature - // predicate - template <typename O, - typename = std::enable_if_t<CheckBoostOptionalSignature<O>::Result()>> - OptionalReferenceSwitch(const O& other) - : Base{} - { - *this = other; - } - OptionalReferenceSwitch& operator=(const T& value) { reset(); @@ -141,21 +109,6 @@ public: return *this; } - // enable copying from types that matches the CheckBoostOptionalSignature - // predicate - template <typename O, - typename = std::enable_if_t<CheckBoostOptionalSignature<O>::Result()>> - OptionalReferenceSwitch& operator=(const O& other) - { - reset(); - if (other) - { - Construct(other.get()); - } - - return *this; - } - ~OptionalReferenceSwitch() { reset(); @@ -294,10 +247,6 @@ public: Optional(EmptyOptional empty) : BaseSwitch{empty} {} Optional(const Optional& other) : BaseSwitch{other} {} Optional(const BaseSwitch& other) : BaseSwitch{other} {} - - template <typename O, - typename = std::enable_if_t<CheckBoostOptionalSignature<O>::Result()>> - Optional(const O& other) : BaseSwitch{other} {} }; } diff --git a/src/armnn/test/OptionalTest.cpp b/src/armnn/test/OptionalTest.cpp index a869c7e191..3f4c02d56f 100644 --- a/src/armnn/test/OptionalTest.cpp +++ b/src/armnn/test/OptionalTest.cpp @@ -5,7 +5,6 @@ #include <boost/test/unit_test.hpp> #include <armnn/Optional.hpp> -#include <boost/optional.hpp> #include <string> namespace @@ -19,19 +18,7 @@ void PassStringRefWithDefault(armnn::Optional<std::string&> value = armnn::Empty { } -void BoostCompatibilityTester(const armnn::Optional<std::string>& optionalString, - bool hasValue, - const std::string& expectedValue) -{ - BOOST_TEST(optionalString.has_value() == hasValue); - if (hasValue) - { - BOOST_TEST(optionalString.value() == expectedValue); - } -} - -} - +} // namespace <anonymous> BOOST_AUTO_TEST_SUITE(OptionalTests) @@ -105,28 +92,6 @@ BOOST_AUTO_TEST_CASE(StringRefTests) BOOST_TEST(optionalHelloRef3.value() == "Long Other String"); } -BOOST_AUTO_TEST_CASE(BoostCompatibilityTests) -{ - // sanity checks - BoostCompatibilityTester(armnn::Optional<std::string>(), false, ""); - BoostCompatibilityTester(armnn::Optional<std::string>("Hello World"), true, "Hello World"); - - // verify boost signature selector - BOOST_TEST(armnn::CheckBoostOptionalSignature<boost::optional<std::string>>::Result() == true); - BOOST_TEST(armnn::CheckBoostOptionalSignature<armnn::Optional<std::string>>::Result() == false); - - // the real thing is to see that we can pass a boost::optional in place - // of an ArmNN Optional - boost::optional<std::string> empty; - boost::optional<std::string> helloWorld("Hello World"); - - BoostCompatibilityTester(empty, false, ""); - BoostCompatibilityTester(helloWorld, true, "Hello World"); - - BoostCompatibilityTester(boost::optional<std::string>(), false, ""); - BoostCompatibilityTester(boost::optional<std::string>("Hello World"), true, "Hello World"); -} - BOOST_AUTO_TEST_CASE(SimpleIntTests) { const int intValue = 123; |