Migrate code to c++14
This commit is contained in:
parent
41319d2708
commit
b42de85031
|
@ -9,7 +9,7 @@ bindir := $(DESTDIR)$(PREFIX)/bin
|
|||
sharedir := $(DESTDIR)$(PREFIX)/share/kak
|
||||
docdir := $(DESTDIR)$(PREFIX)/share/doc/kak
|
||||
|
||||
CXXFLAGS += -std=gnu++11 -g -Wall -Wno-reorder -Wno-sign-compare -pedantic
|
||||
CXXFLAGS += -std=c++14 -g -Wall -Wno-reorder -Wno-sign-compare -pedantic
|
||||
ifneq (,$(findstring CYGWIN,$(os)))
|
||||
LDFLAGS += -rdynamic
|
||||
endif
|
||||
|
|
|
@ -84,7 +84,7 @@ WindowAndSelections ClientManager::get_free_window(Buffer& buffer)
|
|||
{ return &ws.window->buffer() == &buffer; });
|
||||
|
||||
if (it == m_free_windows.rend())
|
||||
return { make_unique<Window>(buffer), { buffer, Selection{} } };
|
||||
return { std::make_unique<Window>(buffer), { buffer, Selection{} } };
|
||||
|
||||
it->window->forget_timestamp();
|
||||
WindowAndSelections res = std::move(*it);
|
||||
|
|
|
@ -91,7 +91,7 @@ using TransformedResult = decltype(std::declval<T>()(*std::declval<I>()));
|
|||
|
||||
template<typename Iterator, typename Transform>
|
||||
struct TransformedIterator : std::iterator<std::forward_iterator_tag,
|
||||
typename std::remove_reference<TransformedResult<Iterator, Transform>>::type>
|
||||
std::remove_reference_t<TransformedResult<Iterator, Transform>>>
|
||||
{
|
||||
TransformedIterator(Transform transform, Iterator it)
|
||||
: m_it(std::move(it)), m_transform(std::move(transform)) {}
|
||||
|
|
17
src/flags.hh
17
src/flags.hh
|
@ -10,21 +10,18 @@ template<typename Flags>
|
|||
struct WithBitOps : std::false_type {};
|
||||
|
||||
template<typename Flags>
|
||||
using UnderlyingType = typename std::underlying_type<Flags>::type;
|
||||
|
||||
template<typename Flags>
|
||||
using EnableIfWithBitOps = typename std::enable_if<WithBitOps<Flags>::value>::type;
|
||||
using EnableIfWithBitOps = std::enable_if_t<WithBitOps<Flags>::value>;
|
||||
|
||||
template<typename Flags, typename = EnableIfWithBitOps<Flags>>
|
||||
constexpr Flags operator|(Flags lhs, Flags rhs)
|
||||
{
|
||||
return (Flags)((UnderlyingType<Flags>) lhs | (UnderlyingType<Flags>) rhs);
|
||||
return (Flags)((std::underlying_type_t<Flags>) lhs | (std::underlying_type_t<Flags>) rhs);
|
||||
}
|
||||
|
||||
template<typename Flags, typename = EnableIfWithBitOps<Flags>>
|
||||
Flags& operator|=(Flags& lhs, Flags rhs)
|
||||
{
|
||||
(UnderlyingType<Flags>&) lhs |= (UnderlyingType<Flags>) rhs;
|
||||
(std::underlying_type_t<Flags>&) lhs |= (std::underlying_type_t<Flags>) rhs;
|
||||
return lhs;
|
||||
}
|
||||
|
||||
|
@ -32,27 +29,27 @@ template<typename Flags>
|
|||
struct TestableFlags
|
||||
{
|
||||
Flags value;
|
||||
constexpr operator bool() const { return (UnderlyingType<Flags>)value; }
|
||||
constexpr operator bool() const { return (std::underlying_type_t<Flags>)value; }
|
||||
constexpr operator Flags() const { return value; }
|
||||
};
|
||||
|
||||
template<typename Flags, typename = EnableIfWithBitOps<Flags>>
|
||||
constexpr TestableFlags<Flags> operator&(Flags lhs, Flags rhs)
|
||||
{
|
||||
return { (Flags)((UnderlyingType<Flags>) lhs & (UnderlyingType<Flags>) rhs) };
|
||||
return { (Flags)((std::underlying_type_t<Flags>) lhs & (std::underlying_type_t<Flags>) rhs) };
|
||||
}
|
||||
|
||||
template<typename Flags, typename = EnableIfWithBitOps<Flags>>
|
||||
Flags& operator&=(Flags& lhs, Flags rhs)
|
||||
{
|
||||
(UnderlyingType<Flags>&) lhs &= (UnderlyingType<Flags>) rhs;
|
||||
(std::underlying_type_t<Flags>&) lhs &= (std::underlying_type_t<Flags>) rhs;
|
||||
return lhs;
|
||||
}
|
||||
|
||||
template<typename Flags, typename = EnableIfWithBitOps<Flags>>
|
||||
constexpr Flags operator~(Flags lhs)
|
||||
{
|
||||
return (Flags)(~(UnderlyingType<Flags>)lhs);
|
||||
return (Flags)(~(std::underlying_type_t<Flags>)lhs);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,10 +19,10 @@ size_t hash_value(const Type&... val)
|
|||
}
|
||||
|
||||
template<typename Type>
|
||||
typename std::enable_if<std::is_enum<Type>::value, size_t>::type
|
||||
std::enable_if_t<std::is_enum<Type>::value, size_t>
|
||||
hash_value(const Type& val)
|
||||
{
|
||||
return hash_value((typename std::underlying_type<Type>::type)val);
|
||||
return hash_value((std::underlying_type_t<Type>)val);
|
||||
}
|
||||
|
||||
template<typename Type>
|
||||
|
|
|
@ -61,7 +61,7 @@ private:
|
|||
template<typename T>
|
||||
std::unique_ptr<SimpleHighlighter<T>> make_simple_highlighter(T func)
|
||||
{
|
||||
return make_unique<SimpleHighlighter<T>>(std::move(func));
|
||||
return std::make_unique<SimpleHighlighter<T>>(std::move(func));
|
||||
}
|
||||
|
||||
using HighlighterParameters = ConstArrayView<String>;
|
||||
|
|
|
@ -272,8 +272,8 @@ public:
|
|||
|
||||
Regex ex{params[0].begin(), params[0].end(), Regex::optimize};
|
||||
|
||||
return {id, make_unique<RegexHighlighter>(std::move(ex),
|
||||
std::move(faces))};
|
||||
return {id, std::make_unique<RegexHighlighter>(std::move(ex),
|
||||
std::move(faces))};
|
||||
}
|
||||
catch (RegexError& err)
|
||||
{
|
||||
|
@ -447,7 +447,7 @@ template<typename RegexGetter, typename FaceGetter>
|
|||
std::unique_ptr<DynamicRegexHighlighter<RegexGetter, FaceGetter>>
|
||||
make_dynamic_regex_highlighter(RegexGetter regex_getter, FaceGetter face_getter)
|
||||
{
|
||||
return make_unique<DynamicRegexHighlighter<RegexGetter, FaceGetter>>(
|
||||
return std::make_unique<DynamicRegexHighlighter<RegexGetter, FaceGetter>>(
|
||||
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], make_unique<HighlighterGroup>());
|
||||
return HighlighterAndId(params[0], std::make_unique<HighlighterGroup>());
|
||||
}
|
||||
|
||||
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], make_unique<RegionsHighlighter>(std::move(regions), default_group)};
|
||||
return {parser[0], std::make_unique<RegionsHighlighter>(std::move(regions), default_group)};
|
||||
}
|
||||
catch (RegexError& err)
|
||||
{
|
||||
|
|
|
@ -261,7 +261,7 @@ void create_local_client(StringView init_command)
|
|||
}
|
||||
|
||||
static Client* client = ClientManager::instance().create_client(
|
||||
make_unique<LocalUI>(), get_env_vars(), init_command);
|
||||
std::make_unique<LocalUI>(), 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, make_unique<NCursesUI>(),
|
||||
RemoteClient client{session, std::make_unique<NCursesUI>(),
|
||||
get_env_vars(), init_command};
|
||||
while (true)
|
||||
event_manager.handle_next_events(EventMode::Normal);
|
||||
|
|
|
@ -94,8 +94,7 @@ private:
|
|||
};
|
||||
|
||||
template<typename T> using SafePtr =
|
||||
RefPtr<T, typename std::conditional<std::is_const<T>::value,
|
||||
const SafeCountable, SafeCountable>::type>;
|
||||
RefPtr<T, std::conditional_t<std::is_const<T>::value, const SafeCountable, SafeCountable>>;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -297,10 +297,10 @@ namespace detail
|
|||
|
||||
template<typename T> using IsString = std::is_convertible<T, StringView>;
|
||||
|
||||
template<typename T, class = typename std::enable_if<!IsString<T>::value>::type>
|
||||
template<typename T, class = std::enable_if_t<!IsString<T>::value>>
|
||||
auto format_param(const T& val) -> decltype(to_string(val)) { return to_string(val); }
|
||||
|
||||
template<typename T, class = typename std::enable_if<IsString<T>::value>::type>
|
||||
template<typename T, class = std::enable_if_t<IsString<T>::value>>
|
||||
StringView format_param(const T& val) { return val; }
|
||||
|
||||
}
|
||||
|
|
28
src/utils.hh
28
src/utils.hh
|
@ -8,34 +8,6 @@
|
|||
namespace Kakoune
|
||||
{
|
||||
|
||||
template<typename T, typename... Args>
|
||||
std::unique_ptr<T> make_unique(Args&&... args)
|
||||
{
|
||||
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
|
||||
}
|
||||
|
||||
template<size_t... I>
|
||||
struct IndexSequence
|
||||
{
|
||||
using Next = IndexSequence<I..., sizeof...(I)>;
|
||||
};
|
||||
|
||||
template<size_t N>
|
||||
struct MakeIndexSequence
|
||||
{
|
||||
using Type = typename MakeIndexSequence<N-1>::Type::Next;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct MakeIndexSequence<0>
|
||||
{
|
||||
using Type = IndexSequence<>;
|
||||
};
|
||||
|
||||
template<size_t N>
|
||||
constexpr typename MakeIndexSequence<N>::Type
|
||||
make_index_sequence() { return typename MakeIndexSequence<N>::Type{}; }
|
||||
|
||||
// *** Singleton ***
|
||||
//
|
||||
// Singleton helper class, every singleton type T should inherit
|
||||
|
|
Loading…
Reference in New Issue
Block a user