Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: proposal for std::forward #51

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/type_traits
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,9 @@ namespace std{
typedef __true_type value;
};



template<typename T> struct remove_reference { typedef T type; };
template<typename T> struct remove_reference<T&> { typedef T type; };
template<typename T> struct remove_reference<T&&> { typedef T type; };
}

#pragma GCC visibility pop
Expand Down
12 changes: 11 additions & 1 deletion src/utility
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ namespace std{
pair(const T1& x, const T2& y) : first(x), second(y) { }
template<class U, class V> pair(const pair<U, V> &p) : first(p.first), second(p.second) { }
};

template <class T1, class T2> bool operator==(const pair<T1,T2>& x, const pair<T1,T2>& y){
using namespace rel_ops;
return (x.first == y.first && x.second==y.second);
Expand All @@ -79,8 +79,18 @@ namespace std{
template <class T1, class T2> pair<T1,T2> make_pair(const T1& x, const T2& y){
return pair<T1,T2>(x, y);
}
}

#include <type_traits>

namespace std {
template <class T> constexpr T&& forward(typename std::remove_reference<T>::type& t) noexcept{
return static_cast<T&&>(t);
}
template <class T> constexpr T&& forward(typename std::remove_reference<T>::type&& t) noexcept{
//static_assert(!std::is_lvalue_reference<T>::value, "Can not forward an rvalue as an lvalue.");
return static_cast<T&&>(t);
}
}

#pragma GCC visibility pop
Expand Down