diff --git a/AK/DistinctNumeric.h b/AK/DistinctNumeric.h index 59c6ad2739a..ae0c43f320e 100644 --- a/AK/DistinctNumeric.h +++ b/AK/DistinctNumeric.h @@ -1,5 +1,6 @@ /* * Copyright (c) 2020, Ben Wiederhake + * Copyright (c) 2021, Andreas Kling * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -26,6 +27,7 @@ #pragma once +#include #include #include @@ -299,6 +301,14 @@ private: T m_value {}; }; +template +struct Formatter> : Formatter { + void format(FormatBuilder& builder, DistinctNumeric value) + { + return Formatter::format(builder, "{}", value.value()); + } +}; + // TODO: When 'consteval' sufficiently-well supported by host compilers, try to // provide a more usable interface like this one: // https://gist.github.com/alimpfard/a3b750e8c3a2f44fb3a2d32038968ddf diff --git a/AK/Tests/TestDistinctNumeric.cpp b/AK/Tests/TestDistinctNumeric.cpp index 9e2b77f8876..0381bb55aad 100644 --- a/AK/Tests/TestDistinctNumeric.cpp +++ b/AK/Tests/TestDistinctNumeric.cpp @@ -24,9 +24,10 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include #include +#include + template class ForType { public: