mirror of
https://github.com/mawww/kakoune.git
synced 2024-11-28 17:13:00 +03:00
Migrate code to c++14
This commit is contained in:
parent
fbffd86f85
commit
7a79cbbc81
@ -59,7 +59,7 @@ ifeq ($(static),yes)
|
||||
LDFLAGS += -static -pthread
|
||||
endif
|
||||
|
||||
CXXFLAGS += -pedantic -std=gnu++11 -g -Wall -Wextra -Wno-unused-parameter -Wno-reorder -Wno-sign-compare -Wno-address -Wno-noexcept-type -Wno-unknown-attributes -Wno-unknown-warning-option
|
||||
CXXFLAGS += -pedantic -std=gnu++14 -g -Wall -Wextra -Wno-unused-parameter -Wno-reorder -Wno-sign-compare -Wno-address -Wno-noexcept-type -Wno-unknown-attributes -Wno-unknown-warning-option
|
||||
|
||||
all : kak
|
||||
|
||||
|
@ -110,7 +110,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->force_redraw();
|
||||
WindowAndSelections res = std::move(*it);
|
||||
|
@ -129,7 +129,7 @@ struct TransformView
|
||||
using ContainerIt = IteratorOf<Container>;
|
||||
|
||||
struct Iterator : std::iterator<std::forward_iterator_tag,
|
||||
typename std::remove_reference<TransformedResult<ContainerIt, Transform>>::type>
|
||||
std::remove_reference_t<TransformedResult<ContainerIt, Transform>>>
|
||||
{
|
||||
Iterator(const TransformView& view, ContainerIt it)
|
||||
: m_it{std::move(it)}, m_view{view} {}
|
||||
|
@ -12,13 +12,13 @@ template<typename Flags>
|
||||
constexpr bool with_bit_ops(Meta::Type<Flags>) { return false; }
|
||||
|
||||
template<typename Flags>
|
||||
using UnderlyingType = typename std::underlying_type<Flags>::type;
|
||||
using UnderlyingType = std::underlying_type_t<Flags>;
|
||||
|
||||
template<typename Flags, typename T = void>
|
||||
using EnableIfWithBitOps = typename std::enable_if<with_bit_ops(Meta::Type<Flags>{}), T>::type;
|
||||
using EnableIfWithBitOps = std::enable_if_t<with_bit_ops(Meta::Type<Flags>{}), T>;
|
||||
|
||||
template<typename Flags, typename T = void>
|
||||
using EnableIfWithoutBitOps = typename std::enable_if<not with_bit_ops(Meta::Type<Flags>{}), T>::type;
|
||||
using EnableIfWithoutBitOps = std::enable_if_t<not with_bit_ops(Meta::Type<Flags>{}), T>;
|
||||
|
||||
template<typename Flags, typename = EnableIfWithBitOps<Flags>>
|
||||
constexpr Flags operator|(Flags lhs, Flags rhs)
|
||||
|
@ -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>
|
||||
|
@ -40,7 +40,7 @@ std::unique_ptr<Highlighter> make_highlighter(Func func, HighlightPass pass = Hi
|
||||
}
|
||||
Func m_func;
|
||||
};
|
||||
return make_unique<SimpleHighlighter>(std::move(func), pass);
|
||||
return std::make_unique<SimpleHighlighter>(std::move(func), pass);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
@ -325,8 +325,8 @@ public:
|
||||
|
||||
Regex ex{params[0], 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))};
|
||||
}
|
||||
|
||||
private:
|
||||
@ -488,7 +488,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));
|
||||
}
|
||||
|
||||
@ -858,7 +858,7 @@ struct WrapHighlighter : Highlighter
|
||||
if (auto width = parser.get_switch("width"))
|
||||
max_width = str_to_int(*width);
|
||||
|
||||
return {"wrap", make_unique<WrapHighlighter>(max_width, (bool)parser.get_switch("word"))};
|
||||
return {"wrap", std::make_unique<WrapHighlighter>(max_width, (bool)parser.get_switch("word"))};
|
||||
}
|
||||
|
||||
const bool m_word_wrap;
|
||||
@ -1021,7 +1021,7 @@ struct LineNumbersHighlighter : Highlighter
|
||||
if (separator.length() > 10)
|
||||
throw runtime_error("Separator length is limited to 10 bytes");
|
||||
|
||||
return {"number_lines", make_unique<LineNumbersHighlighter>((bool)parser.get_switch("relative"), (bool)parser.get_switch("hlcursor"), separator.str())};
|
||||
return {"number_lines", std::make_unique<LineNumbersHighlighter>((bool)parser.get_switch("relative"), (bool)parser.get_switch("hlcursor"), separator.str())};
|
||||
}
|
||||
|
||||
private:
|
||||
@ -1253,7 +1253,7 @@ struct FlagLinesHighlighter : Highlighter
|
||||
// throw if wrong option type
|
||||
GlobalScope::instance().options()[option_name].get<LineAndSpecList>();
|
||||
|
||||
return {"hlflags_" + params[1], make_unique<FlagLinesHighlighter>(option_name, default_face) };
|
||||
return {"hlflags_" + params[1], std::make_unique<FlagLinesHighlighter>(option_name, default_face) };
|
||||
}
|
||||
|
||||
private:
|
||||
@ -1412,7 +1412,7 @@ struct RangesHighlighter : Highlighter
|
||||
// throw if wrong option type
|
||||
GlobalScope::instance().options()[option_name].get<RangeAndStringList>();
|
||||
|
||||
return {"hlranges_" + params[0], make_unique<RangesHighlighter>(option_name)};
|
||||
return {"hlranges_" + params[0], std::make_unique<RangesHighlighter>(option_name)};
|
||||
}
|
||||
|
||||
private:
|
||||
@ -1454,7 +1454,7 @@ struct ReplaceRangesHighlighter : Highlighter
|
||||
// throw if wrong option type
|
||||
GlobalScope::instance().options()[option_name].get<RangeAndStringList>();
|
||||
|
||||
return {"replace_ranges_" + params[0], make_unique<ReplaceRangesHighlighter>(option_name)};
|
||||
return {"replace_ranges_" + params[0], std::make_unique<ReplaceRangesHighlighter>(option_name)};
|
||||
}
|
||||
|
||||
private:
|
||||
@ -1517,7 +1517,7 @@ HighlighterAndId create_highlighter_group(HighlighterParameters params)
|
||||
ParametersParser parser{params, param_desc};
|
||||
HighlightPass passes = parse_passes(parser.get_switch("passes").value_or("colorize"));
|
||||
|
||||
return HighlighterAndId(parser[0], make_unique<HighlighterGroup>(passes));
|
||||
return HighlighterAndId(parser[0], std::make_unique<HighlighterGroup>(passes));
|
||||
}
|
||||
|
||||
struct ReferenceHighlighter : Highlighter
|
||||
@ -1533,7 +1533,7 @@ struct ReferenceHighlighter : Highlighter
|
||||
};
|
||||
ParametersParser parser{params, param_desc};
|
||||
HighlightPass passes = parse_passes(parser.get_switch("passes").value_or("colorize"));
|
||||
return {parser[0], make_unique<ReferenceHighlighter>(passes, parser[0])};
|
||||
return {parser[0], std::make_unique<ReferenceHighlighter>(passes, parser[0])};
|
||||
}
|
||||
|
||||
private:
|
||||
@ -1849,7 +1849,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)};
|
||||
}
|
||||
|
||||
private:
|
||||
@ -1963,7 +1963,7 @@ private:
|
||||
|
||||
void setup_builtin_highlighters(HighlighterGroup& group)
|
||||
{
|
||||
group.add_child({"tabulations"_str, make_unique<TabulationHighlighter>()});
|
||||
group.add_child({"tabulations"_str, std::make_unique<TabulationHighlighter>()});
|
||||
group.add_child({"unprintable"_str, make_highlighter(expand_unprintable)});
|
||||
group.add_child({"selections"_str, make_highlighter(highlight_selections)});
|
||||
}
|
||||
|
12
src/main.cc
12
src/main.cc
@ -182,7 +182,7 @@ void register_registers()
|
||||
RegisterManager& register_manager = RegisterManager::instance();
|
||||
|
||||
for (auto c : "abcdefghijklmnopqrstuvwxyz/\"|^@:")
|
||||
register_manager.add_register(c, make_unique<StaticRegister>());
|
||||
register_manager.add_register(c, std::make_unique<StaticRegister>());
|
||||
|
||||
using StringList = Vector<String, MemoryDomain::Registers>;
|
||||
|
||||
@ -228,7 +228,7 @@ void register_registers()
|
||||
}));
|
||||
}
|
||||
|
||||
register_manager.add_register('_', make_unique<NullRegister>());
|
||||
register_manager.add_register('_', std::make_unique<NullRegister>());
|
||||
}
|
||||
|
||||
static void check_tabstop(const int& val)
|
||||
@ -376,9 +376,9 @@ std::unique_ptr<UserInterface> make_ui(UIType ui_type)
|
||||
|
||||
switch (ui_type)
|
||||
{
|
||||
case UIType::NCurses: return make_unique<NCursesUI>();
|
||||
case UIType::Json: return make_unique<JsonUI>();
|
||||
case UIType::Dummy: return make_unique<DummyUI>();
|
||||
case UIType::NCurses: return std::make_unique<NCursesUI>();
|
||||
case UIType::Json: return std::make_unique<JsonUI>();
|
||||
case UIType::Dummy: return std::make_unique<DummyUI>();
|
||||
}
|
||||
throw logic_error{};
|
||||
}
|
||||
@ -470,7 +470,7 @@ std::unique_ptr<UserInterface> create_local_ui(UIType ui_type)
|
||||
create_fifo_buffer("*stdin*", fd, Buffer::Flags::None);
|
||||
}
|
||||
|
||||
return make_unique<LocalUI>();
|
||||
return std::make_unique<LocalUI>();
|
||||
}
|
||||
|
||||
int run_client(StringView session, StringView client_init,
|
||||
|
@ -223,7 +223,7 @@ public:
|
||||
: format("[{}] - {}", option_type_name(Meta::Type<T>{}), docstring);
|
||||
m_descs.emplace_back(new OptionDesc{name.str(), std::move(doc), flags});
|
||||
return *opts.insert({m_descs.back()->name(),
|
||||
make_unique<TypedCheckedOption<T, validator>>(m_global_manager, *m_descs.back(), value)});
|
||||
std::make_unique<TypedCheckedOption<T, validator>>(m_global_manager, *m_descs.back(), value)});
|
||||
}
|
||||
|
||||
const OptionDesc* option_desc(StringView name) const
|
||||
|
@ -75,13 +75,13 @@ std::unique_ptr<Register> make_dyn_reg(Func func)
|
||||
{
|
||||
throw runtime_error("this register is not assignable");
|
||||
};
|
||||
return make_unique<DynamicRegister<Func, decltype(setter)>>(std::move(func), setter);
|
||||
return std::make_unique<DynamicRegister<Func, decltype(setter)>>(std::move(func), setter);
|
||||
}
|
||||
|
||||
template<typename Getter, typename Setter>
|
||||
std::unique_ptr<Register> make_dyn_reg(Getter getter, Setter setter)
|
||||
{
|
||||
return make_unique<DynamicRegister<Getter, Setter>>(std::move(getter), std::move(setter));
|
||||
return std::make_unique<DynamicRegister<Getter, Setter>>(std::move(getter), std::move(setter));
|
||||
}
|
||||
|
||||
class NullRegister : public Register
|
||||
|
@ -93,10 +93,12 @@ private:
|
||||
const Type& type() const { return *static_cast<const Type*>(this); }
|
||||
};
|
||||
|
||||
[[gnu::optimize(3)]] // this is recursive for constexpr reason
|
||||
constexpr ByteCount strlen(const char* s)
|
||||
{
|
||||
return *s == 0 ? 0 : strlen(s+1) + 1;
|
||||
int i = 0;
|
||||
while (*s++ != 0)
|
||||
++i;
|
||||
return {i};
|
||||
}
|
||||
|
||||
class String : public StringOps<String, char>
|
||||
@ -406,12 +408,12 @@ to_string(const StronglyTypedNumber<RealType, ValueType>& val)
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template<typename T> using IsString = std::is_convertible<T, StringView>;
|
||||
template<typename T> constexpr bool is_string = std::is_convertible<T, StringView>::value;
|
||||
|
||||
template<typename T, class = typename std::enable_if<not IsString<T>::value>::type>
|
||||
template<typename T, class = std::enable_if_t<not is_string<T>>>
|
||||
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<is_string<T>>>
|
||||
StringView format_param(const T& val) { return val; }
|
||||
|
||||
}
|
||||
|
@ -113,12 +113,6 @@ private:
|
||||
|
||||
// *** Misc helper functions ***
|
||||
|
||||
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<typename T>
|
||||
bool operator== (const std::unique_ptr<T>& lhs, T* rhs)
|
||||
{
|
||||
|
@ -17,9 +17,9 @@ struct Value
|
||||
Value() = default;
|
||||
|
||||
template<typename T,
|
||||
typename = typename std::enable_if<not std::is_same<Value, T>::value>::type>
|
||||
typename = std::enable_if_t<not std::is_same<Value, T>::value>>
|
||||
Value(T&& val)
|
||||
: m_value{new Model<typename std::remove_reference<T>::type>{std::forward<T>(val)}} {}
|
||||
: m_value{new Model<std::remove_reference_t<T>>{std::forward<T>(val)}} {}
|
||||
|
||||
Value(const Value& val) = delete;
|
||||
Value(Value&&) = default;
|
||||
|
Loading…
Reference in New Issue
Block a user