~ubuntu-branches/debian/sid/gsmartcontrol/sid

« back to all changes in this revision

Viewing changes to src/hz/down_cast.h

  • Committer: Package Import Robot
  • Author(s): Giuseppe Iuculano
  • Date: 2013-05-31 11:41:52 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20130531114152-5ljhkuswwpt4kdwo
Tags: 0.8.7-1
* [314881d] Updated debian/watch
* [18ebada] Imported Upstream version 0.8.7
* [c2a1f1b] debian/rules: Provide build-arch and build-indep
* [d3036a4] Enabled Hardening Options
* [2edfb87] Refreshed patches and removed patches apllied upstream
* [ac3b953] Bump to standard versions 3.9.4
* [292c276] Remove quilt from depends

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/**************************************************************************
2
2
 Copyright:
3
 
      (C) 2003 - 2011  Alexander Shaduri <ashaduri 'at' gmail.com>
 
3
      (C) 2003 - 2012  Alexander Shaduri <ashaduri 'at' gmail.com>
4
4
 License: See LICENSE_zlib.txt file
5
5
***************************************************************************/
 
6
/// \file
 
7
/// \author Alexander Shaduri
 
8
/// \ingroup hz
 
9
/// \weakgroup hz
 
10
/// @{
6
11
 
7
12
#ifndef HZ_DOWN_CAST_H
8
13
#define HZ_DOWN_CAST_H
18
23
namespace hz {
19
24
 
20
25
 
21
 
// Perform a down cast.
22
 
 
23
 
// This cast works with polymorphic and non-polymorphic types.
24
 
// If RTTI is disabled, it will revert to static_cast; otherwise,
25
 
// dynamic_cast is used for polymorphic types and static_cast
26
 
// for non-polymorphic types.
27
 
 
28
 
// Use with pointers only!
 
26
/// Perform a down cast (pointers only!).
 
27
/// This cast works with polymorphic and non-polymorphic types.
 
28
/// If RTTI is disabled, it will revert to static_cast; otherwise,
 
29
/// dynamic_cast is used for polymorphic types and static_cast
 
30
/// for non-polymorphic types.
 
31
template<typename Target, typename Source> inline
 
32
Target down_cast(const Source& arg);
29
33
 
30
34
 
31
35
 
48
52
 
49
53
namespace internal {
50
54
 
 
55
        /// Helper for down_cast, uses dynamic_cast unless the types are non-polymorphic,
 
56
        /// in which case static_cast is used.
51
57
        template<typename Target, typename Source,
52
58
                        bool Polymorphic = type_is_polymorphic<typename type_remove_pointer<Target>::type>::value
53
59
                                        && type_is_polymorphic<typename type_remove_pointer<Source>::type>::value >
60
66
        };
61
67
 
62
68
 
63
 
        // non-polymorphic specialization
 
69
        /// Non-polymorphic specialization
64
70
        template<typename Target, typename Source>
65
71
        struct down_cast_helper<Target, Source, false>
66
72
        {
95
101
 
96
102
 
97
103
#endif
 
104
 
 
105
/// @}