.. _page_type_traits: Type_traits =========== The **type_traits** header file contains metaprogramming tools for compile-time type introspection. The header provides a set of templates that can be used to query properties of types. * **has_push_back** .. doxygengroup:: has_push_back_struct :project: libutils :content-only: * **has_insert** .. doxygengroup:: has_insert_struct :project: libutils :content-only: * **remove_cvref** .. doxygengroup:: remove_cvref_alias :project: libutils :content-only: * **invoke_or_return** .. doxygengroup:: invoke_or_return :project: libutils :content-only: Usage ----- The following examples demonstrates how to use the **type_traits** header file: - ``has_push_back`` .. code-block:: cpp std::cout << std::boolalpha << "utils::has_push_back_v: " << utils::has_push_back_v << '\n' << "utils::has_push_back_v>: " << utils::has_push_back_v> << std::endl; Output: .. code-block:: none utils::has_push_back_v: false utils::has_push_back_v>: true - ``has_insert`` .. code-block:: cpp std::cout << std::boolalpha << "utils::has_insert_v: " << utils::has_insert_v << '\n' << "utils::has_insert_v>: " << utils::has_insert_v> << std::endl; Output: .. code-block:: none utils::has_insert_v: false utils::has_insert_v>: true - ``remove_cvref`` .. code-block:: cpp std::cout << std::boolalpha << "std::is_same_v, int>: " << std::is_same_v, int> << '\n' << "std::is_same_v, int>: " << std::is_same_v, int> << std::endl; Output: .. code-block:: none std::is_same_v, int>: true std::is_same_v, int>: true - ``invoke_or_return`` .. code-block:: cpp int some_function(SomeLargeObject& a, Funcs&&... funcs) { // If no funcs are provided, return the reference to the object itself // Otherwise, create a copy of object and apply the functions on it and return the result further_processing(a, utils::invoke_or_return(std::forward(funcs), a)); }