Skip to content

Commit cbeced4

Browse files
committed
CI now builds in windows too
* made Abseil & Boost optional * minor warning fixes in svector * Updated unit tests so it compiles with strict warnings * Bump version to 1.0.3
1 parent 63ea333 commit cbeced4

23 files changed

+171
-74
lines changed

.github/workflows/main.yml

+30-10
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,27 @@ jobs:
88
lint:
99
runs-on: ubuntu-latest
1010
steps:
11-
- uses: actions/checkout@v1
12-
- uses: actions/setup-python@v1
11+
- uses: actions/checkout@v3
12+
- uses: actions/setup-python@v4
1313
with:
1414
python-version: '3.x'
1515
- run: ./scripts/lint/lint-all.py
1616

1717
linux:
1818
runs-on: ubuntu-latest
1919
steps:
20-
- uses: actions/checkout@v1
21-
- name: install dependencies boost
22-
run: sudo apt-get install -yq libboost-dev
20+
- uses: actions/checkout@v3
21+
- run: sudo apt-get install -yq libboost-dev
2322
- uses: hendrikmuhs/[email protected]
24-
- uses: actions/setup-python@v1
23+
- uses: actions/setup-python@v4
2524
with:
2625
python-version: '3.x'
2726
- run: pip install meson ninja
2827
- run: meson setup builddir/
2928
env:
3029
CXX: ccache c++
3130
- run: meson test -C builddir/ -v
32-
- uses: actions/upload-artifact@v1
31+
- uses: actions/upload-artifact@v3
3332
if: failure()
3433
with:
3534
name: Linux_Meson_Testlog
@@ -38,17 +37,38 @@ jobs:
3837
macos:
3938
runs-on: macos-latest
4039
steps:
41-
- uses: actions/checkout@v1
42-
- uses: actions/setup-python@v1
40+
- uses: actions/checkout@v3
41+
- uses: actions/setup-python@v4
4342
with:
4443
python-version: '3.x'
4544
- run: brew install gcc boost ccache meson ninja
4645
- run: meson setup builddir/
4746
env:
4847
CXX: ccache c++
4948
- run: meson test -C builddir/ -v
50-
- uses: actions/upload-artifact@v1
49+
- uses: actions/upload-artifact@v3
5150
if: failure()
5251
with:
5352
name: MacOS_Meson_Testlog
5453
path: builddir/meson-logs/testlog.txt
54+
55+
windows:
56+
runs-on: windows-latest
57+
steps:
58+
- uses: actions/checkout@v3
59+
- uses: actions/setup-python@v4
60+
with:
61+
python-version: '3.x'
62+
- uses: BSFishy/pip-action@v1
63+
with:
64+
packages: ninja meson
65+
- uses: ilammy/msvc-dev-cmd@v1
66+
- run: meson setup builddir
67+
- run: meson test -C builddir -v
68+
- uses: actions/upload-artifact@v3
69+
if: failure()
70+
with:
71+
name: Windows_Meson_Testlog
72+
path: |
73+
builddir/meson-logs/testlog.txt
74+
builddir/test/test-svector.exe

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cmake_minimum_required(VERSION 3.12)
22
project("svector"
3-
VERSION 1.0.2
3+
VERSION 1.0.3
44
DESCRIPTION " Compact SVO optimized vector for C++17 or higher"
55
HOMEPAGE_URL "https://github.com/martinus/svector")
66

include/ankerl/svector.h

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// ┌─┐┬ ┬┌─┐┌─┐┌┬┐┌─┐┬─┐ Compact SVO optimized vector C++17 or higher
2-
// └─┐└┐┌┘├┤ │ │ │ │├┬┘ Version 1.0.2
2+
// └─┐└┐┌┘├┤ │ │ │ │├┬┘ Version 1.0.3
33
// └─┘ └┘ └─┘└─┘ ┴ └─┘┴└─ https://github.com/martinus/svector
44
//
55
// Licensed under the MIT License <http://opensource.org/licenses/MIT>.
66
// SPDX-License-Identifier: MIT
7-
// Copyright (c) 2022 Martin Leitner-Ankerl <[email protected]>
7+
// Copyright (c) 2022-2023 Martin Leitner-Ankerl <[email protected]>
88
//
99
// Permission is hereby granted, free of charge, to any person obtaining a copy
1010
// of this software and associated documentation files (the "Software"), to deal
@@ -30,7 +30,7 @@
3030
// see https://semver.org/spec/v2.0.0.html
3131
#define ANKERL_SVECTOR_VERSION_MAJOR 1 // incompatible API changes
3232
#define ANKERL_SVECTOR_VERSION_MINOR 0 // add functionality in a backwards compatible manner
33-
#define ANKERL_SVECTOR_VERSION_PATCH 2 // backwards compatible bug fixes
33+
#define ANKERL_SVECTOR_VERSION_PATCH 3 // backwards compatible bug fixes
3434

3535
// API versioning with inline namespace, see https://www.foonathan.net/2018/11/inline-namespaces/
3636
#define ANKERL_SVECTOR_VERSION_CONCAT1(major, minor, patch) v##major##_##minor##_##patch
@@ -211,7 +211,7 @@ class svector {
211211

212212
// sets size of direct mode and mode to direct too.
213213
constexpr void set_direct_and_size(size_t s) {
214-
m_data[0] = (s << 1U) | 1U;
214+
m_data[0] = static_cast<uint8_t>((s << 1U) | 1U);
215215
}
216216

217217
[[nodiscard]] auto direct_data() -> T* {
@@ -285,9 +285,9 @@ class svector {
285285
// indirect -> indirect
286286
uninitialized_move_and_destroy(data<direction::indirect>(), storage->data(), size<direction::indirect>());
287287
storage->size(size<direction::indirect>());
288-
auto* storage = indirect();
289-
std::destroy_at(storage);
290-
::operator delete(storage);
288+
auto* storage_direct = indirect();
289+
std::destroy_at(storage_direct);
290+
::operator delete(storage_direct);
291291
}
292292
set_indirect(storage);
293293
}

meson.build

+7-2
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,14 @@
1818
#
1919

2020
project('svector', 'cpp',
21-
version: '1.0.2',
21+
version: '1.0.3',
2222
license: 'MIT',
23-
default_options : ['cpp_std=c++17', 'warning_level=3', 'werror=true'])
23+
default_options : [
24+
'cpp_std=c++17',
25+
'warning_level=3',
26+
'werror=true',
27+
'b_ndebug=true', # otherwise absl is really slow!
28+
])
2429

2530
incdir = include_directories('include')
2631
subdir('test')

subprojects/abseil-cpp.wrap

+11-8
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
11
[wrap-file]
2-
directory = abseil-cpp-20211102.0
3-
source_url = https://github.com/abseil/abseil-cpp/archive/20211102.0.tar.gz
4-
source_filename = abseil-cpp-20211102.0.tar.gz
5-
source_hash = dcf71b9cba8dc0ca9940c4b316a0c796be8fab42b070bb6b7cab62b48f0e66c4
6-
patch_filename = abseil-cpp_20211102.0-3_patch.zip
7-
patch_url = https://wrapdb.mesonbuild.com/v2/abseil-cpp_20211102.0-3/get_patch
8-
patch_hash = 3b49ff46df64414bac034b58bf36a07457375b6f8d8b5158e341157c6f9efad2
2+
directory = abseil-cpp-20230125.1
3+
source_url = https://github.com/abseil/abseil-cpp/archive/20230125.1.tar.gz
4+
source_filename = abseil-cpp-20230125.1.tar.gz
5+
source_hash = 81311c17599b3712069ded20cca09a62ab0bf2a89dfa16993786c8782b7ed145
6+
patch_filename = abseil-cpp_20230125.1-1_patch.zip
7+
patch_url = https://wrapdb.mesonbuild.com/v2/abseil-cpp_20230125.1-1/get_patch
8+
patch_hash = a920ab28067e433d7ead2d564a4f511628f498f0723f7f94d19317877787ef39
9+
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/abseil-cpp_20230125.1-1/abseil-cpp-20230125.1.tar.gz
10+
wrapdb_version = 20230125.1-1
911

1012
[provide]
1113
absl_base = absl_base_dep
1214
absl_container = absl_container_dep
1315
absl_debugging = absl_debugging_dep
16+
absl_log = absl_log_dep
1417
absl_flags = absl_flags_dep
1518
absl_hash = absl_hash_dep
19+
absl_crc = absl_crc_dep
1620
absl_numeric = absl_numeric_dep
1721
absl_random = absl_random_dep
1822
absl_status = absl_status_dep
1923
absl_strings = absl_strings_dep
2024
absl_synchronization = absl_synchronization_dep
2125
absl_time = absl_time_dep
2226
absl_types = absl_types_dep
23-

subprojects/doctest.wrap

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
[wrap-file]
2-
directory = doctest-2.4.8
3-
source_url = https://github.com/doctest/doctest/archive/refs/tags/v2.4.8.tar.gz
4-
source_filename = doctest-2.4.8.tar.gz
5-
source_hash = f52763630aa17bd9772b54e14b6cdd632c87adf0169455a86a49bd94abf2cd83
2+
directory = doctest-2.4.9
3+
source_url = https://github.com/doctest/doctest/archive/refs/tags/v2.4.9.tar.gz
4+
source_filename = doctest-2.4.9.tar.gz
5+
source_hash = 19b2df757f2f3703a5e63cee553d85596875f06d91a3333acd80a969ef210856
6+
wrapdb_version = 2.4.9-1
67

78
[provide]
89
dependency_names = doctest
9-

subprojects/fmt.wrap

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
[wrap-file]
2-
directory = fmt-8.1.1
3-
source_url = https://github.com/fmtlib/fmt/archive/8.1.1.tar.gz
4-
source_filename = fmt-8.1.1.tar.gz
5-
source_hash = 3d794d3cf67633b34b2771eb9f073bde87e846e0d395d254df7b211ef1ec7346
6-
patch_filename = fmt_8.1.1-1_patch.zip
7-
patch_url = https://wrapdb.mesonbuild.com/v2/fmt_8.1.1-1/get_patch
8-
patch_hash = 6035a67c7a8c90bed74c293c7265c769f47a69816125f7566bccb8e2543cee5e
2+
directory = fmt-9.1.0
3+
source_url = https://github.com/fmtlib/fmt/archive/9.1.0.tar.gz
4+
source_filename = fmt-9.1.0.tar.gz
5+
source_hash = 5dea48d1fcddc3ec571ce2058e13910a0d4a6bab4cc09a809d8b1dd1c88ae6f2
6+
patch_filename = fmt_9.1.0-1_patch.zip
7+
patch_url = https://wrapdb.mesonbuild.com/v2/fmt_9.1.0-1/get_patch
8+
patch_hash = 4557b9ba87b3eb63694ed9b21d1a2117d4a97ca56b91085b10288e9a5294adf8
9+
wrapdb_version = 9.1.0-1
910

1011
[provide]
1112
fmt = fmt_dep
12-

test/app/boost_absl.h

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#pragma once
2+
3+
#if __has_include(<absl/container/inlined_vector.h>)
4+
# define ANKERL_SVECTOR_HAS_ABSL() 1
5+
# include <absl/container/inlined_vector.h>
6+
#else
7+
# define ANKERL_SVECTOR_HAS_ABSL() 0
8+
#endif
9+
10+
#if __has_include(<boost/container/small_vector.hpp>)
11+
# define ANKERL_SVECTOR_HAS_BOOST() 1
12+
# include <boost/container/small_vector.hpp>
13+
#else
14+
# define ANKERL_SVECTOR_HAS_BOOST() 0
15+
#endif

test/bench/bench_accumulate.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
#include <ankerl/svector.h>
2+
#include <app/boost_absl.h>
23
#include <app/name_of_type.h>
34
#include <app/nanobench.h>
45

56
#include <doctest.h>
67

7-
#include <absl/container/inlined_vector.h>
8-
#include <boost/container/small_vector.hpp>
98
#include <fmt/format.h>
109

1110
#include <fstream>
@@ -35,8 +34,12 @@ TEST_CASE("bench_accumulate_numeric" * doctest::skip() * doctest::test_suite("be
3534
bench.epochs(100);
3635

3736
accumulate_numeric<std::vector<uint64_t>>(num_items, bench);
37+
#if ANKERL_SVECTOR_HAS_ABSL()
3838
accumulate_numeric<absl::InlinedVector<uint64_t, 7>>(num_items, bench);
39+
#endif
40+
#if ANKERL_SVECTOR_HAS_BOOST()
3941
accumulate_numeric<boost::container::small_vector<uint64_t, 7>>(num_items, bench);
42+
#endif
4043
accumulate_numeric<ankerl::svector<uint64_t, 7>>(num_items, bench);
4144

4245
auto f = std::ofstream("bench_accumulate_numeric.html");

test/bench/bench_emplace_back.cpp

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
#include <ankerl/svector.h>
2+
#include <app/boost_absl.h>
23
#include <app/name_of_type.h>
34
#include <app/nanobench.h>
45

56
#include <doctest.h>
67

7-
#include <absl/container/inlined_vector.h>
8-
#include <boost/container/small_vector.hpp>
98
#include <fmt/format.h>
109

1110
#include <fstream>
@@ -31,8 +30,12 @@ TEST_CASE("bench_emplace_back_int" * doctest::skip() * doctest::test_suite("benc
3130
bench.epochs(100);
3231

3332
emplace_back<std::vector<int>>(bench, num_items);
33+
#if ANKERL_SVECTOR_HAS_ABSL()
3434
emplace_back<absl::InlinedVector<int, 4>>(bench, num_items);
35+
#endif
36+
#if ANKERL_SVECTOR_HAS_BOOST()
3537
emplace_back<boost::container::small_vector<int, 4>>(bench, num_items);
38+
#endif
3639
emplace_back<ankerl::svector<int, 4>>(bench, num_items);
3740

3841
auto f = std::ofstream("bench_emplace_back_int.html");
@@ -46,8 +49,12 @@ TEST_CASE("bench_emplace_back_string" * doctest::skip() * doctest::test_suite("b
4649
bench.epochs(100);
4750

4851
emplace_back<std::vector<std::string>>(bench, num_items, "hello");
52+
#if ANKERL_SVECTOR_HAS_ABSL()
4953
emplace_back<absl::InlinedVector<std::string, 7>>(bench, num_items, "hello");
54+
#endif
55+
#if ANKERL_SVECTOR_HAS_BOOST()
5056
emplace_back<boost::container::small_vector<std::string, 7>>(bench, num_items, "hello");
57+
#endif
5158
emplace_back<ankerl::svector<std::string, 7>>(bench, num_items, "hello");
5259

5360
auto f = std::ofstream("bench_emplace_back_string.html");

test/bench/bench_fill_front.cpp

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
#include <ankerl/svector.h>
2+
#include <app/boost_absl.h>
23
#include <app/name_of_type.h>
34
#include <app/nanobench.h>
45

56
#include <doctest.h>
67

7-
#include <absl/container/inlined_vector.h>
8-
#include <boost/container/small_vector.hpp>
98
#include <fmt/format.h>
109

1110
#include <fstream>
@@ -32,8 +31,12 @@ TEST_CASE("bench_fill_front_int" * doctest::skip() * doctest::test_suite("bench"
3231
bench.title("emplace(vec.begin(), ...)");
3332

3433
fill_front<std::vector<int>>(bench, num_items);
34+
#if ANKERL_SVECTOR_HAS_ABSL()
3535
fill_front<absl::InlinedVector<int, 7>>(bench, num_items);
36+
#endif
37+
#if ANKERL_SVECTOR_HAS_BOOST()
3638
fill_front<boost::container::small_vector<int, 7>>(bench, num_items);
39+
#endif
3740
fill_front<ankerl::svector<int, 7>>(bench, num_items);
3841

3942
auto f = std::ofstream("bench_fill_front_int.html");
@@ -47,8 +50,12 @@ TEST_CASE("bench_fill_front_string" * doctest::skip() * doctest::test_suite("ben
4750

4851
fill_front<std::vector<std::string>>(bench, num_items, "hello");
4952
fill_front<ankerl::svector<std::string, 7>>(bench, num_items, "hello");
53+
#if ANKERL_SVECTOR_HAS_ABSL()
5054
fill_front<absl::InlinedVector<std::string, 7>>(bench, num_items, "hello");
55+
#endif
56+
#if ANKERL_SVECTOR_HAS_BOOST()
5157
fill_front<boost::container::small_vector<std::string, 7>>(bench, num_items, "hello");
58+
#endif
5259

5360
auto f = std::ofstream("bench_fill_front_string.html");
5461
bench.render(ankerl::nanobench::templates::htmlBoxplot(), f);

test/bench/bench_fill_random.cpp

+11-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
#include <ankerl/svector.h>
2+
#include <app/boost_absl.h>
23
#include <app/name_of_type.h>
34
#include <app/nanobench.h>
45

56
#include <doctest.h>
67

7-
#include <absl/container/inlined_vector.h>
8-
#include <boost/container/small_vector.hpp>
98
#include <fmt/format.h>
109

1110
#include <fstream>
@@ -18,7 +17,7 @@ void fill_random(ankerl::nanobench::Bench& bench, size_t num_items) {
1817
auto rng = ankerl::nanobench::Rng(1234);
1918
auto vec = Vec();
2019
for (size_t i = 0; i < num_items; ++i) {
21-
auto it = vec.begin() + rng.bounded(vec.size());
20+
auto it = vec.begin() + rng.bounded(static_cast<uint32_t>(vec.size()));
2221
if constexpr (std::is_same_v<typename Vec::value_type, std::string>) {
2322
vec.emplace(it, "hello");
2423
} else {
@@ -36,8 +35,12 @@ TEST_CASE("bench_fill_random_uint64_t" * doctest::skip() * doctest::test_suite("
3635
bench.epochs(100);
3736

3837
fill_random<std::vector<uint64_t>>(bench, num_items);
38+
#if ANKERL_SVECTOR_HAS_ABSL()
3939
fill_random<absl::InlinedVector<uint64_t, 7>>(bench, num_items);
40+
#endif
41+
#if ANKERL_SVECTOR_HAS_BOOST()
4042
fill_random<boost::container::small_vector<uint64_t, 7>>(bench, num_items);
43+
#endif
4144
fill_random<ankerl::svector<uint64_t, 7>>(bench, num_items);
4245

4346
auto f = std::ofstream("bench_fill_random_uint64_t.html");
@@ -51,8 +54,13 @@ TEST_CASE("bench_fill_random_string" * doctest::skip() * doctest::test_suite("be
5154
bench.epochs(100);
5255

5356
fill_random<std::vector<std::string>>(bench, num_items);
57+
#if ANKERL_SVECTOR_HAS_ABSL()
5458
fill_random<absl::InlinedVector<std::string, 7>>(bench, num_items);
59+
#endif
60+
#if ANKERL_SVECTOR_HAS_BOOST()
5561
fill_random<boost::container::small_vector<std::string, 7>>(bench, num_items);
62+
63+
#endif
5664
fill_random<ankerl::svector<std::string, 7>>(bench, num_items);
5765

5866
auto f = std::ofstream("bench_fill_random_string.html");

0 commit comments

Comments
 (0)