paludis  Version 2.6.0
wrapped_value.hh
1 /* vim: set sw=4 sts=4 et foldmethod=syntax : */
2 
3 /*
4  * Copyright (c) 2010 Ciaran McCreesh
5  *
6  * This file is part of the Paludis package manager. Paludis is free software;
7  * you can redistribute it and/or modify it under the terms of the GNU General
8  * Public License version 2, as published by the Free Software Foundation.
9  *
10  * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
11  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13  * details.
14  *
15  * You should have received a copy of the GNU General Public License along with
16  * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
17  * Place, Suite 330, Boston, MA 02111-1307 USA
18  */
19 
20 #ifndef PALUDIS_GUARD_PALUDIS_UTIL_WRAPPED_VALUE_HH
21 #define PALUDIS_GUARD_PALUDIS_UTIL_WRAPPED_VALUE_HH 1
22 
23 #include <paludis/util/wrapped_value-fwd.hh>
24 #include <paludis/util/no_type.hh>
25 #include <paludis/util/operators.hh>
26 #include <memory>
27 
28 namespace paludis
29 {
30  template <typename T_>
31  struct WrappedValueDevoid
32  {
33  typedef T_ Type;
34  };
35 
36  template <>
37  struct WrappedValueDevoid<void>
38  {
39  typedef NoType<0u> * Type;
40  };
41 
42  template <typename Tag_>
43  class PALUDIS_VISIBLE WrappedValue :
45  {
46  private:
47  std::shared_ptr<const typename WrappedValueTraits<Tag_>::UnderlyingType> _value;
48 
49  public:
50  explicit WrappedValue(
52  const typename WrappedValueDevoid<typename WrappedValueTraits<Tag_>::ValidationParamsType>::Type & = static_cast<NoType<0u> *>(nullptr)
53  );
54 
55  WrappedValue & operator= (const WrappedValue &);
56  WrappedValue(const WrappedValue &);
57  ~WrappedValue();
58 
59  const typename WrappedValueTraits<Tag_>::UnderlyingType & value() const PALUDIS_ATTRIBUTE((warn_unused_result));
60 
61  bool operator< (const WrappedValue &) const PALUDIS_ATTRIBUTE((warn_unused_result));
62  bool operator== (const WrappedValue &) const PALUDIS_ATTRIBUTE((warn_unused_result));
63  };
64 }
65 
66 #endif
Definition: about_metadata-fwd.hh:23
Definition: wrapped_value-fwd.hh:35
Definition: wrapped_value-fwd.hh:32
Definition: no_type.hh:43
#define PALUDIS_ATTRIBUTE(x)
Definition: attributes.hh:53
#define PALUDIS_VISIBLE
Definition: attributes.hh:59
bool operator==(const PackageID &, const PackageID &) PALUDIS_ATTRIBUTE((warn_unused_result)) PALUDIS_VISIBLE