diff options
author | Norbert Preining <norbert@preining.info> | 2023-06-08 03:01:59 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2023-06-08 03:01:59 +0000 |
commit | 538e6d6e7c75b7cca5470604811205f9dbd55c03 (patch) | |
tree | 4807afb694acc9e4ecff2d466d5e37788127d6fb /graphics/asymptote/LspCpp/include/LibLsp/JsonRpc | |
parent | 5c99135c06494b236cce7fd76e346851cf8c4408 (diff) |
CTAN sync 202306080301
Diffstat (limited to 'graphics/asymptote/LspCpp/include/LibLsp/JsonRpc')
3 files changed, 25 insertions, 17 deletions
diff --git a/graphics/asymptote/LspCpp/include/LibLsp/JsonRpc/optionalVersion.h b/graphics/asymptote/LspCpp/include/LibLsp/JsonRpc/optionalVersion.h new file mode 100644 index 0000000000..f767b18f90 --- /dev/null +++ b/graphics/asymptote/LspCpp/include/LibLsp/JsonRpc/optionalVersion.h @@ -0,0 +1,13 @@ +#ifndef boost +#if __cplusplus < 201703L + +#include <boost/optional.hpp> +using boost::optional; + +#else + +#include <optional> +using std::optional; + +#endif +#endif diff --git a/graphics/asymptote/LspCpp/include/LibLsp/JsonRpc/serializer.h b/graphics/asymptote/LspCpp/include/LibLsp/JsonRpc/serializer.h index 477c822845..1763c84f5f 100644 --- a/graphics/asymptote/LspCpp/include/LibLsp/JsonRpc/serializer.h +++ b/graphics/asymptote/LspCpp/include/LibLsp/JsonRpc/serializer.h @@ -1,11 +1,6 @@ #pragma once #include "macro_map.h" -#ifdef boost -#include "optional.hpp" -#else -#include <boost/optional.hpp> -#endif #include <cassert> #include <memory> @@ -16,6 +11,7 @@ #include <map> #include <algorithm> +#include "optionalVersion.h" struct AbsolutePath; @@ -205,9 +201,8 @@ void Reflect(Reader& visitor, SerializeFormat& value); void Reflect(Writer& visitor, SerializeFormat& value); //// Type constructors - template <typename T> -void Reflect(Reader& visitor, boost::optional<T>& value) { +void Reflect(Reader& visitor, optional<T>& value) { if (visitor.IsNull()) { visitor.GetNull(); return; @@ -217,7 +212,7 @@ void Reflect(Reader& visitor, boost::optional<T>& value) { value = std::move(real_value); } template <typename T> -void Reflect(Writer& visitor, boost::optional<T>& value) { +void Reflect(Writer& visitor, optional<T>& value) { if (value) Reflect(visitor, *value); else @@ -226,7 +221,7 @@ void Reflect(Writer& visitor, boost::optional<T>& value) { template <typename T> -void ReflectMember(Writer& visitor, const char* name, boost::optional<T>& value) { +void ReflectMember(Writer& visitor, const char* name, optional<T>& value) { // For TypeScript optional property key?: value in the spec, // We omit both key and value if value is std::nullopt (null) for JsonWriter // to reduce output. But keep it for other serialization formats. @@ -237,7 +232,6 @@ void ReflectMember(Writer& visitor, const char* name, boost::optional<T>& value) } - template <typename T> void ReflectMember(Writer& visitor, const char* name, @@ -329,7 +323,7 @@ void ReflectMember(Writer& visitor, const char* name, T& value) { } template<class _Ty1, class _Ty2> -void Reflect(Writer& visitor, std::pair< boost::optional<_Ty1>, boost::optional<_Ty2> >& value) +void Reflect(Writer& visitor, std::pair< optional<_Ty1>, optional<_Ty2> >& value) { if (value.first) { @@ -341,7 +335,7 @@ void Reflect(Writer& visitor, std::pair< boost::optional<_Ty1>, boost::optional } } template<class _Ty2> -void Reflect(Reader& visitor, std::pair< boost::optional<bool>, boost::optional<_Ty2> >& value) +void Reflect(Reader& visitor, std::pair< optional<bool>, optional<_Ty2> >& value) { if(visitor.IsBool()) { @@ -352,7 +346,7 @@ void Reflect(Reader& visitor, std::pair< boost::optional<bool>, boost::optional Reflect(visitor, value.second); } template<class _Ty2> -void Reflect(Reader& visitor, std::pair< boost::optional<std::string>, boost::optional<_Ty2> >& value) +void Reflect(Reader& visitor, std::pair< optional<std::string>, optional<_Ty2> >& value) { if (visitor.IsString()) { @@ -365,7 +359,7 @@ void Reflect(Reader& visitor, std::pair< boost::optional<std::string>, boost::o template<class _Ty1, class _Ty2> -void Reflect(Reader& visitor, std::pair< boost::optional<_Ty1>, boost::optional<_Ty2> >& value) +void Reflect(Reader& visitor, std::pair< optional<_Ty1>, optional<_Ty2> >& value) { try { diff --git a/graphics/asymptote/LspCpp/include/LibLsp/JsonRpc/threaded_queue.h b/graphics/asymptote/LspCpp/include/LibLsp/JsonRpc/threaded_queue.h index 3e1ba547ca..e8fc6d13ea 100644 --- a/graphics/asymptote/LspCpp/include/LibLsp/JsonRpc/threaded_queue.h +++ b/graphics/asymptote/LspCpp/include/LibLsp/JsonRpc/threaded_queue.h @@ -1,6 +1,6 @@ #pragma once -#include <boost/optional/optional.hpp> +#include <optional> #include <algorithm> #include <atomic> #include <condition_variable> @@ -11,6 +11,7 @@ #include <utility> #include <vector> +#include "optionalVersion.h" struct MultiQueueWaiter; @@ -156,7 +157,7 @@ struct ThreadedQueue : public BaseThreadQueue { // Get the first element from the queue without blocking. Returns a null // value if the queue is empty. - boost::optional<T> TryDequeue(bool priority) { + optional<T> TryDequeue(bool priority) { std::lock_guard<std::mutex> lock(mutex); auto pop = [&](std::deque<T>* q) { @@ -167,7 +168,7 @@ struct ThreadedQueue : public BaseThreadQueue { }; auto get_result = [&](std::deque<T>* first, - std::deque<T>* second) -> boost::optional<T> { + std::deque<T>* second) -> optional<T> { if (!first->empty()) return pop(first); if (!second->empty()) |