Add ptr to docs

This commit is contained in:
Victor Zverovich
2020-08-21 06:54:05 -07:00
parent 1651b2d433
commit a0dcfbc57b
2 changed files with 13 additions and 3 deletions

View File

@@ -304,6 +304,10 @@ Utilities
.. doxygentypedef:: fmt::char_t .. doxygentypedef:: fmt::char_t
.. doxygenfunction:: fmt::ptr(const T *)
.. doxygenfunction:: fmt::ptr(const std::unique_ptr<T>&)
.. doxygenfunction:: fmt::ptr(const std::shared_ptr<T>&)
.. doxygenfunction:: fmt::to_string(const T&) .. doxygenfunction:: fmt::to_string(const T&)
.. doxygenfunction:: fmt::to_wstring(const T&) .. doxygenfunction:: fmt::to_wstring(const T&)

View File

@@ -3347,9 +3347,15 @@ typename Context::iterator vformat_to(
return h.context.out(); return h.context.out();
} }
// Casts ``p`` to ``const void*`` for pointer formatting. /**
// Example: \rst
// auto s = format("{}", ptr(p)); Converts ``p`` to ``const void*`` for pointer formatting.
**Example**::
auto s = fmt::format("{}", fmt::ptr(p));
\endrst
*/
template <typename T> inline const void* ptr(const T* p) { return p; } template <typename T> inline const void* ptr(const T* p) { return p; }
template <typename T> inline const void* ptr(const std::unique_ptr<T>& p) { template <typename T> inline const void* ptr(const std::unique_ptr<T>& p) {
return p.get(); return p.get();