Skip to content

Commit 3d1ace8

Browse files
committed
Fixed all gcc cxx11 related bugsd
1 parent d633b92 commit 3d1ace8

File tree

151 files changed

+681
-828
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

151 files changed

+681
-828
lines changed

examples/chain.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#include <Lz/Lz.hpp>
22

3+
// TODO lz::as for cxx 11
4+
35
int main() {
46
int arr[]{ 3, 2, 4, 5 };
57
int arr2[]{ 3, 2, 5, 5 };

examples/chunk_if.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#include <Lz/chunk_if.hpp>
22
#include <vector>
33

4+
// TODO lz::t_chunk_if cxx 11
5+
46
int main() {
57
std::string s = "hello world; this is a message;";
68
auto chunked = lz::chunk_if(s, [](const char c) { return c == ';'; });

examples/split.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ int main() {
4545

4646
std::cout << "\n\nUsing other container types:\n";
4747
std::vector<int> to_split2 = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
48-
auto to_split_on = { 5 };
48+
std::array<int, 1> to_split_on = { 5 };
4949
// to_split_on must be by reference!
5050
const auto splitter3 = lz::split(to_split2, to_split_on);
5151
// Returns an iterable of iterables
@@ -112,7 +112,7 @@ int main() {
112112

113113
std::cout << "\n\nUsing other container types:\n";
114114
std::vector<int> to_split2 = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
115-
auto to_split_on = { 5 };
115+
std::array<int, 1> to_split_on = { 5 };
116116
// to_split_on must be by reference!
117117
const auto splitter3 = lz::split(to_split2, to_split_on);
118118
// Returns an iterable of iterables

include/Lz/any_iterable.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ class any_iterable : public lazy_view {
5454
*/
5555
template<LZ_CONCEPT_ITERABLE Iterable>
5656
any_iterable(Iterable&& iterable) :
57-
_begin{ std::make_unique<any_iter_impl<Iterable>>(detail::begin(std::forward<Iterable>(iterable))) },
58-
_end{ std::make_unique<any_iter_impl<Iterable>>(detail::end(std::forward<Iterable>(iterable))) } {
57+
_begin{ detail::make_unique<any_iter_impl<Iterable>>(detail::begin(std::forward<Iterable>(iterable))) },
58+
_end{ detail::make_unique<any_iter_impl<Iterable>>(detail::end(std::forward<Iterable>(iterable))) } {
5959
}
6060

6161
LZ_NODISCARD it begin() const& {

include/Lz/basic_iterable.hpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -313,19 +313,19 @@ copy_to_container(Iterable&& iterable, Container& container) {
313313

314314
template<class Container>
315315
struct container_constructor {
316-
template<class Container, LZ_CONCEPT_ITERABLE Iterable, class... Args>
316+
template<LZ_CONCEPT_ITERABLE Iterable, class... Args>
317317
using can_construct = std::is_constructible<Container, iter_t<Iterable>, sentinel_t<Iterable>, Args...>;
318318

319319
template<LZ_CONCEPT_ITERABLE Iterable, class... Args>
320-
LZ_NODISCARD constexpr enable_if<can_construct<Container, Iterable, Args...>::value, Container>
320+
LZ_NODISCARD constexpr enable_if<can_construct<Iterable, Args...>::value, Container>
321321
construct(Iterable&& iterable, Args&&... args) const {
322322
return Container(detail::begin(std::forward<Iterable>(iterable)), detail::end(std::forward<Iterable>(iterable)),
323323
std::forward<Args>(args)...);
324324
}
325325

326326
template<LZ_CONCEPT_ITERABLE Iterable, class... Args>
327327
LZ_NODISCARD LZ_CONSTEXPR_CXX_20
328-
enable_if<!can_construct<Container, Iterable, Args...>::value, Container>
328+
enable_if<!can_construct<Iterable, Args...>::value, Container>
329329
construct(Iterable&& iterable, Args&&... args) const {
330330
Container container(std::forward<Args>(args)...);
331331
prealloc_container<Iterable, Container>{}.try_reserve(iterable, container);
@@ -525,9 +525,9 @@ LZ_MODULE_EXPORT_SCOPE_BEGIN
525525

526526
#ifdef LZ_HAS_CXX_11
527527

528-
static const detail::iterable_printer print{};
528+
constexpr detail::iterable_printer print{};
529529

530-
static const detail::iterable_formatter format{};
530+
constexpr detail::iterable_formatter format{};
531531

532532
#else
533533

include/Lz/c_string.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ LZ_MODULE_EXPORT_SCOPE_BEGIN
2323
* auto cstr = str | lz::c_string;
2424
* ```
2525
*/
26-
static constexpr detail::c_string_adaptor detail::c_string_adaptor::c_string{};
26+
constexpr detail::c_string_adaptor c_string{};
2727

2828
#else
2929

include/Lz/cached_size.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ namespace lz {
4747
* - lz::zip
4848
* Are planning to call begin() or end() multiple times
4949
*/
50-
static constexpr detail::cached_size_adaptor cache_size{};
50+
constexpr detail::cached_size_adaptor cache_size{};
5151

5252
#else
5353

include/Lz/cartesian_product.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ LZ_MODULE_EXPORT_SCOPE_BEGIN
2424
* auto product = a | lz::cartesian_product(b); // product = {{1, 3}, {1, 4}, {2, 3}, {2, 4}}
2525
* ```
2626
*/
27-
static constexpr detail::cartesian_product_adaptor detail::cartesian_product_adaptor::cartesian_product{};
27+
constexpr detail::cartesian_product_adaptor cartesian_product{};
2828

2929
#else
3030

include/Lz/chunk_if.hpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ LZ_MODULE_EXPORT_SCOPE_BEGIN
2929
* ```
3030
* @tparam ValueType The value type of the chunked iterable.
3131
*/
32+
// TODO
3233
template<class ValueType>
33-
static constexpr detail::chunk_if_adaptor<ValueType> detail::chunk_if_adaptor<ValueType>::t_chunk_if;
34+
using t_chunk_if = detail::chunk_if_adaptor<ValueType>;
3435

3536
/**
3637
* @brief This adaptor is used to make chunks of the iterable, based on a condition returned by the function passed. The iterator
@@ -46,7 +47,7 @@ static constexpr detail::chunk_if_adaptor<ValueType> detail::chunk_if_adaptor<Va
4647
* auto chunked = vec | lz::chunk_if([](int i) { return i % 2 == 0; }); // chunked = { {1, 2}, {3, 4}, {5} } }
4748
* ```
4849
*/
49-
static constexpr detail::chunk_if_adaptor<void> detail::chunk_if_adaptor<void>::chunk_if{};
50+
constexpr detail::chunk_if_adaptor<void> chunk_if{};
5051

5152
/**
5253
* @brief This adaptor is used to make chunks of the iterable, based on a condition returned by the function passed. The iterator
@@ -63,7 +64,7 @@ static constexpr detail::chunk_if_adaptor<void> detail::chunk_if_adaptor<void>::
6364
* // chunked = { string_view{"hello"}, string_view{"world"}, string_view{""}, string_view{""} }
6465
* ```
6566
*/
66-
static constexpr detail::chunk_if_adaptor<lz::string_view> detail::chunk_if_adaptor<lz::string_view>::sv_chunk_if{};
67+
constexpr detail::chunk_if_adaptor<lz::string_view> sv_chunk_if{};
6768

6869
/**
6970
* @brief This adaptor is used to make chunks of the iterable, based on a condition returned by the function passed. The iterator
@@ -80,7 +81,7 @@ static constexpr detail::chunk_if_adaptor<lz::string_view> detail::chunk_if_adap
8081
* // chunked = { std::string{"hello"}, std::string{"world"}, std::string{""}, std::string{""} }
8182
* ```
8283
*/
83-
static constexpr detail::chunk_if_adaptor<std::string> detail::chunk_if_adaptor<std::string>::s_chunk_if{};
84+
constexpr detail::chunk_if_adaptor<std::string> s_chunk_if{};
8485

8586
#else
8687

include/Lz/chunks.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ LZ_MODULE_EXPORT_SCOPE_BEGIN
3939
* auto chunked = vec | lz::chunks(3); // chunked = { {1, 2, 3}, {4, 5} }
4040
* ```
4141
*/
42-
static constexpr detail::chunks_adaptor detail::chunks_adaptor::chunks;
42+
constexpr detail::chunks_adaptor chunks;
4343

4444
#else
4545

include/Lz/common.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ LZ_MODULE_EXPORT_SCOPE_BEGIN
3131
* Will not result in an iterable where its end() and begin() functions return the same type. This is because
3232
* the common view is created first and then the take view is created. The take view will return another sentinel.
3333
*/
34-
static constexpr detail::common_adaptor detail::common_adaptor::common{};
34+
constexpr detail::common_adaptor common{};
3535

3636
#else
3737

include/Lz/concatenate.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ LZ_MODULE_EXPORT_SCOPE_BEGIN
2424
* auto concatenated = a | lz::concat(b); // concatenated = {1, 2, 3, 4}
2525
* ```
2626
*/
27-
static constexpr detail::concatenate_adaptor detail::concatenate_adaptor::concat{};
27+
constexpr detail::concatenate_adaptor concat{};
2828

2929
#else
3030

include/Lz/detail/adaptors/c_string.hpp

+24-9
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,7 @@ namespace lz {
99
namespace detail {
1010
struct c_string_adaptor {
1111
using adaptor = c_string_adaptor;
12-
13-
#ifdef LZ_HAS_CXX_11
14-
15-
static constexpr adaptor c_string;
16-
17-
#endif
18-
12+
1913
/**
2014
* @brief This adaptor is used to create a c forward iterable cstring iterable object. Its end() function will return a
2115
* sentinel, rather than an actual iterator. This iterable does not contain a .size() method. Example:
@@ -29,10 +23,31 @@ struct c_string_adaptor {
2923
* @param str The string to create a cstring iterable from.
3024
**/
3125
template<class C>
32-
LZ_NODISCARD constexpr c_string_iterable<decay_t<C>> operator()(C&& str) const noexcept {
33-
return { std::forward<C>(str) };
26+
LZ_NODISCARD constexpr c_string_iterable<C> operator()(C* str) const noexcept {
27+
return { str };
3428
}
29+
30+
/**
31+
* @brief This adaptor is used to create a c forward iterable cstring iterable object. Its end() function will return a
32+
* sentinel, rather than an actual iterator. This iterable does not contain a .size() method. Example:
33+
* ```cpp
34+
* const char* str = "Hello, World!";
35+
* auto cstr = lz::c_string(str);
36+
* // or:
37+
* const char str[] = "Hello, World!";
38+
* auto cstr = str | lz::c_string;
39+
* ```
40+
* @param str The string to create a cstring iterable from.
41+
**/
42+
template<class C>
43+
LZ_NODISCARD constexpr c_string_iterable<const C> operator()(const C* str) const noexcept {
44+
return { str };
45+
}
46+
3547
};
48+
49+
template class c_string_iterable<const char>;
50+
3651
} // namespace detail
3752
} // namespace lz
3853

include/Lz/detail/adaptors/cached_size.hpp

-6
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@ namespace detail {
1010
struct cached_size_adaptor {
1111
using adaptor = cached_size_adaptor;
1212

13-
#ifdef LZ_HAS_CXX_11
14-
15-
static constexpr adaptor cache_size;
16-
17-
#endif
18-
1913
/**
2014
* @brief Creates an iterable with a size. Gets the size eagerly (using `lz::eager_size`), so if the input iterable is
2115
* bidirectional or less and is not sized, the entire iterable will be traversed. This can be handy if you want to

include/Lz/detail/adaptors/cartesian_product.hpp

-6
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,6 @@ namespace detail {
1212
struct cartesian_product_adaptor {
1313
using adaptor = cartesian_product_adaptor;
1414

15-
#ifdef LZ_HAS_CXX_11
16-
17-
static constexpr adaptor cartesian_product{};
18-
19-
#endif
20-
2115
/**
2216
* @brief Performs a cartesian product on the given iterables. This means that it will return all possible combinations
2317
* of the elements of the given iterables. Contains a .size() function if all of the iterables have a .size() function.

include/Lz/detail/adaptors/chunk_if.hpp

-16
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,6 @@ template<class ValueType>
1414
struct chunk_if_adaptor {
1515
using adaptor = chunk_if_adaptor<ValueType>;
1616

17-
#ifdef LZ_HAS_CXX_11
18-
19-
static constexpr adaptor t_chunk_if{};
20-
21-
static constexpr chunk_if_adaptor<lz::string_view> sv_chunk_if{};
22-
23-
static constexpr chunk_if_adaptor<std::string> s_chunk_if{};
24-
25-
#endif
26-
2717
/**
2818
* @brief This adaptor is used to make chunks of the iterable, based on a condition returned by the function passed. The
2919
* iterator category is forward, and returns a sentinel. It returns an iterable of some type T of which T must be
@@ -81,12 +71,6 @@ template<>
8171
struct chunk_if_adaptor<void> {
8272
using adaptor = chunk_if_adaptor<void>;
8373

84-
#ifdef LZ_HAS_CXX_11
85-
86-
static constexpr adaptor chunk_if{};
87-
88-
#endif
89-
9074
/**
9175
* @brief This adaptor is used to make chunks of the iterable, based on a condition returned by the function passed. The
9276
* iterator category is forward, and returns a sentinel. It returns an iterable of iterables. This iterable does not contain

include/Lz/detail/adaptors/chunks.hpp

-6
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,6 @@ namespace detail {
1313
struct chunks_adaptor {
1414
using adaptor = chunks_adaptor;
1515

16-
#ifdef LZ_HAS_CXX_11
17-
18-
static constexpr adaptor chunks{};
19-
20-
#endif
21-
2216
/**
2317
* @brief This adaptor is used to make chunks of the iterable, based on chunk size. The iterator
2418
* category is the same as its input iterable. It returns an iterable of iterables. Its end() function will return a sentinel,

include/Lz/detail/adaptors/common.hpp

+1-7
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,7 @@ namespace lz {
1010
namespace detail {
1111
struct common_adaptor {
1212
using adaptor = common_adaptor;
13-
14-
#ifdef LZ_HAS_CXX_11
15-
16-
static constexpr adaptor common{};
17-
18-
#endif
19-
13+
2014
/**
2115
* Creates a common view from an iterator and a sentinel. The iterable must have a sentinel type (i.e. its begin() function
2216
* must return a different type than its end() function), otherwise a static assertion will fail.

include/Lz/detail/adaptors/concatenate.hpp

-6
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,6 @@ namespace detail {
1111
struct concatenate_adaptor {
1212
using adaptor = concatenate_adaptor;
1313

14-
#ifdef LZ_HAS_CXX_11
15-
16-
static constexpr adaptor concat{};
17-
18-
#endif
19-
2014
/**
2115
* @brief Concatenates multiple iterables into one iterable. Contains a .size() function if all iterables have a .size()
2216
* function. The size is the sum of all the sizes of the iterables. Contains a sentinel if one of the iterables contains a

include/Lz/detail/adaptors/drop.hpp

-6
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,6 @@ namespace detail {
1212
struct drop_adaptor {
1313
using adaptor = drop_adaptor;
1414

15-
#ifdef LZ_HAS_CXX_11
16-
17-
static constexpr adaptor drop{};
18-
19-
#endif
20-
2115
/**
2216
* @brief This adaptor is used to drop the first n elements of an iterable. The iterator category is the same as the input
2317
* iterator category. Its end() function will return the same type as its input iterable. If its input iterable has a

include/Lz/detail/adaptors/drop_while.hpp

-6
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,6 @@ namespace detail {
1212
struct drop_while_adaptor {
1313
using adaptor = drop_while_adaptor;
1414

15-
#ifdef LZ_HAS_CXX_11
16-
17-
static constexpr drop_while_adaptor drop_while{};
18-
19-
#endif
20-
2115
/**
2216
* @brief This adaptor is used to make an iterable where the iterator keeps dropping elements as long as the predicate returns
2317
* `true`. Once it has returned `false`, it will no longer do such thing. The iterator category is the same as its input

include/Lz/detail/adaptors/enumerate.hpp

-6
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,6 @@ namespace detail {
1212
struct enumerate_adaptor {
1313
using adaptor = enumerate_adaptor;
1414

15-
#ifdef LZ_HAS_CXX_11
16-
17-
static constexpr adaptor enumerate{};
18-
19-
#endif
20-
2115
/**
2216
* @brief Returns an iterable that enumerates the elements of the input iterable, meaning it returns a std::pair<IntType,
2317
* ValueType>, where std::pair::first_type is an integer (corresponding to the current index) and std::pair::second_type is

include/Lz/detail/adaptors/except.hpp

+1-6
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,7 @@ namespace lz {
1212
namespace detail {
1313
struct except_adaptor {
1414
using adaptor = except_adaptor;
15-
16-
#ifdef LZ_HAS_CXX_11
17-
18-
static constexpr adaptor except{};
19-
20-
#endif
15+
2116
// clang-format off
2217

2318
/**

include/Lz/detail/adaptors/exclude.hpp

-6
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,6 @@ namespace detail {
1212
struct exclude_adaptor {
1313
using adaptor = exclude_adaptor;
1414

15-
#ifdef LZ_HAS_CXX_11
16-
17-
static constexpr adaptor exclude{};
18-
19-
#endif
20-
2115
/**
2216
* @brief Excludes elements from a container, using two indexes. The first index is means the start index, the second index
2317
* means the end index. Contains a .size() method if the input iterable contains a .size() method, its iterator category is

include/Lz/detail/adaptors/exclusive_scan.hpp

-6
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,6 @@ namespace detail {
1313
struct exclusive_scan_adaptor {
1414
using adaptor = exclusive_scan_adaptor;
1515

16-
#ifdef LZ_HAS_CXX_11
17-
18-
static constexpr adaptor exclusive_scan{};
19-
20-
#endif
21-
2216
/**
2317
* @brief Performs an exclusive scan on a container. The first element will be the init value, the second element will be the
2418
* first element of the container + the init value, the third element will be the second element + last returned element

0 commit comments

Comments
 (0)