Skip to content

Commit b85e4ec

Browse files
committed
WL#15429 Enable using c++17 standard
Change-Id: I9237d8893a3841381942af5a0300e0b89a8e3471
1 parent a28a9ea commit b85e4ec

File tree

18 files changed

+108
-105
lines changed

18 files changed

+108
-105
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2015, 2020, Oracle and/or its affiliates.
1+
# Copyright (c) 2015, 2022, Oracle and/or its affiliates.
22
#
33
# This program is free software; you can redistribute it and/or modify
44
# it under the terms of the GNU General Public License, version 2.0, as
@@ -149,7 +149,7 @@ add_config_option(BUNDLE_DEPENDENCIES BOOL ADVANCED DEFAULT OFF
149149
#
150150

151151
enable_pic()
152-
enable_cxx11()
152+
enable_cxx17()
153153

154154
#
155155
# Configure static runtime library on Windows if requested

cdk/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2015, 2020, Oracle and/or its affiliates.
1+
# Copyright (c) 2015, 2022, Oracle and/or its affiliates.
22
#
33
# This program is free software; you can redistribute it and/or modify
44
# it under the terms of the GNU General Public License, version 2.0, as
@@ -81,7 +81,7 @@ endif()
8181
#
8282

8383
enable_pic()
84-
enable_cxx11()
84+
enable_cxx17()
8585
# ??? -mt
8686

8787
set(HAVE_MOVE_SEMANTICS 1)

cdk/cmake/compiler/CLANG.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved.
22
#
33
# This program is free software; you can redistribute it and/or modify
44
# it under the terms of the GNU General Public License, version 2.0, as
@@ -27,9 +27,9 @@
2727
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2828

2929

30-
function(enable_cxx11)
30+
function(enable_cxx17)
3131

32-
add_flags(CXX -std=c++11)
32+
add_flags(CXX -std=c++17)
3333

3434
#
3535
# If Clang is used on macOS and deployment target is not specified

cdk/cmake/compiler/MSVC.cmake

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights reserved.
22
#
33
# This program is free software; you can redistribute it and/or modify
44
# it under the terms of the GNU General Public License, version 2.0, as
@@ -62,9 +62,14 @@ set(VS "vs${VS}" CACHE INTERNAL "")
6262
function(enable_pic)
6363
endfunction()
6464

65-
# C++11 is enabled by default for compilers that we support.
65+
function(enable_cxx17)
6666

67-
function(enable_cxx11)
67+
# Note: std::shared_ptr<>::unique is deprecated in C++17 [1].
68+
# TODO: Remove Supression once WL15527 is implemented
69+
# [1] https://en.cppreference.com/w/cpp/memory/shared_ptr/unique
70+
71+
add_flags(CXX /std:c++17
72+
-D_SILENCE_CXX17_SHARED_PTR_UNIQUE_DEPRECATION_WARNING)
6873
endfunction()
6974

7075
# Note: Needs to be implemented if we ever want to change the default

cdk/cmake/compiler/SUNPRO.cmake

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2019, 2020, Oracle and/or its affiliates.
1+
# Copyright (c) 2019, 2022, Oracle and/or its affiliates.
22
#
33
# This program is free software; you can redistribute it and/or modify
44
# it under the terms of the GNU General Public License, version 2.0, as
@@ -53,15 +53,15 @@ endfunction()
5353
# -----------------------------------------------------------------
5454

5555

56-
function(enable_cxx11)
56+
function(enable_cxx17)
5757

58-
# Note: calling _enable_cxx11() did not work on Solaris
58+
# Note: calling _enable_cxx17() did not work on Solaris
5959
#
6060
# With SunPro use GNU libstdc++ implementation of c++ std library. This
61-
# is the default for -std=c++11, but we set it explicitly to be on the safe
61+
# is the default for -std=c++17, but we set it explicitly to be on the safe
6262
# side.
6363
#
64-
add_flags(CXX -std=c++11 -library=stdcpp)
64+
add_flags(CXX -std=c++17 -library=stdcpp)
6565

6666
endfunction()
6767

cdk/cmake/platform.cmake

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights reserved.
22
#
33
# This program is free software; you can redistribute it and/or modify
44
# it under the terms of the GNU General Public License, version 2.0, as
@@ -41,7 +41,7 @@
4141
# Defines the following commands:
4242
#
4343
# enable_pic()
44-
# enable_cxx11()
44+
# enable_cxx17()
4545
# set_arch(A)
4646
# set_visibility()
4747
#
@@ -105,15 +105,15 @@ endmacro()
105105

106106
if(CMAKE_VERSION VERSION_LESS "3.1.3")
107107

108-
function(enable_cxx11)
109-
add_flags(CXX -std=c++11)
108+
function(enable_cxx17)
109+
add_flags(CXX -std=c++17)
110110
endfunction()
111111

112112
else()
113113

114-
function(enable_cxx11)
114+
function(enable_cxx17)
115115
set(CMAKE_CXX_EXTENSIONS OFF PARENT_SCOPE)
116-
set(CMAKE_CXX_STANDARD 11 PARENT_SCOPE)
116+
set(CMAKE_CXX_STANDARD 17 PARENT_SCOPE)
117117
set(CMAKE_CXX_STANDARD_REQUIRED ON PARENT_SCOPE)
118118
endfunction()
119119

cdk/cmake/testing.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ IF(WITH_TESTS)
165165
/wd4456 # declaration of hides previous local declaration
166166
)
167167

168+
target_compile_options(${TEST} PUBLIC /std:c++14)
169+
168170
if(STATIC_TESTS_MSVCRT)
169171
target_compile_options(${TEST} PRIVATE
170172
$<$<CONFIG:Debug>:/MTd>

cdk/extra/protobuf/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ SET(PROTO_SRC_DIR "${PROJECT_SOURCE_DIR}/protobuf-3.19.6")
7070
#
7171

7272
enable_pic()
73-
enable_cxx11()
73+
enable_cxx17()
7474

7575
# -O3 using GCC on SPARC leds to segfault on protoc
7676
if(SPARC AND GCC)

cdk/foundation/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
# Detect required std features.
3232
#
3333

34-
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -std=c++11")
34+
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -std=c++17")
3535

3636
include(CheckCXXSourceCompiles)
3737
include(CheckTypeSize)

cdk/include/mysql/cdk/foundation/string.h

Lines changed: 36 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2020, Oracle and/or its affiliates.
2+
* Copyright (c) 2015, 2022, Oracle and/or its affiliates.
33
*
44
* This program is free software; you can redistribute it and/or modify
55
* it under the terms of the GNU General Public License, version 2.0, as
@@ -382,60 +382,53 @@ size_t str_encode(
382382

383383
template <class ENC>
384384
class char_iterator_base
385-
: public std::iterator<
386-
std::input_iterator_tag,
387-
char_t,
388-
long,
389-
const char_t*,
390-
const char_t&
391-
>
392385
{
393-
protected:
386+
public:
387+
using iterator_category = std::input_iterator_tag;
388+
using value_type = char_t;
389+
using difference_type = long;
390+
using pointer = const char_t*;
391+
using reference = const char_t&;
394392

395-
using code_unit = typename ENC::Ch;
393+
protected:
394+
using code_unit = typename ENC::Ch;
396395

397-
Mem_stream<code_unit> m_stream;
396+
Mem_stream<code_unit> m_stream;
398397

399-
/*
400-
If m_char !=0 then it contains the current character (which was already
401-
decoded) and m_pos points at the next code unit after the character.
402-
If m_char == 0 then m_pos points at the first code unit of the next
403-
character (which is not yet decoded).
404-
405-
m_char != 0
406-
| m_pos m_pos (m_char == 0)
407-
| | |
408-
v v v
409-
------|===|-------- ----|===|-----
410-
411-
TODO: m_pos is redundant, as it is the same as m_stream.src_ ?
412-
*/
398+
/*
399+
If m_char !=0 then it contains the current character (which was already
400+
decoded) and m_pos points at the next code unit after the character.
401+
If m_char == 0 then m_pos points at the first code unit of the next
402+
character (which is not yet decoded).
413403
414-
const code_unit *m_pos = nullptr;
415-
char_t m_char = 0;
416-
bool m_at_end = false;
404+
m_char != 0
405+
| m_pos m_pos (m_char == 0)
406+
| | |
407+
v v v
408+
------|===|-------- ----|===|-----
417409
418-
public:
410+
TODO: m_pos is redundant, as it is the same as m_stream.src_ ?
411+
*/
419412

420-
char_iterator_base()
421-
: m_at_end(true)
422-
{}
413+
const code_unit *m_pos = nullptr;
414+
char_t m_char = 0;
415+
bool m_at_end = false;
423416

424-
char_iterator_base(const code_unit *beg, const code_unit *end)
425-
: m_stream(beg, end), m_pos(beg)
426-
{}
417+
public:
418+
char_iterator_base() : m_at_end(true) {}
427419

428-
char_iterator_base(const code_unit *beg, size_t len)
429-
: char_iterator_base(beg, beg + len)
430-
{}
420+
char_iterator_base(const code_unit *beg, const code_unit *end)
421+
: m_stream(beg, end), m_pos(beg) {}
431422

432-
char_iterator_base(const char_iterator_base &other) = default;
433-
char_iterator_base& operator=(const char_iterator_base&) = default;
423+
char_iterator_base(const code_unit *beg, size_t len)
424+
: char_iterator_base(beg, beg + len) {}
434425

435-
// examine current character
426+
char_iterator_base(const char_iterator_base &other) = default;
427+
char_iterator_base &operator=(const char_iterator_base &) = default;
436428

437-
reference operator*() const
438-
{
429+
// examine current character
430+
431+
reference operator*() const {
439432
/*
440433
If m_char != 0 then it already contains the current character and
441434
the corresponding code units have been consumed from the input stream.

include/mysqlx/devapi/common.h

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
33
*
44
* This program is free software; you can redistribute it and/or modify
55
* it under the terms of the GNU General Public License, version 2.0, as
@@ -388,18 +388,20 @@ template<
388388
typename Reference = typename std::iterator_traits<T*>::reference
389389
>
390390
struct Iterator
391-
: std::iterator < std::input_iterator_tag, T, Distance, Pointer, Reference >
392391
{
393-
protected:
394-
395-
typename std::remove_reference<Impl>::type *m_impl = NULL;
396-
bool m_at_end = false;
392+
public:
393+
using iterator_category = std::input_iterator_tag;
394+
using value_type = T;
395+
using difference_type = Distance;
396+
using pointer = Pointer;
397+
using reference = Reference;
397398

398-
public:
399+
protected:
400+
typename std::remove_reference<Impl>::type *m_impl = NULL;
401+
bool m_at_end = false;
399402

400-
Iterator(Impl& impl)
401-
: m_impl(&impl)
402-
{
403+
public:
404+
Iterator(Impl &impl) : m_impl(&impl) {
403405
m_impl->iterator_start();
404406
m_at_end = !m_impl->iterator_next();
405407
}

include/mysqlx/devapi/settings.h

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2020, Oracle and/or its affiliates.
2+
* Copyright (c) 2015, 2022, Oracle and/or its affiliates.
33
*
44
* This program is free software; you can redistribute it and/or modify
55
* it under the terms of the GNU General Public License, version 2.0, as
@@ -359,24 +359,19 @@ do_set(session_opt_list_t &&opts);
359359

360360
template<typename Option, typename base_iterator>
361361
class iterator
362-
: public std::iterator<std::input_iterator_tag,
363-
std::pair<Option, mysqlx::Value>>
364362
{
365363
base_iterator m_it;
366364
std::pair<Option, mysqlx::Value> m_pair;
367365

368366
public:
369-
iterator(const base_iterator &init)
370-
: m_it(init)
371-
{}
367+
using iterator_category = std::input_iterator_tag;
368+
using value_type = std::pair<Option, mysqlx::Value>;
372369

373-
iterator(const iterator &init)
374-
: m_it(init.m_it)
375-
{}
370+
iterator(const base_iterator &init) : m_it(init) {}
376371

372+
iterator(const iterator &init) : m_it(init.m_it) {}
377373

378-
std::pair<Option, mysqlx::Value>& operator*()
379-
{
374+
std::pair<Option, mysqlx::Value> &operator*() {
380375
auto &el = *m_it;
381376
m_pair.first = static_cast<typename Option::Enum>(el.first);
382377
m_pair.second = el.second;

jdbc/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ if(NOT DEFINED CMAKE_CXX_FLAGS)
157157
set_visibility(hidden)
158158
endif()
159159

160-
enable_cxx11()
160+
enable_cxx17()
161161

162162

163163
#-----------------

jdbc/cmake/compiler/CLANG.cmake

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved.
22
#
33
# This program is free software; you can redistribute it and/or modify
44
# it under the terms of the GNU General Public License, version 2.0, as
@@ -27,21 +27,25 @@
2727
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2828

2929

30-
function(enable_cxx11)
30+
function(enable_cxx17)
31+
32+
add_flags(CXX -std=c++17)
3133

3234
#
33-
# If Clang is used and deployment target is not specified
35+
# If Clang is used on macOS and deployment target is not specified
3436
# with MACOSX_DEPLOYMENT_TARGET environment variable, make
3537
# sure that clang's native implementation of C++ std
3638
# libarary (libc++) is used. Otherwise clang defaults to
3739
# GNU version (libstdc++) which is outdated and does
38-
# not handle C++11 well.
40+
# not handle C++17 well.
3941
#
4042
# TODO: Add option to use the default runtime if user wishes
4143
# so.
4244
#
4345

44-
add_flags(CXX -std=c++11 -stdlib=libc++)
46+
if (MACOS)
47+
add_flags(CXX -stdlib=libc++)
48+
endif()
4549

4650
endfunction()
4751

jdbc/cmake/compiler/MSVC.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights reserved.
22
#
33
# This program is free software; you can redistribute it and/or modify
44
# it under the terms of the GNU General Public License, version 2.0, as
@@ -64,7 +64,7 @@ endfunction()
6464

6565
# C++11 is enabled by default for compilers that we support.
6666

67-
function(enable_cxx11)
67+
function(enable_cxx17)
6868
endfunction()
6969

7070
# Note: Needs to be implemented if we ever want to change the default

0 commit comments

Comments
 (0)