提交 71917ae5 创建 作者: Austin Clements's avatar Austin Clements

Move standard stuff to utility and type_traits

So I can stop hunting for things like this. I also planned to use these in user space (cpputil.hh isn't user space friendly), though didn't wind up doing that.
上级 b5cdc429
#pragma once #pragma once
template<class A, class B> #include <type_traits>
class pair { #include <utility>
public:
typedef A first_type;
typedef B second_type;
A first;
B second;
pair(const pair&) = default;
pair(pair&&) = default;
constexpr pair() : first(), second() {}
pair(const A &a, const B &b) : first(a), second(b) {}
bool operator==(const pair<A, B> &other) { using std::pair;
return first == other.first && second == other.second; using std::make_pair;
}
};
template<int N> template<int N>
class strbuf { class strbuf {
...@@ -33,13 +20,6 @@ class strbuf { ...@@ -33,13 +20,6 @@ class strbuf {
} }
}; };
template<class A, class B>
pair<A, B>
make_pair(const A &a, const B &b)
{
return pair<A, B>(a, b);
}
class scoped_acquire { class scoped_acquire {
private: private:
spinlock *_l; spinlock *_l;
...@@ -54,25 +34,6 @@ class scoped_acquire { ...@@ -54,25 +34,6 @@ class scoped_acquire {
class retryable {}; class retryable {};
namespace std { namespace std {
template<class T>
struct remove_reference
{ typedef T type; };
template<class T>
struct remove_reference<T&>
{ typedef T type; };
template<class T>
struct remove_reference<T&&>
{ typedef T type; };
template<class T>
typename remove_reference<T>::type&&
move(T&& a)
{
return static_cast<typename remove_reference<T>::type&&>(a);
}
struct ostream { int next_width; }; struct ostream { int next_width; };
extern ostream cout; extern ostream cout;
......
// -*- c++ -*-
#pragma once
namespace std {
template<class T>
struct remove_reference
{ typedef T type; };
template<class T>
struct remove_reference<T&>
{ typedef T type; };
template<class T>
struct remove_reference<T&&>
{ typedef T type; };
}
// -*- c++ -*-
#pragma once
#include <type_traits>
namespace std {
template<class T>
typename remove_reference<T>::type&&
move(T&& a)
{
return static_cast<typename remove_reference<T>::type&&>(a);
}
template<class A, class B>
struct pair {
typedef A first_type;
typedef B second_type;
A first;
B second;
pair(const pair&) = default;
pair(pair&&) = default;
constexpr pair() : first(), second() {}
pair(const A &a, const B &b) : first(a), second(b) {}
bool operator==(const pair<A, B> &other) {
return first == other.first && second == other.second;
}
};
template<class A, class B>
pair<A, B>
make_pair(const A &a, const B &b)
{
return pair<A, B>(a, b);
}
}
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论