Skip to content

Commit

Permalink
Merge pull request #212 from BioDataAnalysis/bda_minor_various_improv…
Browse files Browse the repository at this point in the history
…ements

Various minor improvements
  • Loading branch information
JohanMabille authored Sep 7, 2020
2 parents 81e467f + ca6d124 commit 86d8071
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 34 deletions.
12 changes: 6 additions & 6 deletions include/xtl/xdynamic_bitset.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ namespace xtl
if (sz != this->m_size) {
#if defined(XTL_NO_EXCEPTIONS)
std::fprintf(stderr, "cannot resize bitset_view\n");
std::terminate();
std::terminate();
#else
throw std::runtime_error("cannot resize bitset_view");
#endif
Expand Down Expand Up @@ -577,18 +577,18 @@ namespace xtl
}

template <class B, class A>
inline void xdynamic_bitset<B, A>::resize(size_type size, bool b)
inline void xdynamic_bitset<B, A>::resize(size_type asize, bool b)
{
size_type old_block_count = base_type::block_count();
size_type new_block_count = base_type::compute_block_count(size);
size_type new_block_count = base_type::compute_block_count(asize);
block_type value = b ? ~block_type(0) : block_type(0);

if (new_block_count != old_block_count)
{
base_type::m_buffer.resize(new_block_count, value);
}

if (b && size > base_type::m_size)
if (b && asize > base_type::m_size)
{
size_type extra_bits = base_type::count_extra_bits();
if (extra_bits > 0)
Expand All @@ -597,7 +597,7 @@ namespace xtl
}
}

base_type::m_size = size;
base_type::m_size = asize;
base_type::zero_unused_bits();
}

Expand Down Expand Up @@ -1077,7 +1077,7 @@ namespace xtl
}

template <class B>
inline auto xdynamic_bitset_base<B>::derived_cast() const -> const derived_class&
inline auto xdynamic_bitset_base<B>::derived_cast() const -> const derived_class&
{
return *(reinterpret_cast<const derived_class*>(this));
}
Expand Down
8 changes: 4 additions & 4 deletions include/xtl/xspan_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ template <typename E, std::ptrdiff_t S>
struct span_storage {
constexpr span_storage() noexcept = default;

constexpr span_storage(E* ptr, std::ptrdiff_t /*unused*/) noexcept
: ptr(ptr)
constexpr span_storage(E* aptr, std::ptrdiff_t /*unused*/) noexcept
: ptr(aptr)
{}

E* ptr = nullptr;
Expand All @@ -159,8 +159,8 @@ template <typename E>
struct span_storage<E, dynamic_extent> {
constexpr span_storage() noexcept = default;

constexpr span_storage(E* ptr, std::size_t size) noexcept
: ptr(ptr), size(size)
constexpr span_storage(E* aptr, std::size_t asize) noexcept
: ptr(aptr), size(asize)
{}

E* ptr = nullptr;
Expand Down
24 changes: 16 additions & 8 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@ if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
set(XTL_INCLUDE_DIR ${xtl_INCLUDE_DIRS})
endif ()

message(STATUS "Forcing tests build type to Release")
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
if(NOT CMAKE_BUILD_TYPE)
message(STATUS "Setting tests build type to Release")
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
else()
message(STATUS "Tests build type is ${CMAKE_BUILD_TYPE}")
endif()

include(CheckCXXCompilerFlag)

Expand All @@ -33,9 +37,11 @@ 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)

CHECK_CXX_COMPILER_FLAG(-march=native HAS_MARCH_NATIVE)
if (HAS_MARCH_NATIVE)
add_compile_options(-march=native)
if(NOT CMAKE_CXX_FLAGS MATCHES "-march")
CHECK_CXX_COMPILER_FLAG(-march=native HAS_MARCH_NATIVE)
if (HAS_MARCH_NATIVE)
add_compile_options(-march=native)
endif()
endif()
if (XTL_DISABLE_EXCEPTIONS)
add_compile_options(-fno-exceptions)
Expand All @@ -54,9 +60,11 @@ if(CMAKE_CXX_COMPILER_ID MATCHES Clang)
if(NOT WIN32)
add_compile_options(-Wunused-parameter -Wextra -Wreorder -Wconversion -Wsign-conversion)

CHECK_CXX_COMPILER_FLAG(-march=native HAS_MARCH_NATIVE)
if (HAS_MARCH_NATIVE)
add_compile_options(-march=native)
if(NOT CMAKE_CXX_FLAGS MATCHES "-march")
CHECK_CXX_COMPILER_FLAG(-march=native HAS_MARCH_NATIVE)
if (HAS_MARCH_NATIVE)
add_compile_options(-march=native)
endif()
endif()
if (XTL_DISABLE_EXCEPTIONS)
add_compile_options(-fno-exceptions)
Expand Down
19 changes: 9 additions & 10 deletions test/test_xiterator_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ namespace adl
namespace xtl
{
using iterator = adl::iterator_test;

TEST(xiterator_base, increment)
{
iterator it;
Expand Down Expand Up @@ -203,38 +203,38 @@ namespace xtl
{
using map_type = std::map<std::string, int>;
map_type m = { {"a", 0}, {"b", 1}, {"c", 2} };
using iterator = xkey_iterator<map_type>;
using xkeyiterator = xkey_iterator<map_type>;

iterator it(m.begin());
xkeyiterator it(m.begin());
EXPECT_EQ(*it, "a");
iterator it2 = it;
xkeyiterator it2 = it;
EXPECT_EQ(it, it2);
++it2;
EXPECT_EQ(*it2, "b");
EXPECT_NE(it, it2);
++it2;
EXPECT_EQ(*it2, "c");
++it2;
EXPECT_EQ(it2, iterator(m.end()));
EXPECT_EQ(it2, xkeyiterator(m.end()));
}

TEST(xiterator_base, xvalue_iterator)
{
using map_type = std::map<std::string, int>;
map_type m = { {"a", 0}, {"b", 1}, {"c", 2} };
using iterator = xvalue_iterator<map_type>;
using xvalueiterator = xvalue_iterator<map_type>;

iterator it(m.begin());
xvalueiterator it(m.begin());
EXPECT_EQ(*it, 0);
iterator it2 = it;
xvalueiterator it2 = it;
EXPECT_EQ(it, it2);
++it2;
EXPECT_EQ(*it2, 1);
EXPECT_NE(it, it2);
++it2;
EXPECT_EQ(*it2, 2);
++it2;
EXPECT_EQ(it2, iterator(m.end()));
EXPECT_EQ(it2, xvalueiterator(m.end()));
}

TEST(xiterator_base, tag_promotion)
Expand Down Expand Up @@ -296,4 +296,3 @@ namespace xtl
EXPECT_EQ(it_end, it);
}
}

6 changes: 0 additions & 6 deletions test/test_xmeta_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,6 @@ namespace xtl
EXPECT_TRUE(res);
}

template <class T>
struct DEBUG
{
using type = typename T::coincoin;
};

TEST(mpl, merge_set)
{
using arg2 = mpl::vector<double, float, int, short>;
Expand Down

0 comments on commit 86d8071

Please sign in to comment.