Skip to content

Commit

Permalink
Merge branch 'release/v0.1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
gmarcais committed May 9, 2022
2 parents 5656e31 + e015c55 commit 0aab8c4
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 16 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/c-cpp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: C/C++ CI

on:
push:
branches:
- master
- develop
pull_request:
branches: [ master ]

jobs:
test:
name: Unit tests on ${{ matrix.os }} with ${{ matrix.compiler }} standard ${{ matrix.standard }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04]
standard: [c++11, c++14, c++17, c++20]
compiler: [g++-10, clang++-12]

steps:
- uses: actions/checkout@v3
- name: Install gtest
run: |
sudo apt-get update
sudo apt-get install libgtest-dev
- name: configure ${{ matrix.standard }}
run: autoreconf -fi && ./configure CXX=${{ matrix.compiler }} CXXFLAGS="-std=${{ matrix.standard }} -Wall -Werror"
- name: check ${{ matrix.standard }}
run: make -j 2 check

test_libcxx:
name: Unit tests with clang and libc++
runs-on: ubuntu-20.04
strategy:
matrix:
standard: [c++11, c++14, c++17, c++20]

steps:
- uses: actions/checkout@v3
- name: Install gtest
run: |
set -e
sudo apt install libc++-12-dev libc++1-12 libc++abi1-12 libc++abi-12-dev
mkdir gtest build
curl -L https://github.com/google/googletest/archive/refs/tags/release-1.11.0.tar.gz | tar zx --strip-components=1 -C gtest
cd build
cmake ../gtest -DBUILD_GMOCK=OFF -DCMAKE_CXX_COMPILER=clang++-12 -DCMAKE_CXX_FLAGS="-stdlib=libc++" -DCMAKE_SHARED_LINKER_FLAGS="-stdlib=libc++"
make -j 2
sudo make install
sudo ldconfig
- name: configure
run: |
autoreconf -fi
PKG_CONFIG_PATH=/usr/local/lib/pkgconfig ./configure CC=clang-12 CXX=clang++-12 CXXFLAGS="-std=${{ matrix.standard }} -Wall -Werror -stdlib=libc++" LDFLAGS="-stdlib=libc++" || cat config.log
- name: check ${{ matrix.standard }}
run: make -j 2 check
6 changes: 3 additions & 3 deletions INSTALL
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Installation Instructions
*************************

Copyright (C) 1994-1996, 1999-2002, 2004-2016 Free Software
Foundation, Inc.
Copyright (C) 1994-1996, 1999-2002, 2004-2017, 2020-2021 Free
Software Foundation, Inc.

Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
Expand Down Expand Up @@ -225,7 +225,7 @@ order to use an ANSI C compiler:

and if that doesn't work, install pre-built binaries of GCC for HP-UX.

HP-UX 'make' updates targets which have the same time stamps as their
HP-UX 'make' updates targets which have the same timestamps as their
prerequisites, which makes it generally unusable when shipped generated
files such as 'configure' are involved. Use GNU 'make' instead.

Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
AC_INIT([compact_vector],[0.1.0],[[email protected]])
AC_INIT([compact_vector],[0.1.1],[[email protected]])
AC_CONFIG_AUX_DIR([build-aux])
AM_SILENT_RULES([yes])
AC_CONFIG_SRCDIR([include/compact_vector.hpp])
Expand Down
31 changes: 20 additions & 11 deletions include/compact_iterator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,15 @@ struct mask_store<W, true> {
}
};

// Replacement for the now deprecated (C++17) std::iterator
template<typename T>
struct iterator_types {
typedef T value_type;
typedef ptrdiff_t difference_type;
typedef T* pointer;
typedef T& reference;
typedef std::random_access_iterator_tag iterator_category;
};

// Base class for the iterators
template<class Derived, typename IDX, unsigned BITS, typename W, unsigned UB>
Expand All @@ -425,7 +434,7 @@ class common {
"The size of integral type IDX must be less than the word type W");

public:
typedef typename std::iterator<std::random_access_iterator_tag, IDX>::difference_type difference_type;
typedef typename iterator_types<IDX>::difference_type difference_type;
static constexpr unsigned used_bits = UB;

Derived& operator=(const Derived& rhs) {
Expand Down Expand Up @@ -453,12 +462,12 @@ class common {
const Derived& self = *static_cast<const Derived*>(this);
const Derived& other = static_cast<const Derived&>(rhs);
const auto ptr_cmp = self.m_ptr <=> other.m_ptr;
if(std::is_neq(ptr_cmp))
if(ptr_cmp != 0)
return ptr_cmp;
return self.m_offset <=> other.m_offset;
}
bool operator==(const common& rhs) const {
return std::is_eq(*this <=> rhs);
return (*this <=> rhs) == 0;
}
bool operator==(std::nullptr_t p) const {
const Derived& self = *static_cast<const Derived*>(this);
Expand Down Expand Up @@ -820,7 +829,7 @@ void swap(lhs_setter<I, BITS, W, TS, UB> x, lhs_setter<I, BITS, W, TS, UB> y) {
// Specialization with BITS=0 (dynamic/runtime number of bits used)
template<typename IDX, typename W, bool TS, unsigned UB>
class iterator<IDX, 0, W, TS, UB> :
public std::iterator<std::random_access_iterator_tag, IDX>,
public iterator_imp::iterator_types<IDX>,
public iterator_imp::common<iterator<IDX, 0, W, TS, UB>, IDX, 0, W, UB>
{
W* m_ptr;
Expand All @@ -832,7 +841,7 @@ class iterator<IDX, 0, W, TS, UB> :
friend class iterator_imp::common<iterator<IDX, 0, W, TS, UB>, IDX, 0, W, UB>;
friend class iterator_imp::common<const_iterator<IDX, 0, W, UB>, IDX, 0, W, UB>;

typedef std::iterator<std::random_access_iterator_tag, IDX> super;
typedef iterator_imp::iterator_types<IDX> super;
public:
typedef typename super::value_type value_type;
typedef typename super::difference_type difference_type;
Expand Down Expand Up @@ -867,7 +876,7 @@ class iterator<IDX, 0, W, TS, UB> :

template<typename IDX, typename W, unsigned UB>
class const_iterator<IDX, 0, W, UB> :
public std::iterator<std::random_access_iterator_tag, const IDX>,
public iterator_imp::iterator_types<const IDX>,
public iterator_imp::common<const_iterator<IDX, 0, W, UB>, IDX, 0, W, UB>
{
const W* m_ptr;
Expand All @@ -879,7 +888,7 @@ class const_iterator<IDX, 0, W, UB> :
friend class iterator_imp::common<iterator<IDX, 0, W, false, UB>, IDX, 0, W, UB>;
friend class iterator_imp::common<const_iterator<IDX, 0, W, UB>, IDX, 0, W, UB>;

typedef std::iterator<std::random_access_iterator_tag, IDX> super;
typedef iterator_imp::iterator_types<IDX> super;
public:
typedef typename super::value_type value_type;
typedef typename super::difference_type difference_type;
Expand All @@ -906,7 +915,7 @@ class const_iterator<IDX, 0, W, UB> :
// No specialization. Static number of bits used.
template<typename IDX, unsigned BITS, typename W, bool TS, unsigned UB>
class iterator :
public std::iterator<std::random_access_iterator_tag, IDX>,
public iterator_imp::iterator_types<IDX>,
public iterator_imp::common<iterator<IDX, BITS, W, TS, UB>, IDX, BITS, W, UB>
{
W* m_ptr;
Expand All @@ -917,7 +926,7 @@ class iterator :
friend class iterator_imp::common<iterator<IDX, BITS, W, TS, UB>, IDX, BITS, W, UB>;
friend class iterator_imp::common<const_iterator<IDX, BITS, W, UB>, IDX, BITS, W, UB>;

typedef std::iterator<std::random_access_iterator_tag, IDX> super;
typedef iterator_imp::iterator_types<IDX> super;
public:
typedef typename super::value_type value_type;
typedef typename super::difference_type difference_type;
Expand Down Expand Up @@ -954,7 +963,7 @@ class iterator :

template<typename IDX, unsigned BITS, typename W, unsigned UB>
class const_iterator :
public std::iterator<std::random_access_iterator_tag, const IDX>,
public iterator_imp::iterator_types<const IDX>,
public iterator_imp::common<const_iterator<IDX, BITS, W, UB>, IDX, BITS, W, UB>
{
const W* m_ptr;
Expand All @@ -965,7 +974,7 @@ class const_iterator :
friend class iterator_imp::common<iterator<IDX, BITS, W, false, UB>, IDX, BITS, W, UB>;
friend class iterator_imp::common<const_iterator<IDX, BITS, W, UB>, IDX, BITS, W, UB>;

typedef std::iterator<std::random_access_iterator_tag, IDX> super;
typedef iterator_imp::iterator_types<IDX> super;
public:
typedef typename super::value_type value_type;
typedef typename super::difference_type difference_type;
Expand Down
1 change: 1 addition & 0 deletions tests/misc.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <fstream>
#include <random>
#include <array>

// Seed a random generator
template <typename EngineT, std::size_t StateSize = EngineT::state_size>
Expand Down
2 changes: 1 addition & 1 deletion unittests/test_compact_vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ void single_thread_test(size_t size, CV& vector1, CV& vector2, CV& vector3) {
std::vector<size_t> order;
auto it1 = vector1.cbegin();
for(size_t i = 0; i < size; ++i) order.push_back(i);
std::random_shuffle(order.begin(), order.end());
std::shuffle(order.begin(), order.end(), prg);
for(auto i : order) {
EXPECT_EQ(ary[i], it1[i]);
EXPECT_EQ(ary[i], vector2[i]);
Expand Down

0 comments on commit 0aab8c4

Please sign in to comment.