1// Copyright (C) 2022 The Qt Company Ltd.
 
    2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
 
    5    \macro Q_DECLARE_TYPEINFO(Type, Flags)
 
    8    You can use this macro to specify information about a custom type
 
    9    \a Type. With accurate type information, Qt's \l{Container Classes}
 
   10    {generic containers} can choose appropriate storage methods and
 
   13    \a Flags can be one of the following:
 
   16    \li \c Q_PRIMITIVE_TYPE specifies that \a Type can be created by
 
   17        zero-initializing its storage, requires no operation to be properly
 
   18        destroyed, and for which memcpy()ing creates a valid independent
 
   20    \li \c Q_RELOCATABLE_TYPE specifies that \a Type has a constructor
 
   21       and/or a destructor but can be moved in memory using \c
 
   23    \li \c Q_MOVABLE_TYPE is the same as \c Q_RELOCATABLE_TYPE. Prefer to use
 
   24        \c Q_RELOCATABLE_TYPE in new code. Note: despite the name, this
 
   25        has nothing to do with move constructors or C++ move semantics.
 
   26    \li \c Q_COMPLEX_TYPE (the default) specifies that \a Type has
 
   27       constructors and/or a destructor and that it may not be moved
 
   31    Example of a "primitive" type:
 
   33    \snippet code/src_corelib_global_qglobal.cpp 38
 
   35    An example of a non-POD "primitive" type is QUuid: Even though
 
   36    QUuid has constructors (and therefore isn't POD), every bit
 
   37    pattern still represents a valid object, and memcpy() can be used
 
   38    to create a valid independent copy of a QUuid object.
 
   40    Example of a relocatable type:
 
   42    \snippet code/src_corelib_global_qglobal.cpp 39
 
   44    Qt will try to detect the class of a type using
 
   45    \l {https://en.cppreference.com/w/cpp/types/is_trivial} {std::is_trivial_v<T>}
 
   47    types and it will require both
 
   48    \l {https://en.cppreference.com/w/cpp/types/is_trivially_copyable} {std::is_trivially_copyable_v<T>}
 
   50    \l {https://en.cppreference.com/w/cpp/types/is_destructible} {std::is_trivially_destructible_v<T>}
 
   51    to identify relocatable types.
 
   52    Use this macro to tune the behavior.
 
   53    For instance many types would be candidates for Q_RELOCATABLE_TYPE despite
 
   54    not being trivially-copyable.