Skip to content

Commit 5f9de8d

Browse files
committed
remove warnings
1 parent f3ca44e commit 5f9de8d

7 files changed

Lines changed: 23 additions & 14 deletions

File tree

include/xtl/xbasic_fixed_string.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -916,8 +916,9 @@ namespace xtl
916916
template <class InputIt>
917917
inline auto xbasic_fixed_string<CT, N, ST, EP, TR>::assign(InputIt first, InputIt last) -> self_type&
918918
{
919-
m_storage.set_size(error_policy::check_size(static_cast<size_type>(std::distance(first, last))));
920-
std::copy(first, last, data());
919+
auto size = static_cast<size_type>(std::distance(first, last));
920+
m_storage.set_size(error_policy::check_size(size));
921+
std::copy_n(first, m_storage.size(), data());
921922
return *this;
922923
}
923924

include/xtl/xsequence.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#define XTL_SEQUENCE_HPP
1212

1313
#include <array>
14+
#include <algorithm>
1415
#include <cstddef>
1516
#include <type_traits>
1617
#include <utility>
@@ -120,7 +121,7 @@ namespace xtl
120121
static inline R forward(const T& r)
121122
{
122123
R ret;
123-
std::copy(std::begin(r), std::end(r), std::begin(ret));
124+
std::copy_n(std::begin(r), std::size(ret), std::begin(ret));
124125
return ret;
125126
}
126127
};

include/xtl/xspan_impl.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -551,13 +551,13 @@ class span {
551551

552552
/* Deduction Guides */
553553
template <class T, size_t N>
554-
span(T (&)[N])->span<T, N>;
554+
span(T (&)[N])->span<T, static_cast<std::ptrdiff_t>(N)>;
555555

556556
template <class T, size_t N>
557-
span(std::array<T, N>&)->span<T, N>;
557+
span(std::array<T, N>&)->span<T, static_cast<std::ptrdiff_t>(N)>;
558558

559559
template <class T, size_t N>
560-
span(const std::array<T, N>&)->span<const T, N>;
560+
span(const std::array<T, N>&)->span<const T, static_cast<std::ptrdiff_t>(N)>;
561561

562562
template <class Container>
563563
span(Container&)->span<typename Container::value_type>;

test/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ if(nlohmann_json_FOUND)
3737
endif()
3838

3939
if(CMAKE_CXX_COMPILER_ID MATCHES GNU OR CMAKE_CXX_COMPILER_ID MATCHES Intel)
40-
add_compile_options(-Wunused-parameter -Wextra -Wreorder -Wconversion -Wsign-conversion)
40+
add_compile_options(-Werror -Wall -Wextra)
4141

4242
if(NOT CMAKE_CXX_FLAGS MATCHES "-march")
4343
CHECK_CXX_COMPILER_FLAG(-march=native HAS_MARCH_NATIVE)
@@ -60,7 +60,7 @@ endif()
6060

6161
if(CMAKE_CXX_COMPILER_ID MATCHES Clang)
6262
if(NOT WIN32)
63-
add_compile_options(-Wunused-parameter -Wextra -Wreorder -Wconversion -Wsign-conversion)
63+
add_compile_options(-Werror -Wall -Wextra)
6464

6565
if(NOT CMAKE_CXX_FLAGS MATCHES "-march")
6666
CHECK_CXX_COMPILER_FLAG(-march=native HAS_MARCH_NATIVE)

test/test_xmasked_value.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,7 @@ namespace xtl
575575
EXPECT_EQ(pow(o, m1).value(), std::pow(5., 5.));
576576
EXPECT_EQ(pow(m1, 2).value(), 25.0);
577577
EXPECT_EQ(pow(2, m1).value(), 32);
578+
EXPECT_EQ(pow(m1, m2).value(), std::pow(5., 5.));
578579
}
579580

580581
TEST(xmasked_value, ternary_op)

test/test_xoptional.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,6 @@ namespace xtl
210210
auto res8 = fma(o1, o2, o3);
211211
EXPECT_EQ(res8, std::fma(d1, d2, d3));
212212

213-
using optional_int = xoptional<int, bool>;
214213
using optional_int_ref = xoptional<int&, bool&>;
215214
int i1 = 9;
216215
int i2 = 4;
@@ -232,7 +231,7 @@ namespace xtl
232231

233232
auto res13 = ~oi1;
234233
EXPECT_EQ(res13, optional(~i1, true));
235-
234+
236235
auto res5 = oi1 || oi2;
237236
EXPECT_EQ(res5, optional(i1 || i2, true));
238237

@@ -297,7 +296,6 @@ namespace xtl
297296

298297
TEST(xoptional, select)
299298
{
300-
using opt_type = xoptional<double, bool>;
301299
using bool_opt_type = xoptional<bool, bool>;
302300
auto missing_val = missing<double>();
303301

test/test_xsequence.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ namespace xtl
4141

4242
TEST(xsequence, forward_type)
4343
{
44-
std::array<int, 2> a, b;
44+
std::array<int, 2> a;
4545
std::vector<int> c;
4646
EXPECT_TRUE(test(std::move(a)));
4747
EXPECT_FALSE(test(a));
@@ -57,11 +57,19 @@ namespace xtl
5757

5858
TEST(xsequence, different_arrays)
5959
{
60-
std::array<int, 3> x, y;
61-
aligned_array<int, 3> aa, ab;
60+
std::array<int, 3> x{};
61+
aligned_array<int, 3> aa{};
6262

6363
auto res1 = test_different_array<aligned_array<int, 3>>(x);
64+
EXPECT_EQ(res1.size(), 3);
65+
EXPECT_EQ(res1[0], 0);
66+
EXPECT_EQ(res1[1], 0);
67+
EXPECT_EQ(res1[2], 0);
6468
auto res2 = test_different_array<aligned_array<int, 3>>(aa);
69+
EXPECT_EQ(res2.size(), 3);
70+
EXPECT_EQ(res2[0], 0);
71+
EXPECT_EQ(res2[1], 0);
72+
EXPECT_EQ(res2[2], 0);
6573
}
6674

6775
TEST(xsequence, forward)

0 commit comments

Comments
 (0)