Skip to content

Commit

Permalink
Update vendor
Browse files Browse the repository at this point in the history
  • Loading branch information
tekezo committed Jul 5, 2023
1 parent 9af87cc commit 4890b30
Show file tree
Hide file tree
Showing 54 changed files with 726 additions and 394 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@
#ifndef TYPE_SAFE_ARITHMETIC_POLICY_HPP_INCLUDED
#define TYPE_SAFE_ARITHMETIC_POLICY_HPP_INCLUDED

#if defined(TYPE_SAFE_IMPORT_STD_MODULE)
import std;
#else
#include <limits>
#include <stdexcept>
#include <type_traits>
#endif

#include <type_safe/config.hpp>
#include <type_safe/detail/assert.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@
#ifndef TYPE_SAFE_BOOLEAN_HPP_INCLUDED
#define TYPE_SAFE_BOOLEAN_HPP_INCLUDED

#if defined(TYPE_SAFE_IMPORT_STD_MODULE)
import std;
#else
#include <functional>
#include <iosfwd>
#include <type_traits>
#include <utility>
#endif

#include <type_safe/detail/force_inline.hpp>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@
#ifndef TYPE_SAFE_BOUNDED_TYPE_HPP_INCLUDED
#define TYPE_SAFE_BOUNDED_TYPE_HPP_INCLUDED

#if defined(TYPE_SAFE_IMPORT_STD_MODULE)
import std;
#else
#include <limits>
#include <type_traits>
#endif

#include <type_safe/constrained_type.hpp>
#include <type_safe/detail/constant_parser.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@
#ifndef TYPE_SAFE_COMPACT_OPTIONAL_HPP_INCLUDED
#define TYPE_SAFE_COMPACT_OPTIONAL_HPP_INCLUDED

#if defined(TYPE_SAFE_IMPORT_STD_MODULE)
import std;
#else
#include <limits>
#include <type_traits>
#endif

#include <type_safe/optional.hpp>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@
#ifndef TYPE_SAFE_CONFIG_HPP_INCLUDED
#define TYPE_SAFE_CONFIG_HPP_INCLUDED

#if defined(TYPE_SAFE_IMPORT_STD_MODULE)
import std;
#else
#include <cstddef>
#include <cstdlib>
#endif

#ifndef TYPE_SAFE_ENABLE_ASSERTIONS
/// Controls whether internal assertions are enabled.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@
#ifndef TYPE_SAFE_CONSTRAINED_TYPE_HPP_INCLUDED
#define TYPE_SAFE_CONSTRAINED_TYPE_HPP_INCLUDED

#if defined(TYPE_SAFE_IMPORT_STD_MODULE)
import std;
#else
#include <iterator>
#include <stdexcept>
#include <type_traits>
#include <utility>
#endif

#include <type_safe/config.hpp>
#include <type_safe/detail/assert.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@
#ifndef TYPE_SAFE_DEFERRED_CONSTRUCTION_HPP_INCLUDED
#define TYPE_SAFE_DEFERRED_CONSTRUCTION_HPP_INCLUDED

#if defined(TYPE_SAFE_IMPORT_STD_MODULE)
import std;
#else
#include <new>
#include <type_traits>
#include <utility>
#endif

#include <type_safe/detail/assert.hpp>

Expand Down Expand Up @@ -166,8 +170,7 @@ class deferred_construction
return static_cast<const void*>(&storage_);
}

using storage_t = typename std::aligned_storage<sizeof(T), alignof(T)>::type;
storage_t storage_;
alignas(T) unsigned char storage_[sizeof(T)];
bool initialized_;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
#ifndef TYPE_SAFE_DETAIL_ALIGNED_UNION_HPP_INCLUDED
#define TYPE_SAFE_DETAIL_ALIGNED_UNION_HPP_INCLUDED

#include <type_traits>
#if defined(TYPE_SAFE_IMPORT_STD_MODULE)
import std;
#else
# include <cstddef>
# include <type_traits>
#endif

namespace type_safe
{
Expand All @@ -30,18 +35,25 @@ namespace detail
return max(t, max(ts...));
}

// std::aligned_union not available on all compilers
template <typename... Types>
struct aligned_union
class aligned_union
{
public:
static constexpr auto size_value = detail::max(sizeof(Types)...);
static constexpr auto alignment_value = detail::max(alignof(Types)...);

using type = typename std::aligned_storage<size_value, alignment_value>::type;
void* get() noexcept
{
return &storage_;
}
const void* get() const noexcept
{
return &storage_;
}

private:
alignas(alignment_value) unsigned char storage_[size_value];
};

template <typename... Types>
using aligned_union_t = typename aligned_union<Types...>::type;
} // namespace detail
} // namespace type_safe

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
#ifndef TYPE_SAFE_DETAIL_ALL_OF_HPP_INCLUDED
#define TYPE_SAFE_DETAIL_ALL_OF_HPP_INCLUDED

#if defined(TYPE_SAFE_IMPORT_STD_MODULE)
import std;
#else
#include <type_traits>
#endif

namespace type_safe
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
#ifndef TYPE_SAFE_DETAIL_ASSIGN_OR_CONSTRUCT_HPP_INCLUDED
#define TYPE_SAFE_DETAIL_ASSIGN_OR_CONSTRUCT_HPP_INCLUDED

#if defined(TYPE_SAFE_IMPORT_STD_MODULE)
import std;
#else
#include <type_traits>
#endif

namespace type_safe
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
#ifndef TYPE_SAFE_DETAIL_CONSTANT_PARSER_HPP_INCLUDED
#define TYPE_SAFE_DETAIL_CONSTANT_PARSER_HPP_INCLUDED

#if defined(TYPE_SAFE_IMPORT_STD_MODULE)
import std;
#else
#include <type_traits>
#endif

namespace type_safe
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
#ifndef TYPE_SAFE_DETAIL_IS_NOTHROW_SWAPABLE_HPP_INCLUDED
#define TYPE_SAFE_DETAIL_IS_NOTHROW_SWAPABLE_HPP_INCLUDED

#if defined(TYPE_SAFE_IMPORT_STD_MODULE)
import std;
#else
#include <utility>
#endif

namespace type_safe
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
#ifndef TYPE_SAFE_DETAIL_MAP_INVOKE_HPP_INCLUDED
#define TYPE_SAFE_DETAIL_MAP_INVOKE_HPP_INCLUDED

#if defined(TYPE_SAFE_IMPORT_STD_MODULE)
import std;
#else
#include <utility>
#endif

namespace type_safe
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
#ifndef TYPE_SAFE_DOWNCAST_HPP_INCLUDED
#define TYPE_SAFE_DOWNCAST_HPP_INCLUDED

#if defined(TYPE_SAFE_IMPORT_STD_MODULE)
import std;
#else
#include <type_traits>
#endif

#include <type_safe/config.hpp>
#include <type_safe/detail/assert.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@
#ifndef TYPE_SAFE_FLAG_SET_HPP_INCLUDED
#define TYPE_SAFE_FLAG_SET_HPP_INCLUDED

#if defined(TYPE_SAFE_IMPORT_STD_MODULE)
import std;
#else
#include <climits>
#include <cstdint>
#include <type_traits>
#endif

#include <type_safe/flag.hpp>
#include <type_safe/types.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@
#ifndef TYPE_SAFE_FLOATING_POINT_HPP_INCLUDED
#define TYPE_SAFE_FLOATING_POINT_HPP_INCLUDED

#if defined(TYPE_SAFE_IMPORT_STD_MODULE)
import std;
#else
#include <functional>
#include <iosfwd>
#include <type_traits>
#endif

#include <type_safe/detail/force_inline.hpp>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
#ifndef TYPE_SAFE_INDEX_HPP_INCLUDED
#define TYPE_SAFE_INDEX_HPP_INCLUDED

#if defined(TYPE_SAFE_IMPORT_STD_MODULE)
import std;
#else
#include <cstddef>
#endif

#include <type_safe/config.hpp>
#include <type_safe/strong_typedef.hpp>
Expand Down
Loading

0 comments on commit 4890b30

Please sign in to comment.