sewenew/redis-plus-plus

[QUESTION]

mike1821 opened this issue · 4 comments

Describe the problem
Hello I am trying to use the provided ReplyUPtr as a return value for an async interface implementation which I am working on.

m_db_client.command<ReplyUPtr>(command , [this]
            (std::future<ReplyUPtr> &&fut) {    

                try {
                    ...
                }
               catch{
                   ...
               }
          });

However, I am getting the following compilation error.

reply.h:74:17: error: no matching function for call to 'parse(sw::redis::reply::ParseTag<std::unique_ptr<redisReply, sw::redis::ReplyDeleter> >, redisReply&)'
     return parse(ParseTag<T>(), reply);
            ~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/sw/redis++/reply.h:73:10: note: candidate: 'template<class T> T sw::redis::reply::parse(redisReply&)'
 inline T parse(redisReply &reply) {
          ^~~~~
/usr/include/sw/redis++/reply.h:73:10: note:   template argument deduction/substitution failed:
/usr/include/sw/redis++/reply.h:74:17: note:   candidate expects 1 argument, 2 provided
     return parse(ParseTag<T>(), reply);
            ~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/sw/redis++/reply.h:441:3: note: candidate: 'template<class T, typename std::enable_if<sw::redis::IsAssociativeContainer<T>::value, int>::type <anonymous> > T sw::redis::reply::parse(sw::redis::reply::ParseTag<T>, redisReply&)'
 T parse(ParseTag<T>, redisReply &reply) {
   ^~~~~
/usr/include/sw/redis++/reply.h:441:3: note:   template argument deduction/substitution failed:
/usr/include/sw/redis++/reply.h:114:94: error: no type named 'type' in 'struct std::enable_if<false, int>'
 template <typename T, typename std::enable_if<IsAssociativeContainer<T>::value, int>::type = 0>
                                                                              ^

Did someone experienced a similar issue? Is there an example of using ReplyUPtr?

Environment:

  • OS: Rocky linux
  • Compiler: g++ 8.5.0
  • hiredis version: v1.0.0, master]
  • redis-plus-plus version: 1.3.10, master

This is not supported.

Why do you want to parse it as a ReplyUPtr? Normally, you should specify the type you want to parse to. Say the return value is a number, you can parse it to a long long, if it's a completed type, you can parse it to a tuple or variant or STL container.

Regards

Hi, thank you for your reply.

The thing is that the return value is not the same in all cases. The command is processing a LUA script which in some cases might return an integer while on some other it might return a string...

Anyway, I suppose I will have to adapt the scripts in order to use the same return value in all scenarios.

Regards

In that case, you can parse it as a std::variant, if you're using c++17. Check this for detail.

Regards

Much appreciated, I will check this