VirtualBox

source: vbox/trunk/include/iprt/cpp/meta.h@ 36532

最後變更 在這個檔案從36532是 36532,由 vboxsync 提交於 14 年 前

IPRT-C++: iprt::list -> RTCList; iprt::mtlist -> RTCMTList

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 3.0 KB
 
1/** @file
2 * IPRT - C++ Meta programming.
3 */
4
5/*
6 * Copyright (C) 2011 Oracle Corporation
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.alldomusa.eu.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 (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 */
25
26#ifndef ___iprt_cpp_meta_h
27#define ___iprt_cpp_meta_h
28
29/** @defgroup grp_rt_cpp_meta C++ Meta programming utilities
30 * @ingroup grp_rt_cpp
31 * @{
32 */
33
34/**
35 * Check for a condition on compile time and dependent of the result TrueResult
36 * or FalseResult will be defined.
37 *
38 * @param Condition Condition to check.
39 * @param TrueResult Result when condition is true.
40 * @param FalseResult Result when condition is false
41 */
42template <bool Condition, typename TrueResult, typename FalseResult>
43struct RTCIf;
44
45/**
46 * True specialization of if_.
47 *
48 * @param TrueResult Result when condition is true.
49 * @param FalseResult Result when condition is false
50 */
51template <typename TrueResult, typename FalseResult>
52struct RTCIf<true, TrueResult, FalseResult>
53{
54 typedef TrueResult result;
55};
56
57/**
58 * False specialization of if_.
59 *
60 * @param TrueResult Result when condition is true.
61 * @param FalseResult Result when condition is false
62 */
63template <typename TrueResult, typename FalseResult>
64struct RTCIf<false, TrueResult, FalseResult>
65{
66 typedef FalseResult result;
67};
68
69/**
70 * Check if @a T is a pointer or not at compile time and dependent of the
71 * result TrueResult or FalseResult will be defined.
72 *
73 * False version of if_ptr.
74 *
75 * @param Condition Condition to check.
76 * @param TrueResult Result when condition is true.
77 * @param FalseResult Result when condition is false
78 */
79template <class T, typename TrueResult, typename FalseResult>
80struct RTCIfPtr
81{
82 typedef FalseResult result;
83};
84
85/**
86 * Check if @a T is a pointer or not at compile time and dependent of the
87 * result TrueResult or FalseResult will be defined.
88 *
89 * True specialization of of_ptr.
90 *
91 * @param Condition Condition to check.
92 * @param TrueResult Result when condition is true.
93 * @param FalseResult Result when condition is false
94 */
95template <class T, typename TrueResult, typename FalseResult>
96struct RTCIfPtr<T*, TrueResult, FalseResult>
97{
98 typedef TrueResult result;
99};
100
101/** @} */
102
103#endif /* !___iprt_cpp_meta_h */
104
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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