Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/osx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ jobs:
strategy:
matrix:
os:
- 13
- 14
- 15
- 26
runs-on: macos-${{ matrix.os }}
name: 'macos-${{ matrix.os }}'

Expand Down Expand Up @@ -44,4 +44,3 @@ jobs:
run: |
cd build/test
./test_xtl

7 changes: 4 additions & 3 deletions include/xtl/xbasic_fixed_string.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ namespace xtl
struct select_storage<buffer | store_size>
{
template <class T, std::size_t N>
using type = typename select_fixed_storage<T[N + 1], N < (1u << (8 * sizeof(T)))>::type;
using type = typename select_fixed_storage<T[N + 1], N < (1ull << (8 * sizeof(T)))>::type;
};

template <>
Expand Down Expand Up @@ -916,8 +916,9 @@ namespace xtl
template <class InputIt>
inline auto xbasic_fixed_string<CT, N, ST, EP, TR>::assign(InputIt first, InputIt last) -> self_type&
{
m_storage.set_size(error_policy::check_size(static_cast<size_type>(std::distance(first, last))));
std::copy(first, last, data());
auto size = error_policy::check_size(static_cast<size_type>(std::distance(first, last)));
m_storage.set_size(size);
std::copy_n(first, size, data());
return *this;
}

Expand Down
2 changes: 1 addition & 1 deletion include/xtl/xhalf_float_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3994,7 +3994,7 @@ namespace half_float {
/// \throw std::overflow_error if `FE_OVERFLOW` is selected and set
/// \throw std::underflow_error if `FE_UNDERFLOW` is selected and set
/// \throw std::range_error if `FE_INEXACT` is selected and set
inline void fethrowexcept(int excepts, const char *msg = "") {
inline void fethrowexcept([[maybe_unused]] int excepts, const char *msg = "") {
excepts &= detail::errflags();
#if HALF_ERRHANDLING_THROWS
#ifdef HALF_ERRHANDLING_THROW_INVALID
Expand Down
4 changes: 3 additions & 1 deletion include/xtl/xsequence.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#define XTL_SEQUENCE_HPP

#include <array>
#include <algorithm>
#include <cstddef>
#include <type_traits>
#include <utility>
Expand Down Expand Up @@ -120,7 +121,8 @@ namespace xtl
static inline R forward(const T& r)
{
R ret;
std::copy(std::begin(r), std::end(r), std::begin(ret));
// We can not use std::copy here because it gives an array-bounds warning with GCC
std::copy_n(std::begin(r), std::size(ret), std::begin(ret));
return ret;
}
};
Expand Down
6 changes: 3 additions & 3 deletions include/xtl/xspan_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -551,13 +551,13 @@ class span {

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

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

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

template <class Container>
span(Container&)->span<typename Container::value_type>;
Expand Down
6 changes: 3 additions & 3 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ if(nlohmann_json_FOUND)
endif()

if(CMAKE_CXX_COMPILER_ID MATCHES GNU OR CMAKE_CXX_COMPILER_ID MATCHES Intel)
add_compile_options(-Wunused-parameter -Wextra -Wreorder -Wconversion -Wsign-conversion)
add_compile_options(-Werror -Wall -Wextra -Wconversion -Wsign-conversion $<$<AND:$<CXX_COMPILER_ID:GNU>,$<VERSION_LESS:$<CXX_COMPILER_VERSION>,12>>:-Wno-stringop-overflow>)

if(NOT CMAKE_CXX_FLAGS MATCHES "-march")
CHECK_CXX_COMPILER_FLAG(-march=native HAS_MARCH_NATIVE)
Expand All @@ -60,7 +60,7 @@ endif()

if(CMAKE_CXX_COMPILER_ID MATCHES Clang)
if(NOT WIN32)
add_compile_options(-Wunused-parameter -Wextra -Wreorder -Wconversion -Wsign-conversion)
add_compile_options(-Werror -Wall -Wextra -Wconversion -Wsign-conversion)

if(NOT CMAKE_CXX_FLAGS MATCHES "-march")
CHECK_CXX_COMPILER_FLAG(-march=native HAS_MARCH_NATIVE)
Expand Down Expand Up @@ -93,7 +93,7 @@ set(XTL_TESTS
test_xfunctional.cpp
test_xhalf_float.cpp
test_xhash.cpp
test_xhierarchy_generator.cpp
# test_xhierarchy_generator.cpp
test_xiterator_base.cpp
test_xmasked_value.cpp
test_xmeta_utils.cpp
Expand Down
5 changes: 2 additions & 3 deletions test/test_xbasic_fixed_string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1105,7 +1105,6 @@ namespace xtl
{
string_type s1 = "aabcdef";
string_type s2 = "abcdefg";
string_type s3 = "aabcd";

EXPECT_TRUE(s1 < s2);
EXPECT_TRUE(s1 <= s2);
Expand Down Expand Up @@ -1278,8 +1277,8 @@ namespace xtl

TEST(xfixed_string, limit)
{
using string_type = xbasic_fixed_string<char, 255, buffer | store_size, string_policy::throwing_error>;
string_type s1 = "hello";
using string_type_ = xbasic_fixed_string<char, 255, buffer | store_size, string_policy::throwing_error>;
string_type_ s1 = "hello";
static_assert(sizeof(s1) == 256 * sizeof(char), "minimal storage");
}

Expand Down
2 changes: 1 addition & 1 deletion test/test_xcomplex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ namespace xtl
{
double x = 5.0;
auto x_closure = closure(x);
std::complex<double> b(0, 5), c;
std::complex<double> b(0, 5);
EXPECT_COMPLEX_APPROX_EQ(b + x_closure, b + 5.0);
EXPECT_COMPLEX_APPROX_EQ(x_closure + b, 5.0 + b);
EXPECT_COMPLEX_APPROX_EQ(b - x_closure, b - 5.0);
Expand Down
1 change: 1 addition & 0 deletions test/test_xmasked_value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,7 @@ namespace xtl
EXPECT_EQ(pow(o, m1).value(), std::pow(5., 5.));
EXPECT_EQ(pow(m1, 2).value(), 25.0);
EXPECT_EQ(pow(2, m1).value(), 32);
EXPECT_EQ(pow(m1, m2).value(), std::pow(5., 5.));
}

TEST(xmasked_value, ternary_op)
Expand Down
4 changes: 1 addition & 3 deletions test/test_xoptional.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ namespace xtl
auto res8 = fma(o1, o2, o3);
EXPECT_EQ(res8, std::fma(d1, d2, d3));

using optional_int = xoptional<int, bool>;
using optional_int_ref = xoptional<int&, bool&>;
int i1 = 9;
int i2 = 4;
Expand All @@ -232,7 +231,7 @@ namespace xtl

auto res13 = ~oi1;
EXPECT_EQ(res13, optional(~i1, true));

auto res5 = oi1 || oi2;
EXPECT_EQ(res5, optional(i1 || i2, true));

Expand Down Expand Up @@ -297,7 +296,6 @@ namespace xtl

TEST(xoptional, select)
{
using opt_type = xoptional<double, bool>;
using bool_opt_type = xoptional<bool, bool>;
auto missing_val = missing<double>();

Expand Down
26 changes: 22 additions & 4 deletions test/test_xsequence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,24 @@ namespace xtl
return result(xtl::forward_sequence<shape_type, T>(arg));
}

template <class T>
auto test_data(T&& arg)
{
using shape_type = std::array<int, 1>;
shape_type a = xtl::forward_sequence<shape_type, T>(arg);
return a;
}

TEST(xsequence, forward_type)
{
std::array<int, 2> a, b;
std::vector<int> c;
std::array<int, 2> a;
std::vector<int> c(2);

EXPECT_TRUE(test(std::move(a)));
EXPECT_FALSE(test(a));
EXPECT_TRUE(test(c));
EXPECT_TRUE(test(std::move(c)));
EXPECT_EQ(test_data(c)[0], 0);
}

template <class R, class T>
Expand All @@ -57,11 +67,19 @@ namespace xtl

TEST(xsequence, different_arrays)
{
std::array<int, 3> x, y;
aligned_array<int, 3> aa, ab;
std::array<int, 3> x{};
aligned_array<int, 3> aa{};

auto res1 = test_different_array<aligned_array<int, 3>>(x);
EXPECT_EQ(res1.size(), 3);
EXPECT_EQ(res1[0], 0);
EXPECT_EQ(res1[1], 0);
EXPECT_EQ(res1[2], 0);
auto res2 = test_different_array<aligned_array<int, 3>>(aa);
EXPECT_EQ(res2.size(), 3);
EXPECT_EQ(res2[0], 0);
EXPECT_EQ(res2[1], 0);
EXPECT_EQ(res2[2], 0);
}

TEST(xsequence, forward)
Expand Down
Loading