فهرست منبع

Fixed constness detection of const char[] arrays

Peter Schojer 18 سال پیش
والد
کامیت
4e730ecc7e
2فایلهای تغییر یافته به همراه15 افزوده شده و 2 حذف شده
  1. 4 2
      Data/include/Poco/Data/Binding.h
  2. 11 0
      Foundation/include/Poco/MetaProgramming.h

+ 4 - 2
Data/include/Poco/Data/Binding.h

@@ -1388,14 +1388,14 @@ template <typename T>
 inline Binding<T>* in(T& t, const std::string& name = "")
 	/// Convenience function for a more compact Binding creation.
 {
-	return new Binding<T>(t, name, AbstractBinding::PD_IN);
+	return use(t, name);
 }
 
 
 inline Binding<NullData>* in(const NullData& t, const std::string& name = "")
 	/// NullData overload.
 {
-	return new Binding<NullData>(const_cast<NullData&>(t), name, AbstractBinding::PD_IN);
+	return use(t, name);
 }
 
 
@@ -1403,6 +1403,7 @@ template <typename T>
 inline Binding<T>* out(T& t)
 	/// Convenience function for a more compact Binding creation.
 {
+	poco_static_assert (!IsConst<T>::VALUE);
 	return new Binding<T>(t, "", AbstractBinding::PD_OUT);
 }
 
@@ -1411,6 +1412,7 @@ template <typename T>
 inline Binding<T>* io(T& t)
 	/// Convenience function for a more compact Binding creation.
 {
+	poco_static_assert (!IsConst<T>::VALUE);
 	return new Binding<T>(t, "", AbstractBinding::PD_IN_OUT);
 }
 

+ 11 - 0
Foundation/include/Poco/MetaProgramming.h

@@ -109,6 +109,17 @@ struct IsConst<const T>
 };
 
 
+template <typename T, int i>
+struct IsConst<const T[i]>
+	/// Specialization for const char arrays
+{
+	enum 
+	{
+		VALUE = 1
+	};
+};
+
+
 template <typename T>
 struct TypeWrapper
 	/// Use the type wrapper if you want to dedecouple constness and references from template types