From eb22603e697569c711bfa2568919b333d82ed0f2 Mon Sep 17 00:00:00 2001 From: Karthikeyan Natarajan Date: Thu, 1 Jun 2023 22:59:40 +0530 Subject: [PATCH 1/2] use east const instead of west const --- .../cudf/column/column_device_view.cuh | 4 +- cpp/include/cudf/column/column_factories.hpp | 2 +- cpp/include/cudf/copying.hpp | 4 +- .../cudf/detail/aggregation/result_cache.hpp | 2 +- cpp/include/cudf/detail/copy_if.cuh | 8 +- cpp/include/cudf/detail/copy_if_else.cuh | 4 +- cpp/include/cudf/detail/copy_range.cuh | 12 +- cpp/include/cudf/detail/null_mask.cuh | 6 +- cpp/include/cudf/detail/scatter.hpp | 4 +- cpp/include/cudf/detail/utilities/cuda.cuh | 6 +- .../detail/utilities/device_operators.cuh | 20 +- .../cudf/detail/utilities/hash_functions.cuh | 4 +- .../cudf/detail/utilities/int_fastdiv.h | 36 +-- .../cudf/detail/utilities/integer_utils.hpp | 2 +- .../detail/utilities/pinned_host_vector.hpp | 6 +- cpp/include/cudf/groupby.hpp | 2 +- cpp/include/cudf/io/csv.hpp | 2 +- cpp/include/cudf/io/data_sink.hpp | 2 +- cpp/include/cudf/io/datasource.hpp | 2 +- cpp/include/cudf/io/detail/data_casting.cuh | 2 +- cpp/include/cudf/io/detail/parquet.hpp | 2 +- cpp/include/cudf/io/json.hpp | 4 +- cpp/include/cudf/io/orc.hpp | 4 +- cpp/include/cudf/io/parquet.hpp | 2 +- .../io/text/data_chunk_source_factories.hpp | 4 +- cpp/include/cudf/io/types.hpp | 6 +- cpp/include/cudf/join.hpp | 2 +- cpp/include/cudf/lists/lists_column_view.hpp | 2 +- cpp/include/cudf/reduction.hpp | 2 +- .../reduction/detail/reduction_operators.cuh | 24 +- cpp/include/cudf/rolling.hpp | 4 +- cpp/include/cudf/scalar/scalar.hpp | 2 +- .../cudf/scalar/scalar_device_view.cuh | 6 +- cpp/include/cudf/strings/combine.hpp | 8 +- .../cudf/strings/detail/char_tables.hpp | 6 +- .../strings/detail/convert/fixed_point.cuh | 4 +- .../cudf/strings/detail/convert/is_float.cuh | 4 +- .../detail/convert/string_to_float.cuh | 6 +- .../strings/detail/convert/string_to_int.cuh | 4 +- cpp/include/cudf/strings/detail/gather.cuh | 4 +- .../detail/strings_column_factories.cuh | 2 +- cpp/include/cudf/strings/detail/utf8.hpp | 2 +- cpp/include/cudf/strings/detail/utilities.cuh | 10 +- cpp/include/cudf/strings/string_view.cuh | 48 ++-- cpp/include/cudf/strings/string_view.hpp | 56 ++-- .../cudf/tdigest/tdigest_column_view.hpp | 4 +- cpp/include/cudf/utilities/error.hpp | 2 +- cpp/include/cudf/utilities/span.hpp | 4 +- cpp/include/cudf/wrappers/dictionary.hpp | 2 +- cpp/include/cudf_test/base_fixture.hpp | 8 +- cpp/include/cudf_test/cxxopts.hpp | 262 +++++++++--------- cpp/include/cudf_test/file_utilities.hpp | 6 +- .../include/cudf_kafka/kafka_callback.hpp | 4 +- 53 files changed, 320 insertions(+), 320 deletions(-) diff --git a/cpp/include/cudf/column/column_device_view.cuh b/cpp/include/cudf/column/column_device_view.cuh index efb96cb6af6..7c137570c35 100644 --- a/cpp/include/cudf/column/column_device_view.cuh +++ b/cpp/include/cudf/column/column_device_view.cuh @@ -442,8 +442,8 @@ class alignas(16) column_device_view : public detail::column_device_view_base { __device__ T element(size_type element_index) const noexcept { size_type index = element_index + offset(); // account for this view's _offset - const auto* d_offsets = d_children[strings_column_view::offsets_column_index].data(); - const char* d_strings = d_children[strings_column_view::chars_column_index].data(); + auto const* d_offsets = d_children[strings_column_view::offsets_column_index].data(); + char const* d_strings = d_children[strings_column_view::chars_column_index].data(); size_type offset = d_offsets[index]; return string_view{d_strings + offset, d_offsets[index + 1] - offset}; } diff --git a/cpp/include/cudf/column/column_factories.hpp b/cpp/include/cudf/column/column_factories.hpp index f0f7bf092d3..99c49ccbfc6 100644 --- a/cpp/include/cudf/column/column_factories.hpp +++ b/cpp/include/cudf/column/column_factories.hpp @@ -374,7 +374,7 @@ std::unique_ptr make_fixed_width_column( * @return Constructed strings column */ std::unique_ptr make_strings_column( - cudf::device_span const> strings, + cudf::device_span const> strings, rmm::cuda_stream_view stream = cudf::get_default_stream(), rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); diff --git a/cpp/include/cudf/copying.hpp b/cpp/include/cudf/copying.hpp index cdb8a1c8a09..b55c40077b1 100644 --- a/cpp/include/cudf/copying.hpp +++ b/cpp/include/cudf/copying.hpp @@ -193,7 +193,7 @@ std::unique_ptr scatter( * @return Result of scattering values from source to target */ std::unique_ptr
scatter( - std::vector> const& source, + std::vector> const& source, column_view const& indices, table_view const& target, rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); @@ -716,7 +716,7 @@ std::unique_ptr
boolean_mask_scatter( * @returns Returns a table by scattering `input` into `target` as per `boolean_mask` */ std::unique_ptr
boolean_mask_scatter( - std::vector> const& input, + std::vector> const& input, table_view const& target, column_view const& boolean_mask, rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); diff --git a/cpp/include/cudf/detail/aggregation/result_cache.hpp b/cpp/include/cudf/detail/aggregation/result_cache.hpp index 89bab94faaf..a0273f6c2c7 100644 --- a/cpp/include/cudf/detail/aggregation/result_cache.hpp +++ b/cpp/include/cudf/detail/aggregation/result_cache.hpp @@ -45,7 +45,7 @@ class result_cache { result_cache() = delete; ~result_cache() = default; result_cache(result_cache const&) = delete; - result_cache& operator=(const result_cache& other) = delete; + result_cache& operator=(result_cache const& other) = delete; result_cache(size_t num_columns) : _cache(num_columns) {} diff --git a/cpp/include/cudf/detail/copy_if.cuh b/cpp/include/cudf/detail/copy_if.cuh index cb3e20b36f2..e82f8d2e723 100644 --- a/cpp/include/cudf/detail/copy_if.cuh +++ b/cpp/include/cudf/detail/copy_if.cuh @@ -161,10 +161,10 @@ __launch_bounds__(block_size) __global__ constexpr int num_warps = block_size / cudf::detail::warp_size; // account for partial blocks with non-warp-aligned offsets - const int last_index = tmp_block_sum + (block_offset % cudf::detail::warp_size) - 1; - const int last_warp = min(num_warps, last_index / cudf::detail::warp_size); - const int wid = threadIdx.x / cudf::detail::warp_size; - const int lane = threadIdx.x % cudf::detail::warp_size; + int const last_index = tmp_block_sum + (block_offset % cudf::detail::warp_size) - 1; + int const last_warp = min(num_warps, last_index / cudf::detail::warp_size); + int const wid = threadIdx.x / cudf::detail::warp_size; + int const lane = threadIdx.x % cudf::detail::warp_size; cudf::size_type tmp_warp_valid_counts{0}; diff --git a/cpp/include/cudf/detail/copy_if_else.cuh b/cpp/include/cudf/detail/copy_if_else.cuh index 083b12edbf8..7b97abdfcd0 100644 --- a/cpp/include/cudf/detail/copy_if_else.cuh +++ b/cpp/include/cudf/detail/copy_if_else.cuh @@ -45,7 +45,7 @@ __launch_bounds__(block_size) __global__ size_type* __restrict__ const valid_count) { const size_type tid = threadIdx.x + blockIdx.x * block_size; - const int warp_id = tid / warp_size; + int const warp_id = tid / warp_size; const size_type warps_per_grid = gridDim.x * block_size / warp_size; // begin/end indices for the column data @@ -59,7 +59,7 @@ __launch_bounds__(block_size) __global__ // lane id within the current warp constexpr size_type leader_lane{0}; - const int lane_id = threadIdx.x % warp_size; + int const lane_id = threadIdx.x % warp_size; size_type warp_valid_count{0}; diff --git a/cpp/include/cudf/detail/copy_range.cuh b/cpp/include/cudf/detail/copy_range.cuh index d8773602252..3edfa0cb6c6 100644 --- a/cpp/include/cudf/detail/copy_range.cuh +++ b/cpp/include/cudf/detail/copy_range.cuh @@ -54,10 +54,10 @@ __global__ void copy_range_kernel(SourceValueIterator source_value_begin, "copy_range_kernel assumes bitmask element size in bits == warp size"); constexpr cudf::size_type leader_lane{0}; - const int lane_id = threadIdx.x % warp_size; + int const lane_id = threadIdx.x % warp_size; const cudf::size_type tid = threadIdx.x + blockIdx.x * blockDim.x; - const int warp_id = tid / warp_size; + int const warp_id = tid / warp_size; const cudf::size_type offset = target.offset(); const cudf::size_type begin_mask_idx = cudf::word_index(offset + target_begin); @@ -79,10 +79,10 @@ __global__ void copy_range_kernel(SourceValueIterator source_value_begin, if (in_range) target.element(index) = *(source_value_begin + source_idx); if (has_validity) { // update bitmask - const bool valid = in_range && *(source_validity_begin + source_idx); - const int active_mask = __ballot_sync(0xFFFF'FFFFu, in_range); - const int valid_mask = __ballot_sync(0xFFFF'FFFFu, valid); - const int warp_mask = active_mask & valid_mask; + bool const valid = in_range && *(source_validity_begin + source_idx); + int const active_mask = __ballot_sync(0xFFFF'FFFFu, in_range); + int const valid_mask = __ballot_sync(0xFFFF'FFFFu, valid); + int const warp_mask = active_mask & valid_mask; cudf::bitmask_type old_mask = target.get_mask_word(mask_idx); if (lane_id == leader_lane) { diff --git a/cpp/include/cudf/detail/null_mask.cuh b/cpp/include/cudf/detail/null_mask.cuh index 3ff3bb4cf3c..6db2d30842b 100644 --- a/cpp/include/cudf/detail/null_mask.cuh +++ b/cpp/include/cudf/detail/null_mask.cuh @@ -262,7 +262,7 @@ __global__ void subtract_set_bits_range_boundaries_kernel(bitmask_type const* bi */ struct bit_to_word_index { bit_to_word_index(bool inclusive) : inclusive(inclusive) {} - __device__ inline size_type operator()(const size_type& bit_index) const + __device__ inline size_type operator()(size_type const& bit_index) const { return word_index(bit_index) + ((inclusive || intra_word_index(bit_index) == 0) ? 0 : 1); } @@ -378,13 +378,13 @@ size_type validate_segmented_indices(IndexIterator indices_begin, IndexIterator } struct index_alternator { - __device__ inline size_type operator()(const size_type& i) const + __device__ inline size_type operator()(size_type const& i) const { return *(d_indices + 2 * i + (is_end ? 1 : 0)); } bool const is_end = false; - const size_type* d_indices; + size_type const* d_indices; }; /** diff --git a/cpp/include/cudf/detail/scatter.hpp b/cpp/include/cudf/detail/scatter.hpp index 39ae4fe1944..94c795f31b2 100644 --- a/cpp/include/cudf/detail/scatter.hpp +++ b/cpp/include/cudf/detail/scatter.hpp @@ -106,7 +106,7 @@ std::unique_ptr
scatter(table_view const& source, * @param mr Device memory resource used to allocate the returned table's device memory * @return Result of scattering values from source to target */ -std::unique_ptr
scatter(std::vector> const& source, +std::unique_ptr
scatter(std::vector> const& source, column_view const& indices, table_view const& target, rmm::cuda_stream_view stream, @@ -136,7 +136,7 @@ std::unique_ptr
boolean_mask_scatter(table_view const& source, * @param stream CUDA stream used for device memory operations and kernel launches. */ std::unique_ptr
boolean_mask_scatter( - std::vector> const& source, + std::vector> const& source, table_view const& target, column_view const& boolean_mask, rmm::cuda_stream_view stream, diff --git a/cpp/include/cudf/detail/utilities/cuda.cuh b/cpp/include/cudf/detail/utilities/cuda.cuh index cdbc26701d1..a1248982ed0 100644 --- a/cpp/include/cudf/detail/utilities/cuda.cuh +++ b/cpp/include/cudf/detail/utilities/cuda.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,8 +41,8 @@ static constexpr size_type warp_size{32}; */ class grid_1d { public: - const int num_threads_per_block; - const int num_blocks; + int const num_threads_per_block; + int const num_blocks; /** * @param overall_num_elements The number of elements the kernel needs to * handle/process, in its main, one-dimensional/linear input (e.g. one or more diff --git a/cpp/include/cudf/detail/utilities/device_operators.cuh b/cpp/include/cudf/detail/utilities/device_operators.cuh index f6d9d32b398..0954d429bb5 100644 --- a/cpp/include/cudf/detail/utilities/device_operators.cuh +++ b/cpp/include/cudf/detail/utilities/device_operators.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -62,7 +62,7 @@ CUDF_HOST_DEVICE inline auto max(LHS const& lhs, RHS const& rhs) */ struct DeviceSum { template ()>* = nullptr> - CUDF_HOST_DEVICE inline auto operator()(const T& lhs, const T& rhs) -> decltype(lhs + rhs) + CUDF_HOST_DEVICE inline auto operator()(T const& lhs, T const& rhs) -> decltype(lhs + rhs) { return lhs + rhs; } @@ -93,13 +93,13 @@ struct DeviceSum { */ struct DeviceCount { template ()>* = nullptr> - CUDF_HOST_DEVICE inline T operator()(const T& lhs, const T& rhs) + CUDF_HOST_DEVICE inline T operator()(T const& lhs, T const& rhs) { return T{DeviceCount{}(lhs.time_since_epoch(), rhs.time_since_epoch())}; } template ()>* = nullptr> - CUDF_HOST_DEVICE inline T operator()(const T&, const T& rhs) + CUDF_HOST_DEVICE inline T operator()(T const&, T const& rhs) { return rhs + T{1}; } @@ -116,7 +116,7 @@ struct DeviceCount { */ struct DeviceMin { template - CUDF_HOST_DEVICE inline auto operator()(const T& lhs, const T& rhs) + CUDF_HOST_DEVICE inline auto operator()(T const& lhs, T const& rhs) -> decltype(cudf::detail::min(lhs, rhs)) { return numeric::detail::min(lhs, rhs); @@ -164,7 +164,7 @@ struct DeviceMin { */ struct DeviceMax { template - CUDF_HOST_DEVICE inline auto operator()(const T& lhs, const T& rhs) + CUDF_HOST_DEVICE inline auto operator()(T const& lhs, T const& rhs) -> decltype(cudf::detail::max(lhs, rhs)) { return numeric::detail::max(lhs, rhs); @@ -211,7 +211,7 @@ struct DeviceMax { */ struct DeviceProduct { template ()>* = nullptr> - CUDF_HOST_DEVICE inline auto operator()(const T& lhs, const T& rhs) -> decltype(lhs * rhs) + CUDF_HOST_DEVICE inline auto operator()(T const& lhs, T const& rhs) -> decltype(lhs * rhs) { return lhs * rhs; } @@ -235,7 +235,7 @@ struct DeviceProduct { */ struct DeviceAnd { template >* = nullptr> - CUDF_HOST_DEVICE inline auto operator()(const T& lhs, const T& rhs) -> decltype(lhs & rhs) + CUDF_HOST_DEVICE inline auto operator()(T const& lhs, T const& rhs) -> decltype(lhs & rhs) { return (lhs & rhs); } @@ -246,7 +246,7 @@ struct DeviceAnd { */ struct DeviceOr { template >* = nullptr> - CUDF_HOST_DEVICE inline auto operator()(const T& lhs, const T& rhs) -> decltype(lhs | rhs) + CUDF_HOST_DEVICE inline auto operator()(T const& lhs, T const& rhs) -> decltype(lhs | rhs) { return (lhs | rhs); } @@ -257,7 +257,7 @@ struct DeviceOr { */ struct DeviceXor { template >* = nullptr> - CUDF_HOST_DEVICE inline auto operator()(const T& lhs, const T& rhs) -> decltype(lhs ^ rhs) + CUDF_HOST_DEVICE inline auto operator()(T const& lhs, T const& rhs) -> decltype(lhs ^ rhs) { return (lhs ^ rhs); } diff --git a/cpp/include/cudf/detail/utilities/hash_functions.cuh b/cpp/include/cudf/detail/utilities/hash_functions.cuh index ca9c16043a3..e57822f3fdb 100644 --- a/cpp/include/cudf/detail/utilities/hash_functions.cuh +++ b/cpp/include/cudf/detail/utilities/hash_functions.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2022, NVIDIA CORPORATION. + * Copyright (c) 2017-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -140,7 +140,7 @@ struct hash_circular_buffer { available_space = space_to_leave; } - __device__ inline const uint8_t& operator[](int idx) const { return storage[idx]; } + __device__ inline uint8_t const& operator[](int idx) const { return storage[idx]; } }; // Get a uint8_t pointer to a column element and its size as a pair. diff --git a/cpp/include/cudf/detail/utilities/int_fastdiv.h b/cpp/include/cudf/detail/utilities/int_fastdiv.h index b56fe0e88c1..ff442af5194 100644 --- a/cpp/include/cudf/detail/utilities/int_fastdiv.h +++ b/cpp/include/cudf/detail/utilities/int_fastdiv.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Copyright 2014 Maxim Milakov * @@ -58,7 +58,7 @@ class int_fastdiv { int p; unsigned int ad, anc, delta, q1, r1, q2, r2, t; - const unsigned two31 = 0x8000'0000u; + unsigned const two31 = 0x8000'0000u; ad = (d == 0) ? 1 : abs(d); t = two31 + ((unsigned int)d >> 31); anc = t - 1 - t % ad; @@ -95,11 +95,11 @@ class int_fastdiv { n_add_sign = 0; } - __host__ __device__ __forceinline__ friend int operator/(const int divident, - const int_fastdiv& divisor); + __host__ __device__ __forceinline__ friend int operator/(int const divident, + int_fastdiv const& divisor); }; -__host__ __device__ __forceinline__ int operator/(const int n, const int_fastdiv& divisor) +__host__ __device__ __forceinline__ int operator/(int const n, int_fastdiv const& divisor) { int q; #ifdef __CUDA_ARCH__ @@ -115,61 +115,61 @@ __host__ __device__ __forceinline__ int operator/(const int n, const int_fastdiv return q; } -__host__ __device__ __forceinline__ int operator%(const int n, const int_fastdiv& divisor) +__host__ __device__ __forceinline__ int operator%(int const n, int_fastdiv const& divisor) { int quotient = n / divisor; int remainder = n - quotient * divisor; return remainder; } -__host__ __device__ __forceinline__ int operator/(const unsigned int n, const int_fastdiv& divisor) +__host__ __device__ __forceinline__ int operator/(unsigned int const n, int_fastdiv const& divisor) { return ((int)n) / divisor; } -__host__ __device__ __forceinline__ int operator%(const unsigned int n, const int_fastdiv& divisor) +__host__ __device__ __forceinline__ int operator%(unsigned int const n, int_fastdiv const& divisor) { return ((int)n) % divisor; } -__host__ __device__ __forceinline__ int operator/(const short n, const int_fastdiv& divisor) +__host__ __device__ __forceinline__ int operator/(short const n, int_fastdiv const& divisor) { return ((int)n) / divisor; } -__host__ __device__ __forceinline__ int operator%(const short n, const int_fastdiv& divisor) +__host__ __device__ __forceinline__ int operator%(short const n, int_fastdiv const& divisor) { return ((int)n) % divisor; } -__host__ __device__ __forceinline__ int operator/(const unsigned short n, - const int_fastdiv& divisor) +__host__ __device__ __forceinline__ int operator/(unsigned short const n, + int_fastdiv const& divisor) { return ((int)n) / divisor; } -__host__ __device__ __forceinline__ int operator%(const unsigned short n, - const int_fastdiv& divisor) +__host__ __device__ __forceinline__ int operator%(unsigned short const n, + int_fastdiv const& divisor) { return ((int)n) % divisor; } -__host__ __device__ __forceinline__ int operator/(const char n, const int_fastdiv& divisor) +__host__ __device__ __forceinline__ int operator/(char const n, int_fastdiv const& divisor) { return ((int)n) / divisor; } -__host__ __device__ __forceinline__ int operator%(const char n, const int_fastdiv& divisor) +__host__ __device__ __forceinline__ int operator%(char const n, int_fastdiv const& divisor) { return ((int)n) % divisor; } -__host__ __device__ __forceinline__ int operator/(const unsigned char n, const int_fastdiv& divisor) +__host__ __device__ __forceinline__ int operator/(unsigned char const n, int_fastdiv const& divisor) { return ((int)n) / divisor; } -__host__ __device__ __forceinline__ int operator%(const unsigned char n, const int_fastdiv& divisor) +__host__ __device__ __forceinline__ int operator%(unsigned char const n, int_fastdiv const& divisor) { return ((int)n) % divisor; } diff --git a/cpp/include/cudf/detail/utilities/integer_utils.hpp b/cpp/include/cudf/detail/utilities/integer_utils.hpp index ccc89b2dce3..8b709f2a8f8 100644 --- a/cpp/include/cudf/detail/utilities/integer_utils.hpp +++ b/cpp/include/cudf/detail/utilities/integer_utils.hpp @@ -107,7 +107,7 @@ constexpr S round_up_unsafe(S number_to_round, S modulus) noexcept * the result will be incorrect */ template -constexpr S div_rounding_up_unsafe(const S& dividend, const T& divisor) noexcept +constexpr S div_rounding_up_unsafe(S const& dividend, T const& divisor) noexcept { return (dividend + divisor - 1) / divisor; } diff --git a/cpp/include/cudf/detail/utilities/pinned_host_vector.hpp b/cpp/include/cudf/detail/utilities/pinned_host_vector.hpp index 83f061e9407..9e2b85ea129 100644 --- a/cpp/include/cudf/detail/utilities/pinned_host_vector.hpp +++ b/cpp/include/cudf/detail/utilities/pinned_host_vector.hpp @@ -50,7 +50,7 @@ class pinned_allocator { public: using value_type = void; ///< The type of the elements in the allocator using pointer = void*; ///< The type returned by address() / allocate() - using const_pointer = const void*; ///< The type returned by address() + using const_pointer = void const*; ///< The type returned by address() using size_type = std::size_t; ///< The type used for the size of the allocation using difference_type = std::ptrdiff_t; ///< The type of the distance between two pointers @@ -76,9 +76,9 @@ class pinned_allocator { public: using value_type = T; ///< The type of the elements in the allocator using pointer = T*; ///< The type returned by address() / allocate() - using const_pointer = const T*; ///< The type returned by address() + using const_pointer = T const*; ///< The type returned by address() using reference = T&; ///< The parameter type for address() - using const_reference = const T&; ///< The parameter type for address() + using const_reference = T const&; ///< The parameter type for address() using size_type = std::size_t; ///< The type used for the size of the allocation using difference_type = std::ptrdiff_t; ///< The type of the distance between two pointers diff --git a/cpp/include/cudf/groupby.hpp b/cpp/include/cudf/groupby.hpp index 2f5c0d53e72..44d8aa5a485 100644 --- a/cpp/include/cudf/groupby.hpp +++ b/cpp/include/cudf/groupby.hpp @@ -294,7 +294,7 @@ class groupby { std::pair, std::unique_ptr
> shift( table_view const& values, host_span offsets, - std::vector> const& fill_values, + std::vector> const& fill_values, rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); /** diff --git a/cpp/include/cudf/io/csv.hpp b/cpp/include/cudf/io/csv.hpp index b5669438b4f..079be2db21b 100644 --- a/cpp/include/cudf/io/csv.hpp +++ b/cpp/include/cudf/io/csv.hpp @@ -208,7 +208,7 @@ class csv_reader_options { [[nodiscard]] std::size_t get_byte_range_padding() const { auto const num_names = _names.size(); - auto const num_dtypes = std::visit([](const auto& dtypes) { return dtypes.size(); }, _dtypes); + auto const num_dtypes = std::visit([](auto const& dtypes) { return dtypes.size(); }, _dtypes); auto const num_columns = std::max(num_dtypes, num_names); auto const max_row_bytes = 16 * 1024; // 16KB diff --git a/cpp/include/cudf/io/data_sink.hpp b/cpp/include/cudf/io/data_sink.hpp index 88f9c188530..01aac2fee99 100644 --- a/cpp/include/cudf/io/data_sink.hpp +++ b/cpp/include/cudf/io/data_sink.hpp @@ -41,7 +41,7 @@ class data_sink { * @param[in] filepath Path to the file to use * @return Constructed data_sink object */ - static std::unique_ptr create(const std::string& filepath); + static std::unique_ptr create(std::string const& filepath); /** * @brief Create a sink from a std::vector diff --git a/cpp/include/cudf/io/datasource.hpp b/cpp/include/cudf/io/datasource.hpp index 5c37be5a56f..e0cfd901615 100644 --- a/cpp/include/cudf/io/datasource.hpp +++ b/cpp/include/cudf/io/datasource.hpp @@ -113,7 +113,7 @@ class datasource { * @param[in] size Bytes from the offset; use zero for entire file (the default is zero) * @return Constructed datasource object */ - static std::unique_ptr create(const std::string& filepath, + static std::unique_ptr create(std::string const& filepath, size_t offset = 0, size_t size = 0); diff --git a/cpp/include/cudf/io/detail/data_casting.cuh b/cpp/include/cudf/io/detail/data_casting.cuh index a62c9873e75..d764e8533c6 100644 --- a/cpp/include/cudf/io/detail/data_casting.cuh +++ b/cpp/include/cudf/io/detail/data_casting.cuh @@ -181,7 +181,7 @@ process_string(in_iterator_t in_begin, cudf::io::parse_options_view const& options) { int32_t bytes = 0; - const auto num_in_chars = thrust::distance(in_begin, in_end); + auto const num_in_chars = thrust::distance(in_begin, in_end); // String values are indicated by keeping the quote character bool const is_string_value = num_in_chars >= 2LL && diff --git a/cpp/include/cudf/io/detail/parquet.hpp b/cpp/include/cudf/io/detail/parquet.hpp index 9a94924824d..1e0a5b2882a 100644 --- a/cpp/include/cudf/io/detail/parquet.hpp +++ b/cpp/include/cudf/io/detail/parquet.hpp @@ -208,7 +208,7 @@ class writer { * @return A parquet-compatible blob that contains the data for all rowgroups in the list */ static std::unique_ptr> merge_row_group_metadata( - const std::vector>>& metadata_list); + std::vector>> const& metadata_list); }; } // namespace detail::parquet diff --git a/cpp/include/cudf/io/json.hpp b/cpp/include/cudf/io/json.hpp index f94fd5adeb8..670409a898a 100644 --- a/cpp/include/cudf/io/json.hpp +++ b/cpp/include/cudf/io/json.hpp @@ -110,7 +110,7 @@ class json_reader_options { * * @param src source information used to read parquet file */ - explicit json_reader_options(const source_info& src) : _source(src) {} + explicit json_reader_options(source_info const& src) : _source(src) {} friend json_reader_options_builder; @@ -192,7 +192,7 @@ class json_reader_options { */ size_t get_byte_range_padding() const { - auto const num_columns = std::visit([](const auto& dtypes) { return dtypes.size(); }, _dtypes); + auto const num_columns = std::visit([](auto const& dtypes) { return dtypes.size(); }, _dtypes); auto const max_row_bytes = 16 * 1024; // 16KB auto const column_bytes = 64; diff --git a/cpp/include/cudf/io/orc.hpp b/cpp/include/cudf/io/orc.hpp index 162c3afcce5..97d2d064284 100644 --- a/cpp/include/cudf/io/orc.hpp +++ b/cpp/include/cudf/io/orc.hpp @@ -445,7 +445,7 @@ class orc_writer_options { // Set of columns to output table_view _table; // Optional associated metadata - const table_input_metadata* _metadata = nullptr; + table_input_metadata const* _metadata = nullptr; // Optional footer key_value_metadata std::map _user_data; // Optional compression statistics @@ -861,7 +861,7 @@ class chunked_orc_writer_options { // Row index stride (maximum number of rows in each row group) size_type _row_index_stride = default_row_index_stride; // Optional associated metadata - const table_input_metadata* _metadata = nullptr; + table_input_metadata const* _metadata = nullptr; // Optional footer key_value_metadata std::map _user_data; // Optional compression statistics diff --git a/cpp/include/cudf/io/parquet.hpp b/cpp/include/cudf/io/parquet.hpp index 582dd1ec557..2b3388d5c53 100644 --- a/cpp/include/cudf/io/parquet.hpp +++ b/cpp/include/cudf/io/parquet.hpp @@ -1072,7 +1072,7 @@ std::unique_ptr> write_parquet(parquet_writer_options const * @return A parquet-compatible blob that contains the data for all row groups in the list */ std::unique_ptr> merge_row_group_metadata( - const std::vector>>& metadata_list); + std::vector>> const& metadata_list); class chunked_parquet_writer_options_builder; diff --git a/cpp/include/cudf/io/text/data_chunk_source_factories.hpp b/cpp/include/cudf/io/text/data_chunk_source_factories.hpp index f5230863f17..046994d33cc 100644 --- a/cpp/include/cudf/io/text/data_chunk_source_factories.hpp +++ b/cpp/include/cudf/io/text/data_chunk_source_factories.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022, NVIDIA CORPORATION. + * Copyright (c) 2021-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,7 +41,7 @@ std::unique_ptr make_source(datasource& data); * @return the data chunk source for the provided host data. It copies data from the host to the * device. */ -std::unique_ptr make_source(host_span data); +std::unique_ptr make_source(host_span data); /** * @brief Creates a data source capable of producing device-buffered views of the file diff --git a/cpp/include/cudf/io/types.hpp b/cpp/include/cudf/io/types.hpp index ffddf1b5a41..b08c50574b6 100644 --- a/cpp/include/cudf/io/types.hpp +++ b/cpp/include/cudf/io/types.hpp @@ -135,7 +135,7 @@ class writer_compression_statistics { * @param other The other writer_compression_statistics object * @return writer_compression_statistics& Reference to this object */ - writer_compression_statistics& operator+=(const writer_compression_statistics& other) noexcept + writer_compression_statistics& operator+=(writer_compression_statistics const& other) noexcept { _num_compressed_bytes += other._num_compressed_bytes; _num_failed_bytes += other._num_failed_bytes; @@ -263,7 +263,7 @@ struct host_buffer { * @param data Pointer to the buffer * @param size Size of the buffer */ - host_buffer(const char* data, size_t size) : data(data), size(size) {} + host_buffer(char const* data, size_t size) : data(data), size(size) {} }; /** @@ -331,7 +331,7 @@ struct source_info { * @param host_data Input buffer in host memory * @param size Size of the buffer */ - explicit source_info(const char* host_data, size_t size) + explicit source_info(char const* host_data, size_t size) : _type(io_type::HOST_BUFFER), _host_buffers( {cudf::host_span(reinterpret_cast(host_data), size)}) diff --git a/cpp/include/cudf/join.hpp b/cpp/include/cudf/join.hpp index 314a1bbfad7..e007f0775fc 100644 --- a/cpp/include/cudf/join.hpp +++ b/cpp/include/cudf/join.hpp @@ -434,7 +434,7 @@ class hash_join { rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()) const; private: - const std::unique_ptr _impl; + const std::unique_ptr _impl; }; /** diff --git a/cpp/include/cudf/lists/lists_column_view.hpp b/cpp/include/cudf/lists/lists_column_view.hpp index 336214e3934..60bdc654af6 100644 --- a/cpp/include/cudf/lists/lists_column_view.hpp +++ b/cpp/include/cudf/lists/lists_column_view.hpp @@ -45,7 +45,7 @@ class lists_column_view : private column_view { */ lists_column_view(column_view const& lists_column); lists_column_view(lists_column_view&&) = default; ///< Move constructor - lists_column_view(const lists_column_view&) = default; ///< Copy constructor + lists_column_view(lists_column_view const&) = default; ///< Copy constructor ~lists_column_view() = default; /** * @brief Copy assignment operator diff --git a/cpp/include/cudf/reduction.hpp b/cpp/include/cudf/reduction.hpp index a5675b5f031..52aebeb55e5 100644 --- a/cpp/include/cudf/reduction.hpp +++ b/cpp/include/cudf/reduction.hpp @@ -198,7 +198,7 @@ std::unique_ptr segmented_reduce( * @returns Scanned output column */ std::unique_ptr scan( - const column_view& input, + column_view const& input, scan_aggregation const& agg, scan_type inclusive, null_policy null_handling = null_policy::EXCLUDE, diff --git a/cpp/include/cudf/reduction/detail/reduction_operators.cuh b/cpp/include/cudf/reduction/detail/reduction_operators.cuh index 7f0f4b14dae..a747f7bade7 100644 --- a/cpp/include/cudf/reduction/detail/reduction_operators.cuh +++ b/cpp/include/cudf/reduction/detail/reduction_operators.cuh @@ -202,9 +202,9 @@ struct compound_op : public simple_op { * @return transformed output result of compound operator */ template - CUDF_HOST_DEVICE inline static ResultType compute_result(const IntermediateType& input, - const cudf::size_type& count, - const cudf::size_type& ddof) + CUDF_HOST_DEVICE inline static ResultType compute_result(IntermediateType const& input, + cudf::size_type const& count, + cudf::size_type const& ddof) { // Enforced interface return Derived::template intermediate::compute_result(input, count, ddof); @@ -231,9 +231,9 @@ struct mean : public compound_op { using IntermediateType = ResultType; // sum value // compute `mean` from intermediate type `IntermediateType` - CUDF_HOST_DEVICE inline static ResultType compute_result(const IntermediateType& input, - const cudf::size_type& count, - const cudf::size_type& ddof) + CUDF_HOST_DEVICE inline static ResultType compute_result(IntermediateType const& input, + cudf::size_type const& count, + cudf::size_type const& ddof) { return (input / count); }; @@ -252,9 +252,9 @@ struct variance : public compound_op { using IntermediateType = var_std; // with sum of value, and sum of squared value // compute `variance` from intermediate type `IntermediateType` - CUDF_HOST_DEVICE inline static ResultType compute_result(const IntermediateType& input, - const cudf::size_type& count, - const cudf::size_type& ddof) + CUDF_HOST_DEVICE inline static ResultType compute_result(IntermediateType const& input, + cudf::size_type const& count, + cudf::size_type const& ddof) { ResultType mean = input.value / count; ResultType asum = input.value_squared; @@ -278,9 +278,9 @@ struct standard_deviation : public compound_op { using IntermediateType = var_std; // with sum of value, and sum of squared value // compute `standard deviation` from intermediate type `IntermediateType` - CUDF_HOST_DEVICE inline static ResultType compute_result(const IntermediateType& input, - const cudf::size_type& count, - const cudf::size_type& ddof) + CUDF_HOST_DEVICE inline static ResultType compute_result(IntermediateType const& input, + cudf::size_type const& count, + cudf::size_type const& ddof) { using intermediateOp = variance::template intermediate; ResultType var = intermediateOp::compute_result(input, count, ddof); diff --git a/cpp/include/cudf/rolling.hpp b/cpp/include/cudf/rolling.hpp index aa78979bf7a..8bbd568f57a 100644 --- a/cpp/include/cudf/rolling.hpp +++ b/cpp/include/cudf/rolling.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -119,7 +119,7 @@ struct window_bounds { // For the present, assume units from context: // 1. For time-based window functions, assume DAYS as before // 2. For all else, assume ROWS as before. - const bool is_unbounded; ///< Whether the window boundary is unbounded + bool const is_unbounded; ///< Whether the window boundary is unbounded const size_type value; ///< Finite window boundary value (in days or rows) private: diff --git a/cpp/include/cudf/scalar/scalar.hpp b/cpp/include/cudf/scalar/scalar.hpp index dab085ad7d5..993b2e5f71d 100644 --- a/cpp/include/cudf/scalar/scalar.hpp +++ b/cpp/include/cudf/scalar/scalar.hpp @@ -545,7 +545,7 @@ class string_scalar : public scalar { * @brief Returns a raw pointer to the string in device memory. * @return a raw pointer to the string in device memory */ - [[nodiscard]] const char* data() const; + [[nodiscard]] char const* data() const; protected: rmm::device_buffer _data{}; ///< device memory containing the string diff --git a/cpp/include/cudf/scalar/scalar_device_view.cuh b/cpp/include/cudf/scalar/scalar_device_view.cuh index 18bcd89a00b..846da0bbe10 100644 --- a/cpp/include/cudf/scalar/scalar_device_view.cuh +++ b/cpp/include/cudf/scalar/scalar_device_view.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -304,7 +304,7 @@ class string_scalar_device_view : public detail::scalar_device_view_base { * validity of the stored value * @param size The pointer to the size of the string in device memory */ - string_scalar_device_view(data_type type, const char* data, bool* is_valid, size_type size) + string_scalar_device_view(data_type type, char const* data, bool* is_valid, size_type size) : detail::scalar_device_view_base(type, is_valid), _data(data), _size(size) { } @@ -337,7 +337,7 @@ class string_scalar_device_view : public detail::scalar_device_view_base { [[nodiscard]] __device__ size_type size() const noexcept { return _size; } private: - const char* _data{}; ///< Pointer to device memory containing the value + char const* _data{}; ///< Pointer to device memory containing the value size_type _size; ///< Size of the string in bytes }; diff --git a/cpp/include/cudf/strings/combine.hpp b/cpp/include/cudf/strings/combine.hpp index 067f646fc33..71f65ac9080 100644 --- a/cpp/include/cudf/strings/combine.hpp +++ b/cpp/include/cudf/strings/combine.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -258,8 +258,8 @@ std::unique_ptr concatenate( * @return New strings column with concatenated results. */ std::unique_ptr join_list_elements( - const lists_column_view& lists_strings_column, - const strings_column_view& separators, + lists_column_view const& lists_strings_column, + strings_column_view const& separators, string_scalar const& separator_narep = string_scalar("", false), string_scalar const& string_narep = string_scalar("", false), separator_on_nulls separate_nulls = separator_on_nulls::YES, @@ -316,7 +316,7 @@ std::unique_ptr join_list_elements( * @return New strings column with concatenated results. */ std::unique_ptr join_list_elements( - const lists_column_view& lists_strings_column, + lists_column_view const& lists_strings_column, string_scalar const& separator = string_scalar(""), string_scalar const& narep = string_scalar("", false), separator_on_nulls separate_nulls = separator_on_nulls::YES, diff --git a/cpp/include/cudf/strings/detail/char_tables.hpp b/cpp/include/cudf/strings/detail/char_tables.hpp index 275b7223a3b..0901076c835 100644 --- a/cpp/include/cudf/strings/detail/char_tables.hpp +++ b/cpp/include/cudf/strings/detail/char_tables.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,7 +33,7 @@ using character_flags_table_type = std::uint8_t; * * @return Device memory pointer to character flags table. */ -const character_flags_table_type* get_character_flags_table(); +character_flags_table_type const* get_character_flags_table(); // utilities to dissect a character-table flag constexpr uint8_t IS_DECIMAL(uint8_t x) { return ((x) & (1 << 0)); } @@ -61,7 +61,7 @@ using character_cases_table_type = uint16_t; * * @return Device memory pointer to character cases table. */ -const character_cases_table_type* get_character_cases_table(); +character_cases_table_type const* get_character_cases_table(); /** * @brief Case mapping structure for special characters. diff --git a/cpp/include/cudf/strings/detail/convert/fixed_point.cuh b/cpp/include/cudf/strings/detail/convert/fixed_point.cuh index 185754a00c8..dd55cae4537 100644 --- a/cpp/include/cudf/strings/detail/convert/fixed_point.cuh +++ b/cpp/include/cudf/strings/detail/convert/fixed_point.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022, NVIDIA CORPORATION. + * Copyright (c) 2021-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,7 +42,7 @@ namespace detail { */ template __device__ inline thrust::pair parse_integer( - char const*& iter, char const* iter_end, const char decimal_pt_char = '.') + char const*& iter, char const* iter_end, char const decimal_pt_char = '.') { // highest value where another decimal digit cannot be appended without an overflow; // this preserves the most digits when scaling the final result for this type diff --git a/cpp/include/cudf/strings/detail/convert/is_float.cuh b/cpp/include/cudf/strings/detail/convert/is_float.cuh index 92c993cfbb5..5b09da96dc4 100644 --- a/cpp/include/cudf/strings/detail/convert/is_float.cuh +++ b/cpp/include/cudf/strings/detail/convert/is_float.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022, NVIDIA CORPORATION. + * Copyright (c) 2021-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -83,7 +83,7 @@ inline __device__ bool is_float(string_view const& d_str) bool decimal_found = false; bool exponent_found = false; size_type bytes = d_str.size_bytes(); - const char* data = d_str.data(); + char const* data = d_str.data(); // sign character allowed at the beginning of the string size_type ch_idx = (*data == '-' || *data == '+') ? 1 : 0; diff --git a/cpp/include/cudf/strings/detail/convert/string_to_float.cuh b/cpp/include/cudf/strings/detail/convert/string_to_float.cuh index 8721f21a7c0..ab934750f9e 100644 --- a/cpp/include/cudf/strings/detail/convert/string_to_float.cuh +++ b/cpp/include/cudf/strings/detail/convert/string_to_float.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,8 +35,8 @@ namespace detail { */ __device__ inline double stod(string_view const& d_str) { - const char* in_ptr = d_str.data(); - const char* end = in_ptr + d_str.size_bytes(); + char const* in_ptr = d_str.data(); + char const* end = in_ptr + d_str.size_bytes(); if (end == in_ptr) return 0.0; double sign{1.0}; if (*in_ptr == '-' || *in_ptr == '+') { diff --git a/cpp/include/cudf/strings/detail/convert/string_to_int.cuh b/cpp/include/cudf/strings/detail/convert/string_to_int.cuh index 6c8de06602e..8bbaea9390c 100644 --- a/cpp/include/cudf/strings/detail/convert/string_to_int.cuh +++ b/cpp/include/cudf/strings/detail/convert/string_to_int.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022, NVIDIA CORPORATION. + * Copyright (c) 2021-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,7 +34,7 @@ __device__ inline int64_t string_to_integer(string_view const& d_str) int64_t value = 0; size_type bytes = d_str.size_bytes(); if (bytes == 0) return value; - const char* ptr = d_str.data(); + char const* ptr = d_str.data(); int sign = 1; if (*ptr == '-' || *ptr == '+') { sign = (*ptr == '-' ? -1 : 1); diff --git a/cpp/include/cudf/strings/detail/gather.cuh b/cpp/include/cudf/strings/detail/gather.cuh index 908871774ad..55063a63edf 100644 --- a/cpp/include/cudf/strings/detail/gather.cuh +++ b/cpp/include/cudf/strings/detail/gather.cuh @@ -41,7 +41,7 @@ namespace strings { namespace detail { // Helper function for loading 16B from a potentially unaligned memory location to registers. -__forceinline__ __device__ uint4 load_uint4(const char* ptr) +__forceinline__ __device__ uint4 load_uint4(char const* ptr) { auto const offset = reinterpret_cast(ptr) % 4; auto const* aligned_ptr = reinterpret_cast(ptr - offset); @@ -100,7 +100,7 @@ __global__ void gather_chars_fn_string_parallel(StringIterator strings_begin, // This check is necessary because string_indices[istring] may be out of bound. if (out_start == out_end) continue; - const char* in_start = strings_begin[string_indices[istring]].data(); + char const* in_start = strings_begin[string_indices[istring]].data(); // Both `out_start_aligned` and `out_end_aligned` are indices into `out_chars`. // `out_start_aligned` is the first 16B aligned memory location after `out_start + 4`. diff --git a/cpp/include/cudf/strings/detail/strings_column_factories.cuh b/cpp/include/cudf/strings/detail/strings_column_factories.cuh index b219b28cf9b..7e608cd10f0 100644 --- a/cpp/include/cudf/strings/detail/strings_column_factories.cuh +++ b/cpp/include/cudf/strings/detail/strings_column_factories.cuh @@ -45,7 +45,7 @@ namespace detail { * @brief Basic type expected for iterators passed to `make_strings_column` that represent string * data in device memory. */ -using string_index_pair = thrust::pair; +using string_index_pair = thrust::pair; /** * @brief Average string byte-length threshold for deciding character-level diff --git a/cpp/include/cudf/strings/detail/utf8.hpp b/cpp/include/cudf/strings/detail/utf8.hpp index 9e1bd10c1cf..df8e2885782 100644 --- a/cpp/include/cudf/strings/detail/utf8.hpp +++ b/cpp/include/cudf/strings/detail/utf8.hpp @@ -108,7 +108,7 @@ constexpr size_type bytes_in_utf8_byte(uint8_t byte) * @param[out] character Single char_utf8 value. * @return The number of bytes in the character */ -constexpr size_type to_char_utf8(const char* str, char_utf8& character) +constexpr size_type to_char_utf8(char const* str, char_utf8& character) { size_type const chr_width = bytes_in_utf8_byte(static_cast(*str)); diff --git a/cpp/include/cudf/strings/detail/utilities.cuh b/cpp/include/cudf/strings/detail/utilities.cuh index 1d48a5cc201..64f5d3f0450 100644 --- a/cpp/include/cudf/strings/detail/utilities.cuh +++ b/cpp/include/cudf/strings/detail/utilities.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,7 +34,7 @@ namespace detail { * @param bytes Number of bytes to copy. * @return Pointer to the end of the output buffer after the copy. */ -__device__ inline char* copy_and_increment(char* buffer, const char* input, size_type bytes) +__device__ inline char* copy_and_increment(char* buffer, char const* input, size_type bytes) { memcpy(buffer, input, bytes); return buffer + bytes; @@ -48,7 +48,7 @@ __device__ inline char* copy_and_increment(char* buffer, const char* input, size * @param d_string String to copy. * @return Pointer to the end of the output buffer after the copy. */ -__device__ inline char* copy_string(char* buffer, const string_view& d_string) +__device__ inline char* copy_string(char* buffer, string_view const& d_string) { return copy_and_increment(buffer, d_string.data(), d_string.size_bytes()); } @@ -62,7 +62,7 @@ class per_context_cache { // If there is no object available in the cache, it calls the initializer // `init` to create a new one and cache it for later uses. template - TableType* find_or_initialize(const Initializer& init) + TableType* find_or_initialize(Initializer const& init) { int device_id; CUDF_CUDA_TRY(cudaGetDevice(&device_id)); @@ -85,7 +85,7 @@ template class thread_safe_per_context_cache : public per_context_cache { public: template - TableType* find_or_initialize(const Initializer& init) + TableType* find_or_initialize(Initializer const& init) { std::lock_guard guard(mutex); return per_context_cache::find_or_initialize(init); diff --git a/cpp/include/cudf/strings/string_view.cuh b/cpp/include/cudf/strings/string_view.cuh index fc4e3d57cfb..8da4d899af9 100644 --- a/cpp/include/cudf/strings/string_view.cuh +++ b/cpp/include/cudf/strings/string_view.cuh @@ -46,7 +46,7 @@ namespace detail { * @param bytes Number of bytes in str. * @return The number of characters in the array. */ -__device__ inline size_type characters_in_string(const char* str, size_type bytes) +__device__ inline size_type characters_in_string(char const* str, size_type bytes) { if ((str == nullptr) || (bytes == 0)) return 0; auto ptr = reinterpret_cast(str); @@ -123,7 +123,7 @@ CUDF_HOST_DEVICE inline string_view string_view::min() { return string_view(); } */ CUDF_HOST_DEVICE inline string_view string_view::max() { - const char* psentinel{nullptr}; + char const* psentinel{nullptr}; #if defined(__CUDA_ARCH__) psentinel = &cudf::strings::detail::max_string_sentinel[0]; #else @@ -142,7 +142,7 @@ __device__ inline size_type string_view::length() const // @cond // this custom iterator knows about UTF8 encoding -__device__ inline string_view::const_iterator::const_iterator(const string_view& str, size_type pos) +__device__ inline string_view::const_iterator::const_iterator(string_view const& str, size_type pos) : p{str.data()}, bytes{str.size_bytes()}, char_pos{pos}, byte_pos{str.byte_offset(pos)} { } @@ -224,37 +224,37 @@ __device__ inline string_view::const_iterator string_view::const_iterator::opera } __device__ inline bool string_view::const_iterator::operator==( - const string_view::const_iterator& rhs) const + string_view::const_iterator const& rhs) const { return (p == rhs.p) && (char_pos == rhs.char_pos); } __device__ inline bool string_view::const_iterator::operator!=( - const string_view::const_iterator& rhs) const + string_view::const_iterator const& rhs) const { return (p != rhs.p) || (char_pos != rhs.char_pos); } __device__ inline bool string_view::const_iterator::operator<( - const string_view::const_iterator& rhs) const + string_view::const_iterator const& rhs) const { return (p == rhs.p) && (char_pos < rhs.char_pos); } __device__ inline bool string_view::const_iterator::operator<=( - const string_view::const_iterator& rhs) const + string_view::const_iterator const& rhs) const { return (p == rhs.p) && (char_pos <= rhs.char_pos); } __device__ inline bool string_view::const_iterator::operator>( - const string_view::const_iterator& rhs) const + string_view::const_iterator const& rhs) const { return (p == rhs.p) && (char_pos > rhs.char_pos); } __device__ inline bool string_view::const_iterator::operator>=( - const string_view::const_iterator& rhs) const + string_view::const_iterator const& rhs) const { return (p == rhs.p) && (char_pos >= rhs.char_pos); } @@ -296,16 +296,16 @@ __device__ inline size_type string_view::byte_offset(size_type pos) const return std::get<0>(strings::detail::bytes_to_character_position(*this, pos)); } -__device__ inline int string_view::compare(const string_view& in) const +__device__ inline int string_view::compare(string_view const& in) const { return compare(in.data(), in.size_bytes()); } -__device__ inline int string_view::compare(const char* data, size_type bytes) const +__device__ inline int string_view::compare(char const* data, size_type bytes) const { size_type const len1 = size_bytes(); - const auto* ptr1 = reinterpret_cast(this->data()); - const auto* ptr2 = reinterpret_cast(data); + auto const* ptr1 = reinterpret_cast(this->data()); + auto const* ptr2 = reinterpret_cast(data); if ((ptr1 == ptr2) && (bytes == len1)) return 0; size_type idx = 0; for (; (idx < len1) && (idx < bytes); ++idx) { @@ -318,39 +318,39 @@ __device__ inline int string_view::compare(const char* data, size_type bytes) co return 0; } -__device__ inline bool string_view::operator==(const string_view& rhs) const +__device__ inline bool string_view::operator==(string_view const& rhs) const { return (size_bytes() == rhs.size_bytes()) && (compare(rhs) == 0); } -__device__ inline bool string_view::operator!=(const string_view& rhs) const +__device__ inline bool string_view::operator!=(string_view const& rhs) const { return compare(rhs) != 0; } -__device__ inline bool string_view::operator<(const string_view& rhs) const +__device__ inline bool string_view::operator<(string_view const& rhs) const { return compare(rhs) < 0; } -__device__ inline bool string_view::operator>(const string_view& rhs) const +__device__ inline bool string_view::operator>(string_view const& rhs) const { return compare(rhs) > 0; } -__device__ inline bool string_view::operator<=(const string_view& rhs) const +__device__ inline bool string_view::operator<=(string_view const& rhs) const { int rc = compare(rhs); return (rc == 0) || (rc < 0); } -__device__ inline bool string_view::operator>=(const string_view& rhs) const +__device__ inline bool string_view::operator>=(string_view const& rhs) const { int rc = compare(rhs); return (rc == 0) || (rc > 0); } -__device__ inline size_type string_view::find(const string_view& str, +__device__ inline size_type string_view::find(string_view const& str, size_type pos, size_type count) const { @@ -358,7 +358,7 @@ __device__ inline size_type string_view::find(const string_view& str, } template -__device__ inline size_type string_view::find_impl(const char* str, +__device__ inline size_type string_view::find_impl(char const* str, size_type bytes, size_type pos, size_type count) const @@ -388,7 +388,7 @@ __device__ inline size_type string_view::find_impl(const char* str, return npos; } -__device__ inline size_type string_view::find(const char* str, +__device__ inline size_type string_view::find(char const* str, size_type bytes, size_type pos, size_type count) const @@ -403,14 +403,14 @@ __device__ inline size_type string_view::find(char_utf8 chr, size_type pos, size return find(str, chwidth, pos, count); } -__device__ inline size_type string_view::rfind(const string_view& str, +__device__ inline size_type string_view::rfind(string_view const& str, size_type pos, size_type count) const { return rfind(str.data(), str.size_bytes(), pos, count); } -__device__ inline size_type string_view::rfind(const char* str, +__device__ inline size_type string_view::rfind(char const* str, size_type bytes, size_type pos, size_type count) const diff --git a/cpp/include/cudf/strings/string_view.hpp b/cpp/include/cudf/strings/string_view.hpp index 23627943d95..60048e0141e 100644 --- a/cpp/include/cudf/strings/string_view.hpp +++ b/cpp/include/cudf/strings/string_view.hpp @@ -60,7 +60,7 @@ class string_view { * * @return A pointer to the internal device array */ - CUDF_HOST_DEVICE [[nodiscard]] inline const char* data() const { return _data; } + CUDF_HOST_DEVICE [[nodiscard]] inline char const* data() const { return _data; } /** * @brief Return true if string has no characters @@ -80,10 +80,10 @@ class string_view { using reference = char_utf8&; using pointer = char_utf8*; using iterator_category = std::input_iterator_tag; - __device__ inline const_iterator(const string_view& str, size_type pos); - const_iterator(const const_iterator& mit) = default; + __device__ inline const_iterator(string_view const& str, size_type pos); + const_iterator(const_iterator const& mit) = default; const_iterator(const_iterator&& mit) = default; - const_iterator& operator=(const const_iterator&) = default; + const_iterator& operator=(const_iterator const&) = default; const_iterator& operator=(const_iterator&&) = default; __device__ inline const_iterator& operator++(); __device__ inline const_iterator operator++(int); @@ -93,19 +93,19 @@ class string_view { __device__ inline const_iterator operator--(int); __device__ inline const_iterator& operator-=(difference_type); __device__ inline const_iterator operator-(difference_type) const; - __device__ inline bool operator==(const const_iterator&) const; - __device__ inline bool operator!=(const const_iterator&) const; - __device__ inline bool operator<(const const_iterator&) const; - __device__ inline bool operator<=(const const_iterator&) const; - __device__ inline bool operator>(const const_iterator&) const; - __device__ inline bool operator>=(const const_iterator&) const; + __device__ inline bool operator==(const_iterator const&) const; + __device__ inline bool operator!=(const_iterator const&) const; + __device__ inline bool operator<(const_iterator const&) const; + __device__ inline bool operator<=(const_iterator const&) const; + __device__ inline bool operator>(const_iterator const&) const; + __device__ inline bool operator>=(const_iterator const&) const; __device__ inline char_utf8 operator*() const; [[nodiscard]] __device__ inline size_type position() const; [[nodiscard]] __device__ inline size_type byte_offset() const; private: friend class string_view; - const char* p{}; + char const* p{}; size_type bytes{}; size_type char_pos{}; size_type byte_pos{}; @@ -154,7 +154,7 @@ class string_view { * not match is greater in the arg string, or all compared characters * match but the arg string is longer. */ - __device__ [[nodiscard]] inline int compare(const string_view& str) const; + __device__ [[nodiscard]] inline int compare(string_view const& str) const; /** * @brief Comparing target string with this string. Each character is compared * as a UTF-8 code-point value. @@ -169,7 +169,7 @@ class string_view { * not match is greater in the arg string, or all compared characters * match but the arg string is longer. */ - __device__ inline int compare(const char* str, size_type bytes) const; + __device__ inline int compare(char const* str, size_type bytes) const; /** * @brief Returns true if rhs matches this string exactly. @@ -177,42 +177,42 @@ class string_view { * @param rhs Target string to compare with this string. * @return true if rhs matches this string exactly */ - __device__ inline bool operator==(const string_view& rhs) const; + __device__ inline bool operator==(string_view const& rhs) const; /** * @brief Returns true if rhs does not match this string. * * @param rhs Target string to compare with this string. * @return true if rhs does not match this string */ - __device__ inline bool operator!=(const string_view& rhs) const; + __device__ inline bool operator!=(string_view const& rhs) const; /** * @brief Returns true if this string is ordered before rhs. * * @param rhs Target string to compare with this string. * @return true if this string is ordered before rhs */ - __device__ inline bool operator<(const string_view& rhs) const; + __device__ inline bool operator<(string_view const& rhs) const; /** * @brief Returns true if rhs is ordered before this string. * * @param rhs Target string to compare with this string. * @return true if rhs is ordered before this string */ - __device__ inline bool operator>(const string_view& rhs) const; + __device__ inline bool operator>(string_view const& rhs) const; /** * @brief Returns true if this string matches or is ordered before rhs. * * @param rhs Target string to compare with this string. * @return true if this string matches or is ordered before rhs */ - __device__ inline bool operator<=(const string_view& rhs) const; + __device__ inline bool operator<=(string_view const& rhs) const; /** * @brief Returns true if rhs matches or is ordered before this string. * * @param rhs Target string to compare with this string. * @return true if rhs matches or is ordered before this string */ - __device__ inline bool operator>=(const string_view& rhs) const; + __device__ inline bool operator>=(string_view const& rhs) const; /** * @brief Returns the character position of the first occurrence where the @@ -224,7 +224,7 @@ class string_view { * Specify -1 to indicate to the end of the string. * @return npos if str is not found in this string. */ - __device__ [[nodiscard]] inline size_type find(const string_view& str, + __device__ [[nodiscard]] inline size_type find(string_view const& str, size_type pos = 0, size_type count = -1) const; /** @@ -238,7 +238,7 @@ class string_view { * Specify -1 to indicate to the end of the string. * @return npos if arg string is not found in this string. */ - __device__ inline size_type find(const char* str, + __device__ inline size_type find(char const* str, size_type bytes, size_type pos = 0, size_type count = -1) const; @@ -265,7 +265,7 @@ class string_view { * Specify -1 to indicate to the end of the string. * @return npos if arg string is not found in this string. */ - __device__ [[nodiscard]] inline size_type rfind(const string_view& str, + __device__ [[nodiscard]] inline size_type rfind(string_view const& str, size_type pos = 0, size_type count = -1) const; /** @@ -279,7 +279,7 @@ class string_view { * Specify -1 to indicate to the end of the string. * @return npos if arg string is not found in this string. */ - __device__ inline size_type rfind(const char* str, + __device__ inline size_type rfind(char const* str, size_type bytes, size_type pos = 0, size_type count = -1) const; @@ -339,12 +339,12 @@ class string_view { * @param data Device char array encoded in UTF8. * @param bytes Number of bytes in data array. */ - CUDF_HOST_DEVICE inline string_view(const char* data, size_type bytes) + CUDF_HOST_DEVICE inline string_view(char const* data, size_type bytes) : _data(data), _bytes(bytes), _length(UNKNOWN_STRING_LENGTH) { } - string_view(const string_view&) = default; ///< Copy constructor + string_view(string_view const&) = default; ///< Copy constructor string_view(string_view&&) = default; ///< Move constructor ~string_view() = default; /** @@ -352,7 +352,7 @@ class string_view { * * @return Reference to this instance */ - string_view& operator=(const string_view&) = default; + string_view& operator=(string_view const&) = default; /** * @brief Move assignment operator * @@ -368,7 +368,7 @@ class string_view { static inline cudf::size_type const npos{-1}; private: - const char* _data{}; ///< Pointer to device memory contain char array for this string + char const* _data{}; ///< Pointer to device memory contain char array for this string size_type _bytes{}; ///< Number of bytes in _data for this string mutable size_type _length{}; ///< Number of characters in this string (computed) @@ -399,7 +399,7 @@ class string_view { * @return npos if str is not found in this string */ template - __device__ inline size_type find_impl(const char* str, + __device__ inline size_type find_impl(char const* str, size_type bytes, size_type pos, size_type count) const; diff --git a/cpp/include/cudf/tdigest/tdigest_column_view.hpp b/cpp/include/cudf/tdigest/tdigest_column_view.hpp index c63e2b16326..89903c24c21 100644 --- a/cpp/include/cudf/tdigest/tdigest_column_view.hpp +++ b/cpp/include/cudf/tdigest/tdigest_column_view.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022, NVIDIA CORPORATION. + * Copyright (c) 2021-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -51,7 +51,7 @@ class tdigest_column_view : private column_view { public: tdigest_column_view(column_view const&); ///< Construct tdigest_column_view from a column_view tdigest_column_view(tdigest_column_view&&) = default; ///< Move constructor - tdigest_column_view(const tdigest_column_view&) = default; ///< Copy constructor + tdigest_column_view(tdigest_column_view const&) = default; ///< Copy constructor ~tdigest_column_view() = default; /** * @brief Copy assignment operator diff --git a/cpp/include/cudf/utilities/error.hpp b/cpp/include/cudf/utilities/error.hpp index f70ef4e5f07..2aeef0bd3ac 100644 --- a/cpp/include/cudf/utilities/error.hpp +++ b/cpp/include/cudf/utilities/error.hpp @@ -201,7 +201,7 @@ struct data_type_error : public std::invalid_argument { namespace cudf { namespace detail { // @cond -inline void throw_cuda_error(cudaError_t error, const char* file, unsigned int line) +inline void throw_cuda_error(cudaError_t error, char const* file, unsigned int line) { // Calls cudaGetLastError to clear the error status. It is nearly certain that a fatal error // occurred if it still returns the same error after a cleanup. diff --git a/cpp/include/cudf/utilities/span.hpp b/cpp/include/cudf/utilities/span.hpp index f339b38d9c8..3e5f6e3e97a 100644 --- a/cpp/include/cudf/utilities/span.hpp +++ b/cpp/include/cudf/utilities/span.hpp @@ -246,7 +246,7 @@ struct host_span : public cudf::detail::span_base, void>* = nullptr> - constexpr host_span(const host_span& other) noexcept + constexpr host_span(host_span const& other) noexcept : base(other.data(), other.size()) { } @@ -313,7 +313,7 @@ struct device_span : public cudf::detail::span_base, void>* = nullptr> - constexpr device_span(const device_span& other) noexcept + constexpr device_span(device_span const& other) noexcept : base(other.data(), other.size()) { } diff --git a/cpp/include/cudf/wrappers/dictionary.hpp b/cpp/include/cudf/wrappers/dictionary.hpp index a0153352f1f..98de549c724 100644 --- a/cpp/include/cudf/wrappers/dictionary.hpp +++ b/cpp/include/cudf/wrappers/dictionary.hpp @@ -65,7 +65,7 @@ struct dictionary_wrapper { * * @return The reference to this dictionary wrapper object */ - dictionary_wrapper& operator=(const dictionary_wrapper&) = default; + dictionary_wrapper& operator=(dictionary_wrapper const&) = default; /** * @brief Construct dictionary_wrapper from a value diff --git a/cpp/include/cudf_test/base_fixture.hpp b/cpp/include/cudf_test/base_fixture.hpp index 6c7c7e87a7e..364355438fd 100644 --- a/cpp/include/cudf_test/base_fixture.hpp +++ b/cpp/include/cudf_test/base_fixture.hpp @@ -308,10 +308,10 @@ inline auto parse_cudf_test_opts(int argc, char** argv) { try { cxxopts::Options options(argv[0], " - cuDF tests command line options"); - const char* env_rmm_mode = std::getenv("GTEST_CUDF_RMM_MODE"); // Overridden by CLI options - const char* env_stream_mode = + char const* env_rmm_mode = std::getenv("GTEST_CUDF_RMM_MODE"); // Overridden by CLI options + char const* env_stream_mode = std::getenv("GTEST_CUDF_STREAM_MODE"); // Overridden by CLI options - const char* env_stream_error_mode = + char const* env_stream_error_mode = std::getenv("GTEST_CUDF_STREAM_ERROR_MODE"); // Overridden by CLI options auto default_rmm_mode = env_rmm_mode ? env_rmm_mode : "pool"; auto default_stream_mode = env_stream_mode ? env_stream_mode : "default"; @@ -339,7 +339,7 @@ inline auto parse_cudf_test_opts(int argc, char** argv) "is not \"default\"", cxxopts::value()->default_value(default_stream_error_mode)); return options.parse(argc, argv); - } catch (const cxxopts::OptionException& e) { + } catch (cxxopts::OptionException const& e) { CUDF_FAIL("Error parsing command line options"); } } diff --git a/cpp/include/cudf_test/cxxopts.hpp b/cpp/include/cudf_test/cxxopts.hpp index d0fc3c7e38c..248fc7532cc 100644 --- a/cpp/include/cudf_test/cxxopts.hpp +++ b/cpp/include/cudf_test/cxxopts.hpp @@ -66,13 +66,13 @@ inline String toLocalString(std::string s) { return icu::UnicodeString::fromUTF8 class UnicodeStringIterator : public std::iterator { public: - UnicodeStringIterator(const icu::UnicodeString* string, int32_t pos) : s(string), i(pos) {} + UnicodeStringIterator(icu::UnicodeString const* string, int32_t pos) : s(string), i(pos) {} value_type operator*() const { return s->char32At(i); } - bool operator==(const UnicodeStringIterator& rhs) const { return s == rhs.s && i == rhs.i; } + bool operator==(UnicodeStringIterator const& rhs) const { return s == rhs.s && i == rhs.i; } - bool operator!=(const UnicodeStringIterator& rhs) const { return !(*this == rhs); } + bool operator!=(UnicodeStringIterator const& rhs) const { return !(*this == rhs); } UnicodeStringIterator& operator++() { @@ -83,7 +83,7 @@ class UnicodeStringIterator : public std::iterator(t); } -inline size_t stringLength(const String& s) { return s.length(); } +inline size_t stringLength(String const& s) { return s.length(); } inline String& stringAppend(String& s, String a) { return s.append(std::move(a)); } @@ -164,7 +164,7 @@ std::string toUTF8String(T&& t) return std::forward(t); } -inline bool empty(const std::string& s) { return s.empty(); } +inline bool empty(std::string const& s) { return s.empty(); } } // namespace cxxopts // ifdef CXXOPTS_USE_UNICODE @@ -187,7 +187,7 @@ class Value : public std::enable_shared_from_this { virtual std::shared_ptr clone() const = 0; - virtual void parse(const std::string& text) const = 0; + virtual void parse(std::string const& text) const = 0; virtual void parse() const = 0; @@ -201,9 +201,9 @@ class Value : public std::enable_shared_from_this { virtual std::string get_implicit_value() const = 0; - virtual std::shared_ptr default_value(const std::string& value) = 0; + virtual std::shared_ptr default_value(std::string const& value) = 0; - virtual std::shared_ptr implicit_value(const std::string& value) = 0; + virtual std::shared_ptr implicit_value(std::string const& value) = 0; virtual std::shared_ptr no_implicit_value() = 0; @@ -212,9 +212,9 @@ class Value : public std::enable_shared_from_this { class OptionException : public std::exception { public: - OptionException(const std::string& message) : m_message(message) {} + OptionException(std::string const& message) : m_message(message) {} - virtual const char* what() const noexcept { return m_message.c_str(); } + virtual char const* what() const noexcept { return m_message.c_str(); } private: std::string m_message; @@ -222,17 +222,17 @@ class OptionException : public std::exception { class OptionSpecException : public OptionException { public: - OptionSpecException(const std::string& message) : OptionException(message) {} + OptionSpecException(std::string const& message) : OptionException(message) {} }; class OptionParseException : public OptionException { public: - OptionParseException(const std::string& message) : OptionException(message) {} + OptionParseException(std::string const& message) : OptionException(message) {} }; class option_exists_error : public OptionSpecException { public: - option_exists_error(const std::string& option) + option_exists_error(std::string const& option) : OptionSpecException("Option " + LQUOTE + option + RQUOTE + " already exists") { } @@ -240,7 +240,7 @@ class option_exists_error : public OptionSpecException { class invalid_option_format_error : public OptionSpecException { public: - invalid_option_format_error(const std::string& format) + invalid_option_format_error(std::string const& format) : OptionSpecException("Invalid option format " + LQUOTE + format + RQUOTE) { } @@ -248,7 +248,7 @@ class invalid_option_format_error : public OptionSpecException { class option_syntax_exception : public OptionParseException { public: - option_syntax_exception(const std::string& text) + option_syntax_exception(std::string const& text) : OptionParseException("Argument " + LQUOTE + text + RQUOTE + " starts with a - but has incorrect syntax") { @@ -257,7 +257,7 @@ class option_syntax_exception : public OptionParseException { class option_not_exists_exception : public OptionParseException { public: - option_not_exists_exception(const std::string& option) + option_not_exists_exception(std::string const& option) : OptionParseException("Option " + LQUOTE + option + RQUOTE + " does not exist") { } @@ -265,7 +265,7 @@ class option_not_exists_exception : public OptionParseException { class missing_argument_exception : public OptionParseException { public: - missing_argument_exception(const std::string& option) + missing_argument_exception(std::string const& option) : OptionParseException("Option " + LQUOTE + option + RQUOTE + " is missing an argument") { } @@ -273,7 +273,7 @@ class missing_argument_exception : public OptionParseException { class option_requires_argument_exception : public OptionParseException { public: - option_requires_argument_exception(const std::string& option) + option_requires_argument_exception(std::string const& option) : OptionParseException("Option " + LQUOTE + option + RQUOTE + " requires an argument") { } @@ -281,7 +281,7 @@ class option_requires_argument_exception : public OptionParseException { class option_not_has_argument_exception : public OptionParseException { public: - option_not_has_argument_exception(const std::string& option, const std::string& arg) + option_not_has_argument_exception(std::string const& option, std::string const& arg) : OptionParseException("Option " + LQUOTE + option + RQUOTE + " does not take an argument, but argument " + LQUOTE + arg + RQUOTE + " given") @@ -291,7 +291,7 @@ class option_not_has_argument_exception : public OptionParseException { class option_not_present_exception : public OptionParseException { public: - option_not_present_exception(const std::string& option) + option_not_present_exception(std::string const& option) : OptionParseException("Option " + LQUOTE + option + RQUOTE + " not present") { } @@ -299,7 +299,7 @@ class option_not_present_exception : public OptionParseException { class argument_incorrect_type : public OptionParseException { public: - argument_incorrect_type(const std::string& arg) + argument_incorrect_type(std::string const& arg) : OptionParseException("Argument " + LQUOTE + arg + RQUOTE + " failed to parse") { } @@ -307,14 +307,14 @@ class argument_incorrect_type : public OptionParseException { class option_required_exception : public OptionParseException { public: - option_required_exception(const std::string& option) + option_required_exception(std::string const& option) : OptionParseException("Option " + LQUOTE + option + RQUOTE + " is required but not present") { } }; template -void throw_or_mimic(const std::string& text) +void throw_or_mimic(std::string const& text) { static_assert(std::is_base_of::value, "throw_or_mimic only works on std::exception and " @@ -347,7 +347,7 @@ struct SignedCheck; template struct SignedCheck { template - void operator()(bool negative, U u, const std::string& text) + void operator()(bool negative, U u, std::string const& text) { if (negative) { if (u > static_cast((std::numeric_limits::min)())) { @@ -364,20 +364,20 @@ struct SignedCheck { template struct SignedCheck { template - void operator()(bool, U, const std::string&) + void operator()(bool, U, std::string const&) { } }; template -void check_signed_range(bool negative, U value, const std::string& text) +void check_signed_range(bool negative, U value, std::string const& text) { SignedCheck::is_signed>()(negative, value, text); } } // namespace detail template -R checked_negate(T&& t, const std::string&, std::true_type) +R checked_negate(T&& t, std::string const&, std::true_type) { // if we got to here, then `t` is a positive number that fits into // `R`. So to avoid MSVC C4146, we first cast it to `R`. @@ -386,14 +386,14 @@ R checked_negate(T&& t, const std::string&, std::true_type) } template -T checked_negate(T&& t, const std::string& text, std::false_type) +T checked_negate(T&& t, std::string const& text, std::false_type) { throw_or_mimic(text); return t; } template -void integer_parser(const std::string& text, T& value) +void integer_parser(std::string const& text, T& value) { std::smatch match; std::regex_match(text, match, integer_pattern); @@ -408,7 +408,7 @@ void integer_parser(const std::string& text, T& value) using US = typename std::make_unsigned::type; constexpr bool is_signed = std::numeric_limits::is_signed; - const bool negative = match.length(1) > 0; + bool const negative = match.length(1) > 0; const uint8_t base = match.length(2) > 0 ? 16 : 10; auto value_match = match[3]; @@ -444,30 +444,30 @@ void integer_parser(const std::string& text, T& value) } template -void stringstream_parser(const std::string& text, T& value) +void stringstream_parser(std::string const& text, T& value) { std::stringstream in(text); in >> value; if (!in) { throw_or_mimic(text); } } -inline void parse_value(const std::string& text, uint8_t& value) { integer_parser(text, value); } +inline void parse_value(std::string const& text, uint8_t& value) { integer_parser(text, value); } -inline void parse_value(const std::string& text, int8_t& value) { integer_parser(text, value); } +inline void parse_value(std::string const& text, int8_t& value) { integer_parser(text, value); } -inline void parse_value(const std::string& text, uint16_t& value) { integer_parser(text, value); } +inline void parse_value(std::string const& text, uint16_t& value) { integer_parser(text, value); } -inline void parse_value(const std::string& text, int16_t& value) { integer_parser(text, value); } +inline void parse_value(std::string const& text, int16_t& value) { integer_parser(text, value); } -inline void parse_value(const std::string& text, uint32_t& value) { integer_parser(text, value); } +inline void parse_value(std::string const& text, uint32_t& value) { integer_parser(text, value); } -inline void parse_value(const std::string& text, int32_t& value) { integer_parser(text, value); } +inline void parse_value(std::string const& text, int32_t& value) { integer_parser(text, value); } -inline void parse_value(const std::string& text, uint64_t& value) { integer_parser(text, value); } +inline void parse_value(std::string const& text, uint64_t& value) { integer_parser(text, value); } -inline void parse_value(const std::string& text, int64_t& value) { integer_parser(text, value); } +inline void parse_value(std::string const& text, int64_t& value) { integer_parser(text, value); } -inline void parse_value(const std::string& text, bool& value) +inline void parse_value(std::string const& text, bool& value) { std::smatch result; std::regex_match(text, result, truthy_pattern); @@ -486,19 +486,19 @@ inline void parse_value(const std::string& text, bool& value) throw_or_mimic(text); } -inline void parse_value(const std::string& text, std::string& value) { value = text; } +inline void parse_value(std::string const& text, std::string& value) { value = text; } // The fallback parser. It uses the stringstream parser to parse all types // that have not been overloaded explicitly. It has to be placed in the // source code before all other more specialized templates. template -void parse_value(const std::string& text, T& value) +void parse_value(std::string const& text, T& value) { stringstream_parser(text, value); } template -void parse_value(const std::string& text, std::vector& value) +void parse_value(std::string const& text, std::vector& value) { std::stringstream in(text); std::string token; @@ -509,7 +509,7 @@ void parse_value(const std::string& text, std::vector& value) } } -inline void parse_value(const std::string& text, char& c) +inline void parse_value(std::string const& text, char& c) { if (text.length() != 1) { throw_or_mimic(text); } @@ -537,7 +537,7 @@ class abstract_value : public Value { virtual ~abstract_value() = default; - abstract_value(const abstract_value& rhs) + abstract_value(abstract_value const& rhs) { if (rhs.m_result) { m_result = std::make_shared(); @@ -552,7 +552,7 @@ class abstract_value : public Value { m_implicit_value = rhs.m_implicit_value; } - void parse(const std::string& text) const { parse_value(text, *m_store); } + void parse(std::string const& text) const { parse_value(text, *m_store); } bool is_container() const { return type_is_container::value; } @@ -562,14 +562,14 @@ class abstract_value : public Value { bool has_implicit() const { return m_implicit; } - std::shared_ptr default_value(const std::string& value) + std::shared_ptr default_value(std::string const& value) { m_default = true; m_default_value = value; return shared_from_this(); } - std::shared_ptr implicit_value(const std::string& value) + std::shared_ptr implicit_value(std::string const& value) { m_implicit = true; m_implicit_value = value; @@ -588,7 +588,7 @@ class abstract_value : public Value { bool is_boolean() const { return std::is_same_v; } - const T& get() const + T const& get() const { if (m_store == nullptr) { return *m_result; @@ -654,36 +654,36 @@ class OptionAdder; class OptionDetails { public: - OptionDetails(const std::string& short_, - const std::string& long_, - const String& desc, - std::shared_ptr val) + OptionDetails(std::string const& short_, + std::string const& long_, + String const& desc, + std::shared_ptr val) : m_short(short_), m_long(long_), m_desc(desc), m_value(val), m_count(0) { } - OptionDetails(const OptionDetails& rhs) : m_desc(rhs.m_desc), m_count(rhs.m_count) + OptionDetails(OptionDetails const& rhs) : m_desc(rhs.m_desc), m_count(rhs.m_count) { m_value = rhs.m_value->clone(); } OptionDetails(OptionDetails&& rhs) = default; - const String& description() const { return m_desc; } + String const& description() const { return m_desc; } - const Value& value() const { return *m_value; } + Value const& value() const { return *m_value; } std::shared_ptr make_storage() const { return m_value->clone(); } - const std::string& short_name() const { return m_short; } + std::string const& short_name() const { return m_short; } - const std::string& long_name() const { return m_long; } + std::string const& long_name() const { return m_long; } private: std::string m_short; std::string m_long; String m_desc; - std::shared_ptr m_value; + std::shared_ptr m_value; int m_count; }; @@ -708,14 +708,14 @@ struct HelpGroupDetails { class OptionValue { public: - void parse(std::shared_ptr details, const std::string& text) + void parse(std::shared_ptr details, std::string const& text) { ensure_value(details); ++m_count; m_value->parse(text); } - void parse_default(std::shared_ptr details) + void parse_default(std::shared_ptr details) { ensure_value(details); m_default = true; @@ -728,19 +728,19 @@ class OptionValue { bool has_default() const noexcept { return m_default; } template - const T& as() const + T const& as() const { if (m_value == nullptr) { throw_or_mimic("No value"); } #ifdef CXXOPTS_NO_RTTI - return static_cast&>(*m_value).get(); + return static_cast const&>(*m_value).get(); #else - return dynamic_cast&>(*m_value).get(); + return dynamic_cast const&>(*m_value).get(); #endif } private: - void ensure_value(std::shared_ptr details) + void ensure_value(std::shared_ptr details) { if (m_value == nullptr) { m_value = details->make_storage(); } } @@ -757,9 +757,9 @@ class KeyValue { { } - const std::string& key() const { return m_key; } + std::string const& key() const { return m_key; } - const std::string& value() const { return m_value; } + std::string const& value() const { return m_value; } template T as() const @@ -783,7 +783,7 @@ class ParseResult { int&, char**&); - size_t count(const std::string& o) const + size_t count(std::string const& o) const { auto iter = m_options->find(o); if (iter == m_options->end()) { return 0; } @@ -793,7 +793,7 @@ class ParseResult { return riter->second.count(); } - const OptionValue& operator[](const std::string& option) const + OptionValue const& operator[](std::string const& option) const { auto iter = m_options->find(option); @@ -804,18 +804,18 @@ class ParseResult { return riter->second; } - const std::vector& arguments() const { return m_sequential; } + std::vector const& arguments() const { return m_sequential; } private: void parse(int& argc, char**& argv); - void add_to_option(const std::string& option, const std::string& arg); + void add_to_option(std::string const& option, std::string const& arg); bool consume_positional(std::string a); void parse_option(std::shared_ptr value, - const std::string& name, - const std::string& arg = ""); + std::string const& name, + std::string const& arg = ""); void parse_default(std::shared_ptr details); @@ -823,7 +823,7 @@ class ParseResult { char* argv[], int& current, std::shared_ptr value, - const std::string& name); + std::string const& name); const std::shared_ptr>> m_options; std::vector m_positional; @@ -837,17 +837,17 @@ class ParseResult { }; struct Option { - Option(const std::string& opts, - const std::string& desc, - const std::shared_ptr& value = ::cxxopts::value(), - const std::string& arg_help = "") + Option(std::string const& opts, + std::string const& desc, + std::shared_ptr const& value = ::cxxopts::value(), + std::string const& arg_help = "") : opts_(opts), desc_(desc), value_(value), arg_help_(arg_help) { } std::string opts_; std::string desc_; - std::shared_ptr value_; + std::shared_ptr value_; std::string arg_help_; }; @@ -895,15 +895,15 @@ class Options { OptionAdder add_options(std::string group = ""); - void add_options(const std::string& group, std::initializer_list