Bump version to 6.4-15
[LibreOffice.git] / include / svl / typedwhich.hxx
blobd3f2bedec67103bebf8bb7dc207baab1e461aa66
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
9 #ifndef INCLUDED_SVL_TYPEDWHICH_HXX
10 #define INCLUDED_SVL_TYPEDWHICH_HXX
12 #include <sal/config.h>
13 #include <sal/types.h>
15 /**
16 * A very thin wrapper around the sal_uInt16 WhichId whose purpose is mostly to carry type information,
17 * so that we Put() and Get() the right subclasses of SfxPoolItem for each WhichId.
19 template <class T> class TypedWhichId final
21 public:
22 explicit constexpr TypedWhichId(sal_uInt16 nWhich)
23 : mnWhich(nWhich)
26 constexpr operator sal_uInt16() const { return mnWhich; }
28 private:
29 sal_uInt16 const mnWhich;
32 template <class T> constexpr bool operator==(sal_uInt16 lhs, TypedWhichId<T> const& rhs)
34 return lhs == sal_uInt16(rhs);
36 template <class T> constexpr bool operator!=(sal_uInt16 lhs, TypedWhichId<T> const& rhs)
38 return lhs != sal_uInt16(rhs);
40 template <class T> constexpr bool operator==(TypedWhichId<T> const& lhs, sal_uInt16 rhs)
42 return sal_uInt16(lhs) == rhs;
44 template <class T> constexpr bool operator!=(TypedWhichId<T> const& lhs, sal_uInt16 rhs)
46 return sal_uInt16(lhs) != rhs;
49 #endif // INCLUDED_SVL_TYPEDWHICH_HXX
51 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */