Skip to content

Commit 43bbb4f

Browse files
authored
Merge pull request #54 from zrax/cxx14
Increase minimum C++ standard to C++14
2 parents 850a96a + 40a327c commit 43bbb4f

File tree

12 files changed

+38
-91
lines changed

12 files changed

+38
-91
lines changed

CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
2222
project(string_theory)
2323

2424
# We will detect and use optional features in newer C++ standards,
25-
# but C++11 is required at minimum
25+
# but C++14 is required at minimum
2626
set(CMAKE_CXX_STANDARD 20)
2727
set(CMAKE_CXX_STANDARD_REQUIRED OFF)
2828
set(CMAKE_CXX_EXTENSIONS OFF)
@@ -60,8 +60,6 @@ try_compile(ST_HAVE_CXX20_CHAR8_TYPES "${PROJECT_BINARY_DIR}"
6060
"${PROJECT_SOURCE_DIR}/cmake/check_char8_types.cpp")
6161
try_compile(ST_HAVE_INT64 "${PROJECT_BINARY_DIR}"
6262
"${PROJECT_SOURCE_DIR}/cmake/check_int64.cpp")
63-
try_compile(ST_HAVE_DEPRECATED_ATTR "${PROJECT_BINARY_DIR}"
64-
"${PROJECT_SOURCE_DIR}/cmake/check_deprecated_attr.cpp")
6563
try_compile(ST_HAVE_NODISCARD_ATTR "${PROJECT_BINARY_DIR}"
6664
"${PROJECT_SOURCE_DIR}/cmake/check_nodiscard.cpp")
6765

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ string_theory supports a variety of platforms and compilers. As of March
119119
- MinGW-w64 GCC 8 (x86_64)
120120

121121
As of string_theory 3.0, support for some older compilers has been dropped.
122-
You'll need a compiler that supports most of C++11.
122+
You'll need a compiler that supports C++14 or later.
123123

124124
Contributing to String Theory
125125
-----------------------------

cmake/check_deprecated_attr.cpp

Lines changed: 0 additions & 39 deletions
This file was deleted.

include/st_config.h.in

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@
2727
#define ST_VERSION_STR "@ST_VERSION@"
2828

2929
#cmakedefine ST_HAVE_INT64
30-
#if (__cplusplus > 201103L) || (defined(_MSVC_LANG) && (_MSVC_LANG > 201103L))
31-
#cmakedefine ST_HAVE_DEPRECATED_ATTR
32-
#endif
3330
#if (__cplusplus > 201402L) || (defined(_MSVC_LANG) && (_MSVC_LANG > 201402L))
3431
#cmakedefine ST_HAVE_NODISCARD_ATTR
3532
#cmakedefine ST_HAVE_CXX17_STRING_VIEW
@@ -62,16 +59,6 @@
6259
ST_AVAILABILITY(tvos,strict,introduced=13.0) \
6360
ST_AVAILABILITY(watchos,strict,introduced=6.0)
6461

65-
#if defined(_MSC_VER)
66-
# define ST_DEPRECATED(message) __declspec(deprecated(message))
67-
#elif defined(__GNUC__)
68-
# define ST_DEPRECATED(message) __attribute__((deprecated(message)))
69-
#elif defined(ST_HAVE_DEPRECATED_ATTR)
70-
# define ST_DEPRECATED(message) [[deprecated(message)]]
71-
#else
72-
# define ST_DEPRECATED(message)
73-
#endif
74-
7562
#ifndef ST_DEPRECATED_VERSION
7663
# if defined(ST_NO_3_0_DEPRECATION)
7764
# define ST_DEPRECATED_VERSION 299
@@ -81,19 +68,19 @@
8168
#endif
8269

8370
#if ST_DEPRECATED_VERSION >= 300
84-
# define ST_DEPRECATED_IN_3_0(message) ST_DEPRECATED(message)
71+
# define ST_DEPRECATED_IN_3_0(message) [[deprecated(message)]]
8572
#else
8673
# define ST_DEPRECATED_IN_3_0(message)
8774
#endif
8875

8976
#if ST_DEPRECATED_VERSION >= 304
90-
# define ST_DEPRECATED_IN_3_4(message) ST_DEPRECATED(message)
77+
# define ST_DEPRECATED_IN_3_4(message) [[deprecated(message)]]
9178
#else
9279
# define ST_DEPRECATED_IN_3_4(message)
9380
#endif
9481

9582
#if ST_DEPRECATED_VERSION >= 400
96-
# define ST_DEPRECATED_IN_4_0(message) ST_DEPRECATED(message)
83+
# define ST_DEPRECATED_IN_4_0(message) [[deprecated(message)]]
9784
#else
9885
# define ST_DEPRECATED_IN_4_0(message)
9986
#endif

include/st_format.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ namespace _ST_PRIVATE
4747
}
4848

4949
ST_NODISCARD
50-
ST::string to_string(bool utf8_encoded, ST::utf_validation_t validation)
50+
ST::string to_string(bool utf8_encoded, ST::utf_validation_t validation) const
5151
{
5252
return m_output.to_string(utf8_encoded, validation);
5353
}

include/st_format_numeric.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ namespace ST
9898

9999
void format(float_T value, char format)
100100
{
101-
static const char valid_formats[] = "efgEFG";
101+
static constexpr const char valid_formats[] = "efgEFG";
102102
if (!std::char_traits<char>::find(valid_formats, sizeof(valid_formats) - 1, format))
103103
throw ST::bad_format("Unsupported floating-point format specifier");
104104

include/st_format_priv.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ namespace _ST_PRIVATE
123123
void format_numeric_s(const ST::format_spec &format,
124124
ST::format_writer &output, int_T value)
125125
{
126-
static_assert(std::is_signed<int_T>::value,
126+
static_assert(std::is_signed_v<int_T>,
127127
"Use _format_numeric_u for unsigned numerics");
128128

129129
int radix = 10;
@@ -148,7 +148,7 @@ namespace _ST_PRIVATE
148148
ST_ASSERT(false, "Invalid digit class for _format_numeric_s");
149149
}
150150

151-
typedef typename std::make_unsigned<int_T>::type uint_T;
151+
typedef std::make_unsigned_t<int_T> uint_T;
152152
ST::uint_formatter<uint_T> formatter;
153153
formatter.format(static_cast<uint_T>(std::abs(value)), radix, upper_case);
154154

@@ -163,7 +163,7 @@ namespace _ST_PRIVATE
163163
void format_numeric_u(const ST::format_spec &format,
164164
ST::format_writer &output, uint_T value)
165165
{
166-
static_assert(std::is_unsigned<uint_T>::value,
166+
static_assert(std::is_unsigned_v<uint_T>,
167167
"Use _format_numeric_s for signed numerics");
168168

169169
int radix = 10;
@@ -209,7 +209,8 @@ namespace _ST_PRIVATE
209209
if (error != conversion_error_t::success)
210210
append_chars(dest, badchar_substitute_utf8, badchar_substitute_utf8_len);
211211

212-
ST_ASSERT(size_t(dest - utf8) <= sizeof(utf8), "Destination buffer too small");
212+
ST_ASSERT(static_cast<size_t>(dest - utf8) <= sizeof(utf8),
213+
"Destination buffer too small");
213214

214215
output.append(utf8, dest - utf8);
215216
}

include/st_formatter.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ namespace ST
9191
bool numeric_pad;
9292
};
9393

94-
static_assert(std::is_standard_layout<ST::format_spec>::value,
94+
static_assert(std::is_standard_layout_v<ST::format_spec>,
9595
"ST::format_spec must be standard-layout to pass across the DLL boundary");
9696

9797
class format_writer
@@ -479,7 +479,7 @@ namespace ST
479479
inline void format_type(const ST::format_spec &format, ST::format_writer &output,
480480
float value)
481481
{
482-
format_type(format, output, double(value));
482+
format_type(format, output, static_cast<double>(value));
483483
}
484484

485485
template<typename value_T>

include/st_iostream.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,30 +38,30 @@ namespace _ST_PRIVATE
3838
: ST::format_writer(format_str), m_stream(stream) { }
3939

4040
template <class write_char_T>
41-
typename std::enable_if<std::is_same<write_char_T, char>::value, void>::type
41+
std::enable_if_t<std::is_same_v<write_char_T, char>, void>
4242
write_data(const char *data, size_t size)
4343
{
4444
m_stream.write(data, size);
4545
}
4646

4747
template <class write_char_T>
48-
typename std::enable_if<std::is_same<write_char_T, wchar_t>::value, void>::type
48+
std::enable_if_t<std::is_same_v<write_char_T, wchar_t>, void>
4949
write_data(const char *data, size_t size)
5050
{
5151
ST::wchar_buffer wide = ST::utf8_to_wchar(data, size);
5252
m_stream.write(wide.data(), wide.size());
5353
}
5454

5555
template <class write_char_T>
56-
typename std::enable_if<std::is_same<write_char_T, char16_t>::value, void>::type
56+
std::enable_if_t<std::is_same_v<write_char_T, char16_t>, void>
5757
write_data(const char *data, size_t size)
5858
{
5959
ST::utf16_buffer utf16 = ST::utf8_to_utf16(data, size);
6060
m_stream.write(utf16.data(), utf16.size());
6161
}
6262

6363
template <class write_char_T>
64-
typename std::enable_if<std::is_same<write_char_T, char32_t>::value, void>::type
64+
std::enable_if_t<std::is_same_v<write_char_T, char32_t>, void>
6565
write_data(const char *data, size_t size)
6666
{
6767
ST::utf32_buffer utf32 = ST::utf8_to_utf32(data, size);

include/st_string.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ namespace ST
6969
friend class string;
7070
};
7171

72-
static_assert(std::is_standard_layout<ST::conversion_result>::value,
72+
static_assert(std::is_standard_layout_v<ST::conversion_result>,
7373
"ST::conversion_result must be standard-layout to pass across the DLL boundary");
7474

7575
class string
@@ -2373,7 +2373,7 @@ namespace ST
23732373
ST_NODISCARD
23742374
string replace(const char8_t *from, const string &to,
23752375
case_sensitivity_t cs = case_sensitive,
2376-
utf_validation_t validation = ST_DEFAULT_VALIDATION)
2376+
utf_validation_t validation = ST_DEFAULT_VALIDATION) const
23772377
{
23782378
return replace(from ? string(from, ST_AUTO_SIZE, validation) : string(), to, cs);
23792379
}
@@ -2545,7 +2545,7 @@ namespace ST
25452545
}
25462546
};
25472547

2548-
static_assert(std::is_standard_layout<ST::string>::value,
2548+
static_assert(std::is_standard_layout_v<ST::string>,
25492549
"ST::string must be standard-layout to pass across the DLL boundary");
25502550

25512551
struct hash

0 commit comments

Comments
 (0)