Skip to content

Commit 5262b89

Browse files
committed
Fix stubs
1. Removed body of `template <class F> function(F&& f)` to avoid type clashes. 2. Copied member declarations of std::allocator from `memory.h` to `string` to avoid undefined symbol issues.
1 parent 24b9f37 commit 5262b89

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

cpp/common/test/includes/standard-library/functional.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,8 @@ template <class> class function;
8989
template <class R, class... Args> class function<R(Args...)> {
9090
public:
9191
function();
92-
template <class F> function(F&& f) {
93-
auto fptr = new F(std::forward<F>(f));
94-
}
92+
template <class F> function(F&& f);
9593
template <class F> function &operator=(F &&);
9694
};
9795
} // namespace std
98-
#endif
96+
#endif

cpp/common/test/includes/standard-library/string

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,25 @@ template <> struct char_traits<wchar_t> {
8888
static int_type eof();
8989
};
9090

91-
template <class T> class allocator;
91+
template <typename T1> struct allocator {
92+
using value_type = T1;
93+
using size_type = std::size_t;
94+
using difference_type = std::ptrdiff_t;
95+
96+
constexpr allocator() noexcept = default;
97+
constexpr allocator(const allocator &) noexcept = default;
98+
99+
template <typename T2> constexpr allocator(const allocator<T2> &) noexcept;
100+
101+
~allocator() = default;
102+
103+
T1 *allocate(std::size_t);
104+
void deallocate(T1 *, std::size_t);
105+
};
106+
107+
template <> struct allocator<void> {
108+
using value_type = void;
109+
};
92110

93111
template <class charT, class traits = char_traits<charT>,
94112
class Allocator = allocator<charT>>
@@ -329,4 +347,4 @@ long double stold(const string &str, size_t *idx = 0);
329347
std::string to_string(int value);
330348
} // namespace std
331349

332-
#endif // _GHLIBCPP_STRING
350+
#endif // _GHLIBCPP_STRING

0 commit comments

Comments
 (0)