Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix fmt::get with function pointers for some GCC versions and legacy Clang #2144

Merged
merged 1 commit into from
Feb 23, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 6 additions & 11 deletions include/fmt/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -3833,21 +3833,16 @@ FMT_CONSTEXPR void advance_to(
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 std::unique_ptr<T>& p) {
return p.get();
template <typename T> const void* ptr(T p) {
static_assert(std::is_pointer<T>::value, "");
return detail::bit_cast<const void*>(p);
}
template <typename T> inline const void* ptr(const std::shared_ptr<T>& p) {
template <typename T> const void* ptr(const std::unique_ptr<T>& p) {
return p.get();
}
#if !FMT_MSC_VER
// MSVC lets function pointers decay to void pointers, so this
// overload is unnecessary.
template <typename T, typename... Args>
inline const void* ptr(T (*fn)(Args...)) {
return detail::bit_cast<const void*>(fn);
template <typename T> const void* ptr(const std::shared_ptr<T>& p) {
return p.get();
}
#endif

class bytes {
private:
Expand Down