1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_IS_SCOPED_ENUM_H
10#define _LIBCPP___TYPE_TRAITS_IS_SCOPED_ENUM_H
11
12#include <__config>
13#include <__type_traits/integral_constant.h>
14#include <__type_traits/is_convertible.h>
15#include <__type_traits/is_enum.h>
16#include <__type_traits/underlying_type.h>
17
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19#  pragma GCC system_header
20#endif
21
22_LIBCPP_BEGIN_NAMESPACE_STD
23
24#if _LIBCPP_STD_VER > 20
25template <class _Tp, bool = is_enum_v<_Tp> >
26struct __is_scoped_enum_helper : false_type {};
27
28template <class _Tp>
29struct __is_scoped_enum_helper<_Tp, true>
30    : public bool_constant<!is_convertible_v<_Tp, underlying_type_t<_Tp> > > {};
31
32template <class _Tp>
33struct _LIBCPP_TEMPLATE_VIS is_scoped_enum
34    : public __is_scoped_enum_helper<_Tp> {};
35
36template <class _Tp>
37inline constexpr bool is_scoped_enum_v = is_scoped_enum<_Tp>::value;
38#endif
39
40_LIBCPP_END_NAMESPACE_STD
41
42#endif // _LIBCPP___TYPE_TRAITS_IS_SCOPED_ENUM_H
43