VirtualBox

source: vbox/trunk/include/iprt/cpputils.h@ 5599

Last change on this file since 5599 was 4071, checked in by vboxsync, 17 years ago

Biggest check-in ever. New source code headers for all (C) innotek files.

  • Property svn:eol-style set to native
File size: 1.7 KB
Line 
1/** @file
2 * innotek Portable Runtime - C++ Utilities (useful templates, defines and such).
3 */
4
5/*
6 * Copyright (C) 2006-2007 innotek GmbH
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License as published by the Free Software Foundation,
12 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
13 * distribution. VirtualBox OSE is distributed in the hope that it will
14 * be useful, but WITHOUT ANY WARRANTY of any kind.
15 */
16
17#ifndef ___iprt_cpputils_h
18#define ___iprt_cpputils_h
19
20/** @defgroup grp_rt_cpputils C++ Utilities
21 * @ingroup grp_rt
22 * @{
23 */
24
25/**
26 * Shortcut to |const_cast<C &>()| that automatically derives the correct
27 * type (class) for the const_cast template's argument from its own argument.
28 * Can be used to temporarily cancel the |const| modifier on the left-hand side
29 * of assignment expressions, like this:
30 * @code
31 * const Class that;
32 * ...
33 * unconst (that) = some_value;
34 * @endcode
35 */
36template <class C>
37inline C &unconst (const C &that) { return const_cast <C &> (that); }
38
39
40/**
41 * Shortcut to |const_cast<C *>()| that automatically derives the correct
42 * type (class) for the const_cast template's argument from its own argument.
43 * Can be used to temporarily cancel the |const| modifier on the left-hand side
44 * of assignment expressions, like this:
45 * @code
46 * const Class *that;
47 * ...
48 * unconst (that) = some_value;
49 * @endcode
50 */
51template <class C>
52inline C *unconst (const C *that) { return const_cast <C *> (that); }
53
54/** @} */
55
56#endif
57
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette