From a3365a9c4af155ae786bd762684d791460a4a477 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Fri, 11 Mar 2016 13:45:01 -0700 Subject: [PATCH] Enable use of shared_mutex now on C++14 --- include/chaiscript/chaiscript_threading.hpp | 23 ++++++--------------- include/chaiscript/dispatchkit/any.hpp | 17 ++++++--------- 2 files changed, 12 insertions(+), 28 deletions(-) diff --git a/include/chaiscript/chaiscript_threading.hpp b/include/chaiscript/chaiscript_threading.hpp index 2a0e63c..126edb9 100644 --- a/include/chaiscript/chaiscript_threading.hpp +++ b/include/chaiscript/chaiscript_threading.hpp @@ -13,6 +13,7 @@ #ifndef CHAISCRIPT_NO_THREADS #include #include +#include #else #ifndef CHAISCRIPT_NO_THREADS_WARNING #pragma message ("ChaiScript is compiling without thread safety.") @@ -42,28 +43,16 @@ namespace chaiscript #ifndef CHAISCRIPT_NO_THREADS template - class unique_lock : public std::unique_lock - { - public: - explicit unique_lock(T &t) : std::unique_lock(t) {} - }; + using unique_lock = std::unique_lock; template - class shared_lock : public std::unique_lock - { - public: - explicit shared_lock(T &t) : std::unique_lock(t) {} - void unlock() {} - }; + using shared_lock = std::shared_lock; template - class lock_guard : public std::lock_guard - { - public: - explicit lock_guard(T &t) : std::lock_guard(t) {} - }; + using lock_guard = std::lock_guard; - class shared_mutex : public std::mutex { }; + + using shared_mutex = std::shared_timed_mutex; using std::mutex; diff --git a/include/chaiscript/dispatchkit/any.hpp b/include/chaiscript/dispatchkit/any.hpp index c9b62a1..e492031 100644 --- a/include/chaiscript/dispatchkit/any.hpp +++ b/include/chaiscript/dispatchkit/any.hpp @@ -28,10 +28,10 @@ namespace chaiscript { bad_any_cast(const bad_any_cast &) = default; - virtual ~bad_any_cast() noexcept {} + ~bad_any_cast() noexcept override = default; /// \brief Description of what error occurred - virtual const char * what() const noexcept override + const char * what() const noexcept override { return m_what.c_str(); } @@ -53,9 +53,10 @@ namespace chaiscript { Data &operator=(const Data &) = delete; - virtual ~Data() {} + virtual ~Data() = default; virtual void *data() = 0; + const std::type_info &type() const { return m_type; @@ -74,8 +75,6 @@ namespace chaiscript { { } - virtual ~Data_Impl() {} - virtual void *data() override { return &m_data; @@ -96,6 +95,8 @@ namespace chaiscript { public: // construct/copy/destruct Any() = default; + Any(Any &&) = default; + Any &operator=(Any &&t_any) = default; Any(const Any &t_any) { @@ -107,8 +108,6 @@ namespace chaiscript { } } - Any(Any &&) = default; - Any &operator=(Any &&t_any) = default; template::type>::value>::type> @@ -137,10 +136,6 @@ namespace chaiscript { } - ~Any() - { - } - // modifiers Any & swap(Any &t_other) {