diff --git a/Makefile.simple b/Makefile.simple index 8a78314a..491c766d 100644 --- a/Makefile.simple +++ b/Makefile.simple @@ -99,7 +99,6 @@ ifeq (${TOOLCHAIN},gcc46) CXXFLAGS_EARLY += -std=c++0x CXXFLAGS_EARLY += -W -Wall -Wextra -Werror CXXFLAGS_EARLY += -Wno-missing-field-initializers -Wno-unused-parameter - CXXFLAGS_EARLY += -DUSE_STDFUNCTION=1 endif ifeq (${TOOLCHAIN},mingw) diff --git a/hyper_function.h b/hyper_function.h index 97a71d18..3e4c5ddd 100644 --- a/hyper_function.h +++ b/hyper_function.h @@ -1,67 +1,54 @@ #pragma once -#if USE_STDFUNCTION - -#include -namespace hr { - using std::function; -} // namespace hr - -#else - #include #include namespace hr { template -class hyper_function; - -template -using function = hyper_function; +class function; template -struct hyper_function_state_base { +struct function_state_base { virtual R call(Args...) const = 0; - virtual hyper_function_state_base *clone() const = 0; - virtual ~hyper_function_state_base() = default; + virtual function_state_base *clone() const = 0; + virtual ~function_state_base() {} }; template -struct hyper_function_state : hyper_function_state_base { - using Self = hyper_function_state; +struct function_state : function_state_base { T t_; - explicit hyper_function_state(T t) : t_(std::move(t)) {} - R call(Args... args) const override { + explicit function_state(T t) : t_(std::move(t)) {} + R call(Args... args) const /*override*/ { return const_cast(t_)(static_cast(args)...); } - hyper_function_state_base *clone() const override { - return new Self(*this); + function_state_base *clone() const /*override*/ { + return new function_state(*this); } }; template -class hyper_function +class function { - hyper_function_state_base *ptr_ = nullptr; + function_state_base *ptr_; public: - hyper_function() = default; + function() : ptr_(nullptr) {} template::type>()(std::declval()...)))> - hyper_function(Callable&& t) : - ptr_(new hyper_function_state::type, R, Args...>(static_cast(t))) + function(Callable&& t) : + ptr_(new function_state::type, R, Args...>(static_cast(t))) {} - ~hyper_function() { + ~function() { delete ptr_; } - hyper_function(hyper_function& rhs) : ptr_(rhs.ptr_ ? rhs.ptr_->clone() : nullptr) {} - hyper_function(const hyper_function& rhs) : ptr_(rhs.ptr_ ? rhs.ptr_->clone() : nullptr) {} - hyper_function(hyper_function&& rhs) noexcept : ptr_(rhs.ptr_) { rhs.ptr_ = nullptr; } - hyper_function(const hyper_function&& rhs) = delete; + function(function& rhs) : ptr_(rhs.ptr_ ? rhs.ptr_->clone() : nullptr) {} + function(const function& rhs) : ptr_(rhs.ptr_ ? rhs.ptr_->clone() : nullptr) {} + function(function&& rhs) noexcept : ptr_(rhs.ptr_) { rhs.ptr_ = nullptr; } + function(const function&& rhs) = delete; - void operator=(hyper_function rhs) noexcept { + void operator=(function rhs) noexcept { std::swap(ptr_, rhs.ptr_); } @@ -75,5 +62,3 @@ public: }; } // namespace hr - -#endif diff --git a/sysconfig.h b/sysconfig.h index 67c630c9..e8bd2eef 100644 --- a/sysconfig.h +++ b/sysconfig.h @@ -72,10 +72,6 @@ #define NOLICENSE ISSTEAM #endif -#ifndef USE_STDFUNCTION -#define USE_STDFUNCTION ISSTEAM -#endif - #ifndef CAP_SHADER #define CAP_SHADER CAP_GL #endif