Skip to content

Commit

Permalink
Vutils
Browse files Browse the repository at this point in the history
  • Loading branch information
vic4key committed Oct 30, 2023
1 parent cc0b5e2 commit 46707ac
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Test/Sample.RESTClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ DEF_SAMPLE(RESTClient)
std::cout << response.text << std::endl;

// create one
rest_client.post(ts("/api/v1/customers"), response, R"({"name":"name 5","phone":"phone 5"})", header);
rest_client.post(ts("/api/v1/customers"), response, "{\"name\":\"name 5\",\"phone\":\"phone 5\"}", header);
std::cout << vu::decode_const_http_status_A(response.status) << std::endl;
std::cout << response.text << std::endl;

Expand All @@ -33,7 +33,7 @@ DEF_SAMPLE(RESTClient)
std::cout << response.text << std::endl;

// update one
rest_client.put(ts("/api/v1/customers/5"), response, R"({"name":"name 5-x","phone":"phone 5-x"})", header);
rest_client.put(ts("/api/v1/customers/5"), response, "{\"name\":\"name 5-x\",\"phone\":\"phone 5-x\"}", header);
std::cout << vu::decode_const_http_status_A(response.status) << std::endl;
std::cout << response.text << std::endl;

Expand Down
8 changes: 7 additions & 1 deletion Test/Sample.String.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,13 @@ DEF_SAMPLE(String)
}
}

std::vector<std::tstring> strings = { ts("ape"), ts("apple"), ts("peach"), ts("puppy") };
std::vector<std::tstring> strings;
{
strings.push_back(ts("ape"));
strings.push_back(ts("apple"));
strings.push_back(ts("peach"));
strings.push_back(ts("puppy"));
}
auto closest_string = vu::find_closest_string(ts("aple"), strings);
assert(closest_string == ts("apple"));

Expand Down
5 changes: 3 additions & 2 deletions include/Vutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -3296,12 +3296,13 @@ class ThreadPool
* Scoped_<handle>
*/

#if defined(_MSC_VER)
// C++14 (MSVC 2015+ or MinGW 5.1+)
#if (defined(_MSC_VER) && _MSC_VER >= 1900) || (defined(__MINGW32__) && __cplusplus >= 201402L)
#include "template/handle.tpl"
ScopedHandleT_Define(HANDLE, HANDLE, INVALID_HANDLE_VALUE, { CloseHandle(h); });
ScopedHandleT_Define(NULL_HANDLE, HANDLE, nullptr, { CloseHandle(h); });
ScopedHandleT_Define(FILE, FILE*, nullptr, { fclose(h); });
#endif // _MSC_VER
#endif

/**
* Path
Expand Down
3 changes: 3 additions & 0 deletions include/template/singleton.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,13 @@ public:
}
}

// C++14 (MSVC 2013+ or MinGW 4.6+)
#if (defined(_MSC_VER) && _MSC_VER >= 1800) || (defined(__MINGW32__) && __cplusplus >= 201103L)
SingletonT(SingletonT&&) = delete;
SingletonT(SingletonT const&) = delete;
SingletonT& operator=(SingletonT&&) = delete;
SingletonT& operator=(SingletonT const&) = delete;
#endif

static T& instance()
{
Expand Down
2 changes: 1 addition & 1 deletion src/details/strfmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ std::unique_ptr<byte[]> VariantT<T>::to_bytes() const
}

std::unique_ptr<byte[]> result(new byte[bytes.size()]);
std::move(bytes.cbegin(), bytes.cend(), result.get());
for (size_t i = 0; i < bytes.size(); i++) result.get()[i] = bytes[i]; // std::move(bytes.cbegin(), bytes.cend(), result.get());
return result;
}

Expand Down

0 comments on commit 46707ac

Please sign in to comment.