Another vocabulary type introduced in C++03 was std::reference_wrapper<T>. It has a simple implementation:
namespace std {
template<typename T>
class reference_wrapper {
T *m_ptr;
public:
reference_wrapper(T& t) noexcept : m_ptr(&t) {}
operator T& () const noexcept { return *m_ptr; }
T& get() const noexcept { return *m_ptr; }
};
template<typename T>
reference_wrapper<T> ref(T& t);
} // namespace std
std::reference_wrapper has a slightly different purpose from vocabulary types such as std::string and int; it's meant specifically as a way to the "tag" values that we'd like to behave as references in contexts where passing native C++ references doesn't work the way we'd like:
int result = 0...