Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/mfbt/   (Firefox Browser Version 153.0.1©)  Datei vom 27.6.2026 mit Größe 1 kB image not shown  

Quelle  UsingEnum.h

  Sprache: C
 

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */


#ifndef mozilla_UsingEnum_h
#define mozilla_UsingEnum_h

#include "mozilla/MacroForEach.h"

// C++20 `using enum` declaration isn't supported in GCC 10. Provide a simple
// macro until our minimum supported GCC has been upgraded to GCC 11. We can
// remove this header and `MOZ_USING_ENUM` after we desupport GCC 10.
//
// Since few developers will be using GCC locally, they may forget to list all
// of the enum's enumerator values and only realize they broke the GCC build
// after their patch is backed out of autoland. To catch this error sooner, use
// the GCC macro in DEBUG builds on all platforms.
//
// Usage:
// ```
// enum class MyEnum { Foo, Bar, Baz };
// MOZ_USING_ENUM(MyEnum, Foo, Bar, Baz);
//
// class MyClass {
//   enum class MyEnum { Foo, Bar, Baz };
//   // Use MOZ_USING_ENUM_STATIC in class declarations because the constexpr
//   // member variables need to be static. This isn't needed for `using enum`.
//   MOZ_USING_ENUM_STATIC(MyEnum, Foo, Bar, Baz);
// };
// ```

#if defined(__cpp_using_enum) && !defined(DEBUG)
#  define MOZ_USING_ENUM(ENUM, ...) using enum ENUM
#  define MOZ_USING_ENUM_STATIC(ENUM, ...) using enum ENUM
#else
#  define MOZ_USING_ENUM_DECLARE(ENUM, NAME) constexpr auto NAME = ENUM::NAME;
#  define MOZ_USING_ENUM(ENUM, ...) \
    MOZ_FOR_EACH(MOZ_USING_ENUM_DECLARE, (ENUM, ), (__VA_ARGS__))

#  define MOZ_USING_ENUM_DECLARE_STATIC(ENUM, NAME) \
    static constexpr auto NAME = ENUM::NAME;
#  define MOZ_USING_ENUM_STATIC(ENUM, ...) \
    MOZ_FOR_EACH(MOZ_USING_ENUM_DECLARE_STATIC, (ENUM, ), (__VA_ARGS__))
#endif

#endif  // mozilla_UsingEnum_h

Messung V0.5 in Prozent
C=85 H=93 G=88

¤ Dauer der Verarbeitung: 0.17 Sekunden  (vorverarbeitet am  2026-08-25) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.