Implement P0607R0 "Inline Variables for Standard Library" for C++17

2017-03-23  Daniel Kruegler  <daniel.kruegler@gmail.com>

	* include/bits/c++config (_GLIBCXX17_INLINE): Define.
	* include/bits/regex_constants.h (All std::regex_constants constants):
	Add _GLIBCXX17_INLINE as per P0607R0.
	* include/bits/std_mutex.h (defer_lock, try_to_lock, adopt_lock):
	Likewise.
	* include/bits/stl_pair.h (piecewise_construct): Likewise.
	* include/bits/uses_allocator.h (allocator_arg, uses_allocator_v)
	(__is_uses_allocator_constructible_v)
	(__is_nothrow_uses_allocator_constructible_v): Likewise.
	* include/std/chrono (treat_as_floating_point_v): Likewise.
	* include/std/functional (is_bind_expression_v, is_placeholder_v):
	Likewise.
	* include/std/optional (nullopt): Likewise.
	* include/std/ratio (ratio_equal_v, ratio_not_equal_v, ratio_less_v)
	ratio_less_equal_v, ratio_greater_v, ratio_greater_equal_v): Likewise.
	* include/std/system_error (is_error_code_enum_v)
	(is_error_condition_enum_v): Likewise.
	* include/std/tuple (tuple_size_v, ignore): Likewise.
	(ignore): Declare ignore constexpr as per LWG 2773, declare assignment
	constexpr as per LWG 2933.
	* include/std/type_traits (All variable templates): Add
	_GLIBCXX17_INLINE as per P0607R0.
	* include/std/variant (variant_size_v, variant_npos, __index_of_v)
	(__tuple_count_v, __exactly_once): Likewise.
	* testsuite/18_support/headers/new/synopsis.cc
	(hardware_destructive_interference_size)
	(hardware_constructive_interference_size): Likewise for commented-out
	variables.
	* testsuite/20_util/tuple/creation_functions/constexpr.cc: Add new
	test function for constexpr std::ignore (LWG 2773).
	* testsuite/20_util/tuple/creation_functions/constexpr_cpp14.cc: New
	test for LWG 2933.

From-SVN: r246423
This commit is contained in:
Daniel Kruegler 2017-03-23 19:40:07 +00:00 committed by Jonathan Wakely
parent 842562b4e1
commit 288695f7a4
21 changed files with 250 additions and 131 deletions

View File

@ -1,3 +1,38 @@
2017-03-23 Daniel Kruegler <daniel.kruegler@gmail.com>
* include/bits/c++config (_GLIBCXX17_INLINE): Define.
* include/bits/regex_constants.h (All std::regex_constants constants):
Add _GLIBCXX17_INLINE as per P0607R0.
* include/bits/std_mutex.h (defer_lock, try_to_lock, adopt_lock):
Likewise.
* include/bits/stl_pair.h (piecewise_construct): Likewise.
* include/bits/uses_allocator.h (allocator_arg, uses_allocator_v)
(__is_uses_allocator_constructible_v)
(__is_nothrow_uses_allocator_constructible_v): Likewise.
* include/std/chrono (treat_as_floating_point_v): Likewise.
* include/std/functional (is_bind_expression_v, is_placeholder_v):
Likewise.
* include/std/optional (nullopt): Likewise.
* include/std/ratio (ratio_equal_v, ratio_not_equal_v, ratio_less_v)
ratio_less_equal_v, ratio_greater_v, ratio_greater_equal_v): Likewise.
* include/std/system_error (is_error_code_enum_v)
(is_error_condition_enum_v): Likewise.
* include/std/tuple (tuple_size_v, ignore): Likewise.
(ignore): Declare ignore constexpr as per LWG 2773, declare assignment
constexpr as per LWG 2933.
* include/std/type_traits (All variable templates): Add
_GLIBCXX17_INLINE as per P0607R0.
* include/std/variant (variant_size_v, variant_npos, __index_of_v)
(__tuple_count_v, __exactly_once): Likewise.
* testsuite/18_support/headers/new/synopsis.cc
(hardware_destructive_interference_size)
(hardware_constructive_interference_size): Likewise for commented-out
variables.
* testsuite/20_util/tuple/creation_functions/constexpr.cc: Add new
test function for constexpr std::ignore (LWG 2773).
* testsuite/20_util/tuple/creation_functions/constexpr_cpp14.cc: New
test for LWG 2933.
2017-03-22 Jonathan Wakely <jwakely@redhat.com>
* include/bits/shared_ptr.h (shared_ptr, weak_ptr): Add deduction

View File

@ -122,6 +122,14 @@
# endif
#endif
#ifndef _GLIBCXX17_INLINE
# if __cplusplus > 201402L
# define _GLIBCXX17_INLINE inline
# else
# define _GLIBCXX17_INLINE
# endif
#endif
// Macro for noexcept, to support in mixed 03/0x mode.
#ifndef _GLIBCXX_NOEXCEPT
# if __cplusplus >= 201103L

View File

@ -84,7 +84,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* Specifies that the matching of regular expressions against a character
* sequence shall be performed without regard to case.
*/
constexpr syntax_option_type icase =
_GLIBCXX17_INLINE constexpr syntax_option_type icase =
static_cast<syntax_option_type>(1 << _S_icase);
/**
@ -92,7 +92,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* container sequence, no sub-expression matches are to be stored in the
* supplied match_results structure.
*/
constexpr syntax_option_type nosubs =
_GLIBCXX17_INLINE constexpr syntax_option_type nosubs =
static_cast<syntax_option_type>(1 << _S_nosubs);
/**
@ -101,14 +101,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* speed with which regular expression objects are constructed. Otherwise
* it has no detectable effect on the program output.
*/
constexpr syntax_option_type optimize =
_GLIBCXX17_INLINE constexpr syntax_option_type optimize =
static_cast<syntax_option_type>(1 << _S_optimize);
/**
* Specifies that character ranges of the form [a-b] should be locale
* sensitive.
*/
constexpr syntax_option_type collate =
_GLIBCXX17_INLINE constexpr syntax_option_type collate =
static_cast<syntax_option_type>(1 << _S_collate);
/**
@ -119,7 +119,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* in the PERL scripting language but extended with elements found in the
* POSIX regular expression grammar.
*/
constexpr syntax_option_type ECMAScript =
_GLIBCXX17_INLINE constexpr syntax_option_type ECMAScript =
static_cast<syntax_option_type>(1 << _S_ECMAScript);
/**
@ -129,7 +129,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* Headers, Section 9, Regular Expressions [IEEE, Information Technology --
* Portable Operating System Interface (POSIX), IEEE Standard 1003.1-2001].
*/
constexpr syntax_option_type basic =
_GLIBCXX17_INLINE constexpr syntax_option_type basic =
static_cast<syntax_option_type>(1 << _S_basic);
/**
@ -138,7 +138,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* Portable Operating System Interface (POSIX), Base Definitions and
* Headers, Section 9, Regular Expressions.
*/
constexpr syntax_option_type extended =
_GLIBCXX17_INLINE constexpr syntax_option_type extended =
static_cast<syntax_option_type>(1 << _S_extended);
/**
@ -149,7 +149,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* \\\\, \\a, \\b, \\f, \\n, \\r, \\t , \\v, \\&apos,, &apos,,
* and \\ddd (where ddd is one, two, or three octal digits).
*/
constexpr syntax_option_type awk =
_GLIBCXX17_INLINE constexpr syntax_option_type awk =
static_cast<syntax_option_type>(1 << _S_awk);
/**
@ -158,7 +158,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* identical to syntax_option_type basic, except that newlines are treated
* as whitespace.
*/
constexpr syntax_option_type grep =
_GLIBCXX17_INLINE constexpr syntax_option_type grep =
static_cast<syntax_option_type>(1 << _S_grep);
/**
@ -167,7 +167,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* IEEE Std 1003.1-2001. This option is identical to syntax_option_type
* extended, except that newlines are treated as whitespace.
*/
constexpr syntax_option_type egrep =
_GLIBCXX17_INLINE constexpr syntax_option_type egrep =
static_cast<syntax_option_type>(1 << _S_egrep);
/**
@ -176,7 +176,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* If specified in a regex with back-references, the exception
* regex_constants::error_complexity will be thrown.
*/
constexpr syntax_option_type __polynomial =
_GLIBCXX17_INLINE constexpr syntax_option_type __polynomial =
static_cast<syntax_option_type>(1 << _S_polynomial);
constexpr inline syntax_option_type
@ -257,14 +257,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* The default matching rules.
*/
constexpr match_flag_type match_default = static_cast<match_flag_type>(0);
_GLIBCXX17_INLINE constexpr match_flag_type match_default =
static_cast<match_flag_type>(0);
/**
* The first character in the sequence [first, last) is treated as though it
* is not at the beginning of a line, so the character (^) in the regular
* expression shall not match [first, first).
*/
constexpr match_flag_type match_not_bol =
_GLIBCXX17_INLINE constexpr match_flag_type match_not_bol =
static_cast<match_flag_type>(1 << _S_not_bol);
/**
@ -272,40 +273,40 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* is not at the end of a line, so the character ($) in the regular
* expression shall not match [last, last).
*/
constexpr match_flag_type match_not_eol =
_GLIBCXX17_INLINE constexpr match_flag_type match_not_eol =
static_cast<match_flag_type>(1 << _S_not_eol);
/**
* The expression \\b is not matched against the sub-sequence
* [first,first).
*/
constexpr match_flag_type match_not_bow =
_GLIBCXX17_INLINE constexpr match_flag_type match_not_bow =
static_cast<match_flag_type>(1 << _S_not_bow);
/**
* The expression \\b should not be matched against the sub-sequence
* [last,last).
*/
constexpr match_flag_type match_not_eow =
_GLIBCXX17_INLINE constexpr match_flag_type match_not_eow =
static_cast<match_flag_type>(1 << _S_not_eow);
/**
* If more than one match is possible then any match is an acceptable
* result.
*/
constexpr match_flag_type match_any =
_GLIBCXX17_INLINE constexpr match_flag_type match_any =
static_cast<match_flag_type>(1 << _S_any);
/**
* The expression does not match an empty sequence.
*/
constexpr match_flag_type match_not_null =
_GLIBCXX17_INLINE constexpr match_flag_type match_not_null =
static_cast<match_flag_type>(1 << _S_not_null);
/**
* The expression only matches a sub-sequence that begins at first .
*/
constexpr match_flag_type match_continuous =
_GLIBCXX17_INLINE constexpr match_flag_type match_continuous =
static_cast<match_flag_type>(1 << _S_continuous);
/**
@ -313,7 +314,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* flags match_not_bol and match_not_bow are ignored by the regular
* expression algorithms 28.11 and iterators 28.12.
*/
constexpr match_flag_type match_prev_avail =
_GLIBCXX17_INLINE constexpr match_flag_type match_prev_avail =
static_cast<match_flag_type>(1 << _S_prev_avail);
/**
@ -342,7 +343,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* undefined, use the empty string instead. If
* nn > match_results::size(), the result is implementation-defined.
*/
constexpr match_flag_type format_default = static_cast<match_flag_type>(0);
_GLIBCXX17_INLINE constexpr match_flag_type format_default =
static_cast<match_flag_type>(0);
/**
* When a regular expression match is to be replaced by a new string, the
@ -350,7 +352,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* in IEEE Std 1003.1- 2001 [IEEE, Information Technology -- Portable
* Operating System Interface (POSIX), IEEE Standard 1003.1-2001].
*/
constexpr match_flag_type format_sed =
_GLIBCXX17_INLINE constexpr match_flag_type format_sed =
static_cast<match_flag_type>(1 << _S_sed);
/**
@ -358,14 +360,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* container sequence being searched that do not match the regular
* expression shall not be copied to the output string.
*/
constexpr match_flag_type format_no_copy =
_GLIBCXX17_INLINE constexpr match_flag_type format_no_copy =
static_cast<match_flag_type>(1 << _S_no_copy);
/**
* When specified during a search and replace operation, only the first
* occurrence of the regular expression shall be replaced.
*/
constexpr match_flag_type format_first_only =
_GLIBCXX17_INLINE constexpr match_flag_type format_first_only =
static_cast<match_flag_type>(1 << _S_first_only);
constexpr inline match_flag_type

View File

@ -139,13 +139,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
struct adopt_lock_t { explicit adopt_lock_t() = default; };
/// Tag used to prevent a scoped lock from acquiring ownership of a mutex.
constexpr defer_lock_t defer_lock { };
_GLIBCXX17_INLINE constexpr defer_lock_t defer_lock { };
/// Tag used to prevent a scoped lock from blocking if a mutex is locked.
constexpr try_to_lock_t try_to_lock { };
_GLIBCXX17_INLINE constexpr try_to_lock_t try_to_lock { };
/// Tag used to make a scoped lock take ownership of a locked mutex.
constexpr adopt_lock_t adopt_lock { };
_GLIBCXX17_INLINE constexpr adopt_lock_t adopt_lock { };
/** @brief A simple scoped lock type.
*

View File

@ -76,7 +76,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
struct piecewise_construct_t { explicit piecewise_construct_t() = default; };
/// piecewise_construct
constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t();
_GLIBCXX17_INLINE constexpr piecewise_construct_t piecewise_construct =
piecewise_construct_t();
// Forward declarations.
template<typename...>

View File

@ -45,7 +45,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
/// [allocator.tag]
struct allocator_arg_t { explicit allocator_arg_t() = default; };
constexpr allocator_arg_t allocator_arg = allocator_arg_t();
_GLIBCXX17_INLINE constexpr allocator_arg_t allocator_arg =
allocator_arg_t();
template<typename _Tp, typename _Alloc, typename = __void_t<>>
struct __uses_allocator_helper
@ -110,7 +111,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
#if __cplusplus > 201402L
template <typename _Tp, typename _Alloc>
constexpr bool uses_allocator_v = uses_allocator<_Tp, _Alloc>::value;
inline constexpr bool uses_allocator_v =
uses_allocator<_Tp, _Alloc>::value;
#endif // C++17
template<template<typename...> class _Predicate,
@ -128,7 +130,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#if __cplusplus >= 201402L
template<typename _Tp, typename _Alloc, typename... _Args>
constexpr bool __is_uses_allocator_constructible_v =
_GLIBCXX17_INLINE constexpr bool __is_uses_allocator_constructible_v =
__is_uses_allocator_constructible<_Tp, _Alloc, _Args...>::value;
#endif // C++14
@ -141,7 +143,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#if __cplusplus >= 201402L
template<typename _Tp, typename _Alloc, typename... _Args>
constexpr bool __is_nothrow_uses_allocator_constructible_v =
_GLIBCXX17_INLINE constexpr bool
__is_nothrow_uses_allocator_constructible_v =
__is_nothrow_uses_allocator_constructible<_Tp, _Alloc, _Args...>::value;
#endif // C++14

View File

@ -211,7 +211,7 @@ _GLIBCXX_END_NAMESPACE_VERSION
#if __cplusplus > 201402L
template <typename _Rep>
constexpr bool treat_as_floating_point_v =
inline constexpr bool treat_as_floating_point_v =
treat_as_floating_point<_Rep>::value;
#endif // C++17

View File

@ -242,9 +242,9 @@ _GLIBCXX_MEM_FN_TRAITS(&&, false_type, true_type)
{ };
#if __cplusplus > 201402L
template <typename _Tp> constexpr bool is_bind_expression_v
template <typename _Tp> inline constexpr bool is_bind_expression_v
= is_bind_expression<_Tp>::value;
template <typename _Tp> constexpr int is_placeholder_v
template <typename _Tp> inline constexpr int is_placeholder_v
= is_placeholder<_Tp>::value;
#endif // C++17

View File

@ -69,7 +69,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
};
/// Tag to disengage optional objects.
constexpr nullopt_t nullopt { nullopt_t::_Construct::_Token };
inline constexpr nullopt_t nullopt { nullopt_t::_Construct::_Token };
/**
* @brief Exception class thrown when a disengaged optional object is

View File

@ -403,17 +403,18 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#if __cplusplus > 201402L
template <typename _R1, typename _R2>
constexpr bool ratio_equal_v = ratio_equal<_R1, _R2>::value;
inline constexpr bool ratio_equal_v = ratio_equal<_R1, _R2>::value;
template <typename _R1, typename _R2>
constexpr bool ratio_not_equal_v = ratio_not_equal<_R1, _R2>::value;
inline constexpr bool ratio_not_equal_v = ratio_not_equal<_R1, _R2>::value;
template <typename _R1, typename _R2>
constexpr bool ratio_less_v = ratio_less<_R1, _R2>::value;
inline constexpr bool ratio_less_v = ratio_less<_R1, _R2>::value;
template <typename _R1, typename _R2>
constexpr bool ratio_less_equal_v = ratio_less_equal<_R1, _R2>::value;
inline constexpr bool ratio_less_equal_v =
ratio_less_equal<_R1, _R2>::value;
template <typename _R1, typename _R2>
constexpr bool ratio_greater_v = ratio_greater<_R1, _R2>::value;
inline constexpr bool ratio_greater_v = ratio_greater<_R1, _R2>::value;
template <typename _R1, typename _R2>
constexpr bool ratio_greater_equal_v
inline constexpr bool ratio_greater_equal_v
= ratio_greater_equal<_R1, _R2>::value;
#endif // C++17

View File

@ -62,9 +62,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#if __cplusplus > 201402L
template <typename _Tp>
constexpr bool is_error_code_enum_v = is_error_code_enum<_Tp>::value;
inline constexpr bool is_error_code_enum_v =
is_error_code_enum<_Tp>::value;
template <typename _Tp>
constexpr bool is_error_condition_enum_v =
inline constexpr bool is_error_condition_enum_v =
is_error_condition_enum<_Tp>::value;
#endif // C++17
inline namespace _V2 {

View File

@ -1268,7 +1268,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#if __cplusplus > 201402L
template <typename _Tp>
constexpr size_t tuple_size_v = tuple_size<_Tp>::value;
inline constexpr size_t tuple_size_v = tuple_size<_Tp>::value;
#endif
/**
@ -1610,16 +1610,20 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#endif
// A class (and instance) which can be used in 'tie' when an element
// of a tuple is not required
// of a tuple is not required.
// _GLIBCXX14_CONSTEXPR
// 2933. PR for LWG 2773 could be clearer
struct _Swallow_assign
{
template<class _Tp>
const _Swallow_assign&
_GLIBCXX14_CONSTEXPR const _Swallow_assign&
operator=(const _Tp&) const
{ return *this; }
};
const _Swallow_assign ignore{};
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 2773. Making std::ignore constexpr
_GLIBCXX17_INLINE constexpr _Swallow_assign ignore{};
/// Partial specialization for tuples
template<typename... _Types, typename _Alloc>

View File

@ -174,15 +174,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ };
template<typename... _Bn>
constexpr bool conjunction_v
inline constexpr bool conjunction_v
= conjunction<_Bn...>::value;
template<typename... _Bn>
constexpr bool disjunction_v
inline constexpr bool disjunction_v
= disjunction<_Bn...>::value;
template<typename _Pp>
constexpr bool negation_v
inline constexpr bool negation_v
= negation<_Pp>::value;
#endif
@ -2656,11 +2656,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#if __cplusplus >= 201402L
/// is_swappable_v
template<typename _Tp>
constexpr bool is_swappable_v = is_swappable<_Tp>::value;
_GLIBCXX17_INLINE constexpr bool is_swappable_v =
is_swappable<_Tp>::value;
/// is_nothrow_swappable_v
template<typename _Tp>
constexpr bool is_nothrow_swappable_v = is_nothrow_swappable<_Tp>::value;
_GLIBCXX17_INLINE constexpr bool is_nothrow_swappable_v =
is_nothrow_swappable<_Tp>::value;
#endif // __cplusplus >= 201402L
namespace __swappable_with_details {
@ -2738,11 +2740,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#if __cplusplus >= 201402L
/// is_swappable_with_v
template<typename _Tp, typename _Up>
constexpr bool is_swappable_with_v = is_swappable_with<_Tp, _Up>::value;
_GLIBCXX17_INLINE constexpr bool is_swappable_with_v =
is_swappable_with<_Tp, _Up>::value;
/// is_nothrow_swappable_with_v
template<typename _Tp, typename _Up>
constexpr bool is_nothrow_swappable_with_v =
_GLIBCXX17_INLINE constexpr bool is_nothrow_swappable_with_v =
is_nothrow_swappable_with<_Tp, _Up>::value;
#endif // __cplusplus >= 201402L
@ -2884,155 +2887,161 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#if __cplusplus > 201402L
# define __cpp_lib_type_trait_variable_templates 201510L
template <typename _Tp>
constexpr bool is_void_v = is_void<_Tp>::value;
inline constexpr bool is_void_v = is_void<_Tp>::value;
template <typename _Tp>
constexpr bool is_null_pointer_v = is_null_pointer<_Tp>::value;
inline constexpr bool is_null_pointer_v = is_null_pointer<_Tp>::value;
template <typename _Tp>
constexpr bool is_integral_v = is_integral<_Tp>::value;
inline constexpr bool is_integral_v = is_integral<_Tp>::value;
template <typename _Tp>
constexpr bool is_floating_point_v = is_floating_point<_Tp>::value;
inline constexpr bool is_floating_point_v = is_floating_point<_Tp>::value;
template <typename _Tp>
constexpr bool is_array_v = is_array<_Tp>::value;
inline constexpr bool is_array_v = is_array<_Tp>::value;
template <typename _Tp>
constexpr bool is_pointer_v = is_pointer<_Tp>::value;
inline constexpr bool is_pointer_v = is_pointer<_Tp>::value;
template <typename _Tp>
constexpr bool is_lvalue_reference_v = is_lvalue_reference<_Tp>::value;
inline constexpr bool is_lvalue_reference_v =
is_lvalue_reference<_Tp>::value;
template <typename _Tp>
constexpr bool is_rvalue_reference_v = is_rvalue_reference<_Tp>::value;
inline constexpr bool is_rvalue_reference_v =
is_rvalue_reference<_Tp>::value;
template <typename _Tp>
constexpr bool is_member_object_pointer_v =
inline constexpr bool is_member_object_pointer_v =
is_member_object_pointer<_Tp>::value;
template <typename _Tp>
constexpr bool is_member_function_pointer_v =
inline constexpr bool is_member_function_pointer_v =
is_member_function_pointer<_Tp>::value;
template <typename _Tp>
constexpr bool is_enum_v = is_enum<_Tp>::value;
inline constexpr bool is_enum_v = is_enum<_Tp>::value;
template <typename _Tp>
constexpr bool is_union_v = is_union<_Tp>::value;
inline constexpr bool is_union_v = is_union<_Tp>::value;
template <typename _Tp>
constexpr bool is_class_v = is_class<_Tp>::value;
inline constexpr bool is_class_v = is_class<_Tp>::value;
template <typename _Tp>
constexpr bool is_function_v = is_function<_Tp>::value;
inline constexpr bool is_function_v = is_function<_Tp>::value;
template <typename _Tp>
constexpr bool is_reference_v = is_reference<_Tp>::value;
inline constexpr bool is_reference_v = is_reference<_Tp>::value;
template <typename _Tp>
constexpr bool is_arithmetic_v = is_arithmetic<_Tp>::value;
inline constexpr bool is_arithmetic_v = is_arithmetic<_Tp>::value;
template <typename _Tp>
constexpr bool is_fundamental_v = is_fundamental<_Tp>::value;
inline constexpr bool is_fundamental_v = is_fundamental<_Tp>::value;
template <typename _Tp>
constexpr bool is_object_v = is_object<_Tp>::value;
inline constexpr bool is_object_v = is_object<_Tp>::value;
template <typename _Tp>
constexpr bool is_scalar_v = is_scalar<_Tp>::value;
inline constexpr bool is_scalar_v = is_scalar<_Tp>::value;
template <typename _Tp>
constexpr bool is_compound_v = is_compound<_Tp>::value;
inline constexpr bool is_compound_v = is_compound<_Tp>::value;
template <typename _Tp>
constexpr bool is_member_pointer_v = is_member_pointer<_Tp>::value;
inline constexpr bool is_member_pointer_v = is_member_pointer<_Tp>::value;
template <typename _Tp>
constexpr bool is_const_v = is_const<_Tp>::value;
inline constexpr bool is_const_v = is_const<_Tp>::value;
template <typename _Tp>
constexpr bool is_volatile_v = is_volatile<_Tp>::value;
inline constexpr bool is_volatile_v = is_volatile<_Tp>::value;
template <typename _Tp>
constexpr bool is_trivial_v = is_trivial<_Tp>::value;
inline constexpr bool is_trivial_v = is_trivial<_Tp>::value;
template <typename _Tp>
constexpr bool is_trivially_copyable_v = is_trivially_copyable<_Tp>::value;
inline constexpr bool is_trivially_copyable_v =
is_trivially_copyable<_Tp>::value;
template <typename _Tp>
constexpr bool is_standard_layout_v = is_standard_layout<_Tp>::value;
inline constexpr bool is_standard_layout_v = is_standard_layout<_Tp>::value;
template <typename _Tp>
constexpr bool is_pod_v = is_pod<_Tp>::value;
inline constexpr bool is_pod_v = is_pod<_Tp>::value;
template <typename _Tp>
constexpr bool is_literal_type_v = is_literal_type<_Tp>::value;
inline constexpr bool is_literal_type_v = is_literal_type<_Tp>::value;
template <typename _Tp>
constexpr bool is_empty_v = is_empty<_Tp>::value;
inline constexpr bool is_empty_v = is_empty<_Tp>::value;
template <typename _Tp>
constexpr bool is_polymorphic_v = is_polymorphic<_Tp>::value;
inline constexpr bool is_polymorphic_v = is_polymorphic<_Tp>::value;
template <typename _Tp>
constexpr bool is_abstract_v = is_abstract<_Tp>::value;
inline constexpr bool is_abstract_v = is_abstract<_Tp>::value;
template <typename _Tp>
constexpr bool is_final_v = is_final<_Tp>::value;
inline constexpr bool is_final_v = is_final<_Tp>::value;
template <typename _Tp>
constexpr bool is_signed_v = is_signed<_Tp>::value;
inline constexpr bool is_signed_v = is_signed<_Tp>::value;
template <typename _Tp>
constexpr bool is_unsigned_v = is_unsigned<_Tp>::value;
inline constexpr bool is_unsigned_v = is_unsigned<_Tp>::value;
template <typename _Tp, typename... _Args>
constexpr bool is_constructible_v = is_constructible<_Tp, _Args...>::value;
inline constexpr bool is_constructible_v =
is_constructible<_Tp, _Args...>::value;
template <typename _Tp>
constexpr bool is_default_constructible_v =
inline constexpr bool is_default_constructible_v =
is_default_constructible<_Tp>::value;
template <typename _Tp>
constexpr bool is_copy_constructible_v = is_copy_constructible<_Tp>::value;
inline constexpr bool is_copy_constructible_v =
is_copy_constructible<_Tp>::value;
template <typename _Tp>
constexpr bool is_move_constructible_v = is_move_constructible<_Tp>::value;
inline constexpr bool is_move_constructible_v =
is_move_constructible<_Tp>::value;
template <typename _Tp, typename _Up>
constexpr bool is_assignable_v = is_assignable<_Tp, _Up>::value;
inline constexpr bool is_assignable_v = is_assignable<_Tp, _Up>::value;
template <typename _Tp>
constexpr bool is_copy_assignable_v = is_copy_assignable<_Tp>::value;
inline constexpr bool is_copy_assignable_v = is_copy_assignable<_Tp>::value;
template <typename _Tp>
constexpr bool is_move_assignable_v = is_move_assignable<_Tp>::value;
inline constexpr bool is_move_assignable_v = is_move_assignable<_Tp>::value;
template <typename _Tp>
constexpr bool is_destructible_v = is_destructible<_Tp>::value;
inline constexpr bool is_destructible_v = is_destructible<_Tp>::value;
template <typename _Tp, typename... _Args>
constexpr bool is_trivially_constructible_v =
inline constexpr bool is_trivially_constructible_v =
is_trivially_constructible<_Tp, _Args...>::value;
template <typename _Tp>
constexpr bool is_trivially_default_constructible_v =
inline constexpr bool is_trivially_default_constructible_v =
is_trivially_default_constructible<_Tp>::value;
template <typename _Tp>
constexpr bool is_trivially_copy_constructible_v =
inline constexpr bool is_trivially_copy_constructible_v =
is_trivially_copy_constructible<_Tp>::value;
template <typename _Tp>
constexpr bool is_trivially_move_constructible_v =
inline constexpr bool is_trivially_move_constructible_v =
is_trivially_move_constructible<_Tp>::value;
template <typename _Tp, typename _Up>
constexpr bool is_trivially_assignable_v =
inline constexpr bool is_trivially_assignable_v =
is_trivially_assignable<_Tp, _Up>::value;
template <typename _Tp>
constexpr bool is_trivially_copy_assignable_v =
inline constexpr bool is_trivially_copy_assignable_v =
is_trivially_copy_assignable<_Tp>::value;
template <typename _Tp>
constexpr bool is_trivially_move_assignable_v =
inline constexpr bool is_trivially_move_assignable_v =
is_trivially_move_assignable<_Tp>::value;
template <typename _Tp>
constexpr bool is_trivially_destructible_v =
inline constexpr bool is_trivially_destructible_v =
is_trivially_destructible<_Tp>::value;
template <typename _Tp, typename... _Args>
constexpr bool is_nothrow_constructible_v =
inline constexpr bool is_nothrow_constructible_v =
is_nothrow_constructible<_Tp, _Args...>::value;
template <typename _Tp>
constexpr bool is_nothrow_default_constructible_v =
inline constexpr bool is_nothrow_default_constructible_v =
is_nothrow_default_constructible<_Tp>::value;
template <typename _Tp>
constexpr bool is_nothrow_copy_constructible_v =
inline constexpr bool is_nothrow_copy_constructible_v =
is_nothrow_copy_constructible<_Tp>::value;
template <typename _Tp>
constexpr bool is_nothrow_move_constructible_v =
inline constexpr bool is_nothrow_move_constructible_v =
is_nothrow_move_constructible<_Tp>::value;
template <typename _Tp, typename _Up>
constexpr bool is_nothrow_assignable_v =
inline constexpr bool is_nothrow_assignable_v =
is_nothrow_assignable<_Tp, _Up>::value;
template <typename _Tp>
constexpr bool is_nothrow_copy_assignable_v =
inline constexpr bool is_nothrow_copy_assignable_v =
is_nothrow_copy_assignable<_Tp>::value;
template <typename _Tp>
constexpr bool is_nothrow_move_assignable_v =
inline constexpr bool is_nothrow_move_assignable_v =
is_nothrow_move_assignable<_Tp>::value;
template <typename _Tp>
constexpr bool is_nothrow_destructible_v =
inline constexpr bool is_nothrow_destructible_v =
is_nothrow_destructible<_Tp>::value;
template <typename _Tp>
constexpr bool has_virtual_destructor_v =
inline constexpr bool has_virtual_destructor_v =
has_virtual_destructor<_Tp>::value;
template <typename _Tp>
constexpr size_t alignment_of_v = alignment_of<_Tp>::value;
inline constexpr size_t alignment_of_v = alignment_of<_Tp>::value;
template <typename _Tp>
constexpr size_t rank_v = rank<_Tp>::value;
inline constexpr size_t rank_v = rank<_Tp>::value;
template <typename _Tp, unsigned _Idx = 0>
constexpr size_t extent_v = extent<_Tp, _Idx>::value;
inline constexpr size_t extent_v = extent<_Tp, _Idx>::value;
template <typename _Tp, typename _Up>
constexpr bool is_same_v = is_same<_Tp, _Up>::value;
inline constexpr bool is_same_v = is_same<_Tp, _Up>::value;
template <typename _Base, typename _Derived>
constexpr bool is_base_of_v = is_base_of<_Base, _Derived>::value;
inline constexpr bool is_base_of_v = is_base_of<_Base, _Derived>::value;
template <typename _From, typename _To>
constexpr bool is_convertible_v = is_convertible<_From, _To>::value;
inline constexpr bool is_convertible_v = is_convertible<_From, _To>::value;
#ifdef __has_builtin
# if !__has_builtin(__has_unique_object_representations)

View File

@ -91,7 +91,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
: std::integral_constant<size_t, sizeof...(_Types)> {};
template<typename _Variant>
constexpr size_t variant_size_v = variant_size<_Variant>::value;
inline constexpr size_t variant_size_v = variant_size<_Variant>::value;
template<size_t _Np, typename _Variant>
struct variant_alternative;
@ -120,7 +120,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
struct variant_alternative<_Np, const volatile _Variant>
{ using type = add_cv_t<variant_alternative_t<_Np, _Variant>>; };
constexpr size_t variant_npos = -1;
inline constexpr size_t variant_npos = -1;
template<size_t _Np, typename... _Types>
constexpr variant_alternative_t<_Np, variant<_Types...>>&
@ -151,7 +151,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
struct __index_of : std::integral_constant<size_t, 0> {};
template<typename _Tp, typename... _Types>
constexpr size_t __index_of_v = __index_of<_Tp, _Types...>::value;
inline constexpr size_t __index_of_v = __index_of<_Tp, _Types...>::value;
template<typename _Tp, typename _First, typename... _Rest>
struct __index_of<_Tp, _First, _Rest...> :
@ -510,7 +510,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
struct __tuple_count;
template<typename _Tp, typename _Tuple>
constexpr size_t __tuple_count_v = __tuple_count<_Tp, _Tuple>::value;
inline constexpr size_t __tuple_count_v =
__tuple_count<_Tp, _Tuple>::value;
template<typename _Tp, typename... _Types>
struct __tuple_count<_Tp, tuple<_Types...>>
@ -524,7 +525,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// TODO: Reuse this in <tuple> ?
template<typename _Tp, typename... _Types>
constexpr bool __exactly_once = __tuple_count_v<_Tp, tuple<_Types...>> == 1;
inline constexpr bool __exactly_once =
__tuple_count_v<_Tp, tuple<_Types...>> == 1;
// Takes _Types and create an overloaded _S_fun for each type.
// If a type appears more than once in _Types, create only one overload.

View File

@ -30,8 +30,10 @@ namespace std {
#if __cplusplus > 201402L
enum class align_val_t : size_t;
// static constexpr size_t hardware_destructive_interference_size;
// static constexpr size_t hardware_constructive_interference_size;
// _GLIBCXX17_INLINE constexpr size_t
// hardware_destructive_interference_size;
// _GLIBCXX17_INLINE constexpr size_t
// hardware_constructive_interference_size;
#endif
}

View File

@ -41,7 +41,7 @@ test02()
// { dg-error "required from here" "" { target *-*-* } 28 }
// { dg-error "expected initializer" "" { target *-*-* } 35 }
// { dg-error "expected initializer" "" { target *-*-* } 37 }
// { dg-error "overflow in addition" "" { target *-*-* } 451 }
// { dg-error "overflow in addition" "" { target *-*-* } 452 }
// { dg-error "overflow in multiplication" "" { target *-*-* } 97 }
// { dg-error "overflow in multiplication" "" { target *-*-* } 99 }
// { dg-error "overflow in multiplication" "" { target *-*-* } 101 }

View File

@ -46,5 +46,5 @@ test01()
scoped_alloc sa;
auto p = sa.allocate(1);
sa.construct(p); // this is required to be ill-formed
// { dg-error "static assertion failed" "" { target *-*-* } 89 }
// { dg-error "static assertion failed" "" { target *-*-* } 90 }
}

View File

@ -118,6 +118,25 @@ test_tuple_cat()
constexpr auto cat1 __attribute__((unused)) = std::tuple_cat(t1, t2);
}
namespace {
template<class T>
constexpr int zero_from_anything(T)
{
return 0;
}
}
// ignore, see LWG 2773
void
test_ignore()
{
constexpr auto ign1 __attribute__((unused)) = std::ignore;
constexpr auto ign2 __attribute__((unused)) = std::make_tuple(std::ignore);
constexpr int ign3 __attribute__((unused)) = zero_from_anything(std::ignore);
}
int
main()
{
@ -126,6 +145,7 @@ main()
test_tie();
test_get();
test_tuple_cat();
test_ignore();
return 0;
}

View File

@ -0,0 +1,31 @@
// { dg-do compile { target c++14 } }
// Copyright (C) 2017 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <tuple>
// ignore, see LWG 2773 + LWG 2933.
constexpr bool
test_ignore()
{
auto res = std::tie(std::ignore);
std::get<0>(res) = 42;
return true;
}
static_assert(test_ignore(), "test_ignore failure");

View File

@ -44,5 +44,5 @@ test01()
{
alloc_type a;
std::tuple<X> t(std::allocator_arg, a); // this is required to be ill-formed
// { dg-error "static assertion failed" "" { target *-*-* } 89 }
// { dg-error "static assertion failed" "" { target *-*-* } 90 }
}

View File

@ -43,4 +43,4 @@ void test01()
tuple<Type> t(allocator_arg, a, 1);
}
// { dg-error "static assertion failed" "" { target *-*-* } 89 }
// { dg-error "static assertion failed" "" { target *-*-* } 90 }