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 <typename T>
 struct has_begin_end
 {
-  template<typename C> static char (&f(typename std::enable_if <
-                                       std::is_same<decltype(static_cast<typename C::const_iterator(C::*)() const>(&C::begin)),
-                                       typename C::const_iterator(C::*)() const>::value, void >::type *))[1];
+  struct Dummy { typedef void const_iterator; };
+  typedef typename std::conditional<has_const_iterator<T>::value, T, Dummy>::type TType;
+  typedef typename TType::const_iterator iter;
 
-  template<typename C> static char (&f(...))[2];
+  struct Fallback { iter begin() const; iter end() const; };
+  struct Derived : TType, Fallback { };
 
-  template<typename C> static char (&g(typename std::enable_if <
-                                       std::is_same<decltype(static_cast<typename C::const_iterator(C::*)() const>(&C::end)),
-                                       typename C::const_iterator(C::*)() const>::value, void >::type *))[1];
+  template<typename C, C> struct ChT;
 
+  template<typename C> static char (&f(ChT<iter (Fallback::*)() const, &C::begin>*))[1];
+  template<typename C> static char (&f(...))[2];
+  template<typename C> static char (&g(ChT<iter (Fallback::*)() const, &C::end>*))[1];
   template<typename C> static char (&g(...))[2];
 
-  static bool const beg_value = sizeof(f<T>(0)) == 1;
-  static bool const end_value = sizeof(g<T>(0)) == 1;
+  static bool const beg_value = sizeof(f<Derived>(0)) == 2;
+  static bool const end_value = sizeof(g<Derived>(0)) == 2;
 };
 
+
 template<typename T>
 struct is_container_not_string : std::integral_constant < bool, has_const_iterator<T>::value && has_begin_end<T>::beg_value && has_begin_end<T>::end_value >
 { };
