summaryrefslogtreecommitdiff
path: root/algparam.h
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2015-07-16 17:11:01 -0400
committerJeffrey Walton <noloader@gmail.com>2015-07-16 17:11:01 -0400
commit3a08e02f71905b77ca7852c09c8a1b46f13a8049 (patch)
treeb75bfb3d8d2a384651d54a3b99045c35ea8d4337 /algparam.h
parent06ea2d2952bd7439de53e7bf6d74da334e951162 (diff)
downloadcryptopp-git-3a08e02f71905b77ca7852c09c8a1b46f13a8049.tar.gz
Cleared Issue #5. Thanks to Jonathan Wakely for the patch
Diffstat (limited to 'algparam.h')
-rw-r--r--algparam.h30
1 files changed, 9 insertions, 21 deletions
diff --git a/algparam.h b/algparam.h
index 44e0ff35..894a3540 100644
--- a/algparam.h
+++ b/algparam.h
@@ -29,7 +29,7 @@ public:
}
template <class T> ConstByteArrayParameter(const T &string, bool deepCopy = false)
{
- CRYPTOPP_COMPILE_ASSERT(sizeof(CPP_TYPENAME T::value_type) == 1);
+ CRYPTOPP_COMPILE_ASSERT(sizeof(CPP_TYPENAME T::value_type) == 1);
Assign((const byte *)string.data(), string.size(), deepCopy);
}
@@ -171,18 +171,6 @@ GetValueHelperClass<T, T> GetValueHelper(const T *pObject, const char *name, con
// ********************************************************
-template <class R>
-R Hack_DefaultValueFromConstReferenceType(const R &)
-{
- return R();
-}
-
-template <class R>
-bool Hack_GetValueIntoConstReference(const NameValuePairs &source, const char *name, const R &value)
-{
- return source.GetValue(name, const_cast<R &>(value));
-}
-
template <class T, class BASE>
class AssignFromHelperClass
{
@@ -197,12 +185,12 @@ public:
}
template <class R>
- AssignFromHelperClass & operator()(const char *name, void (T::*pm)(R)) // VC60 workaround: "const R &" here causes compiler error
+ AssignFromHelperClass & operator()(const char *name, void (T::*pm)(const R&))
{
if (!m_done)
{
- R value = Hack_DefaultValueFromConstReferenceType(reinterpret_cast<R>(*(int *)NULL));
- if (!Hack_GetValueIntoConstReference(m_source, name, value))
+ R value;
+ if(!m_source.GetValue(name, value))
throw InvalidArgument(std::string(typeid(T).name()) + ": Missing required parameter '" + name + "'");
(m_pObject->*pm)(value);
}
@@ -210,15 +198,15 @@ public:
}
template <class R, class S>
- AssignFromHelperClass & operator()(const char *name1, const char *name2, void (T::*pm)(R, S)) // VC60 workaround: "const R &" here causes compiler error
+ AssignFromHelperClass & operator()(const char *name1, const char *name2, void (T::*pm)(const R&, const S&))
{
if (!m_done)
{
- R value1 = Hack_DefaultValueFromConstReferenceType(reinterpret_cast<R>(*(int *)NULL));
- if (!Hack_GetValueIntoConstReference(m_source, name1, value1))
+ R value1;
+ if (!m_source.GetValue(name1, value1))
throw InvalidArgument(std::string(typeid(T).name()) + ": Missing required parameter '" + name1 + "'");
- S value2 = Hack_DefaultValueFromConstReferenceType(reinterpret_cast<S>(*(int *)NULL));
- if (!Hack_GetValueIntoConstReference(m_source, name2, value2))
+ S value2;
+ if (!m_source.GetValue(name2, value2))
throw InvalidArgument(std::string(typeid(T).name()) + ": Missing required parameter '" + name2 + "'");
(m_pObject->*pm)(value1, value2);
}