VirtualBox

Changeset 48833 in vbox


Ignore:
Timestamp:
Oct 3, 2013 1:22:14 PM (11 years ago)
Author:
vboxsync
Message:

cpp/utils.h: Added RT_CPP_GETTER_UNCONST and RT_CPP_GETTER_UNCONST_RET for generating non-const getters from a const one. Avoid stupid code duplication.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/cpp/utils.h

    r37491 r48833  
    9797}
    9898
     99
     100/**
     101 * Macro for generating a non-const getter version from a const getter.
     102 *
     103 * @param   a_RetType       The getter return type.
     104 * @param   a_Class         The class name.
     105 * @param   a_Getter        The getter name.
     106 * @param   a_ArgDecls      The argument declaration for the getter method.
     107 * @param   a_ArgList       The argument list for the call.
     108 */
     109#define RT_CPP_GETTER_UNCONST(a_RetType, a_Class, a_Getter, a_ArgDecls, a_ArgList) \
     110    a_RetType a_Getter a_ArgDecls \
     111    {  \
     112        return static_cast< a_Class const *>(this)-> a_Getter a_ArgList; \
     113    }
     114
     115
     116/**
     117 * Macro for generating a non-const getter version from a const getter,
     118 * unconsting the return value as well.
     119 *
     120 * @param   a_RetType       The getter return type.
     121 * @param   a_Class         The class name.
     122 * @param   a_Getter        The getter name.
     123 * @param   a_ArgDecls      The argument declaration for the getter method.
     124 * @param   a_ArgList       The argument list for the call.
     125 */
     126#define RT_CPP_GETTER_UNCONST_RET(a_RetType, a_Class, a_Getter, a_ArgDecls, a_ArgList) \
     127    a_RetType a_Getter a_ArgDecls \
     128    {  \
     129        return const_cast<a_RetType>(static_cast< a_Class const *>(this)-> a_Getter a_ArgList); \
     130    }
     131
     132
    99133/** @} */
    100134
Note: See TracChangeset for help on using the changeset viewer.

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