add utf8 string size and remove string dep
This commit is contained in:
15
src/math/max.hpp
Normal file
15
src/math/max.hpp
Normal file
@@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
namespace hack
|
||||
{
|
||||
// std::common_type_t - делает сравнение по правилу тенарного оператора
|
||||
// и выводит низводящий возвращающий тип. Т.е. если в качестве одного из
|
||||
// параметров передалась ссылка, то произойдет низведление до типа ссылки
|
||||
template<typename T, typename U, typename RT = std::common_type_t<T, U>>
|
||||
inline RT max(T a, U b)
|
||||
{
|
||||
return a > b ? a : b;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,6 @@
|
||||
inc += include_directories('.')
|
||||
|
||||
subdir('string')
|
||||
subdir('logger')
|
||||
|
||||
deps += string_dep
|
||||
deps += logger_dep
|
||||
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
headers = ['string.hpp', 'string_concat_helper.hpp']
|
||||
sources = ['string.cpp']
|
||||
|
||||
lib = library(
|
||||
'string',
|
||||
include_directories : inc,
|
||||
sources: [headers, sources]
|
||||
)
|
||||
|
||||
string_dep = declare_dependency(
|
||||
include_directories: inc,
|
||||
link_with: lib
|
||||
)
|
||||
@@ -1,5 +0,0 @@
|
||||
#include "string.hpp"
|
||||
|
||||
namespace hack::string
|
||||
{
|
||||
}
|
||||
@@ -5,7 +5,6 @@
|
||||
#include <iostream>
|
||||
#include <tuple>
|
||||
|
||||
|
||||
namespace hack::string
|
||||
{
|
||||
using v_str = std::vector<std::string>;
|
||||
|
||||
10
src/string/utf8_len.hpp
Normal file
10
src/string/utf8_len.hpp
Normal file
@@ -0,0 +1,10 @@
|
||||
#include <locale>
|
||||
#include <codecvt>
|
||||
|
||||
namespace hack::string
|
||||
{
|
||||
inline std::size_t utf8_len(const std::string& utf8)
|
||||
{
|
||||
return std::wstring_convert<std::codecvt_utf8<char32_t>, char32_t>{}.from_bytes(utf8).size();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user