34 lines · c
1namespace std {2 3void __f() {}4 5template <class _Tp>6class reference_wrapper {7public:8 typedef _Tp type;9 10private:11 type *__f_;12 13public:14 reference_wrapper(type &__f)15 : __f_(&__f) {}16 // access17 operator type &() const { return *__f_; }18 type &get() const { return *__f_; }19};20 21template <class _Tp>22inline reference_wrapper<_Tp>23ref(_Tp &__t) noexcept {24 return reference_wrapper<_Tp>(__t);25}26 27template <class _Tp>28inline reference_wrapper<_Tp>29ref(reference_wrapper<_Tp> __t) noexcept {30 return ref(__t.get());31}32 33} // namespace std34