Skip to content

Commit

Permalink
Fix up constructors/assignments and usages
Browse files Browse the repository at this point in the history
- Explicitly set each operator=
- Explicitly import the base class
- Explicitly default the constructors of higher-level classes
  • Loading branch information
ThePhD committed Aug 24, 2020
1 parent 761f0bd commit f0818b7
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 7 deletions.
4 changes: 3 additions & 1 deletion benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ add_subdirectory(../vendor/benchmark "benchmark")
file(GLOB_RECURSE itsy.bitsy.benchmarks.sources CONFIGURE_DEPENDS source/**)

add_executable(itsy.bitsy.benchmarks ${itsy.bitsy.benchmarks.sources})
target_include_directories(itsy.bitsy.benchmarks PRIVATE
target_include_directories(itsy.bitsy.benchmarks PRIVATE
include
)
target_include_directories(itsy.bitsy.benchmarks SYSTEM PRIVATE
../vendor/span-lite/include
)
target_link_libraries(itsy.bitsy.benchmarks PRIVATE
Expand Down
2 changes: 2 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ function (make_example example_source_name itsy_bitsy_target target_suffix)
)
target_include_directories(${example_target} PRIVATE
include
)
target_include_directories(${example_target} SYSTEM PRIVATE
../vendor/span-lite/include/
)
if (ITSY_BITSY_TESTS)
Expand Down
7 changes: 6 additions & 1 deletion include/itsy/detail/small_bit_vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2910,8 +2910,13 @@ namespace ITSY_BITSY_SOURCE_NAMESPACE
using __base_t = __packed_small_bit_vector<_Type, _InlineWords, _Allocator, false>;

public:

using __base_t::__base_t;
using __base_t::operator=;
__small_bit_vector(const __small_bit_vector&) = default;
__small_bit_vector(__small_bit_vector&&) = default;

__small_bit_vector& operator=(const __small_bit_vector&) = default;
__small_bit_vector& operator=(__small_bit_vector&&) = default;

This comment has been minimized.

Copy link
@jeb2239

jeb2239 Aug 27, 2020

Why is this necessary doesn't the base class have all these operations?

This comment has been minimized.

Copy link
@ThePhD

ThePhD Aug 28, 2020

Author Owner

Because the ones generated by the compiler do not include the proper set of operations. Each one must be defaulted and/or hand-written at each level of the hierarchy.

};
} // namespace ITSY_BITSY_SOURCE_NAMESPACE

Expand Down
12 changes: 10 additions & 2 deletions include/itsy/dynamic_bitset.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ namespace bitsy
using const_sentinel = typename base_t::const_sentinel;

using base_t::base_t;
using base_t::operator=;
dynamic_bitset(const dynamic_bitset&) = default;
dynamic_bitset(dynamic_bitset&&) = default;

dynamic_bitset& operator=(const dynamic_bitset&) = default;
dynamic_bitset& operator=(dynamic_bitset&&) = default;
};

template<typename T, typename Allocator = std::allocator<T>>
Expand All @@ -63,7 +67,11 @@ namespace bitsy
using const_sentinel = typename base_t::const_sentinel;

using base_t::base_t;
using base_t::operator=;
packed_dynamic_bitset(const packed_dynamic_bitset&) = default;
packed_dynamic_bitset(packed_dynamic_bitset&&) = default;

packed_dynamic_bitset& operator=(const packed_dynamic_bitset&) = default;
packed_dynamic_bitset& operator=(packed_dynamic_bitset&&) = default;
};
} // namespace bitsy

Expand Down
12 changes: 10 additions & 2 deletions include/itsy/small_bit_vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ namespace bitsy
using const_sentinel = typename base_t::const_sentinel;

using base_t::base_t;
using base_t::operator=;
small_bit_vector(const small_bit_vector&) = default;
small_bit_vector(small_bit_vector&&) = default;

small_bit_vector& operator=(const small_bit_vector&) = default;
small_bit_vector& operator=(small_bit_vector&&) = default;
};

template<typename Word,
Expand All @@ -71,7 +75,11 @@ namespace bitsy
using const_sentinel = typename base_t::const_sentinel;

using base_t::base_t;
using base_t::operator=;
packed_small_bit_vector(const packed_small_bit_vector&) = default;
packed_small_bit_vector(packed_small_bit_vector&&) = default;

packed_small_bit_vector& operator=(const packed_small_bit_vector&) = default;
packed_small_bit_vector& operator=(packed_small_bit_vector&&) = default;

This comment has been minimized.

Copy link
@jeb2239

jeb2239 Aug 27, 2020

same here why do we need this? I tried to export the |= operator in this way and it just ends up calling itself recursively.

This comment has been minimized.

Copy link
@ThePhD

ThePhD Aug 28, 2020

Author Owner

I sent an e-mail: check that!

};
} // namespace bitsy

Expand Down
2 changes: 1 addition & 1 deletion vendor/span-lite

0 comments on commit f0818b7

Please sign in to comment.