-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[proxy](6/n) self-vendor utility headers (#721)
- Loading branch information
1 parent
e874617
commit 0027f02
Showing
22 changed files
with
141 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#include <utility> | ||
|
||
namespace snmalloc | ||
{ | ||
namespace stl | ||
{ | ||
using std::declval; | ||
using std::forward; | ||
using std::move; | ||
template<class T1, class T2> | ||
using Pair = std::pair<T1, T2>; | ||
} // namespace stl | ||
} // namespace snmalloc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#pragma once | ||
|
||
#include "snmalloc/stl/type_traits.h" | ||
|
||
// This is used by clang to provide better analysis of lifetimes. | ||
#if __has_cpp_attribute(_Clang::__lifetimebound__) | ||
# define SNMALLOC_LIFETIMEBOUND [[_Clang::__lifetimebound__]] | ||
#else | ||
# define SNMALLOC_LIFETIMEBOUND | ||
#endif | ||
|
||
namespace snmalloc | ||
{ | ||
namespace stl | ||
{ | ||
template<class T> | ||
[[nodiscard]] inline constexpr T&& | ||
forward(remove_reference_t<T>& ref) noexcept | ||
{ | ||
return static_cast<T&&>(ref); | ||
} | ||
|
||
template<class T> | ||
[[nodiscard]] inline constexpr T&& | ||
forward(SNMALLOC_LIFETIMEBOUND remove_reference_t<T>&& ref) noexcept | ||
{ | ||
static_assert( | ||
!is_lvalue_reference_v<T>, "cannot forward an rvalue as an lvalue"); | ||
return static_cast<T&&>(ref); | ||
} | ||
|
||
template<class T> | ||
[[nodiscard]] inline constexpr remove_reference_t<T>&& | ||
move(SNMALLOC_LIFETIMEBOUND T&& ref) noexcept | ||
{ | ||
#ifdef __clang__ | ||
using U [[gnu::nodebug]] = remove_reference_t<T>; | ||
#else | ||
using U = remove_reference_t<T>; | ||
#endif | ||
return static_cast<U&&>(ref); | ||
} | ||
|
||
#pragma GCC diagnostic push | ||
#pragma GCC diagnostic ignored "-Wdeprecated" | ||
// First try instantiation with reference types, then fall back to value | ||
// types. Use int to prioritize reference types. | ||
template<class T> | ||
T&& declval_impl(int); | ||
template<class T> | ||
T declval_impl(long); | ||
#pragma GCC diagnostic pop | ||
|
||
template<class T> | ||
constexpr inline decltype(declval_impl<T>(0)) declval() noexcept | ||
{ | ||
static_assert( | ||
!is_same_v<T, T>, "declval cannot be used in an evaluation context"); | ||
} | ||
|
||
template<class T1, class T2> | ||
struct Pair | ||
{ | ||
T1 first; | ||
T2 second; | ||
}; | ||
} // namespace stl | ||
} // namespace snmalloc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#pragma once | ||
|
||
#include "snmalloc/stl/common.h" | ||
|
||
#if SNMALLOC_USE_SELF_VENDORED_STL | ||
# include "snmalloc/stl/gnu/utility.h" | ||
#else | ||
# include "snmalloc/stl/cxx/utility.h" | ||
#endif |