diff --git a/single_include/flux.hpp b/single_include/flux.hpp index 58eea88d..0179cea1 100644 --- a/single_include/flux.hpp +++ b/single_include/flux.hpp @@ -23,6 +23,30 @@ #define FLUX_CORE_CONCEPTS_HPP_INCLUDED +// Copyright (c) 2023 Tristan Brindle (tcbrindle at gmail dot com) +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef FLUX_CORE_UTILS_HPP_INCLUDED +#define FLUX_CORE_UTILS_HPP_INCLUDED + + +// Copyright (c) 2023 Tristan Brindle (tcbrindle at gmail dot com) +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef FLUX_CORE_ASSERT_HPP_INCLUDED +#define FLUX_CORE_ASSERT_HPP_INCLUDED + + +// Copyright (c) 2023 Tristan Brindle (tcbrindle at gmail dot com) +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef FLUX_CORE_CONFIG_HPP_INCLUDED +#define FLUX_CORE_CONFIG_HPP_INCLUDED + + // Copyright (c) 2022 Tristan Brindle (tcbrindle at gmail dot com) // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -51,6 +75,10 @@ ::flux::inc(_flux_seq_, _flux_cur_)) \ if (_flux_var_decl_ = ::flux::read_at(_flux_seq_, _flux_cur_); true) +#define FLUX_ASSERT(cond) (::flux::assert_(cond, "assertion '" #cond "' failed")) + +#define FLUX_DEBUG_ASSERT(cond) (::flux::assert_(!::flux::config::enable_debug_asserts || (cond), "assertion '" #cond "' failed")); + #ifdef FLUX_MODULE_INTERFACE #define FLUX_EXPORT export #else @@ -60,31 +88,6 @@ #endif // FLUX_CORE_MACROS_HPP_INCLUDED -// Copyright (c) 2023 Tristan Brindle (tcbrindle at gmail dot com) -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#ifndef FLUX_CORE_UTILS_HPP_INCLUDED -#define FLUX_CORE_UTILS_HPP_INCLUDED - - -// Copyright (c) 2023 Tristan Brindle (tcbrindle at gmail dot com) -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#ifndef FLUX_CORE_ASSERT_HPP_INCLUDED -#define FLUX_CORE_ASSERT_HPP_INCLUDED - - -// Copyright (c) 2023 Tristan Brindle (tcbrindle at gmail dot com) -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#ifndef FLUX_CORE_CONFIG_HPP_INCLUDED -#define FLUX_CORE_CONFIG_HPP_INCLUDED - - - #include #include #include @@ -242,8 +245,8 @@ namespace detail { struct runtime_error_fn { [[noreturn]] - inline void operator()(char const* msg, - std::source_location loc = std::source_location::current()) const + void operator()(char const* msg, + std::source_location loc = std::source_location::current()) const { if constexpr (config::on_error == error_policy::unwind) { char buf[1024]; @@ -317,10 +320,6 @@ FLUX_EXPORT inline constexpr auto assert_ = detail::assert_fn{}; FLUX_EXPORT inline constexpr auto bounds_check = detail::bounds_check_fn{}; FLUX_EXPORT inline constexpr auto indexed_bounds_check = detail::indexed_bounds_check_fn{}; -#define FLUX_ASSERT(cond) (::flux::assert_(cond, "assertion '" #cond "' failed")) - -#define FLUX_DEBUG_ASSERT(cond) (::flux::assert_(!::flux::config::enable_debug_asserts || (cond), "assertion '" #cond "' failed")); - } // namespace flux #endif // FLUX_CORE_ASSERT_HPP_INCLUDED @@ -927,6 +926,7 @@ concept adaptable_sequence = detail::trivially_copyable_sequence>)) && !detail::is_ilist; +FLUX_EXPORT template struct inline_sequence_base; @@ -2245,18 +2245,21 @@ FLUX_EXPORT inline constexpr auto either = [](auto&& p, auto&& or_) { namespace detail { +FLUX_EXPORT template constexpr auto operator!(detail::predicate

pred) { return not_(std::move(pred)); } +FLUX_EXPORT template constexpr auto operator&&(detail::predicate lhs, detail::predicate rhs) { return both(std::move(lhs), std::move(rhs)); } +FLUX_EXPORT template constexpr auto operator||(detail::predicate lhs, detail::predicate rhs) { @@ -2916,7 +2919,6 @@ struct inline_sequence_base { - // Copyright (c) 2022 Tristan Brindle (tcbrindle at gmail dot com) // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -11780,11 +11782,12 @@ constexpr auto inline_sequence_base::output_to(Iter iter) -> Iter namespace flux { +FLUX_EXPORT struct from_sequence_t { explicit from_sequence_t() = default; }; -inline constexpr auto from_sequence = from_sequence_t{}; +FLUX_EXPORT inline constexpr auto from_sequence = from_sequence_t{}; namespace detail { @@ -12273,6 +12276,80 @@ FLUX_EXPORT inline constexpr auto make_array_ptr_unchecked = #endif +// Copyright (c) 2022 Tristan Brindle (tcbrindle at gmail dot com) +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef FLUX_SOURCE_BITSET_HPP_INCLUDED +#define FLUX_SOURCE_BITSET_HPP_INCLUDED + + + +#include + +namespace flux { + +template +struct sequence_traits> { + + using value_type = bool; + + using self_t = std::bitset; + + static constexpr auto first(self_t const&) -> std::size_t { return 0; } + + static constexpr auto is_last(self_t const&, std::size_t idx) { return idx == N; } + + static constexpr auto read_at(self_t& self, std::size_t idx) + -> typename std::bitset::reference + { + return self[idx]; + } + + static constexpr auto read_at(self_t const& self, std::size_t idx) -> bool + { + return self[idx]; + } + + static constexpr auto move_at(self_t const& self, std::size_t idx) -> bool + { + return self[idx]; + } + + static constexpr auto inc(self_t const&, std::size_t& idx) -> std::size_t& + { + return ++idx; + } + + static constexpr auto dec(self_t const&, std::size_t& idx) -> std::size_t& + { + return --idx; + } + + static constexpr auto inc(self_t const&, std::size_t& idx, std::ptrdiff_t off) + -> std::size_t& + { + return idx += static_cast(off); + } + + static constexpr auto distance(self_t const&, std::size_t from, std::size_t to) + -> std::ptrdiff_t + { + return static_cast(to) - static_cast(from); + } + + static constexpr auto last(self_t const&) -> std::size_t { return N; } + + static constexpr auto size(self_t const&) -> std::ptrdiff_t { return N; } + +}; + + +} // namespace flux + +#endif + + // Copyright (c) 2022 Tristan Brindle (tcbrindle at gmail dot com) // Distributed under the Boost Software License, Version 1.0. (See accompanying