Skip to content

Commit

Permalink
Something something beautiful.
Browse files Browse the repository at this point in the history
  • Loading branch information
ThePhD committed Apr 3, 2020
1 parent 9fb43d6 commit 4081576
Show file tree
Hide file tree
Showing 14 changed files with 122 additions and 95 deletions.
4 changes: 2 additions & 2 deletions benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ target_link_libraries(itsy.bitsy.benchmarks PRIVATE
)
if (MSVC)
target_compile_options(itsy.bitsy.benchmarks PRIVATE
/std:c++latest
/std:c++17
/EHsc
/utf-8
/permissive-
/W4
)
else()
target_compile_options(itsy.bitsy.benchmarks PRIVATE
-std=c++2a
-std=c++17
-Wno-unknown-warning -Wno-unknown-warning-option
-Wall -Werror -Wextra -Wpedantic -pedantic -pedantic-errors
)
Expand Down
12 changes: 7 additions & 5 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,26 @@ function (make_example example_source_name itsy_bitsy_target target_suffix)
if (MSVC)
target_compile_options(${example_target}
PRIVATE
/std:c++latest
/std:c++17
/EHsc
/utf-8
/permissive-
/W4
)
else()
target_compile_options(${example_target}
PRIVATE -std=c++2a -Wpedantic -Wall -Werror)
PRIVATE -std=c++17 -Wpedantic -Wall -Werror)
endif()
target_compile_definitions(${example_target} PRIVATE __STDC_WANT_LIB_EXT1__=1)
target_compile_definitions(${example_target} PRIVATE
__STDC_WANT_LIB_EXT1__=1
ITSY_BITSY_USE_NONSTD_SPAN=1)
target_link_libraries(${example_target}
PRIVATE
${itsy_bitsy_target}
)
target_include_directories(${example_target} PRIVATE
"include"
"../vendor/span-lite/include/"
include
../vendor/span-lite/include/
)
if (ITSY_BITSY_TESTS)
add_test(NAME ${example_target} COMMAND ${example_target})
Expand Down
11 changes: 8 additions & 3 deletions examples/include/span.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@

#include <itsy/bitsy.hpp>

#if defined(__has_include) && __has_include(<span>) && (!defined(__GLIBCXX__) || __cplusplus > 201709L)
#if (defined(__has_include) && __has_include(<version>)) || (__cplusplus > 201709L)
#include <version>
#endif

#if defined(__cpp_lib_span)

#include <span>

Expand All @@ -33,7 +37,7 @@ namespace shim
using ::ranges::span;
}

#elif defined(__has_include) && __has_include(<nonstd/span.hpp>)
#elif (defined(__has_include) && __has_include(<nonstd/span.hpp>)) || (defined(ITSY_BITSY_USE_NONSTD_SPAN) && ITSY_BITSY_USE_NONSTD_SPAN != 0)

#include <nonstd/span.hpp>

Expand All @@ -44,7 +48,8 @@ namespace shim

#else

#error "Cannot use this feature: a std::span of some sort is required"
#error \
"Cannot use this feature: a span of some sort is required! Please pull in the submodules or provide your own span on the include paths."

#endif // Span bullshit

Expand Down
2 changes: 1 addition & 1 deletion include/itsy/bit_iterator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace bitsy
template<typename T>
using bit_mask_type_t = typename bit_mask_type<T>::type;

template<typename Ref, typename Mask = bit_mask_type_t<Ref>>
template<typename Ref, typename Mask>
using bit_reference = ::ITSY_BITSY_DETAIL_NAMESPACE::__bit_reference<Ref, Mask>;

template<typename Pointer>
Expand Down
3 changes: 2 additions & 1 deletion include/itsy/detail/algorithm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,7 @@ namespace ITSY_BITSY_DETAIL_NAMESPACE
__bit_fill_n_value(__bit_iterator<_ForwardIt> __first, _Size __count)
{
using __iterator = __bit_iterator<_ForwardIt>;
using __difference_type = typename __iterator::difference_type;
using __base_iterator = typename __iterator::iterator_type;
using __base_value_type = typename ::std::iterator_traits<__base_iterator>::value_type;
using __base_underlying_value_type = __any_to_underlying_t<__base_value_type>;
Expand All @@ -875,7 +876,7 @@ namespace ITSY_BITSY_DETAIL_NAMESPACE
}
}
__base_iterator __first_base = ::std::move(__first).base();
for (; __count >= __binary_digits_v<__base_value_type>;
for (; __count >= static_cast<__difference_type>(__binary_digits_v<__base_value_type>);
++__first_base, (void)(__count -= __binary_digits_v<__base_value_type>))
{
if constexpr (_Value)
Expand Down
13 changes: 13 additions & 0 deletions include/itsy/detail/bit_detail.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <iterator>
#include <type_traits>
#include <utility>
#include <memory>

namespace ITSY_BITSY_DETAIL_NAMESPACE
{
Expand Down Expand Up @@ -469,6 +470,18 @@ namespace ITSY_BITSY_DETAIL_NAMESPACE
return __end_it;
}
}

template <typename _It>
decltype(auto) __adl_to_address (const _It& __it) noexcept {
#if __cpp_to_address
using ::std::to_address;
#endif
return to_address(__it);
}

template <typename _It>
using __adl_to_address_test = decltype(__adl_to_address(::std::declval<_It>()));

} // namespace ITSY_BITSY_DETAIL_NAMESPACE

#endif // ITSY_BITSY_DETAIL_BIT_DETAIL_HPP
35 changes: 20 additions & 15 deletions include/itsy/detail/bit_iterator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,14 +376,14 @@ namespace ITSY_BITSY_DETAIL_NAMESPACE

public:
// types
using iterator_type = _Pointer;
using iterator_type = _Pointer;
using iterator_category = typename ::std::iterator_traits<iterator_type>::iterator_category;
using iterator_concept = __iterator_concept_t<iterator_type>;
using value_type = __bit_value;
using reference = __bit_reference<__base_reference, __bit_mask_type_t<__word_type>>;
using pointer = reference*;
using size_type = __size_type;
using difference_type = __difference_type;
using iterator_concept = __iterator_concept_t<iterator_type>;
using value_type = __bit_value;
using reference = __bit_reference<__base_reference, __bit_mask_type_t<__word_type>>;
using pointer = reference*;
using size_type = __size_type;
using difference_type = __difference_type;

// constructors
constexpr __bit_pointer() noexcept : _M_base_it(), _M_bit_ref_storage()
Expand Down Expand Up @@ -501,12 +501,14 @@ namespace ITSY_BITSY_DETAIL_NAMESPACE
return this->_M_is_alive();
}

constexpr reference operator*() const noexcept
constexpr reference
operator*() const noexcept
{
return this->_M_bit_ref_storage._M_value;
}

constexpr pointer operator->() const noexcept
constexpr pointer
operator->() const noexcept
{
return std::addressof(const_cast<__bit_pointer*>(this)->_M_bit_ref_storage._M_value);
}
Expand Down Expand Up @@ -630,9 +632,9 @@ namespace ITSY_BITSY_DETAIL_NAMESPACE
}
else
{
if constexpr (__is_detected_v<__std_to_address_test, iterator_type>)
if constexpr (__is_detected_v<__adl_to_address_test, iterator_type>)
{
return ::std::to_address(this->_M_base_it) != nullptr;
return __adl_to_address(this->_M_base_it) != nullptr;
}
else
{
Expand Down Expand Up @@ -722,7 +724,7 @@ namespace ITSY_BITSY_DETAIL_NAMESPACE
public:
using iterator_type = __base_iterator;
using iterator_category = typename ::std::iterator_traits<iterator_type>::iterator_category;
using iterator_concept = __iterator_concept_t<iterator_type>;
using iterator_concept = __iterator_concept_t<iterator_type>;
using value_type = __bit_value;
using pointer = __bit_pointer<iterator_type>;
using reference = __bit_reference<__word_ref_type, __mask_type>;
Expand Down Expand Up @@ -753,17 +755,20 @@ namespace ITSY_BITSY_DETAIL_NAMESPACE
operator=(__bit_iterator&& __right) noexcept = default;

// observers
constexpr reference operator*() const noexcept
constexpr reference
operator*() const noexcept
{
return reference(*this->_M_base_it, this->_M_pos);
}

constexpr pointer operator->() const noexcept
constexpr pointer
operator->() const noexcept
{
return pointer(this->_M_base_it, this->_M_pos);
}

constexpr reference operator[](difference_type n) const
constexpr reference
operator[](difference_type n) const
{
__bit_iterator __shifted = *this + n;
return *__shifted;
Expand Down
Loading

0 comments on commit 4081576

Please sign in to comment.