/usr/include/dlib/ref.h is in libdlib-dev 18.18-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | // Copyright (C) 2010 Davis E. King (davis@dlib.net)
// License: Boost Software License See LICENSE.txt for the full license.
#ifndef DLIB_REFERENCE_WRAPpER_H_
#define DLIB_REFERENCE_WRAPpER_H_
namespace dlib
{
// ----------------------------------------------------------------------------------------
template<
typename T
>
class reference_wrapper
{
/*!
WHAT THIS OBJECT REPRESENTS
This is a simple object that just holds a reference to another object.
It is useful because it can serve as a kind of "copyable reference".
!*/
public:
typedef T type;
explicit reference_wrapper(T& o) : obj(&o) {}
operator T&() const { return *obj; }
T& get() const { return *obj; }
private:
T* obj;
};
// ----------------------------------------------------------------------------------------
template <typename T>
reference_wrapper<T> ref(
T& obj
) { return reference_wrapper<T>(obj); }
/*!
ensures
- returns a reference_wrapper that contains a reference to obj.
!*/
// ----------------------------------------------------------------------------------------
template <typename T>
reference_wrapper<T> ref(
reference_wrapper<T> obj
) { return obj; }
/*!
ensures
- returns the given reference_wrapper object without modification
!*/
// ----------------------------------------------------------------------------------------
template <typename T>
reference_wrapper<const T> cref(
const T& obj
) { return reference_wrapper<const T>(obj); }
/*!
ensures
- returns a reference_wrapper that contains a constant reference to obj.
!*/
// ----------------------------------------------------------------------------------------
template <typename T>
reference_wrapper<const T> cref(
reference_wrapper<T> obj
) { return cref(obj.get()); }
/*!
ensures
- converts the given reference_wrapper into a reference_wrapper that contains a
constant reference.
!*/
// ----------------------------------------------------------------------------------------
}
#endif // DLIB_REFERENCE_WRAPpER_H_
|