Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 207d415

Browse filesBrowse files
GeoffHadlingtonappkins
authored andcommitted
Bugfix for C++17 (#9)
Bracket operator of struct 'optional' has been replaced with a standard constructor. logger.hpp inclusion in reply.cpp. Change of optional to optional_t where struct used. enableIf template added to C++ branching in optional.hpp
1 parent fbfc245 commit 207d415
Copy full SHA for 207d415

File tree

4 files changed

+18
-12
lines changed
Filter options

4 files changed

+18
-12
lines changed

‎includes/cpp_redis/core/reply.hpp

Copy file name to clipboardExpand all lines: includes/cpp_redis/core/reply.hpp
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ namespace cpp_redis {
195195
explicit operator bool() const;
196196

197197
public:
198-
optional<int64_t> try_get_int() const;
198+
optional_t<int64_t> try_get_int() const;
199199

200200
public:
201201
/**

‎includes/cpp_redis/misc/convert.hpp

Copy file name to clipboardExpand all lines: includes/cpp_redis/misc/convert.hpp
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ namespace cpp_redis {
3030
class try_convert {
3131
public:
3232
template <class T>
33-
static enableIf<std::is_convertible<T, std::string>::value, optional<int64_t> > to_int(T value) {
33+
static enableIf<std::is_convertible<T, std::string>::value, optional_t<int64_t> > to_int(T value) {
3434
try {
3535
std::stringstream stream(value);
3636
int64_t x;
3737
stream >> x;
38-
return optional<int64_t>()(x);
38+
return optional_t<int64_t>(x);
3939
} catch (std::exception &exc) {
4040
return {};
4141
}

‎includes/cpp_redis/misc/optional.hpp

Copy file name to clipboardExpand all lines: includes/cpp_redis/misc/optional.hpp
+10-5Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,12 @@
2828
#if __cplusplus >= 201703L
2929
#include <optional>
3030

31+
namespace cpp_redis {
3132
template <class T>
3233
using optional_t = std::optional<T>;
34+
35+
template <int I, class T>
36+
using enableIf = typename std::enable_if<I, T>::type;
3337
#else
3438

3539
#include <cpp_redis/misc/logger.hpp>
@@ -40,11 +44,12 @@ using enableIf = typename std::enable_if<I, T>::type;
4044

4145
template <class T>
4246
struct optional {
43-
optional<T>&
44-
operator()(T value) {
45-
m_value = value;
46-
return *this;
47-
}
47+
optional(T value) : m_value(value) {}
48+
// optional<T>&
49+
// operator()(T value) {
50+
// m_value = value;
51+
// return *this;
52+
// }
4853

4954
T m_value;
5055

‎sources/core/reply.cpp

Copy file name to clipboardExpand all lines: sources/core/reply.cpp
+5-4Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
#include <cpp_redis/core/reply.hpp>
2424
#include <cpp_redis/misc/error.hpp>
25+
#include <cpp_redis/misc/logger.hpp>
2526

2627
namespace cpp_redis {
2728

@@ -45,12 +46,12 @@ namespace cpp_redis {
4546
m_int_val = other.m_int_val;
4647
}
4748

48-
optional<int64_t> reply::try_get_int() const {
49+
optional_t<int64_t> reply::try_get_int() const {
4950
if (is_integer())
50-
return optional<int64_t>()(m_int_val);
51+
return optional_t<int64_t>(m_int_val);
5152

52-
__CPP_REDIS_LOG(1, "Reply is not an integer");
53-
return {};
53+
__CPP_REDIS_LOG(1, "Reply is not an integer");
54+
return {0};
5455
}
5556

5657
reply &

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.