gcc/libstdc++-v3/include/experimental/propagate_const

541 lines
15 KiB
Plaintext
Raw Normal View History

2015-07-03 16:08:37 +02:00
// <experimental/propagate_const> -*- C++ -*-
// Copyright (C) 2015-2020 Free Software Foundation, Inc.
2015-07-03 16:08:37 +02:00
//
// 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.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file experimental/propagate_const
* This is a TS C++ Library header.
Improve docs for Library Fundamentals TS * doc/doxygen/doxygroups.cc: Move description of experimental group here. * include/experimental/algorithm: Add to libfund-ts doc group. * include/experimental/any: Likewise. Do not document implementation details. * include/experimental/array: Add to libfund-ts doc group. * include/experimental/bits/lfts_config.h: Define libfund-ts doc group for Library Fundamentals. * include/experimental/chrono: Add to libfund-ts doc group. * include/experimental/deque: Likewise. * include/experimental/forward_list: Likewise. * include/experimental/functional: Likewise. * include/experimental/iterator: Likewise. * include/experimental/list: Likewise. * include/experimental/map: Likewise. * include/experimental/memory: Likewise. * include/experimental/memory_resource: Likewise. Improve docs. details. * include/experimental/numeric: Add to libfund-ts doc group. * include/experimental/optional: Likewise. * include/experimental/propagate_const: Likewise. * include/experimental/random: Likewise. * include/experimental/ratio: Likewise. * include/experimental/regex: Likewise. * include/experimental/set: Likewise. * include/experimental/source_location: Likewise. * include/experimental/string: Likewise. * include/experimental/string_view: Likewise. * include/experimental/system_error: Likewise. * include/experimental/tuple: Likewise. * include/experimental/type_traits: Likewise. * include/experimental/unordered_map: Likewise. * include/experimental/unordered_set: Likewise. * include/experimental/utility: Likewise. * include/experimental/vector: Likewise. * testsuite/experimental/any/misc/any_cast_neg.cc: Adjust dg-error. * testsuite/experimental/array/neg.cc: Adjust dg-error. * testsuite/experimental/propagate_const/assignment/move_neg.cc: Likewise. * testsuite/experimental/propagate_const/cons/move_neg.cc: Likewise. * testsuite/experimental/propagate_const/requirements2.cc: Likewise. * testsuite/experimental/propagate_const/requirements3.cc: Likewise. * testsuite/experimental/propagate_const/requirements4.cc: Likewise. * testsuite/experimental/propagate_const/requirements5.cc: Likewise. From-SVN: r270809
2019-05-02 17:46:29 +02:00
* @ingroup libfund-ts
2015-07-03 16:08:37 +02:00
*/
#ifndef _GLIBCXX_EXPERIMENTAL_PROPAGATE_CONST
#define _GLIBCXX_EXPERIMENTAL_PROPAGATE_CONST 1
#pragma GCC system_header
PR libstdc++/79433 no #error for including TS headers with wrong -std PR libstdc++/79433 * include/Makefile.am: Remove <bits/c++14_warning.h>. * include/Makefile.in: Regenerate. * include/bits/c++14_warning.h: Remove. * include/experimental/algorithm: Do not include <c++14_warning.h>. * include/experimental/any: Likewise. * include/experimental/array: Likewise. * include/experimental/bits/erase_if.h: Likewise. * include/experimental/bits/lfts_config.h: Likewise. * include/experimental/bits/shared_ptr.h: Likewise. * include/experimental/bits/string_view.tcc: Likewise. * include/experimental/chrono: Likewise. * include/experimental/deque: Likewise. * include/experimental/filesystem: Do not include <c++0x_warning.h>. * include/experimental/forward_list: Do not include <c++14_warning.h>. * include/experimental/functional: Likewise. * include/experimental/iterator: Likewise. * include/experimental/list: Likewise. * include/experimental/map: Likewise. * include/experimental/memory: Likewise. * include/experimental/numeric: Likewise. * include/experimental/optional: Likewise. * include/experimental/propagate_const: Likewise. * include/experimental/ratio: Likewise. * include/experimental/regex: Likewise. * include/experimental/set: Likewise. * include/experimental/string: Likewise. * include/experimental/string_view: Likewise. * include/experimental/system_error: Likewise. * include/experimental/tuple: Likewise. * include/experimental/type_traits: Likewise. * include/experimental/unordered_map: Likewise. * include/experimental/unordered_set: Likewise. * include/experimental/vector: Likewise. * testsuite/experimental/any/misc/any_cast_neg.cc: Adjust dg-error line number. * testsuite/experimental/array/neg.cc: Likewise. * testsuite/experimental/propagate_const/assignment/move_neg.cc: Likewise. * testsuite/experimental/propagate_const/cons/move_neg.cc: Likewise. * testsuite/experimental/propagate_const/requirements2.cc: Likewise. * testsuite/experimental/propagate_const/requirements3.cc: Likewise. * testsuite/experimental/propagate_const/requirements4.cc: Likewise. * testsuite/experimental/propagate_const/requirements5.cc: Likewise. From-SVN: r252019
2017-09-12 16:03:06 +02:00
#if __cplusplus >= 201402L
2015-07-03 16:08:37 +02:00
#include <type_traits>
Avoid #include <functional> in other headers * include/bits/shared_ptr_base.h: Include <functional>. [!__cpp_rtti]: Do not include <typeinfo>. * include/experimental/array: Do not include <functional>. * include/experimental/memory: Include <bits/functional_hash.h> instead of <functional>. * include/experimental/propagate_const: Include <bits/stl_function.h>, <bits/functional_hash.h>, and <bits/move.h> instead of <functional>. * include/experimental/tuple: Do not include <functional>. * include/std/future: Include <functional>. * include/std/memory: Do not include <functional>. * include/std/mutex: [_GLIBCXX_HAVE_TLS]: Likewise. * testsuite/20_util/shared_ptr/thread/default_weaktoshared.cc: Add missing includes. * testsuite/20_util/shared_ptr/thread/mutex_weaktoshared.cc: Likewise. * testsuite/20_util/specialized_algorithms/memory_management_tools/ 1.cc: Likewise. * testsuite/30_threads/call_once/60497.cc: Likewise. * testsuite/30_threads/lock/2.cc: Likewise. * testsuite/30_threads/thread/native_handle/cancel.cc: Likewise. * testsuite/experimental/algorithm/sample.cc: Likewise. * testsuite/experimental/array/make_array.cc: Likewise. * testsuite/experimental/array/neg.cc: Likewise. Adjust dg-error line. * testsuite/experimental/propagate_const/assignment/move_neg.cc: Adjust dg-error lines. * testsuite/experimental/propagate_const/cons/move_neg.cc: Likewise. * testsuite/experimental/propagate_const/requirements2.cc: Likewise. * testsuite/experimental/propagate_const/requirements3.cc: Likewise. * testsuite/experimental/propagate_const/requirements4.cc: Likewise. * testsuite/experimental/propagate_const/requirements5.cc: Likewise. From-SVN: r241131
2016-10-13 18:59:19 +02:00
#include <bits/functional_hash.h>
#include <bits/move.h>
#include <bits/stl_function.h>
Fix libstdc++ versioned namespace build PR libstdc++/68323 PR libstdc++/77794 * config/abi/pre/gnu-versioned-namespace.ver: Add exports for __cxa_thread_atexit and __gnu_cxx::__freeres. * include/Makefile.am: Add <experimental/bits/lfts_config.h> * include/Makefile.in: Regenerate. * include.bits/basic_string.h: Fix nesting of versioned namespaces. * include/bits/c++config: Declare versioned namespaces for literals. * include/bits/regex.h (basic_regex, match_results): Add workarounds for PR c++/59256. * include/bits/uniform_int_dist.h: Fix nesting of versioned namespace. * include/std/chrono: Likewise. * include/std/complex: Likewise. * include/std/string_view: Likewise. * include/std/variant: Likewise. Add workaround for PR c++/59256. * include/experimental/bits/fs_fwd.h: Declare versioned namespace. * include/experimental/bits/lfts_config.h: Declare versioned namespaces. * include/experimental/algorithm: Include <experimental/bits/lfts_config.h>. * include/experimental/any: Likewise. * include/experimental/bits/erase_if.h: Likewise. * include/experimental/chrono: Likewise. * include/experimental/functional: Likewise. * include/experimental/memory_resource: Likewise. * include/experimental/optional: Likewise. * include/experimental/propagate_const: Likewise. * include/experimental/random: Likewise. * include/experimental/ratio: Likewise. * include/experimental/system_error: Likewise. * include/experimental/tuple: Likewise. * include/experimental/type_traits: Likewise. * include/experimental/utility: Likewise. * include/experimental/string_view: Likewise. Fix nesting of versioned namespaces. * include/experimental/bits/string_view.tcc: Reopen inline namespace for non-inline function definitions. * testsuite/17_intro/using_namespace_std_exp_neg.cc: New test. * testsuite/20_util/duration/literals/range.cc: Adjust dg-error line. * testsuite/experimental/any/misc/any_cast_neg.cc: Likewise. * testsuite/experimental/propagate_const/assignment/move_neg.cc: Likewise. * testsuite/experimental/propagate_const/cons/move_neg.cc: Likewise. * testsuite/experimental/propagate_const/requirements2.cc: Likewise. * testsuite/experimental/propagate_const/requirements3.cc: Likewise. * testsuite/experimental/propagate_const/requirements4.cc: Likewise. * testsuite/experimental/propagate_const/requirements5.cc: Likewise. * testsuite/ext/profile/mutex_extensions_neg.cc: Likewise. From-SVN: r240714
2016-10-03 16:35:28 +02:00
#include <experimental/bits/lfts_config.h>
2015-07-03 16:08:37 +02:00
namespace std _GLIBCXX_VISIBILITY(default)
{
re PR libstdc++/81064 (Inline namespace regression) 2017-07-23 François Dumont <fdumont@gcc.gnu.org> PR libstdc++/81064 * include/bits/algorithmfwd.h: Reorganize versioned namespace. * include/bits/basic_string.h: Likewise. * include/bits/c++config: Likewise. * include/bits/deque.tcc: Likewise. * include/bits/forward_list.h: Likewise. * include/bits/forward_list.tcc: Likewise. * include/bits/hashtable_policy.h: Likewise. * include/bits/list.tcc: Likewise. * include/bits/move.h: Likewise. * include/bits/quoted_string.h: Likewise. * include/bits/random.h: Likewise. * include/bits/random.tcc: Likewise. * include/bits/regex.h: Likewise. * include/bits/regex.tcc: Likewise. * include/bits/regex_automaton.h: Likewise. * include/bits/regex_automaton.tcc: Likewise. * include/bits/regex_compiler.h: Likewise. * include/bits/regex_compiler.tcc: Likewise. * include/bits/regex_constants.h: Likewise. * include/bits/regex_error.h: Likewise. * include/bits/regex_executor.h: Likewise. * include/bits/regex_executor.tcc: Likewise. * include/bits/regex_scanner.h: Likewise. * include/bits/regex_scanner.tcc: Likewise. * include/bits/specfun.h: Likewise. * include/bits/stl_algo.h: Likewise. * include/bits/stl_algobase.h: Likewise. * include/bits/stl_bvector.h: Likewise. * include/bits/stl_deque.h: Likewise. * include/bits/stl_iterator.h: Likewise. * include/bits/stl_iterator_base_funcs.h: Likewise. * include/bits/stl_list.h: Likewise. * include/bits/stl_map.h: Likewise. * include/bits/stl_multimap.h: Likewise. * include/bits/stl_multiset.h: Likewise. * include/bits/stl_relops.h: Likewise. * include/bits/stl_set.h: Likewise. * include/bits/stl_vector.h: Likewise. * include/bits/uniform_int_dist.h: Likewise. * include/bits/unordered_map.h: Likewise. * include/bits/unordered_set.h: Likewise. * include/bits/vector.tcc: Likewise. * include/c_global/cmath: Likewise. * include/c_std/cmath: Likewise. * include/decimal/decimal: Likewise. * include/decimal/decimal.h: Likewise. * include/experimental/algorithm: Likewise. * include/experimental/any: Likewise. * include/experimental/array: Likewise. * include/experimental/bits/erase_if.h: Likewise. * include/experimental/bits/fs_dir.h: Likewise. * include/experimental/bits/fs_fwd.h: Likewise. * include/experimental/bits/fs_ops.h: Likewise. * include/experimental/bits/fs_path.h: Likewise. * include/experimental/bits/lfts_config.h: Likewise. * include/experimental/bits/shared_ptr.h: Likewise. * include/experimental/bits/string_view.tcc: Likewise. * include/experimental/chrono: Likewise. * include/experimental/deque: Likewise. * include/experimental/filesystem: Likewise. * include/experimental/forward_list: Likewise. * include/experimental/functional: Likewise. * include/experimental/iterator: Likewise. * include/experimental/list: Likewise. * include/experimental/map: Likewise. * include/experimental/memory: Likewise. * include/experimental/memory_resource: Likewise. * include/experimental/numeric: Likewise. * include/experimental/optional: Likewise. * include/experimental/propagate_const: Likewise. * include/experimental/random: Likewise. * include/experimental/ratio: Likewise. * include/experimental/regex: Likewise. * include/experimental/set: Likewise. * include/experimental/source_location: Likewise. * include/experimental/string: Likewise. * include/experimental/string_view: Likewise. * include/experimental/system_error: Likewise. * include/experimental/tuple: Likewise. * include/experimental/type_traits: Likewise. * include/experimental/unordered_map: Likewise. * include/experimental/unordered_set: Likewise. * include/experimental/utility: Likewise. * include/experimental/vector: Likewise. * include/ext/bitmap_allocator.h: Likewise. * include/ext/codecvt_specializations.h: Likewise. * include/ext/rope: Likewise. * include/ext/typelist.h: Likewise. * include/std/chrono: Likewise. * include/std/complex: Likewise. * include/std/functional: Likewise. * include/std/numeric: Likewise. * include/std/string_view: Likewise. * include/std/thread: Likewise. * include/std/variant: Likewise. * include/tr1/array: Likewise. * include/tr1/bessel_function.tcc: Likewise. * include/tr1/beta_function.tcc: Likewise. * include/tr1/cmath: Likewise. * include/tr1/complex: Likewise. * include/tr1/ell_integral.tcc: Likewise. * include/tr1/exp_integral.tcc: Likewise. * include/tr1/functional: Likewise. * include/tr1/functional_hash.h: Likewise. * include/tr1/gamma.tcc: Likewise. * include/tr1/hashtable.h: Likewise. * include/tr1/hashtable_policy.h: Likewise. * include/tr1/hypergeometric.tcc: Likewise. * include/tr1/legendre_function.tcc: Likewise. * include/tr1/modified_bessel_func.tcc: Likewise. * include/tr1/poly_hermite.tcc: Likewise. * include/tr1/poly_laguerre.tcc: Likewise. * include/tr1/random.h: Likewise. * include/tr1/random.tcc: Likewise. * include/tr1/regex: Likewise. * include/tr1/riemann_zeta.tcc: Likewise. * include/tr1/shared_ptr.h: Likewise. * include/tr1/special_function_util.h: Likewise. * include/tr1/tuple: Likewise. * include/tr1/type_traits: Likewise. * include/tr1/unordered_map.h: Likewise. * include/tr1/unordered_set.h: Likewise. * include/tr1/utility: Likewise. * include/tr2/bool_set: Likewise. * include/tr2/bool_set.tcc: Likewise. * include/tr2/dynamic_bitset: Likewise. * include/tr2/dynamic_bitset.tcc: Likewise. * include/tr2/ratio: Likewise. * include/tr2/type_traits: Likewise. * src/c++11/chrono.cc: Likewise. * src/c++11/compatibility-c++0x.cc: Likewise. * src/c++11/compatibility-chrono.cc: Likewise. * src/c++11/cxx11-shim_facets.cc: Likewise. * src/c++11/hashtable_c++0x.cc: Likewise. * src/c++11/placeholders.cc: Likewise. * src/c++11/thread.cc: Likewise. * src/c++98/bitmap_allocator.cc: Likewise. * src/c++98/hashtable_tr1.cc: Likewise. * src/c++98/list.cc: Likewise. * src/shared/hashtable-aux.cc: Likewise. * testsuite/20_util/duration/literals/range.cc: Adapt line number. * testsuite/20_util/duration/requirements/typedefs_neg1.cc: Likewise. * testsuite/20_util/duration/requirements/typedefs_neg2.cc: Likewise. * testsuite/20_util/duration/requirements/typedefs_neg3.cc: Likewise. * testsuite/20_util/forward/c_neg.cc: Likewise. * testsuite/20_util/forward/f_neg.cc: Likewise. * testsuite/26_numerics/gcd/gcd_neg.cc: Likewise. * testsuite/26_numerics/lcm/lcm_neg.cc: Likewise. * testsuite/26_numerics/random/pr60037-neg.cc: Likewise. * python/libstdcxx/v6/printers.py: Adapt. From-SVN: r250458
2017-07-23 10:41:35 +02:00
_GLIBCXX_BEGIN_NAMESPACE_VERSION
2015-07-03 16:08:37 +02:00
namespace experimental
{
inline namespace fundamentals_v2
{
/**
* @defgroup propagate_const Const-propagating wrapper
Improve docs for Library Fundamentals TS * doc/doxygen/doxygroups.cc: Move description of experimental group here. * include/experimental/algorithm: Add to libfund-ts doc group. * include/experimental/any: Likewise. Do not document implementation details. * include/experimental/array: Add to libfund-ts doc group. * include/experimental/bits/lfts_config.h: Define libfund-ts doc group for Library Fundamentals. * include/experimental/chrono: Add to libfund-ts doc group. * include/experimental/deque: Likewise. * include/experimental/forward_list: Likewise. * include/experimental/functional: Likewise. * include/experimental/iterator: Likewise. * include/experimental/list: Likewise. * include/experimental/map: Likewise. * include/experimental/memory: Likewise. * include/experimental/memory_resource: Likewise. Improve docs. details. * include/experimental/numeric: Add to libfund-ts doc group. * include/experimental/optional: Likewise. * include/experimental/propagate_const: Likewise. * include/experimental/random: Likewise. * include/experimental/ratio: Likewise. * include/experimental/regex: Likewise. * include/experimental/set: Likewise. * include/experimental/source_location: Likewise. * include/experimental/string: Likewise. * include/experimental/string_view: Likewise. * include/experimental/system_error: Likewise. * include/experimental/tuple: Likewise. * include/experimental/type_traits: Likewise. * include/experimental/unordered_map: Likewise. * include/experimental/unordered_set: Likewise. * include/experimental/utility: Likewise. * include/experimental/vector: Likewise. * testsuite/experimental/any/misc/any_cast_neg.cc: Adjust dg-error. * testsuite/experimental/array/neg.cc: Adjust dg-error. * testsuite/experimental/propagate_const/assignment/move_neg.cc: Likewise. * testsuite/experimental/propagate_const/cons/move_neg.cc: Likewise. * testsuite/experimental/propagate_const/requirements2.cc: Likewise. * testsuite/experimental/propagate_const/requirements3.cc: Likewise. * testsuite/experimental/propagate_const/requirements4.cc: Likewise. * testsuite/experimental/propagate_const/requirements5.cc: Likewise. From-SVN: r270809
2019-05-02 17:46:29 +02:00
* @ingroup libfund-ts
2015-07-03 16:08:37 +02:00
*
* A const-propagating wrapper that propagates const to pointer-like members,
* as described in n4388 "A Proposal to Add a Const-Propagating Wrapper
* to the Standard Library".
*
* @{
*/
Improve docs for Library Fundamentals TS * doc/doxygen/doxygroups.cc: Move description of experimental group here. * include/experimental/algorithm: Add to libfund-ts doc group. * include/experimental/any: Likewise. Do not document implementation details. * include/experimental/array: Add to libfund-ts doc group. * include/experimental/bits/lfts_config.h: Define libfund-ts doc group for Library Fundamentals. * include/experimental/chrono: Add to libfund-ts doc group. * include/experimental/deque: Likewise. * include/experimental/forward_list: Likewise. * include/experimental/functional: Likewise. * include/experimental/iterator: Likewise. * include/experimental/list: Likewise. * include/experimental/map: Likewise. * include/experimental/memory: Likewise. * include/experimental/memory_resource: Likewise. Improve docs. details. * include/experimental/numeric: Add to libfund-ts doc group. * include/experimental/optional: Likewise. * include/experimental/propagate_const: Likewise. * include/experimental/random: Likewise. * include/experimental/ratio: Likewise. * include/experimental/regex: Likewise. * include/experimental/set: Likewise. * include/experimental/source_location: Likewise. * include/experimental/string: Likewise. * include/experimental/string_view: Likewise. * include/experimental/system_error: Likewise. * include/experimental/tuple: Likewise. * include/experimental/type_traits: Likewise. * include/experimental/unordered_map: Likewise. * include/experimental/unordered_set: Likewise. * include/experimental/utility: Likewise. * include/experimental/vector: Likewise. * testsuite/experimental/any/misc/any_cast_neg.cc: Adjust dg-error. * testsuite/experimental/array/neg.cc: Adjust dg-error. * testsuite/experimental/propagate_const/assignment/move_neg.cc: Likewise. * testsuite/experimental/propagate_const/cons/move_neg.cc: Likewise. * testsuite/experimental/propagate_const/requirements2.cc: Likewise. * testsuite/experimental/propagate_const/requirements3.cc: Likewise. * testsuite/experimental/propagate_const/requirements4.cc: Likewise. * testsuite/experimental/propagate_const/requirements5.cc: Likewise. From-SVN: r270809
2019-05-02 17:46:29 +02:00
/// Const-propagating wrapper.
2015-07-03 16:08:37 +02:00
template <typename _Tp>
class propagate_const
{
public:
typedef remove_reference_t<decltype(*std::declval<_Tp&>())> element_type;
2015-07-03 16:08:37 +02:00
private:
template <typename _Up>
struct __is_propagate_const : false_type
{ };
template <typename _Up>
struct __is_propagate_const<propagate_const<_Up>> : true_type
{ };
template <typename _Up>
friend constexpr const _Up&
get_underlying(const propagate_const<_Up>& __pt) noexcept;
template <typename _Up>
friend constexpr _Up&
get_underlying(propagate_const<_Up>& __pt) noexcept;
template <typename _Up>
static constexpr element_type*
__to_raw_pointer(_Up* __u)
{ return __u; }
template <typename _Up>
static constexpr element_type*
__to_raw_pointer(_Up& __u)
{ return __u.get(); }
template <typename _Up>
static constexpr const element_type*
__to_raw_pointer(const _Up* __u)
{ return __u; }
template <typename _Up>
static constexpr const element_type*
__to_raw_pointer(const _Up& __u)
{ return __u.get(); }
public:
static_assert(__and_<is_object<typename remove_pointer<_Tp>::type>,
__not_<is_array<_Tp>>,
__or_<is_class<_Tp>, is_pointer<_Tp>>>::value,
"propagate_const requires a class or a pointer to an"
" object type");
// [propagate_const.ctor], constructors
constexpr propagate_const() = default;
propagate_const(const propagate_const& __p) = delete;
constexpr propagate_const(propagate_const&& __p) = default;
template <typename _Up, typename
enable_if<__and_<is_constructible<_Tp, _Up&&>,
is_convertible<_Up&&, _Tp>>::value, bool
>::type=true>
constexpr propagate_const(propagate_const<_Up>&& __pu)
: _M_t(std::move(get_underlying(__pu)))
2015-07-03 16:08:37 +02:00
{}
template <typename _Up, typename
enable_if<__and_<is_constructible<_Tp, _Up&&>,
__not_<is_convertible<_Up&&, _Tp>>>::value,
bool>::type=false>
constexpr explicit propagate_const(propagate_const<_Up>&& __pu)
: _M_t(std::move(get_underlying(__pu)))
2015-07-03 16:08:37 +02:00
{}
template <typename _Up, typename
enable_if<__and_<is_constructible<_Tp, _Up&&>,
is_convertible<_Up&&, _Tp>,
__not_<__is_propagate_const<
typename decay<_Up>::type>>
>::value, bool>::type=true>
constexpr propagate_const(_Up&& __u)
: _M_t(std::forward<_Up>(__u))
2015-07-03 16:08:37 +02:00
{}
template <typename _Up, typename
enable_if<__and_<is_constructible<_Tp, _Up&&>,
__not_<is_convertible<_Up&&, _Tp>>,
__not_<__is_propagate_const<
typename decay<_Up>::type>>
>::value, bool>::type=false>
constexpr explicit propagate_const(_Up&& __u)
: _M_t(std::forward<_Up>(__u))
2015-07-03 16:08:37 +02:00
{}
// [propagate_const.assignment], assignment
propagate_const& operator=(const propagate_const& __p) = delete;
constexpr propagate_const& operator=(propagate_const&& __p) = default;
template <typename _Up, typename =
typename enable_if<is_convertible<_Up&&, _Tp>::value>::type>
constexpr propagate_const& operator=(propagate_const<_Up>&& __pu)
{
_M_t = std::move(get_underlying(__pu));
return *this;
2015-07-03 16:08:37 +02:00
}
template <typename _Up, typename =
typename enable_if<__and_<is_convertible<_Up&&, _Tp>,
__not_<__is_propagate_const<
typename decay<_Up>::type>>
>::value>::type>
constexpr propagate_const& operator=(_Up&& __u)
{
_M_t = std::forward<_Up>(__u);
return *this;
2015-07-03 16:08:37 +02:00
}
// [propagate_const.const_observers], const observers
explicit constexpr operator bool() const
{
return bool(_M_t);
2015-07-03 16:08:37 +02:00
}
constexpr const element_type* operator->() const
{
return get();
}
template <typename _Up = _Tp,
typename enable_if<__or_<is_pointer<_Up>,
is_convertible<_Up,
const element_type*>
>::value, bool>::type = true>
constexpr operator const element_type*() const
{
return get();
}
constexpr const element_type& operator*() const
{
return *get();
}
constexpr const element_type* get() const
{
return __to_raw_pointer(_M_t);
2015-07-03 16:08:37 +02:00
}
// [propagate_const.non_const_observers], non-const observers
constexpr element_type* operator->()
{
return get();
}
template <typename _Up = _Tp,
typename enable_if<__or_<is_pointer<_Up>,
is_convertible<_Up,
const element_type*>
>::value, bool>::type = true>
constexpr operator element_type*()
{
return get();
}
constexpr element_type& operator*()
{
return *get();
}
constexpr element_type* get()
{
return __to_raw_pointer(_M_t);
2015-07-03 16:08:37 +02:00
}
// [propagate_const.modifiers], modifiers
constexpr void
swap(propagate_const& __pt) noexcept(__is_nothrow_swappable<_Tp>::value)
{
using std::swap;
swap(_M_t, get_underlying(__pt));
2015-07-03 16:08:37 +02:00
}
private:
_Tp _M_t;
2015-07-03 16:08:37 +02:00
};
// [propagate_const.relational], relational operators
template <typename _Tp>
constexpr bool
operator==(const propagate_const<_Tp>& __pt, nullptr_t)
{
return get_underlying(__pt) == nullptr;
}
template <typename _Tp>
constexpr bool
operator==(nullptr_t, const propagate_const<_Tp>& __pu)
{
return nullptr == get_underlying(__pu);
}
template <typename _Tp>
constexpr bool
operator!=(const propagate_const<_Tp>& __pt, nullptr_t)
{
return get_underlying(__pt) != nullptr;
}
template <typename _Tp>
constexpr bool operator!=(nullptr_t, const propagate_const<_Tp>& __pu)
{
return nullptr != get_underlying(__pu);
}
template <typename _Tp, typename _Up>
constexpr bool
operator==(const propagate_const<_Tp>& __pt,
const propagate_const<_Up>& __pu)
{
return get_underlying(__pt) == get_underlying(__pu);
}
template <typename _Tp, typename _Up>
constexpr bool
operator!=(const propagate_const<_Tp>& __pt,
const propagate_const<_Up>& __pu)
{
return get_underlying(__pt) != get_underlying(__pu);
}
template <typename _Tp, typename _Up>
constexpr bool
operator<(const propagate_const<_Tp>& __pt,
const propagate_const<_Up>& __pu)
{
return get_underlying(__pt) < get_underlying(__pu);
}
template <typename _Tp, typename _Up>
constexpr bool
operator>(const propagate_const<_Tp>& __pt,
const propagate_const<_Up>& __pu)
{
return get_underlying(__pt) > get_underlying(__pu);
}
template <typename _Tp, typename _Up>
constexpr bool
operator<=(const propagate_const<_Tp>& __pt,
const propagate_const<_Up>& __pu)
{
return get_underlying(__pt) <= get_underlying(__pu);
}
template <typename _Tp, typename _Up>
constexpr bool
operator>=(const propagate_const<_Tp>& __pt,
const propagate_const<_Up>& __pu)
{
return get_underlying(__pt) >= get_underlying(__pu);
}
template <typename _Tp, typename _Up>
constexpr bool
operator==(const propagate_const<_Tp>& __pt, const _Up& __u)
{
return get_underlying(__pt) == __u;
}
template <typename _Tp, typename _Up>
constexpr bool
operator!=(const propagate_const<_Tp>& __pt, const _Up& __u)
{
return get_underlying(__pt) != __u;
}
template <typename _Tp, typename _Up>
constexpr bool
operator<(const propagate_const<_Tp>& __pt, const _Up& __u)
{
return get_underlying(__pt) < __u;
}
template <typename _Tp, typename _Up>
constexpr bool
operator>(const propagate_const<_Tp>& __pt, const _Up& __u)
{
return get_underlying(__pt) > __u;
}
template <typename _Tp, typename _Up>
constexpr bool
operator<=(const propagate_const<_Tp>& __pt, const _Up& __u)
{
return get_underlying(__pt) <= __u;
}
template <typename _Tp, typename _Up>
constexpr bool
operator>=(const propagate_const<_Tp>& __pt, const _Up& __u)
{
return get_underlying(__pt) >= __u;
}
template <typename _Tp, typename _Up>
constexpr bool
operator==(const _Tp& __t, const propagate_const<_Up>& __pu)
{
return __t == get_underlying(__pu);
}
template <typename _Tp, typename _Up>
constexpr bool
operator!=(const _Tp& __t, const propagate_const<_Up>& __pu)
{
return __t != get_underlying(__pu);
}
template <typename _Tp, typename _Up>
constexpr bool
operator<(const _Tp& __t, const propagate_const<_Up>& __pu)
{
return __t < get_underlying(__pu);
}
template <typename _Tp, typename _Up>
constexpr bool
operator>(const _Tp& __t, const propagate_const<_Up>& __pu)
{
return __t > get_underlying(__pu);
}
template <typename _Tp, typename _Up>
constexpr bool
operator<=(const _Tp& __t, const propagate_const<_Up>& __pu)
{
return __t <= get_underlying(__pu);
}
template <typename _Tp, typename _Up>
constexpr bool
operator>=(const _Tp& __t, const propagate_const<_Up>& __pu)
{
return __t >= get_underlying(__pu);
}
// [propagate_const.algorithms], specialized algorithms
template <typename _Tp>
constexpr void
swap(propagate_const<_Tp>& __pt, propagate_const<_Tp>& __pt2)
noexcept(__is_nothrow_swappable<_Tp>::value)
{
__pt.swap(__pt2);
}
// [propagate_const.underlying], underlying pointer access
template <typename _Tp>
constexpr const _Tp&
get_underlying(const propagate_const<_Tp>& __pt) noexcept
{
return __pt._M_t;
2015-07-03 16:08:37 +02:00
}
template <typename _Tp>
constexpr _Tp&
get_underlying(propagate_const<_Tp>& __pt) noexcept
{
return __pt._M_t;
2015-07-03 16:08:37 +02:00
}
// @} group propagate_const
} // namespace fundamentals_v2
} // namespace experimental
// [propagate_const.hash], hash support
template <typename _Tp>
struct hash<experimental::propagate_const<_Tp>>
{
using result_type = size_t;
using argument_type = experimental::propagate_const<_Tp>;
size_t
operator()(const experimental::propagate_const<_Tp>& __t) const
noexcept(noexcept(hash<_Tp>{}(get_underlying(__t))))
{
return hash<_Tp>{}(get_underlying(__t));
}
};
// [propagate_const.comparison_function_objects], comparison function objects
template <typename _Tp>
struct equal_to<experimental::propagate_const<_Tp>>
{
constexpr bool
operator()(const experimental::propagate_const<_Tp>& __x,
const experimental::propagate_const<_Tp>& __y) const
{
return equal_to<_Tp>{}(get_underlying(__x), get_underlying(__y));
}
typedef experimental::propagate_const<_Tp> first_argument_type;
typedef experimental::propagate_const<_Tp> second_argument_type;
typedef bool result_type;
};
template <typename _Tp>
struct not_equal_to<experimental::propagate_const<_Tp>>
{
constexpr bool
operator()(const experimental::propagate_const<_Tp>& __x,
const experimental::propagate_const<_Tp>& __y) const
{
return not_equal_to<_Tp>{}(get_underlying(__x), get_underlying(__y));
}
typedef experimental::propagate_const<_Tp> first_argument_type;
typedef experimental::propagate_const<_Tp> second_argument_type;
typedef bool result_type;
};
template <typename _Tp>
struct less<experimental::propagate_const<_Tp>>
{
constexpr bool
operator()(const experimental::propagate_const<_Tp>& __x,
const experimental::propagate_const<_Tp>& __y) const
{
return less<_Tp>{}(get_underlying(__x), get_underlying(__y));
}
typedef experimental::propagate_const<_Tp> first_argument_type;
typedef experimental::propagate_const<_Tp> second_argument_type;
typedef bool result_type;
};
template <typename _Tp>
struct greater<experimental::propagate_const<_Tp>>
{
constexpr bool
operator()(const experimental::propagate_const<_Tp>& __x,
const experimental::propagate_const<_Tp>& __y) const
{
return greater<_Tp>{}(get_underlying(__x), get_underlying(__y));
}
typedef experimental::propagate_const<_Tp> first_argument_type;
typedef experimental::propagate_const<_Tp> second_argument_type;
typedef bool result_type;
};
template <typename _Tp>
struct less_equal<experimental::propagate_const<_Tp>>
{
constexpr bool
operator()(const experimental::propagate_const<_Tp>& __x,
const experimental::propagate_const<_Tp>& __y) const
{
return less_equal<_Tp>{}(get_underlying(__x), get_underlying(__y));
}
typedef experimental::propagate_const<_Tp> first_argument_type;
typedef experimental::propagate_const<_Tp> second_argument_type;
typedef bool result_type;
};
template <typename _Tp>
struct greater_equal<experimental::propagate_const<_Tp>>
{
constexpr bool
operator()(const experimental::propagate_const<_Tp>& __x,
const experimental::propagate_const<_Tp>& __y) const
{
return greater_equal<_Tp>{}(get_underlying(__x), get_underlying(__y));
}
typedef experimental::propagate_const<_Tp> first_argument_type;
typedef experimental::propagate_const<_Tp> second_argument_type;
typedef bool result_type;
};
re PR libstdc++/81064 (Inline namespace regression) 2017-07-23 François Dumont <fdumont@gcc.gnu.org> PR libstdc++/81064 * include/bits/algorithmfwd.h: Reorganize versioned namespace. * include/bits/basic_string.h: Likewise. * include/bits/c++config: Likewise. * include/bits/deque.tcc: Likewise. * include/bits/forward_list.h: Likewise. * include/bits/forward_list.tcc: Likewise. * include/bits/hashtable_policy.h: Likewise. * include/bits/list.tcc: Likewise. * include/bits/move.h: Likewise. * include/bits/quoted_string.h: Likewise. * include/bits/random.h: Likewise. * include/bits/random.tcc: Likewise. * include/bits/regex.h: Likewise. * include/bits/regex.tcc: Likewise. * include/bits/regex_automaton.h: Likewise. * include/bits/regex_automaton.tcc: Likewise. * include/bits/regex_compiler.h: Likewise. * include/bits/regex_compiler.tcc: Likewise. * include/bits/regex_constants.h: Likewise. * include/bits/regex_error.h: Likewise. * include/bits/regex_executor.h: Likewise. * include/bits/regex_executor.tcc: Likewise. * include/bits/regex_scanner.h: Likewise. * include/bits/regex_scanner.tcc: Likewise. * include/bits/specfun.h: Likewise. * include/bits/stl_algo.h: Likewise. * include/bits/stl_algobase.h: Likewise. * include/bits/stl_bvector.h: Likewise. * include/bits/stl_deque.h: Likewise. * include/bits/stl_iterator.h: Likewise. * include/bits/stl_iterator_base_funcs.h: Likewise. * include/bits/stl_list.h: Likewise. * include/bits/stl_map.h: Likewise. * include/bits/stl_multimap.h: Likewise. * include/bits/stl_multiset.h: Likewise. * include/bits/stl_relops.h: Likewise. * include/bits/stl_set.h: Likewise. * include/bits/stl_vector.h: Likewise. * include/bits/uniform_int_dist.h: Likewise. * include/bits/unordered_map.h: Likewise. * include/bits/unordered_set.h: Likewise. * include/bits/vector.tcc: Likewise. * include/c_global/cmath: Likewise. * include/c_std/cmath: Likewise. * include/decimal/decimal: Likewise. * include/decimal/decimal.h: Likewise. * include/experimental/algorithm: Likewise. * include/experimental/any: Likewise. * include/experimental/array: Likewise. * include/experimental/bits/erase_if.h: Likewise. * include/experimental/bits/fs_dir.h: Likewise. * include/experimental/bits/fs_fwd.h: Likewise. * include/experimental/bits/fs_ops.h: Likewise. * include/experimental/bits/fs_path.h: Likewise. * include/experimental/bits/lfts_config.h: Likewise. * include/experimental/bits/shared_ptr.h: Likewise. * include/experimental/bits/string_view.tcc: Likewise. * include/experimental/chrono: Likewise. * include/experimental/deque: Likewise. * include/experimental/filesystem: Likewise. * include/experimental/forward_list: Likewise. * include/experimental/functional: Likewise. * include/experimental/iterator: Likewise. * include/experimental/list: Likewise. * include/experimental/map: Likewise. * include/experimental/memory: Likewise. * include/experimental/memory_resource: Likewise. * include/experimental/numeric: Likewise. * include/experimental/optional: Likewise. * include/experimental/propagate_const: Likewise. * include/experimental/random: Likewise. * include/experimental/ratio: Likewise. * include/experimental/regex: Likewise. * include/experimental/set: Likewise. * include/experimental/source_location: Likewise. * include/experimental/string: Likewise. * include/experimental/string_view: Likewise. * include/experimental/system_error: Likewise. * include/experimental/tuple: Likewise. * include/experimental/type_traits: Likewise. * include/experimental/unordered_map: Likewise. * include/experimental/unordered_set: Likewise. * include/experimental/utility: Likewise. * include/experimental/vector: Likewise. * include/ext/bitmap_allocator.h: Likewise. * include/ext/codecvt_specializations.h: Likewise. * include/ext/rope: Likewise. * include/ext/typelist.h: Likewise. * include/std/chrono: Likewise. * include/std/complex: Likewise. * include/std/functional: Likewise. * include/std/numeric: Likewise. * include/std/string_view: Likewise. * include/std/thread: Likewise. * include/std/variant: Likewise. * include/tr1/array: Likewise. * include/tr1/bessel_function.tcc: Likewise. * include/tr1/beta_function.tcc: Likewise. * include/tr1/cmath: Likewise. * include/tr1/complex: Likewise. * include/tr1/ell_integral.tcc: Likewise. * include/tr1/exp_integral.tcc: Likewise. * include/tr1/functional: Likewise. * include/tr1/functional_hash.h: Likewise. * include/tr1/gamma.tcc: Likewise. * include/tr1/hashtable.h: Likewise. * include/tr1/hashtable_policy.h: Likewise. * include/tr1/hypergeometric.tcc: Likewise. * include/tr1/legendre_function.tcc: Likewise. * include/tr1/modified_bessel_func.tcc: Likewise. * include/tr1/poly_hermite.tcc: Likewise. * include/tr1/poly_laguerre.tcc: Likewise. * include/tr1/random.h: Likewise. * include/tr1/random.tcc: Likewise. * include/tr1/regex: Likewise. * include/tr1/riemann_zeta.tcc: Likewise. * include/tr1/shared_ptr.h: Likewise. * include/tr1/special_function_util.h: Likewise. * include/tr1/tuple: Likewise. * include/tr1/type_traits: Likewise. * include/tr1/unordered_map.h: Likewise. * include/tr1/unordered_set.h: Likewise. * include/tr1/utility: Likewise. * include/tr2/bool_set: Likewise. * include/tr2/bool_set.tcc: Likewise. * include/tr2/dynamic_bitset: Likewise. * include/tr2/dynamic_bitset.tcc: Likewise. * include/tr2/ratio: Likewise. * include/tr2/type_traits: Likewise. * src/c++11/chrono.cc: Likewise. * src/c++11/compatibility-c++0x.cc: Likewise. * src/c++11/compatibility-chrono.cc: Likewise. * src/c++11/cxx11-shim_facets.cc: Likewise. * src/c++11/hashtable_c++0x.cc: Likewise. * src/c++11/placeholders.cc: Likewise. * src/c++11/thread.cc: Likewise. * src/c++98/bitmap_allocator.cc: Likewise. * src/c++98/hashtable_tr1.cc: Likewise. * src/c++98/list.cc: Likewise. * src/shared/hashtable-aux.cc: Likewise. * testsuite/20_util/duration/literals/range.cc: Adapt line number. * testsuite/20_util/duration/requirements/typedefs_neg1.cc: Likewise. * testsuite/20_util/duration/requirements/typedefs_neg2.cc: Likewise. * testsuite/20_util/duration/requirements/typedefs_neg3.cc: Likewise. * testsuite/20_util/forward/c_neg.cc: Likewise. * testsuite/20_util/forward/f_neg.cc: Likewise. * testsuite/26_numerics/gcd/gcd_neg.cc: Likewise. * testsuite/26_numerics/lcm/lcm_neg.cc: Likewise. * testsuite/26_numerics/random/pr60037-neg.cc: Likewise. * python/libstdcxx/v6/printers.py: Adapt. From-SVN: r250458
2017-07-23 10:41:35 +02:00
_GLIBCXX_END_NAMESPACE_VERSION
2015-07-03 16:08:37 +02:00
} // namespace std
#endif // C++14
#endif // _GLIBCXX_EXPERIMENTAL_PROPAGATE_CONST