From 4e730ecc7e2461f309659d37cf6f5c78fd70824d Mon Sep 17 00:00:00 2001 From: Peter Schojer Date: Wed, 14 May 2008 06:00:40 +0000 Subject: [PATCH] Fixed constness detection of const char[] arrays --- Data/include/Poco/Data/Binding.h | 6 ++++-- Foundation/include/Poco/MetaProgramming.h | 11 +++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Data/include/Poco/Data/Binding.h b/Data/include/Poco/Data/Binding.h index 58757cb39..a9a4e1240 100644 --- a/Data/include/Poco/Data/Binding.h +++ b/Data/include/Poco/Data/Binding.h @@ -1388,14 +1388,14 @@ template inline Binding* in(T& t, const std::string& name = "") /// Convenience function for a more compact Binding creation. { - return new Binding(t, name, AbstractBinding::PD_IN); + return use(t, name); } inline Binding* in(const NullData& t, const std::string& name = "") /// NullData overload. { - return new Binding(const_cast(t), name, AbstractBinding::PD_IN); + return use(t, name); } @@ -1403,6 +1403,7 @@ template inline Binding* out(T& t) /// Convenience function for a more compact Binding creation. { + poco_static_assert (!IsConst::VALUE); return new Binding(t, "", AbstractBinding::PD_OUT); } @@ -1411,6 +1412,7 @@ template inline Binding* io(T& t) /// Convenience function for a more compact Binding creation. { + poco_static_assert (!IsConst::VALUE); return new Binding(t, "", AbstractBinding::PD_IN_OUT); } diff --git a/Foundation/include/Poco/MetaProgramming.h b/Foundation/include/Poco/MetaProgramming.h index 1a9a41ae0..f8d34cba8 100644 --- a/Foundation/include/Poco/MetaProgramming.h +++ b/Foundation/include/Poco/MetaProgramming.h @@ -109,6 +109,17 @@ struct IsConst }; +template +struct IsConst + /// Specialization for const char arrays +{ + enum + { + VALUE = 1 + }; +}; + + template struct TypeWrapper /// Use the type wrapper if you want to dedecouple constness and references from template types