diff --git a/include/opc/ua/protocol/variant.h b/include/opc/ua/protocol/variant.h index 9dc5b15..317cb17 100644 --- a/include/opc/ua/protocol/variant.h +++ b/include/opc/ua/protocol/variant.h @@ -76,22 +76,25 @@ public: template struct has_begin_end { - template static char (&f(typename std::enable_if < - std::is_same(&C::begin)), - typename C::const_iterator(C::*)() const>::value, void >::type *))[1]; + struct Dummy { typedef void const_iterator; }; + typedef typename std::conditional::value, T, Dummy>::type TType; + typedef typename TType::const_iterator iter; - template static char (&f(...))[2]; + struct Fallback { iter begin() const; iter end() const; }; + struct Derived : TType, Fallback { }; - template static char (&g(typename std::enable_if < - std::is_same(&C::end)), - typename C::const_iterator(C::*)() const>::value, void >::type *))[1]; + template struct ChT; + template static char (&f(ChT*))[1]; + template static char (&f(...))[2]; + template static char (&g(ChT*))[1]; template static char (&g(...))[2]; - static bool const beg_value = sizeof(f(0)) == 1; - static bool const end_value = sizeof(g(0)) == 1; + static bool const beg_value = sizeof(f(0)) == 2; + static bool const end_value = sizeof(g(0)) == 2; }; + template struct is_container_not_string : std::integral_constant < bool, has_const_iterator::value && has_begin_end::beg_value && has_begin_end::end_value > { };