diff --git a/src/Makefile b/src/Makefile index 74b7bad1..e30c6f2b 100644 --- a/src/Makefile +++ b/src/Makefile @@ -9,7 +9,7 @@ bindir := $(DESTDIR)$(PREFIX)/bin sharedir := $(DESTDIR)$(PREFIX)/share/kak docdir := $(DESTDIR)$(PREFIX)/share/doc/kak -CXXFLAGS += -std=gnu++1y -g -Wall -Wno-reorder -Wno-sign-compare -pedantic +CXXFLAGS += -std=gnu++11 -g -Wall -Wno-reorder -Wno-sign-compare -pedantic ifneq (,$(findstring CYGWIN,$(os))) LDFLAGS += -rdynamic endif diff --git a/src/client_manager.cc b/src/client_manager.cc index edb3251e..ecade79c 100644 --- a/src/client_manager.cc +++ b/src/client_manager.cc @@ -84,7 +84,7 @@ WindowAndSelections ClientManager::get_free_window(Buffer& buffer) { return &ws.window->buffer() == &buffer; }); if (it == m_free_windows.rend()) - return { std::make_unique(buffer), { buffer, Selection{} } }; + return { make_unique(buffer), { buffer, Selection{} } }; it->window->forget_timestamp(); WindowAndSelections res = std::move(*it); diff --git a/src/containers.hh b/src/containers.hh index 0f94dba7..56e5fc1f 100644 --- a/src/containers.hh +++ b/src/containers.hh @@ -91,7 +91,7 @@ using TransformedResult = decltype(std::declval()(*std::declval())); template struct TransformedIterator : std::iterator>> + typename std::remove_reference>::type> { TransformedIterator(Transform transform, Iterator it) : m_it(std::move(it)), m_transform(std::move(transform)) {} diff --git a/src/flags.hh b/src/flags.hh index f3562d95..2b68751b 100644 --- a/src/flags.hh +++ b/src/flags.hh @@ -10,18 +10,21 @@ template struct WithBitOps : std::false_type {}; template -using EnableIfWithBitOps = std::enable_if_t::value>; +using UnderlyingType = typename std::underlying_type::type; + +template +using EnableIfWithBitOps = typename std::enable_if::value>::type; template> constexpr Flags operator|(Flags lhs, Flags rhs) { - return (Flags)((std::underlying_type_t) lhs | (std::underlying_type_t) rhs); + return (Flags)((UnderlyingType) lhs | (UnderlyingType) rhs); } template> Flags& operator|=(Flags& lhs, Flags rhs) { - (std::underlying_type_t&) lhs |= (std::underlying_type_t) rhs; + (UnderlyingType&) lhs |= (UnderlyingType) rhs; return lhs; } @@ -29,27 +32,27 @@ template struct TestableFlags { Flags value; - constexpr operator bool() const { return (std::underlying_type_t)value; } + constexpr operator bool() const { return (UnderlyingType)value; } constexpr operator Flags() const { return value; } }; template> constexpr TestableFlags operator&(Flags lhs, Flags rhs) { - return { (Flags)((std::underlying_type_t) lhs & (std::underlying_type_t) rhs) }; + return { (Flags)((UnderlyingType) lhs & (UnderlyingType) rhs) }; } template> Flags& operator&=(Flags& lhs, Flags rhs) { - (std::underlying_type_t&) lhs &= (std::underlying_type_t) rhs; + (UnderlyingType&) lhs &= (UnderlyingType) rhs; return lhs; } template> constexpr Flags operator~(Flags lhs) { - return (Flags)(~(std::underlying_type_t)lhs); + return (Flags)(~(UnderlyingType)lhs); } } diff --git a/src/hash.hh b/src/hash.hh index 232baea5..3fc8abd2 100644 --- a/src/hash.hh +++ b/src/hash.hh @@ -19,10 +19,10 @@ size_t hash_value(const Type&... val) } template -std::enable_if_t::value, size_t> +typename std::enable_if::value, size_t>::type hash_value(const Type& val) { - return hash_value((std::underlying_type_t)val); + return hash_value((typename std::underlying_type::type)val); } template diff --git a/src/highlighter.hh b/src/highlighter.hh index ddd2a78b..4e259c51 100644 --- a/src/highlighter.hh +++ b/src/highlighter.hh @@ -61,7 +61,7 @@ private: template std::unique_ptr> make_simple_highlighter(T func) { - return std::make_unique>(std::move(func)); + return make_unique>(std::move(func)); } using HighlighterParameters = ConstArrayView; diff --git a/src/highlighters.cc b/src/highlighters.cc index 091bbb4e..aa1e09eb 100644 --- a/src/highlighters.cc +++ b/src/highlighters.cc @@ -272,8 +272,8 @@ public: Regex ex{params[0].begin(), params[0].end(), Regex::optimize}; - return {id, std::make_unique(std::move(ex), - std::move(faces))}; + return {id, make_unique(std::move(ex), + std::move(faces))}; } catch (RegexError& err) { @@ -447,7 +447,7 @@ template std::unique_ptr> make_dynamic_regex_highlighter(RegexGetter regex_getter, FaceGetter face_getter) { - return std::make_unique>( + return make_unique>( std::move(regex_getter), std::move(face_getter)); } @@ -896,7 +896,7 @@ HighlighterAndId create_highlighter_group(HighlighterParameters params) if (params.size() != 1) throw runtime_error("wrong parameter count"); - return HighlighterAndId(params[0], std::make_unique()); + return HighlighterAndId(params[0], make_unique()); } HighlighterAndId create_reference_highlighter(HighlighterParameters params) @@ -1200,7 +1200,7 @@ public: } auto default_group = parser.get_switch("default").value_or(StringView{}).str(); - return {parser[0], std::make_unique(std::move(regions), default_group)}; + return {parser[0], make_unique(std::move(regions), default_group)}; } catch (RegexError& err) { diff --git a/src/main.cc b/src/main.cc index c8fc9d03..7b1f62f9 100644 --- a/src/main.cc +++ b/src/main.cc @@ -261,7 +261,7 @@ void create_local_client(StringView init_command) } static Client* client = ClientManager::instance().create_client( - std::make_unique(), get_env_vars(), init_command); + make_unique(), get_env_vars(), init_command); signal(SIGHUP, [](int) { if (client) ClientManager::instance().remove_client(*client); @@ -299,7 +299,7 @@ int run_client(StringView session, StringView init_command) try { EventManager event_manager; - RemoteClient client{session, std::make_unique(), + RemoteClient client{session, make_unique(), get_env_vars(), init_command}; while (true) event_manager.handle_next_events(EventMode::Normal); diff --git a/src/safe_ptr.hh b/src/safe_ptr.hh index 5fe894b3..2e3b3d2b 100644 --- a/src/safe_ptr.hh +++ b/src/safe_ptr.hh @@ -94,7 +94,8 @@ private: }; template using SafePtr = - RefPtr::value, const SafeCountable, SafeCountable>>; + RefPtr::value, + const SafeCountable, SafeCountable>::type>; } diff --git a/src/string.hh b/src/string.hh index e2e2d412..b5ad8e5a 100644 --- a/src/string.hh +++ b/src/string.hh @@ -297,10 +297,10 @@ namespace detail template using IsString = std::is_convertible; -template::value>> +template::value>::type> auto format_param(const T& val) -> decltype(to_string(val)) { return to_string(val); } -template::value>> +template::value>::type> StringView format_param(const T& val) { return val; } } diff --git a/src/utils.hh b/src/utils.hh index 7a7eb071..ee2591c0 100644 --- a/src/utils.hh +++ b/src/utils.hh @@ -8,6 +8,34 @@ namespace Kakoune { +template +std::unique_ptr make_unique(Args&&... args) +{ + return std::unique_ptr(new T(std::forward(args)...)); +} + +template +struct IndexSequence +{ + using Next = IndexSequence; +}; + +template +struct MakeIndexSequence +{ + using Type = typename MakeIndexSequence::Type::Next; +}; + +template<> +struct MakeIndexSequence<0> +{ + using Type = IndexSequence<>; +}; + +template +constexpr typename MakeIndexSequence::Type +make_index_sequence() { return typename MakeIndexSequence::Type{}; } + // *** Singleton *** // // Singleton helper class, every singleton type T should inherit