================
@@ -1,44 +1,40 @@
#ifndef
LLVM_CLANG_TOOLS_EXTRA_TEST_CLANG_TIDY_CHECKERS_INPUTS_BDE_TYPES_OPTIONAL_H_
#define
LLVM_CLANG_TOOLS_EXTRA_TEST_CLANG_TIDY_CHECKERS_INPUTS_BDE_TYPES_OPTIONAL_H_
-/// Mock of `bsl::optional`.
+#include "../../std/types/optional.h"
+
namespace bsl {
+ class string {};
+}
-// clang-format off
-template <typename T> struct remove_reference { using type = T; };
-template <typename T> struct remove_reference<T&> { using type = T; };
-template <typename T> struct remove_reference<T&&> { using type = T; };
-// clang-format on
+/// Mock of `BloombergLP::bslstl::Optional_Base`
+namespace BloombergLP::bslstl {
-template <typename T>
-using remove_reference_t = typename remove_reference<T>::type;
+template <class T>
+constexpr bool isAllocatorAware() {
+ return false;
+}
-template <typename T>
-constexpr T &&forward(remove_reference_t<T> &t) noexcept;
+template <>
+constexpr bool isAllocatorAware<bsl::string>() {
+ return true;
+}
-template <typename T>
-constexpr T &&forward(remove_reference_t<T> &&t) noexcept;
+// Note: real `Optional_Base` uses `BloombergLP::bslma::UsesBslmaAllocator`
+// to check if type is alocator-aware.
+// This is simplified mock to illustrate similar behaviour.
+template <class T, bool AA = isAllocatorAware<T>()>
+class Optional_Base {
-template <typename T>
-constexpr remove_reference_t<T> &&move(T &&x);
-
-struct nullopt_t {
- constexpr explicit nullopt_t() {}
};
-constexpr nullopt_t nullopt;
+template <class T>
+class Optional_Base<T, false> : public std::optional<T> {
+};
-template <typename T>
-class optional {
+template <class T>
+class Optional_Base<T, true> {
----------------
BaLiKfromUA wrote:
this mock might be merged to `template <class T, bool AA =
isAllocatorAware<T>()> class Optional_Base`
https://github.com/llvm/llvm-project/pull/168863
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits