mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 13:36:13 +03:00
AK: Add formatter for DistinctNumeric
This commit is contained in:
parent
489317e573
commit
e00f519cdd
Notes:
sideshowbarker
2024-07-18 22:24:32 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/e00f519cddc
@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2020, Ben Wiederhake <BenWiederhake.GitHub@gmx.de>
|
* Copyright (c) 2020, Ben Wiederhake <BenWiederhake.GitHub@gmx.de>
|
||||||
|
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@ -26,6 +27,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <AK/Format.h>
|
||||||
#include <AK/Traits.h>
|
#include <AK/Traits.h>
|
||||||
#include <AK/Types.h>
|
#include <AK/Types.h>
|
||||||
|
|
||||||
@ -299,6 +301,14 @@ private:
|
|||||||
T m_value {};
|
T m_value {};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<typename T, typename X, bool Incr, bool Cmp, bool Bool, bool Flags, bool Shift, bool Arith>
|
||||||
|
struct Formatter<DistinctNumeric<T, X, Incr, Cmp, Bool, Flags, Shift, Arith>> : Formatter<FormatString> {
|
||||||
|
void format(FormatBuilder& builder, DistinctNumeric<T, X, Incr, Cmp, Bool, Flags, Shift, Arith> value)
|
||||||
|
{
|
||||||
|
return Formatter<FormatString>::format(builder, "{}", value.value());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// TODO: When 'consteval' sufficiently-well supported by host compilers, try to
|
// TODO: When 'consteval' sufficiently-well supported by host compilers, try to
|
||||||
// provide a more usable interface like this one:
|
// provide a more usable interface like this one:
|
||||||
// https://gist.github.com/alimpfard/a3b750e8c3a2f44fb3a2d32038968ddf
|
// https://gist.github.com/alimpfard/a3b750e8c3a2f44fb3a2d32038968ddf
|
||||||
|
@ -24,9 +24,10 @@
|
|||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <AK/DistinctNumeric.h>
|
|
||||||
#include <AK/TestSuite.h>
|
#include <AK/TestSuite.h>
|
||||||
|
|
||||||
|
#include <AK/DistinctNumeric.h>
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class ForType {
|
class ForType {
|
||||||
public:
|
public:
|
||||||
|
Loading…
Reference in New Issue
Block a user