1.1 --- a/src/lemon/utility.h Sat May 14 17:29:28 2005 +0000
1.2 +++ b/src/lemon/utility.h Sat May 14 17:32:11 2005 +0000
1.3 @@ -107,6 +107,47 @@
1.4 template <class Cond, class T>
1.5 struct lazy_disable_if : public lazy_disable_if_c<Cond::value, T> {};
1.6
1.7 + // smart referencing
1.8 +
1.9 + template <typename _Type, typename Enable = void>
1.10 + struct SmartReference {
1.11 + typedef _Type& Type;
1.12 + };
1.13 +
1.14 + template <typename _Type>
1.15 + struct SmartReference<
1.16 + _Type,
1.17 + typename enable_if<typename _Type::NeedCopy, void>::type
1.18 + > {
1.19 + typedef _Type Type;
1.20 + };
1.21 +
1.22 + template <typename _Type, typename Enable = void>
1.23 + struct SmartConstReference {
1.24 + typedef const _Type& Type;
1.25 + };
1.26 +
1.27 + template <typename _Type>
1.28 + struct SmartConstReference<
1.29 + _Type,
1.30 + typename enable_if<typename _Type::NeedCopy, void>::type
1.31 + > {
1.32 + typedef const _Type Type;
1.33 + };
1.34 +
1.35 + template <typename _Type, typename Enable = void>
1.36 + struct SmartParameter {
1.37 + typedef _Type& Type;
1.38 + };
1.39 +
1.40 + template <typename _Type>
1.41 + struct SmartParameter<
1.42 + _Type,
1.43 + typename enable_if<typename _Type::NeedCopy, void>::type
1.44 + > {
1.45 + typedef const _Type& Type;
1.46 + };
1.47 +
1.48 } // namespace lemon
1.49
1.50 #endif