You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@geode.apache.org by "Ernest Burghardt (Jira)" <ji...@apache.org> on 2022/02/24 21:14:00 UTC

[jira] [Closed] (GEODE-3972) Disambiguate the Region interface template resolutions

     [ https://issues.apache.org/jira/browse/GEODE-3972?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ernest Burghardt closed GEODE-3972.
-----------------------------------

> 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
>            Priority: Major
>
> 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
(v8.20.1#820001)