Mock class template
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
#include <initializer_list> | |
namespace mock { | |
template <class T> | |
struct allocator {}; | |
template <class T> | |
struct char_traits {}; | |
// C++20 https://timsong-cpp.github.io/cppwp/n4861/basic.string | |
template<class charT, class traits = char_traits<charT>, | |
class Allocator = allocator<charT>> | |
struct basic_string { | |
using size_type = std::size_t; | |
constexpr basic_string() noexcept(noexcept(Allocator())) : basic_string(Allocator()) {} | |
constexpr explicit basic_string(const Allocator&) noexcept {} | |
constexpr basic_string(const basic_string&) {} | |
constexpr basic_string(basic_string&&) noexcept {} | |
constexpr basic_string(const basic_string&, size_type, const Allocator& = Allocator()) {} | |
constexpr basic_string(const basic_string&, size_type, size_type, const Allocator& = Allocator()) {} | |
template<class T> | |
constexpr basic_string(const T&, size_type, size_type, const Allocator& = Allocator()) {} | |
template<class T> | |
constexpr explicit basic_string(const T&, const Allocator& = Allocator()) {} | |
constexpr basic_string(const charT*, size_type, const Allocator& = Allocator()) {} | |
constexpr basic_string(const charT*, const Allocator& = Allocator()) {} | |
constexpr basic_string(size_type, charT, const Allocator& = Allocator()) {} | |
template<class InputIterator> | |
constexpr basic_string(InputIterator, InputIterator, const Allocator& = Allocator()); | |
constexpr basic_string(std::initializer_list<charT>, const Allocator& = Allocator()) {} | |
constexpr basic_string(const basic_string&, const Allocator&) {} | |
constexpr basic_string(basic_string&&, const Allocator&) {} | |
#if __cplusplus > 202002L | |
// C++2b https://wg21.link/p2166r1 | |
basic_string(std::nullptr_t) = delete; | |
#endif | |
}; | |
// basic_string typedef names | |
using string = basic_string<char>; | |
using u8string = basic_string<char8_t>; | |
using u16string = basic_string<char16_t>; | |
using u32string = basic_string<char32_t>; | |
using wstring = basic_string<wchar_t>; | |
} |
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
#include <initializer_list> | |
namespace mock { | |
template <class T> | |
struct allocator {}; | |
#if 1 | |
// C++20 https://timsong-cpp.github.io/cppwp/n4861/vector | |
template <class T, class Allocator = allocator<T>> | |
struct vector { | |
using size_type = std::size_t; | |
constexpr vector() noexcept(noexcept(Allocator())) : vector(Allocator()) {} | |
constexpr explicit vector(const Allocator&) noexcept {} | |
constexpr explicit vector(size_type, const Allocator& = Allocator()) {} | |
constexpr vector(size_type, const T&, const Allocator& = Allocator()) {} | |
template<class InputIterator> | |
constexpr vector(InputIterator, InputIterator, const Allocator& = Allocator()) {} | |
constexpr vector(const vector&) {} | |
constexpr vector(vector&&) noexcept {} | |
constexpr vector(const vector&, const Allocator&) {} | |
constexpr vector(vector&&, const Allocator&) {} | |
constexpr vector(std::initializer_list<T>, const Allocator& = Allocator()); | |
}; | |
#else | |
// no allocator support | |
template <class T> | |
struct vector { | |
using size_type = std::size_t; | |
constexpr vector() {} | |
constexpr explicit vector(size_type) {} | |
constexpr vector(size_type, const T&) {} | |
template<class InputIterator> | |
constexpr vector(InputIterator, InputIterator) {} | |
constexpr vector(const vector& x) {} | |
constexpr vector(vector&&) noexcept {} | |
constexpr vector(std::initializer_list<T>) {} | |
}; | |
#endif | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment