You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@geode.apache.org by "David Kimura (JIRA)" <ji...@apache.org> on 2017/11/13 20:49:00 UTC
[jira] [Created] (GEODE-3972) Disambiguate the Region interface
template resolutions
David Kimura created GEODE-3972:
-----------------------------------
Summary: Disambiguate the Region interface template resolutions
Key: GEODE-3972
URL: https://issues.apache.org/jira/browse/GEODE-3972
Project: Geode
Issue Type: Improvement
Components: native client
Reporter: David Kimura
Region interface has unintuitive template type resolution. For example: {{Region::put}} has following signatures:
{noformat}
virtual void put(const CacheableKeyPtr& key, const CacheablePtr& value, const SerializablePtr& aCallbackArgument = nullptr) = 0;
template <class KEYTYPE, class VALUETYPE>
inline void put(const KEYTYPE& key, const VALUETYPE& value, const SerializablePtr& arg = nullptr) {
put(createKey(key), createValue(value), arg);
}
template <class KEYTYPE>
inline void put(const KEYTYPE& key, const CacheablePtr& value, const SerializablePtr& arg = nullptr) {
put(createKey(key), value, arg);
}
template <class VALUETYPE>
inline void put(const CacheableKeyPtr& key, const VALUETYPE& value, const SerializablePtr& arg = nullptr) {
put(key, createValue(value), arg);
}
{noformat}
If user calls {{region.put(a_key, CacheableString::create("a_value"), ...)}} they might expect it to call non-templated put since CacheableString derives from Cacheable. Instead it seems to call the templated method. Ideally, we should probably have our API match non-templated method signature in this particular case.
One solution may be to use type traits. So, template signature on put interface may look something like:
{noformat}
template <class KEYTYPE, class VALUETYPE>
inline void put(
const typename std::enable_if<is_integral_or_char_ptr<KEYTYPE>::value>::type& key = 0,
const typename std::enable_if<is_integral_or_char_ptr<VALUETYPE>::value>::type& value = 0,
const SerializablePtr& arg = nullptr) {
{noformat}
And then implement {{is_integral_or_char_ptr}}. We should then evaluate whether {{createValue}} and {{createKey}} templates are needed any longer.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)