Skip to content

Commit d70b893

Browse files
committed
Bump project requirement to C++17
1 parent a579b4a commit d70b893

19 files changed

Lines changed: 101 additions & 139 deletions

.github/workflows/ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,10 @@ jobs:
200200
-Value "set(VCPKG_BUILD_TYPE release)","set(VCPKG_OSX_DEPLOYMENT_TARGET 10.15)"
201201
202202
# NOTE: Avoids a libtorrent ABI issue. See https://github.com/arvidn/libtorrent/issues/4965
203-
- name: force AppleClang to compile libtorrent with C++14
203+
- name: force AppleClang to compile libtorrent with C++17
204204
run: |
205205
(Get-Content -path ${{ env.RUNVCPKG_VCPKG_ROOT }}/ports/libtorrent/portfile.cmake).Replace( `
206-
'${FEATURE_OPTIONS}', '${FEATURE_OPTIONS} -DCMAKE_CXX_STANDARD=14') `
206+
'${FEATURE_OPTIONS}', '${FEATURE_OPTIONS} -DCMAKE_CXX_STANDARD=17') `
207207
| Set-Content -Path ${{ env.RUNVCPKG_VCPKG_ROOT }}/ports/libtorrent/portfile.cmake
208208
209209
- name: install dependencies via vcpkg

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ install:
129129
130130
cmake \
131131
-DCMAKE_BUILD_TYPE=Release \
132-
-DCMAKE_CXX_STANDARD=14 \
132+
-DCMAKE_CXX_STANDARD=17 \
133133
-Ddeprecated-functions=OFF \
134134
-DOPENSSL_ROOT_DIR="$openssl_root_path" \
135135
./
@@ -145,7 +145,7 @@ install:
145145
146146
cmake \
147147
-DCMAKE_BUILD_TYPE=Release \
148-
-DCMAKE_CXX_STANDARD=14 \
148+
-DCMAKE_CXX_STANDARD=17 \
149149
-Ddeprecated-functions=ON \
150150
-DOPENSSL_ROOT_DIR="$openssl_root_path" \
151151
./

cmake/Modules/MacroQbtCommonConfig.cmake

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,11 @@ macro(qbt_common_config)
2020

2121
add_library(qbt_common_cfg INTERFACE)
2222

23-
# Full C++ 14 support is required
23+
# Full C++ 17 support is required
2424
# See also https://cmake.org/cmake/help/latest/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.html
2525
# for a breakdown of the features that CMake recognizes for each C++ standard
2626
target_compile_features(qbt_common_cfg INTERFACE
27-
cxx_std_14
28-
cxx_aggregate_default_initializers
29-
cxx_attribute_deprecated
30-
cxx_binary_literals
31-
cxx_contextual_conversions
32-
cxx_decltype_auto
33-
cxx_digit_separators
34-
cxx_generic_lambdas
35-
cxx_lambda_init_captures
36-
cxx_relaxed_constexpr
37-
cxx_return_type_deduction
38-
cxx_variable_templates
27+
cxx_std_17
3928
)
4029

4130
set(QBT_PROJECT_VERSION "${qBittorrent_VERSION_MAJOR}.${qBittorrent_VERSION_MINOR}.${qBittorrent_VERSION_PATCH}")

configure

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5564,18 +5564,18 @@ $as_echo "yes" >&6; }
55645564
LIBS="$zlib_LIBS $LIBS"
55655565
fi
55665566

5567-
# Check if already in >= C++14 mode because of the flags returned by one of the above packages
5567+
# Check if already in >= C++17 mode because of the flags returned by one of the above packages
55685568
TMP_CXXFLAGS="$CXXFLAGS"
55695569
CXXFLAGS=""
5570-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler defaults to C++14 or later mode" >&5
5571-
$as_echo_n "checking if compiler defaults to C++14 or later mode... " >&6; }
5570+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler defaults to C++17 or later mode" >&5
5571+
$as_echo_n "checking if compiler defaults to C++17 or later mode... " >&6; }
55725572
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
55735573
/* end confdefs.h. */
55745574
55755575
#ifndef __cplusplus
55765576
#error "This is not a C++ compiler"
5577-
#elif __cplusplus < 201402L
5578-
#error "This is not a C++14 compiler"
5577+
#elif __cplusplus < 201703L
5578+
#error "This is not a C++17 compiler"
55795579
#endif
55805580
int
55815581
main ()
@@ -5589,27 +5589,27 @@ _ACEOF
55895589
if ac_fn_cxx_try_compile "$LINENO"; then :
55905590
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
55915591
$as_echo "yes" >&6; }
5592-
QBT_CXX14_FOUND="yes"
5592+
QBT_CXX17_FOUND="yes"
55935593
else
55945594
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
55955595
$as_echo "no" >&6; }
5596-
QBT_CXX14_FOUND="no"
5596+
QBT_CXX17_FOUND="no"
55975597
fi
55985598
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
55995599

5600-
# In case of no, check if the compiler can support at least C++14
5600+
# In case of no, check if the compiler can support at least C++17
56015601
# and if yes, enable it leaving a warning to the user
5602-
if test "x$QBT_CXX14_FOUND" = "xno"; then :
5603-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler supports C++14" >&5
5604-
$as_echo_n "checking if compiler supports C++14... " >&6; }
5605-
CXXFLAGS="-std=c++14"
5602+
if test "x$QBT_CXX17_FOUND" = "xno"; then :
5603+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler supports C++17" >&5
5604+
$as_echo_n "checking if compiler supports C++17... " >&6; }
5605+
CXXFLAGS="-std=c++17"
56065606
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
56075607
/* end confdefs.h. */
56085608
56095609
#ifndef __cplusplus
56105610
#error "This is not a C++ compiler"
5611-
#elif __cplusplus < 201402L
5612-
#error "This is not a C++14 compiler"
5611+
#elif __cplusplus < 201703L
5612+
#error "This is not a C++17 compiler"
56135613
#endif
56145614
int
56155615
main ()
@@ -5623,17 +5623,17 @@ _ACEOF
56235623
if ac_fn_cxx_try_compile "$LINENO"; then :
56245624
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
56255625
$as_echo "yes" >&6; }
5626-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if C++14 is disabled by the set compiler flags" >&5
5627-
$as_echo_n "checking if C++14 is disabled by the set compiler flags... " >&6; }
5626+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if C++17 is disabled by the set compiler flags" >&5
5627+
$as_echo_n "checking if C++17 is disabled by the set compiler flags... " >&6; }
56285628
# prepend the flag so it won't override conflicting user defined flags
5629-
CXXFLAGS="-std=c++14 $TMP_CXXFLAGS"
5629+
CXXFLAGS="-std=c++17 $TMP_CXXFLAGS"
56305630
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
56315631
/* end confdefs.h. */
56325632
56335633
#ifndef __cplusplus
56345634
#error "This is not a C++ compiler"
5635-
#elif __cplusplus < 201402L
5636-
#error "This is not a C++14 compiler"
5635+
#elif __cplusplus < 201703L
5636+
#error "This is not a C++17 compiler"
56375637
#endif
56385638
int
56395639
main ()
@@ -5647,19 +5647,19 @@ _ACEOF
56475647
if ac_fn_cxx_try_compile "$LINENO"; then :
56485648
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
56495649
$as_echo "no" >&6; }
5650-
QBT_ADD_CONFIG="$QBT_ADD_CONFIG c++14"
5651-
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: C++14 mode is now force enabled. The C++ mode should match the mode that other libraries were built with, otherwise you'll likely get linking errors." >&5
5652-
$as_echo "$as_me: WARNING: C++14 mode is now force enabled. The C++ mode should match the mode that other libraries were built with, otherwise you'll likely get linking errors." >&2;}
5650+
QBT_ADD_CONFIG="$QBT_ADD_CONFIG c++17"
5651+
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: C++17 mode is now force enabled. The C++ mode should match the mode that other libraries were built with, otherwise you'll likely get linking errors." >&5
5652+
$as_echo "$as_me: WARNING: C++17 mode is now force enabled. The C++ mode should match the mode that other libraries were built with, otherwise you'll likely get linking errors." >&2;}
56535653
else
56545654
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
56555655
$as_echo "yes" >&6; }
5656-
as_fn_error $? "The compiler supports C++14 but the user or a dependency has explicitly enabled a lower mode." "$LINENO" 5
5656+
as_fn_error $? "The compiler supports C++17 but the user or a dependency has explicitly enabled a lower mode." "$LINENO" 5
56575657
fi
56585658
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
56595659
else
56605660
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
56615661
$as_echo "no" >&6; }
5662-
as_fn_error $? "A compiler supporting C++14 is required." "$LINENO" 5
5662+
as_fn_error $? "A compiler supporting C++17 is required." "$LINENO" 5
56635663
fi
56645664
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
56655665

@@ -7034,7 +7034,9 @@ $as_echo X/"$am_mf" |
70347034
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
70357035
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
70367036
as_fn_error $? "Something went wrong bootstrapping makefile fragments
7037-
for automatic dependency tracking. Try re-running configure with the
7037+
for automatic dependency tracking. If GNU make was not used, consider
7038+
re-running the configure script with MAKE=\"gmake\" (or whatever is
7039+
necessary). You can also try re-running configure with the
70387040
'--disable-dependency-tracking' option to at least be able to build
70397041
the package (albeit without support for automatic dependency tracking).
70407042
See \`config.log' for more details" "$LINENO" 5; }
@@ -8351,7 +8353,9 @@ $as_echo X/"$am_mf" |
83518353
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
83528354
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
83538355
as_fn_error $? "Something went wrong bootstrapping makefile fragments
8354-
for automatic dependency tracking. Try re-running configure with the
8356+
for automatic dependency tracking. If GNU make was not used, consider
8357+
re-running the configure script with MAKE=\"gmake\" (or whatever is
8358+
necessary). You can also try re-running configure with the
83558359
'--disable-dependency-tracking' option to at least be able to build
83568360
the package (albeit without support for automatic dependency tracking).
83578361
See \`config.log' for more details" "$LINENO" 5; }

configure.ac

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -194,34 +194,34 @@ PKG_CHECK_MODULES(zlib,
194194
[CXXFLAGS="$zlib_CFLAGS $CXXFLAGS"
195195
LIBS="$zlib_LIBS $LIBS"])
196196

197-
# Check if already in >= C++14 mode because of the flags returned by one of the above packages
197+
# Check if already in >= C++17 mode because of the flags returned by one of the above packages
198198
TMP_CXXFLAGS="$CXXFLAGS"
199199
CXXFLAGS=""
200-
AC_MSG_CHECKING([if compiler defaults to C++14 or later mode])
201-
AC_COMPILE_IFELSE([DETECT_CPP14_PROGRAM()],
200+
AC_MSG_CHECKING([if compiler defaults to C++17 or later mode])
201+
AC_COMPILE_IFELSE([DETECT_CPP17_PROGRAM()],
202202
[AC_MSG_RESULT([yes])
203-
QBT_CXX14_FOUND="yes"],
203+
QBT_CXX17_FOUND="yes"],
204204
[AC_MSG_RESULT([no])
205-
QBT_CXX14_FOUND="no"])
205+
QBT_CXX17_FOUND="no"])
206206

207-
# In case of no, check if the compiler can support at least C++14
207+
# In case of no, check if the compiler can support at least C++17
208208
# and if yes, enable it leaving a warning to the user
209-
AS_IF([test "x$QBT_CXX14_FOUND" = "xno"],
210-
[AC_MSG_CHECKING([if compiler supports C++14])
211-
CXXFLAGS="-std=c++14"
212-
AC_COMPILE_IFELSE([DETECT_CPP14_PROGRAM()],
209+
AS_IF([test "x$QBT_CXX17_FOUND" = "xno"],
210+
[AC_MSG_CHECKING([if compiler supports C++17])
211+
CXXFLAGS="-std=c++17"
212+
AC_COMPILE_IFELSE([DETECT_CPP17_PROGRAM()],
213213
[AC_MSG_RESULT([yes])
214-
AC_MSG_CHECKING([if C++14 is disabled by the set compiler flags])
214+
AC_MSG_CHECKING([if C++17 is disabled by the set compiler flags])
215215
# prepend the flag so it won't override conflicting user defined flags
216-
CXXFLAGS="-std=c++14 $TMP_CXXFLAGS"
217-
AC_COMPILE_IFELSE([DETECT_CPP14_PROGRAM()],
216+
CXXFLAGS="-std=c++17 $TMP_CXXFLAGS"
217+
AC_COMPILE_IFELSE([DETECT_CPP17_PROGRAM()],
218218
[AC_MSG_RESULT([no])
219-
QBT_ADD_CONFIG="$QBT_ADD_CONFIG c++14"
220-
AC_MSG_WARN([C++14 mode is now force enabled. The C++ mode should match the mode that other libraries were built with, otherwise you'll likely get linking errors.])],
219+
QBT_ADD_CONFIG="$QBT_ADD_CONFIG c++17"
220+
AC_MSG_WARN([C++17 mode is now force enabled. The C++ mode should match the mode that other libraries were built with, otherwise you'll likely get linking errors.])],
221221
[AC_MSG_RESULT([yes])
222-
AC_MSG_ERROR([The compiler supports C++14 but the user or a dependency has explicitly enabled a lower mode.])])],
222+
AC_MSG_ERROR([The compiler supports C++17 but the user or a dependency has explicitly enabled a lower mode.])])],
223223
[AC_MSG_RESULT([no])
224-
AC_MSG_ERROR([A compiler supporting C++14 is required.])])
224+
AC_MSG_ERROR([A compiler supporting C++17 is required.])])
225225
])
226226
CXXFLAGS="$TMP_CXXFLAGS"
227227

m4/qbittorrent.m4

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ AC_DEFUN([FIND_QTDBUS],
3737
HAVE_QTDBUS=[false]])
3838
])
3939

40-
# DETECT_CPP14_PROGRAM()
41-
# Detects if at least C++14 mode is enabled.
40+
# DETECT_CPP17_PROGRAM()
41+
# Detects if at least C++17 mode is enabled.
4242
# --------------------------------------
43-
AC_DEFUN([DETECT_CPP14_PROGRAM],
43+
AC_DEFUN([DETECT_CPP17_PROGRAM],
4444
[AC_LANG_PROGRAM([[
4545
#ifndef __cplusplus
4646
#error "This is not a C++ compiler"
47-
#elif __cplusplus < 201402L
48-
#error "This is not a C++14 compiler"
47+
#elif __cplusplus < 201703L
48+
#error "This is not a C++17 compiler"
4949
#endif]],
5050
[[]])
5151
])

src/base/algorithm.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,14 @@
3232

3333
namespace Algorithm
3434
{
35-
template <typename ...>
36-
using void_t = void; // replace this with std::void_t in C++17
37-
3835
template <typename T, typename = void>
3936
struct HasMappedType
4037
: std::false_type
4138
{
4239
};
4340

4441
template <typename T>
45-
struct HasMappedType<T, void_t<typename T::mapped_type>>
42+
struct HasMappedType<T, std::void_t<typename T::mapped_type>>
4643
: std::true_type
4744
{
4845
};

src/base/bittorrent/common.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,4 @@
3030

3131
#include <QString>
3232

33-
// TODO: Make it inline in C++17
34-
extern const QString QB_EXT;
33+
inline const QString QB_EXT {QStringLiteral(".!qB")};

src/base/bittorrent/ltunderlyingtype.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,14 @@
3030

3131
#include <type_traits>
3232

33-
template <typename ...>
34-
using void_t = void; // replace this with std::void_t in C++17
35-
3633
template <typename T, typename = void>
3734
struct HasUnderlyingType
3835
: std::false_type
3936
{
4037
};
4138

4239
template <typename T>
43-
struct HasUnderlyingType<T, void_t<typename T::underlying_type>>
40+
struct HasUnderlyingType<T, std::void_t<typename T::underlying_type>>
4441
: std::true_type
4542
{
4643
};

src/base/bittorrent/session.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,9 +291,8 @@ namespace
291291
LowerLimited<T> lowerLimited(T limit, T ret) { return LowerLimited<T>(limit, ret); }
292292

293293
template <typename T>
294-
std::function<T (const T&)> clampValue(const T lower, const T upper)
294+
auto clampValue(const T lower, const T upper)
295295
{
296-
// TODO: change return type to `auto` when using C++17
297296
return [lower, upper](const T value) -> T
298297
{
299298
if (value < lower)

0 commit comments

Comments
 (0)