Skip to content

Commit

Permalink
πŸ›  Change from cf-hack to cf for messing with clang format line endings
Browse files Browse the repository at this point in the history
β€” πŸ”₯ Remove redundant type_traits header.
β€” ✨ single_value_iterator, but it should be changed to repeat_iterator and given a specific kind of sentinel to gow ith it
β€” ✨ Minor improvements for basic_text type (still needs to have actual methods on it)
  • Loading branch information
ThePhD committed Jul 3, 2022
1 parent bf20f1c commit ef92651
Show file tree
Hide file tree
Showing 58 changed files with 910 additions and 193 deletions.
6 changes: 3 additions & 3 deletions include/ztd/ranges/counted_iterator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,9 @@ namespace ztd { namespace ranges {
}

template <typename _RightIt,
::std::enable_if_t< // cf-hack
is_iterator_random_access_iterator_v<_RightIt> // cf-hack
&& is_iterator_random_access_iterator_v<_It> // cf-hack
::std::enable_if_t< // cf
is_iterator_random_access_iterator_v<_RightIt> // cf
&& is_iterator_random_access_iterator_v<_It> // cf
>* = nullptr>
friend constexpr iterator_difference_type_t<_RightIt> operator-(
const __counted_iterator& __left, const __counted_iterator<_RightIt>& __right) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,52 +1,73 @@
// =============================================================================
//
// ztd.text
// Copyright Β© 2022 JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC
// Contact: opensource@soasis.org
//
// Commercial License Usage
// Licensees holding valid commercial ztd.text licenses may use this file in
// accordance with the commercial license agreement provided with the
// Software or, alternatively, in accordance with the terms contained in
// a written agreement between you and Shepherd's Oasis, LLC.
// For licensing terms and conditions see your agreement. For
// further information contact opensource@soasis.org.
//
// Apache License Version 2 Usage
// Alternatively, this file may be used under the terms of Apache License
// Version 2.0 (the "License") for non-commercial use; you may not use this
// file except in compliance with the License. You may obtain a copy of the
// License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// ============================================================================ //

#pragma once

#ifndef ZTD_TEXT_TYPE_TRAITS_HPP
#define ZTD_TEXT_TYPE_TRAITS_HPP

#include <ztd/text/version.hpp>

#include <ztd/text/forward.hpp>

#include <ztd/idk/type_traits.hpp>
#include <ztd/idk/reference_wrapper.hpp>

#include <type_traits>

#include <ztd/prologue.hpp>

// clang-format off
// clang-format on

#include <ztd/epilogue.hpp>

#endif // ZTD_TEXT_TYPE_TRAITS_HPP
// =============================================================================
//
// ztd.text
// Copyright Β© 2022 JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC
// Contact: opensource@soasis.org
//
// Commercial License Usage
// Licensees holding valid commercial ztd.text licenses may use this file in
// accordance with the commercial license agreement provided with the
// Software or, alternatively, in accordance with the terms contained in
// a written agreement between you and Shepherd's Oasis, LLC.
// For licensing terms and conditions see your agreement. For
// further information contact opensource@soasis.org.
//
// Apache License Version 2 Usage
// Alternatively, this file may be used under the terms of Apache License
// Version 2.0 (the "License") for non-commercial use; you may not use this
// file except in compliance with the License. You may obtain a copy of the
// License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// ============================================================================ //

#pragma once

#ifndef ZTD_RANGES_FROM_RANGE_HPP
#define ZTD_RANGES_FROM_RANGE_HPP

#include <ztd/ranges/version.hpp>

#if ZTD_IS_ON(ZTD_STD_LIBRARY_FROM_RANGE_T)
#include <ranges>
#endif

#include <ztd/prologue.hpp>

namespace ztd { namespace ranges {
ZTD_RANGES_INLINE_ABI_NAMESPACE_OPEN_I_

#if ZTD_IS_OFF(ZTD_STD_LIBRARY_FROM_RANGE_T)
namespace __rng_detail {
struct __from_range_t { };
} // namespace __rng_detail
#endif


using from_range_t =
#if ZTD_IS_ON(ZTD_STD_LIBRARY_FROM_RANGE_T)
::std::from_range_t
#else
__rng_detail::__from_range_t
#endif
;

#if ZTD_IS_ON(ZTD_STD_LIBRARY_FROM_RANGE_T)
inline constexpr ::std::from_range_t& from_range = ::std::from_range;
#else
inline constexpr from_range_t from_range = {};
#endif

ZTD_RANGES_INLINE_ABI_NAMESPACE_CLOSE_I_
}} // namespace ztd::ranges

#include <ztd/epilogue.hpp>

#endif // ZTD_RANGES_FROM_RANGE_HPP
182 changes: 182 additions & 0 deletions include/ztd/ranges/single_value_iterator.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
// =============================================================================
//
// ztd.text
// Copyright Β© 2022 JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC
// Contact: opensource@soasis.org
//
// Commercial License Usage
// Licensees holding valid commercial ztd.text licenses may use this file in
// accordance with the commercial license agreement provided with the
// Software or, alternatively, in accordance with the terms contained in
// a written agreement between you and Shepherd's Oasis, LLC.
// For licensing terms and conditions see your agreement. For
// further information contact opensource@soasis.org.
//
// Apache License Version 2 Usage
// Alternatively, this file may be used under the terms of Apache License
// Version 2.0 (the "License") for non-commercial use; you may not use this
// file except in compliance with the License. You may obtain a copy of the
// License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// ============================================================================ //

#pragma once

#ifndef ZTD_RANGES_COUNTED_ITERATOR_HPP
#define ZTD_RANGES_COUNTED_ITERATOR_HPP

#include <ztd/ranges/version.hpp>

#include <ztd/ranges/unreachable_sentinel_t.hpp>
#include <ztd/ranges/iterator.hpp>

#include <ztd/idk/unwrap.hpp>
#include <ztd/idk/ebco.hpp>

#include <iterator>
#include <utility>
#include <limits>

#if ZTD_IS_ON(ZTD_STD_LIBRARY_RANGES)
#include <ranges>
#endif

#include <ztd/prologue.hpp>

namespace ztd { namespace ranges {
ZTD_RANGES_INLINE_ABI_NAMESPACE_OPEN_I_

using single_value_sentinel = unreachable_sentinel_t;

template <typename _Value>
class single_value_iterator : private ebco<_Value, 0> {
private:
using __base_value = ebco<_Value, 0>;

public:
using iterator_type = _It;
using value_type = _Value;
using reference = decltype(::ztd::unwrap(_Value));
using difference_type = ::std::ptrdiff_t;

constexpr single_value_iterator() = default;
constexpr single_value_iterator(const value_type& __value) noexcept(
::std::is_nothrow_copy_constructible_v<value_type>)
: __base_value(__value) {
}
constexpr single_value_iterator(value_type&& __value) noexcept(
::std::is_nothrow_move_constructible_v<value_type>)
: __base_value(__value) {
}
template <typename... _Args>
constexpr single_value_iterator(::std::in_place_t, _Args&&... __args) noexcept(
::std::is_nothrow_constructible_v<value_type, _Args...>)
: __base_value(::std::forward<_Args>(__args)...) {
}

constexpr single_value_iterator& operator=(const single_value_iterator&) = default;
constexpr single_value_iterator& operator=(single_value_iterator&&) = default;

constexpr const value_type& value() const& noexcept {
return this->__base_value::get_value();
}

constexpr value_type& value() & noexcept {
return this->__base_value::get_value();
}

constexpr value_type&& value() && noexcept {
return this->__base_value::get_value();
}

constexpr decltype(auto) operator*() noexcept {
return this->__base_value::get_value();
}

constexpr decltype(auto) operator*() const noexcept {
return this->__base_value::get_value();
}

constexpr single_value_iterator& operator++() noexcept {
return *this;
}

constexpr single_value_iterator operator++(int) noexcept {
return this->__base_value::get_value();
}

constexpr single_value_iterator& operator--() noexcept {
return *this;
}

constexpr single_value_iterator operator--(int) noexcept {
return *this;
}

constexpr single_value_iterator operator+(difference_type __diff) const {
return *this;
}

friend constexpr single_value_iterator operator+(difference_type __diff, const single_value_iterator& __it) {
return __it;
}

constexpr single_value_iterator& operator+=(difference_type __diff) {
return *this;
}

constexpr single_value_iterator operator-(difference_type __diff) const {
return *this;
}

friend constexpr difference_type operator-(
const single_value_iterator& __left, const single_value_iterator& __right) noexcet {
if (__left.value() == __right.value()) {
return 0;
}
else {
return (::std::numeric_limits<difference_type>::max)();
}
}

constexpr single_value_iterator& operator-=(difference_type __diff) {
return *this;
}

template <typename _ItTy = _It, ::std::enable_if_t<is_iterator_random_access_iterator_v<_ItTy>>* = nullptr>
constexpr decltype(auto) operator[](difference_type __index) const {
return this->_M_it[__index];
}

friend constexpr difference_type operator-(const single_value_iterator&, single_value_sentinel) noexcept {
return (::std::numeric_limits<difference_type>::min)();
}

friend constexpr difference_type operator-(
default_sentinel_t, const single_value_iterator& __right) noexcept {
return (::std::numeric_limits<difference_type>::max)();
}
};

//////
/// @brief "Yes, Sir!"
///
/// @remarks In honor of S. Canon
//////
template <typename _Value>
using yessirator = single_value_iterator<_Value>;

ZTD_RANGES_INLINE_ABI_NAMESPACE_CLOSE_I_
}} // namespace ztd::ranges

#include <ztd/epilogue.hpp>

#endif // ZTD_RANGES_COUNTED_ITERATOR_HPP
2 changes: 1 addition & 1 deletion include/ztd/text/any_encoding.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@
#include <ztd/text/count_as_encoded.hpp>
#include <ztd/text/count_as_decoded.hpp>
#include <ztd/text/text_tag.hpp>
#include <ztd/text/type_traits.hpp>
#include <ztd/text/detail/transcode_routines.hpp>

#include <ztd/idk/ebco.hpp>
#include <ztd/ranges/range.hpp>
#include <ztd/ranges/adl.hpp>
#include <ztd/idk/span.hpp>
#include <ztd/idk/type_traits.hpp>

#include <cstdint>
#include <cstddef>
Expand Down
2 changes: 1 addition & 1 deletion include/ztd/text/assert.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
// clang-format on

#define ZTD_TEXT_ASSERT(...) ZTD_TEXT_ASSERT_I_(__VA_ARGS__)
#define ZTD_TEXT_ASSERT_MESSAGE(...) ZTD_TEXT_ASSERT_MESSAGE_I_(__VA_ARGS__)
#define ZTD_TEXT_ASSERT_MESSAGE(_MESSAGE, ...) ZTD_TEXT_ASSERT_MESSAGE_I_(_MESSAGE, __VA_ARGS__)

#include <ztd/epilogue.hpp>

Expand Down
9 changes: 5 additions & 4 deletions include/ztd/text/basic_c_string_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@
#include <ztd/text/version.hpp>

#include <ztd/text/forward.hpp>
#include <ztd/text/type_traits.hpp>
#include <ztd/text/assert.hpp>
#include <ztd/text/char_traits.hpp>

#include <ztd/idk/ebco.hpp>
#include <ztd/idk/charN_t.hpp>
#include <ztd/idk/empty_string.hpp>
#include <ztd/idk/type_traits.hpp>
#include <ztd/ranges/reconstruct.hpp>

#include <string_view>
Expand Down Expand Up @@ -139,9 +140,9 @@ namespace ztd { namespace text {
}

template <typename _Arg,
::std::enable_if_t<
!::std::is_same_v<remove_cvref_t<_Arg>,
basic_c_string_view> && !::std::is_same_v<remove_cvref_t<_Arg>, const_pointer> && !::std::is_array_v<remove_cvref_t<_Arg>>>* = nullptr>
::std::enable_if_t<!::std::is_same_v<remove_cvref_t<_Arg>, basic_c_string_view> // cf
&& !::std::is_convertible_v<remove_cvref_t<_Arg>, const_pointer> && // cf
!::std::is_array_v<remove_cvref_t<_Arg>>>* = nullptr>
constexpr basic_c_string_view(_Arg&& __arg) noexcept : __base_t(::std::data(__arg), ::std::size(__arg)) {
ZTD_TEXT_ASSERT_MESSAGE_I_("c_string_view must be null-terminated!", this->_M_last_element_check());
}
Expand Down
2 changes: 1 addition & 1 deletion include/ztd/text/basic_iconv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@
#include <ztd/text/encode_result.hpp>
#include <ztd/text/no_encoding.hpp>
#include <ztd/text/encoding_error.hpp>
#include <ztd/text/type_traits.hpp>
#include <ztd/text/c_string_view.hpp>
#include <ztd/text/iconv_names.hpp>
#include <ztd/text/detail/iconv.hpp>
#include <ztd/text/detail/encoding_name.hpp>

#include <ztd/idk/span.hpp>
#include <ztd/idk/endian.hpp>
#include <ztd/idk/type_traits.hpp>
#include <ztd/ranges/reconstruct.hpp>
#include <ztd/ranges/adl.hpp>
#include <ztd/ranges/algorithm.hpp>
Expand Down

0 comments on commit ef92651

Please sign in to comment.