1 //===---------------------------------------------------------------------===//
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
7 //===---------------------------------------------------------------------===//
9 #ifndef _LIBCPP___FWD_VARIANT_H
10 #define _LIBCPP___FWD_VARIANT_H
13 #include <__cstddef/size_t.h>
15 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16 # pragma GCC system_header
19 _LIBCPP_BEGIN_NAMESPACE_STD
21 #if _LIBCPP_STD_VER >= 17
23 template <class... _Types
>
24 class _LIBCPP_TEMPLATE_VIS variant
;
27 struct _LIBCPP_TEMPLATE_VIS variant_size
;
30 inline constexpr size_t variant_size_v
= variant_size
<_Tp
>::value
;
32 template <size_t _Ip
, class _Tp
>
33 struct _LIBCPP_TEMPLATE_VIS variant_alternative
;
35 template <size_t _Ip
, class _Tp
>
36 using variant_alternative_t
= typename variant_alternative
<_Ip
, _Tp
>::type
;
38 inline constexpr size_t variant_npos
= static_cast<size_t>(-1);
40 template <size_t _Ip
, class... _Types
>
42 _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
constexpr variant_alternative_t
<_Ip
, variant
<_Types
...>>&
43 get(variant
<_Types
...>&);
45 template <size_t _Ip
, class... _Types
>
47 _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
constexpr variant_alternative_t
<_Ip
, variant
<_Types
...>>&&
48 get(variant
<_Types
...>&&);
50 template <size_t _Ip
, class... _Types
>
52 _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
constexpr const variant_alternative_t
<_Ip
, variant
<_Types
...>>&
53 get(const variant
<_Types
...>&);
55 template <size_t _Ip
, class... _Types
>
57 _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
constexpr const variant_alternative_t
<_Ip
, variant
<_Types
...>>&&
58 get(const variant
<_Types
...>&&);
60 template <class _Tp
, class... _Types
>
61 _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
constexpr _Tp
& get(variant
<_Types
...>&);
63 template <class _Tp
, class... _Types
>
64 _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
constexpr _Tp
&& get(variant
<_Types
...>&&);
66 template <class _Tp
, class... _Types
>
67 _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
constexpr const _Tp
& get(const variant
<_Types
...>&);
69 template <class _Tp
, class... _Types
>
70 _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
constexpr const _Tp
&&
71 get(const variant
<_Types
...>&&);
73 #endif // _LIBCPP_STD_VER >= 17
75 _LIBCPP_END_NAMESPACE_STD
77 #endif // _LIBCPP___FWD_VARIANT_H