Skip to content

Commit

Permalink
refactor(c/driver/postgresql): start C++17 (#1472)
Browse files Browse the repository at this point in the history
  • Loading branch information
WillAyd authored Jan 19, 2024
1 parent d78ce71 commit 53f3128
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 2 additions & 0 deletions c/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ include(BuildUtils)
project(adbc
VERSION "${ADBC_BASE_VERSION}"
LANGUAGES C CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

include(CTest)

Expand Down
9 changes: 5 additions & 4 deletions c/driver/postgresql/copy/writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@

#pragma once

#include <charconv>
#include <cinttypes>
#include <limits>
#include <memory>
#include <string>
#include <string_view>
#include <utility>
#include <vector>

Expand Down Expand Up @@ -237,10 +239,9 @@ class PostgresCopyNumericFieldWriter : public PostgresCopyFieldWriter {
const int start_pos =
digits_remaining < kDecDigits ? 0 : digits_remaining - kDecDigits;
const size_t len = digits_remaining < 4 ? digits_remaining : kDecDigits;
char substr[kDecDigits + 1];
std::memcpy(substr, decimal_string + start_pos, len);
substr[len] = '\0';
int16_t val = static_cast<int16_t>(std::atoi(substr));
const std::string_view substr{decimal_string + start_pos, len};
int16_t val{};
std::from_chars(substr.data(), substr.data() + substr.size(), val);

if (val == 0) {
if (!seen_decimal && truncating_trailing_zeros) {
Expand Down
1 change: 0 additions & 1 deletion ci/scripts/cpp_clang_tidy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ build_subproject() {
-DADBC_DRIVER_SNOWFLAKE="${BUILD_DRIVER_SNOWFLAKE}" \
-DADBC_USE_ASAN="${ADBC_USE_ASAN}" \
-DADBC_USE_UBSAN="${ADBC_USE_UBSAN}" \
-DCMAKE_CXX_STANDARD=17 \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}" \
-DCMAKE_INSTALL_LIBDIR=lib \
Expand Down

0 comments on commit 53f3128

Please sign in to comment.