mirror of
https://github.com/red0124/ssp.git
synced 2025-01-23 13:05:20 +01:00
try ubuntu icc pipeline
This commit is contained in:
parent
62e01561b2
commit
bb9c6a625e
@ -1,40 +0,0 @@
|
|||||||
/* Copyright (C) 1992-2020 Free Software Foundation, Inc.
|
|
||||||
This file is part of the GNU C Library.
|
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2.1 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
The GNU C 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
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with the GNU C Library; if not, see
|
|
||||||
<https://www.gnu.org/licenses/>. */
|
|
||||||
|
|
||||||
#ifndef _ALLOCA_H
|
|
||||||
#define _ALLOCA_H 1
|
|
||||||
|
|
||||||
#include <features.h>
|
|
||||||
|
|
||||||
#define __need_size_t
|
|
||||||
#include <stddef.h>
|
|
||||||
|
|
||||||
__BEGIN_DECLS
|
|
||||||
|
|
||||||
/* Remove any previous definitions. */
|
|
||||||
#undef alloca
|
|
||||||
|
|
||||||
/* Allocate a block that will be freed when the calling function exits. */
|
|
||||||
extern void *alloca (size_t __size) __THROW;
|
|
||||||
|
|
||||||
#ifdef __GNUC__
|
|
||||||
# define alloca(size) __builtin_alloca (size)
|
|
||||||
#endif /* GCC. */
|
|
||||||
|
|
||||||
__END_DECLS
|
|
||||||
|
|
||||||
#endif /* alloca.h */
|
|
Binary file not shown.
@ -1,40 +0,0 @@
|
|||||||
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
|
|
||||||
#ifndef _ASM_GENERIC_ERRNO_BASE_H
|
|
||||||
#define _ASM_GENERIC_ERRNO_BASE_H
|
|
||||||
|
|
||||||
#define EPERM 1 /* Operation not permitted */
|
|
||||||
#define ENOENT 2 /* No such file or directory */
|
|
||||||
#define ESRCH 3 /* No such process */
|
|
||||||
#define EINTR 4 /* Interrupted system call */
|
|
||||||
#define EIO 5 /* I/O error */
|
|
||||||
#define ENXIO 6 /* No such device or address */
|
|
||||||
#define E2BIG 7 /* Argument list too long */
|
|
||||||
#define ENOEXEC 8 /* Exec format error */
|
|
||||||
#define EBADF 9 /* Bad file number */
|
|
||||||
#define ECHILD 10 /* No child processes */
|
|
||||||
#define EAGAIN 11 /* Try again */
|
|
||||||
#define ENOMEM 12 /* Out of memory */
|
|
||||||
#define EACCES 13 /* Permission denied */
|
|
||||||
#define EFAULT 14 /* Bad address */
|
|
||||||
#define ENOTBLK 15 /* Block device required */
|
|
||||||
#define EBUSY 16 /* Device or resource busy */
|
|
||||||
#define EEXIST 17 /* File exists */
|
|
||||||
#define EXDEV 18 /* Cross-device link */
|
|
||||||
#define ENODEV 19 /* No such device */
|
|
||||||
#define ENOTDIR 20 /* Not a directory */
|
|
||||||
#define EISDIR 21 /* Is a directory */
|
|
||||||
#define EINVAL 22 /* Invalid argument */
|
|
||||||
#define ENFILE 23 /* File table overflow */
|
|
||||||
#define EMFILE 24 /* Too many open files */
|
|
||||||
#define ENOTTY 25 /* Not a typewriter */
|
|
||||||
#define ETXTBSY 26 /* Text file busy */
|
|
||||||
#define EFBIG 27 /* File too large */
|
|
||||||
#define ENOSPC 28 /* No space left on device */
|
|
||||||
#define ESPIPE 29 /* Illegal seek */
|
|
||||||
#define EROFS 30 /* Read-only file system */
|
|
||||||
#define EMLINK 31 /* Too many links */
|
|
||||||
#define EPIPE 32 /* Broken pipe */
|
|
||||||
#define EDOM 33 /* Math argument out of domain of func */
|
|
||||||
#define ERANGE 34 /* Math result not representable */
|
|
||||||
|
|
||||||
#endif
|
|
Binary file not shown.
@ -1,123 +0,0 @@
|
|||||||
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
|
|
||||||
#ifndef _ASM_GENERIC_ERRNO_H
|
|
||||||
#define _ASM_GENERIC_ERRNO_H
|
|
||||||
|
|
||||||
#include <asm-generic/errno-base.h>
|
|
||||||
|
|
||||||
#define EDEADLK 35 /* Resource deadlock would occur */
|
|
||||||
#define ENAMETOOLONG 36 /* File name too long */
|
|
||||||
#define ENOLCK 37 /* No record locks available */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This error code is special: arch syscall entry code will return
|
|
||||||
* -ENOSYS if users try to call a syscall that doesn't exist. To keep
|
|
||||||
* failures of syscalls that really do exist distinguishable from
|
|
||||||
* failures due to attempts to use a nonexistent syscall, syscall
|
|
||||||
* implementations should refrain from returning -ENOSYS.
|
|
||||||
*/
|
|
||||||
#define ENOSYS 38 /* Invalid system call number */
|
|
||||||
|
|
||||||
#define ENOTEMPTY 39 /* Directory not empty */
|
|
||||||
#define ELOOP 40 /* Too many symbolic links encountered */
|
|
||||||
#define EWOULDBLOCK EAGAIN /* Operation would block */
|
|
||||||
#define ENOMSG 42 /* No message of desired type */
|
|
||||||
#define EIDRM 43 /* Identifier removed */
|
|
||||||
#define ECHRNG 44 /* Channel number out of range */
|
|
||||||
#define EL2NSYNC 45 /* Level 2 not synchronized */
|
|
||||||
#define EL3HLT 46 /* Level 3 halted */
|
|
||||||
#define EL3RST 47 /* Level 3 reset */
|
|
||||||
#define ELNRNG 48 /* Link number out of range */
|
|
||||||
#define EUNATCH 49 /* Protocol driver not attached */
|
|
||||||
#define ENOCSI 50 /* No CSI structure available */
|
|
||||||
#define EL2HLT 51 /* Level 2 halted */
|
|
||||||
#define EBADE 52 /* Invalid exchange */
|
|
||||||
#define EBADR 53 /* Invalid request descriptor */
|
|
||||||
#define EXFULL 54 /* Exchange full */
|
|
||||||
#define ENOANO 55 /* No anode */
|
|
||||||
#define EBADRQC 56 /* Invalid request code */
|
|
||||||
#define EBADSLT 57 /* Invalid slot */
|
|
||||||
|
|
||||||
#define EDEADLOCK EDEADLK
|
|
||||||
|
|
||||||
#define EBFONT 59 /* Bad font file format */
|
|
||||||
#define ENOSTR 60 /* Device not a stream */
|
|
||||||
#define ENODATA 61 /* No data available */
|
|
||||||
#define ETIME 62 /* Timer expired */
|
|
||||||
#define ENOSR 63 /* Out of streams resources */
|
|
||||||
#define ENONET 64 /* Machine is not on the network */
|
|
||||||
#define ENOPKG 65 /* Package not installed */
|
|
||||||
#define EREMOTE 66 /* Object is remote */
|
|
||||||
#define ENOLINK 67 /* Link has been severed */
|
|
||||||
#define EADV 68 /* Advertise error */
|
|
||||||
#define ESRMNT 69 /* Srmount error */
|
|
||||||
#define ECOMM 70 /* Communication error on send */
|
|
||||||
#define EPROTO 71 /* Protocol error */
|
|
||||||
#define EMULTIHOP 72 /* Multihop attempted */
|
|
||||||
#define EDOTDOT 73 /* RFS specific error */
|
|
||||||
#define EBADMSG 74 /* Not a data message */
|
|
||||||
#define EOVERFLOW 75 /* Value too large for defined data type */
|
|
||||||
#define ENOTUNIQ 76 /* Name not unique on network */
|
|
||||||
#define EBADFD 77 /* File descriptor in bad state */
|
|
||||||
#define EREMCHG 78 /* Remote address changed */
|
|
||||||
#define ELIBACC 79 /* Can not access a needed shared library */
|
|
||||||
#define ELIBBAD 80 /* Accessing a corrupted shared library */
|
|
||||||
#define ELIBSCN 81 /* .lib section in a.out corrupted */
|
|
||||||
#define ELIBMAX 82 /* Attempting to link in too many shared libraries */
|
|
||||||
#define ELIBEXEC 83 /* Cannot exec a shared library directly */
|
|
||||||
#define EILSEQ 84 /* Illegal byte sequence */
|
|
||||||
#define ERESTART 85 /* Interrupted system call should be restarted */
|
|
||||||
#define ESTRPIPE 86 /* Streams pipe error */
|
|
||||||
#define EUSERS 87 /* Too many users */
|
|
||||||
#define ENOTSOCK 88 /* Socket operation on non-socket */
|
|
||||||
#define EDESTADDRREQ 89 /* Destination address required */
|
|
||||||
#define EMSGSIZE 90 /* Message too long */
|
|
||||||
#define EPROTOTYPE 91 /* Protocol wrong type for socket */
|
|
||||||
#define ENOPROTOOPT 92 /* Protocol not available */
|
|
||||||
#define EPROTONOSUPPORT 93 /* Protocol not supported */
|
|
||||||
#define ESOCKTNOSUPPORT 94 /* Socket type not supported */
|
|
||||||
#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */
|
|
||||||
#define EPFNOSUPPORT 96 /* Protocol family not supported */
|
|
||||||
#define EAFNOSUPPORT 97 /* Address family not supported by protocol */
|
|
||||||
#define EADDRINUSE 98 /* Address already in use */
|
|
||||||
#define EADDRNOTAVAIL 99 /* Cannot assign requested address */
|
|
||||||
#define ENETDOWN 100 /* Network is down */
|
|
||||||
#define ENETUNREACH 101 /* Network is unreachable */
|
|
||||||
#define ENETRESET 102 /* Network dropped connection because of reset */
|
|
||||||
#define ECONNABORTED 103 /* Software caused connection abort */
|
|
||||||
#define ECONNRESET 104 /* Connection reset by peer */
|
|
||||||
#define ENOBUFS 105 /* No buffer space available */
|
|
||||||
#define EISCONN 106 /* Transport endpoint is already connected */
|
|
||||||
#define ENOTCONN 107 /* Transport endpoint is not connected */
|
|
||||||
#define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */
|
|
||||||
#define ETOOMANYREFS 109 /* Too many references: cannot splice */
|
|
||||||
#define ETIMEDOUT 110 /* Connection timed out */
|
|
||||||
#define ECONNREFUSED 111 /* Connection refused */
|
|
||||||
#define EHOSTDOWN 112 /* Host is down */
|
|
||||||
#define EHOSTUNREACH 113 /* No route to host */
|
|
||||||
#define EALREADY 114 /* Operation already in progress */
|
|
||||||
#define EINPROGRESS 115 /* Operation now in progress */
|
|
||||||
#define ESTALE 116 /* Stale file handle */
|
|
||||||
#define EUCLEAN 117 /* Structure needs cleaning */
|
|
||||||
#define ENOTNAM 118 /* Not a XENIX named type file */
|
|
||||||
#define ENAVAIL 119 /* No XENIX semaphores available */
|
|
||||||
#define EISNAM 120 /* Is a named type file */
|
|
||||||
#define EREMOTEIO 121 /* Remote I/O error */
|
|
||||||
#define EDQUOT 122 /* Quota exceeded */
|
|
||||||
|
|
||||||
#define ENOMEDIUM 123 /* No medium found */
|
|
||||||
#define EMEDIUMTYPE 124 /* Wrong medium type */
|
|
||||||
#define ECANCELED 125 /* Operation Canceled */
|
|
||||||
#define ENOKEY 126 /* Required key not available */
|
|
||||||
#define EKEYEXPIRED 127 /* Key has expired */
|
|
||||||
#define EKEYREVOKED 128 /* Key has been revoked */
|
|
||||||
#define EKEYREJECTED 129 /* Key was rejected by service */
|
|
||||||
|
|
||||||
/* for robust mutexes */
|
|
||||||
#define EOWNERDEAD 130 /* Owner died */
|
|
||||||
#define ENOTRECOVERABLE 131 /* State not recoverable */
|
|
||||||
|
|
||||||
#define ERFKILL 132 /* Operation not possible due to RF-kill */
|
|
||||||
|
|
||||||
#define EHWPOISON 133 /* Memory page has hardware error */
|
|
||||||
|
|
||||||
#endif
|
|
Binary file not shown.
@ -1,144 +0,0 @@
|
|||||||
/* Copyright (C) 1991-2020 Free Software Foundation, Inc.
|
|
||||||
This file is part of the GNU C Library.
|
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2.1 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
The GNU C 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
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with the GNU C Library; if not, see
|
|
||||||
<https://www.gnu.org/licenses/>. */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* ISO C99 Standard: 7.2 Diagnostics <assert.h>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef _ASSERT_H
|
|
||||||
|
|
||||||
# undef _ASSERT_H
|
|
||||||
# undef assert
|
|
||||||
# undef __ASSERT_VOID_CAST
|
|
||||||
|
|
||||||
# ifdef __USE_GNU
|
|
||||||
# undef assert_perror
|
|
||||||
# endif
|
|
||||||
|
|
||||||
#endif /* assert.h */
|
|
||||||
|
|
||||||
#define _ASSERT_H 1
|
|
||||||
#include <features.h>
|
|
||||||
|
|
||||||
#if defined __cplusplus && __GNUC_PREREQ (2,95)
|
|
||||||
# define __ASSERT_VOID_CAST static_cast<void>
|
|
||||||
#else
|
|
||||||
# define __ASSERT_VOID_CAST (void)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* void assert (int expression);
|
|
||||||
|
|
||||||
If NDEBUG is defined, do nothing.
|
|
||||||
If not, and EXPRESSION is zero, print an error message and abort. */
|
|
||||||
|
|
||||||
#ifdef NDEBUG
|
|
||||||
|
|
||||||
# define assert(expr) (__ASSERT_VOID_CAST (0))
|
|
||||||
|
|
||||||
/* void assert_perror (int errnum);
|
|
||||||
|
|
||||||
If NDEBUG is defined, do nothing. If not, and ERRNUM is not zero, print an
|
|
||||||
error message with the error text for ERRNUM and abort.
|
|
||||||
(This is a GNU extension.) */
|
|
||||||
|
|
||||||
# ifdef __USE_GNU
|
|
||||||
# define assert_perror(errnum) (__ASSERT_VOID_CAST (0))
|
|
||||||
# endif
|
|
||||||
|
|
||||||
#else /* Not NDEBUG. */
|
|
||||||
|
|
||||||
#ifndef _ASSERT_H_DECLS
|
|
||||||
#define _ASSERT_H_DECLS
|
|
||||||
__BEGIN_DECLS
|
|
||||||
|
|
||||||
/* This prints an "Assertion failed" message and aborts. */
|
|
||||||
extern void __assert_fail (const char *__assertion, const char *__file,
|
|
||||||
unsigned int __line, const char *__function)
|
|
||||||
__THROW __attribute__ ((__noreturn__));
|
|
||||||
|
|
||||||
/* Likewise, but prints the error text for ERRNUM. */
|
|
||||||
extern void __assert_perror_fail (int __errnum, const char *__file,
|
|
||||||
unsigned int __line, const char *__function)
|
|
||||||
__THROW __attribute__ ((__noreturn__));
|
|
||||||
|
|
||||||
|
|
||||||
/* The following is not at all used here but needed for standard
|
|
||||||
compliance. */
|
|
||||||
extern void __assert (const char *__assertion, const char *__file, int __line)
|
|
||||||
__THROW __attribute__ ((__noreturn__));
|
|
||||||
|
|
||||||
|
|
||||||
__END_DECLS
|
|
||||||
#endif /* Not _ASSERT_H_DECLS */
|
|
||||||
|
|
||||||
/* When possible, define assert so that it does not add extra
|
|
||||||
parentheses around EXPR. Otherwise, those added parentheses would
|
|
||||||
suppress warnings we'd expect to be detected by gcc's -Wparentheses. */
|
|
||||||
# if defined __cplusplus
|
|
||||||
# define assert(expr) \
|
|
||||||
(static_cast <bool> (expr) \
|
|
||||||
? void (0) \
|
|
||||||
: __assert_fail (#expr, __FILE__, __LINE__, __ASSERT_FUNCTION))
|
|
||||||
# elif !defined __GNUC__ || defined __STRICT_ANSI__
|
|
||||||
# define assert(expr) \
|
|
||||||
((expr) \
|
|
||||||
? __ASSERT_VOID_CAST (0) \
|
|
||||||
: __assert_fail (#expr, __FILE__, __LINE__, __ASSERT_FUNCTION))
|
|
||||||
# else
|
|
||||||
/* The first occurrence of EXPR is not evaluated due to the sizeof,
|
|
||||||
but will trigger any pedantic warnings masked by the __extension__
|
|
||||||
for the second occurrence. The ternary operator is required to
|
|
||||||
support function pointers and bit fields in this context, and to
|
|
||||||
suppress the evaluation of variable length arrays. */
|
|
||||||
# define assert(expr) \
|
|
||||||
((void) sizeof ((expr) ? 1 : 0), __extension__ ({ \
|
|
||||||
if (expr) \
|
|
||||||
; /* empty */ \
|
|
||||||
else \
|
|
||||||
__assert_fail (#expr, __FILE__, __LINE__, __ASSERT_FUNCTION); \
|
|
||||||
}))
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifdef __USE_GNU
|
|
||||||
# define assert_perror(errnum) \
|
|
||||||
(!(errnum) \
|
|
||||||
? __ASSERT_VOID_CAST (0) \
|
|
||||||
: __assert_perror_fail ((errnum), __FILE__, __LINE__, __ASSERT_FUNCTION))
|
|
||||||
# endif
|
|
||||||
|
|
||||||
/* Version 2.4 and later of GCC define a magical variable `__PRETTY_FUNCTION__'
|
|
||||||
which contains the name of the function currently being defined.
|
|
||||||
This is broken in G++ before version 2.6.
|
|
||||||
C9x has a similar variable called __func__, but prefer the GCC one since
|
|
||||||
it demangles C++ function names. */
|
|
||||||
# if defined __cplusplus ? __GNUC_PREREQ (2, 6) : __GNUC_PREREQ (2, 4)
|
|
||||||
# define __ASSERT_FUNCTION __extension__ __PRETTY_FUNCTION__
|
|
||||||
# else
|
|
||||||
# if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
|
|
||||||
# define __ASSERT_FUNCTION __func__
|
|
||||||
# else
|
|
||||||
# define __ASSERT_FUNCTION ((const char *) 0)
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
|
|
||||||
#endif /* NDEBUG. */
|
|
||||||
|
|
||||||
|
|
||||||
#if defined __USE_ISOC11 && !defined __cplusplus
|
|
||||||
# undef static_assert
|
|
||||||
# define static_assert _Static_assert
|
|
||||||
#endif
|
|
Binary file not shown.
@ -1,86 +0,0 @@
|
|||||||
// <algorithm> -*- C++ -*-
|
|
||||||
|
|
||||||
// Copyright (C) 2001-2020 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.
|
|
||||||
|
|
||||||
// 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/>.
|
|
||||||
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
* Copyright (c) 1994
|
|
||||||
* Hewlett-Packard Company
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, distribute and sell this software
|
|
||||||
* and its documentation for any purpose is hereby granted without fee,
|
|
||||||
* provided that the above copyright notice appear in all copies and
|
|
||||||
* that both that copyright notice and this permission notice appear
|
|
||||||
* in supporting documentation. Hewlett-Packard Company makes no
|
|
||||||
* representations about the suitability of this software for any
|
|
||||||
* purpose. It is provided "as is" without express or implied warranty.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* Copyright (c) 1996,1997
|
|
||||||
* Silicon Graphics Computer Systems, Inc.
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, distribute and sell this software
|
|
||||||
* and its documentation for any purpose is hereby granted without fee,
|
|
||||||
* provided that the above copyright notice appear in all copies and
|
|
||||||
* that both that copyright notice and this permission notice appear
|
|
||||||
* in supporting documentation. Silicon Graphics makes no
|
|
||||||
* representations about the suitability of this software for any
|
|
||||||
* purpose. It is provided "as is" without express or implied warranty.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @file include/algorithm
|
|
||||||
* This is a Standard C++ Library header.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _GLIBCXX_ALGORITHM
|
|
||||||
#define _GLIBCXX_ALGORITHM 1
|
|
||||||
|
|
||||||
#pragma GCC system_header
|
|
||||||
|
|
||||||
#include <utility> // UK-300.
|
|
||||||
#include <bits/stl_algobase.h>
|
|
||||||
#include <bits/stl_algo.h>
|
|
||||||
#if __cplusplus > 201703L
|
|
||||||
# include <bits/ranges_algo.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if __cplusplus > 201402L
|
|
||||||
// Parallel STL algorithms
|
|
||||||
# if _PSTL_EXECUTION_POLICIES_DEFINED
|
|
||||||
// If <execution> has already been included, pull in implementations
|
|
||||||
# include <pstl/glue_algorithm_impl.h>
|
|
||||||
# else
|
|
||||||
// Otherwise just pull in forward declarations
|
|
||||||
# include <pstl/glue_algorithm_defs.h>
|
|
||||||
# define _PSTL_ALGORITHM_FORWARD_DECLARED 1
|
|
||||||
# endif
|
|
||||||
|
|
||||||
// Feature test macro for parallel algorithms
|
|
||||||
# define __cpp_lib_parallel_algorithm 201603L
|
|
||||||
#endif // C++17
|
|
||||||
|
|
||||||
#ifdef _GLIBCXX_PARALLEL
|
|
||||||
# include <parallel/algorithm>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* _GLIBCXX_ALGORITHM */
|
|
Binary file not shown.
@ -1,451 +0,0 @@
|
|||||||
// <array> -*- C++ -*-
|
|
||||||
|
|
||||||
// Copyright (C) 2007-2020 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.
|
|
||||||
|
|
||||||
// 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 include/array
|
|
||||||
* This is a Standard C++ Library header.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _GLIBCXX_ARRAY
|
|
||||||
#define _GLIBCXX_ARRAY 1
|
|
||||||
|
|
||||||
#pragma GCC system_header
|
|
||||||
|
|
||||||
#if __cplusplus < 201103L
|
|
||||||
# include <bits/c++0x_warning.h>
|
|
||||||
#else
|
|
||||||
|
|
||||||
#include <utility>
|
|
||||||
#include <bits/functexcept.h>
|
|
||||||
#include <bits/stl_algobase.h>
|
|
||||||
#include <bits/range_access.h>
|
|
||||||
|
|
||||||
namespace std _GLIBCXX_VISIBILITY(default)
|
|
||||||
{
|
|
||||||
_GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
|
||||||
|
|
||||||
template<typename _Tp, std::size_t _Nm>
|
|
||||||
struct __array_traits
|
|
||||||
{
|
|
||||||
typedef _Tp _Type[_Nm];
|
|
||||||
typedef __is_swappable<_Tp> _Is_swappable;
|
|
||||||
typedef __is_nothrow_swappable<_Tp> _Is_nothrow_swappable;
|
|
||||||
|
|
||||||
static constexpr _Tp&
|
|
||||||
_S_ref(const _Type& __t, std::size_t __n) noexcept
|
|
||||||
{ return const_cast<_Tp&>(__t[__n]); }
|
|
||||||
|
|
||||||
static constexpr _Tp*
|
|
||||||
_S_ptr(const _Type& __t) noexcept
|
|
||||||
{ return const_cast<_Tp*>(__t); }
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename _Tp>
|
|
||||||
struct __array_traits<_Tp, 0>
|
|
||||||
{
|
|
||||||
struct _Type { };
|
|
||||||
typedef true_type _Is_swappable;
|
|
||||||
typedef true_type _Is_nothrow_swappable;
|
|
||||||
|
|
||||||
static constexpr _Tp&
|
|
||||||
_S_ref(const _Type&, std::size_t) noexcept
|
|
||||||
{ return *static_cast<_Tp*>(nullptr); }
|
|
||||||
|
|
||||||
static constexpr _Tp*
|
|
||||||
_S_ptr(const _Type&) noexcept
|
|
||||||
{ return nullptr; }
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief A standard container for storing a fixed size sequence of elements.
|
|
||||||
*
|
|
||||||
* @ingroup sequences
|
|
||||||
*
|
|
||||||
* Meets the requirements of a <a href="tables.html#65">container</a>, a
|
|
||||||
* <a href="tables.html#66">reversible container</a>, and a
|
|
||||||
* <a href="tables.html#67">sequence</a>.
|
|
||||||
*
|
|
||||||
* Sets support random access iterators.
|
|
||||||
*
|
|
||||||
* @tparam Tp Type of element. Required to be a complete type.
|
|
||||||
* @tparam Nm Number of elements.
|
|
||||||
*/
|
|
||||||
template<typename _Tp, std::size_t _Nm>
|
|
||||||
struct array
|
|
||||||
{
|
|
||||||
typedef _Tp value_type;
|
|
||||||
typedef value_type* pointer;
|
|
||||||
typedef const value_type* const_pointer;
|
|
||||||
typedef value_type& reference;
|
|
||||||
typedef const value_type& const_reference;
|
|
||||||
typedef value_type* iterator;
|
|
||||||
typedef const value_type* const_iterator;
|
|
||||||
typedef std::size_t size_type;
|
|
||||||
typedef std::ptrdiff_t difference_type;
|
|
||||||
typedef std::reverse_iterator<iterator> reverse_iterator;
|
|
||||||
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
|
||||||
|
|
||||||
// Support for zero-sized arrays mandatory.
|
|
||||||
typedef _GLIBCXX_STD_C::__array_traits<_Tp, _Nm> _AT_Type;
|
|
||||||
typename _AT_Type::_Type _M_elems;
|
|
||||||
|
|
||||||
// No explicit construct/copy/destroy for aggregate type.
|
|
||||||
|
|
||||||
// DR 776.
|
|
||||||
_GLIBCXX20_CONSTEXPR void
|
|
||||||
fill(const value_type& __u)
|
|
||||||
{ std::fill_n(begin(), size(), __u); }
|
|
||||||
|
|
||||||
_GLIBCXX20_CONSTEXPR void
|
|
||||||
swap(array& __other)
|
|
||||||
noexcept(_AT_Type::_Is_nothrow_swappable::value)
|
|
||||||
{ std::swap_ranges(begin(), end(), __other.begin()); }
|
|
||||||
|
|
||||||
// Iterators.
|
|
||||||
_GLIBCXX17_CONSTEXPR iterator
|
|
||||||
begin() noexcept
|
|
||||||
{ return iterator(data()); }
|
|
||||||
|
|
||||||
_GLIBCXX17_CONSTEXPR const_iterator
|
|
||||||
begin() const noexcept
|
|
||||||
{ return const_iterator(data()); }
|
|
||||||
|
|
||||||
_GLIBCXX17_CONSTEXPR iterator
|
|
||||||
end() noexcept
|
|
||||||
{ return iterator(data() + _Nm); }
|
|
||||||
|
|
||||||
_GLIBCXX17_CONSTEXPR const_iterator
|
|
||||||
end() const noexcept
|
|
||||||
{ return const_iterator(data() + _Nm); }
|
|
||||||
|
|
||||||
_GLIBCXX17_CONSTEXPR reverse_iterator
|
|
||||||
rbegin() noexcept
|
|
||||||
{ return reverse_iterator(end()); }
|
|
||||||
|
|
||||||
_GLIBCXX17_CONSTEXPR const_reverse_iterator
|
|
||||||
rbegin() const noexcept
|
|
||||||
{ return const_reverse_iterator(end()); }
|
|
||||||
|
|
||||||
_GLIBCXX17_CONSTEXPR reverse_iterator
|
|
||||||
rend() noexcept
|
|
||||||
{ return reverse_iterator(begin()); }
|
|
||||||
|
|
||||||
_GLIBCXX17_CONSTEXPR const_reverse_iterator
|
|
||||||
rend() const noexcept
|
|
||||||
{ return const_reverse_iterator(begin()); }
|
|
||||||
|
|
||||||
_GLIBCXX17_CONSTEXPR const_iterator
|
|
||||||
cbegin() const noexcept
|
|
||||||
{ return const_iterator(data()); }
|
|
||||||
|
|
||||||
_GLIBCXX17_CONSTEXPR const_iterator
|
|
||||||
cend() const noexcept
|
|
||||||
{ return const_iterator(data() + _Nm); }
|
|
||||||
|
|
||||||
_GLIBCXX17_CONSTEXPR const_reverse_iterator
|
|
||||||
crbegin() const noexcept
|
|
||||||
{ return const_reverse_iterator(end()); }
|
|
||||||
|
|
||||||
_GLIBCXX17_CONSTEXPR const_reverse_iterator
|
|
||||||
crend() const noexcept
|
|
||||||
{ return const_reverse_iterator(begin()); }
|
|
||||||
|
|
||||||
// Capacity.
|
|
||||||
constexpr size_type
|
|
||||||
size() const noexcept { return _Nm; }
|
|
||||||
|
|
||||||
constexpr size_type
|
|
||||||
max_size() const noexcept { return _Nm; }
|
|
||||||
|
|
||||||
_GLIBCXX_NODISCARD constexpr bool
|
|
||||||
empty() const noexcept { return size() == 0; }
|
|
||||||
|
|
||||||
// Element access.
|
|
||||||
_GLIBCXX17_CONSTEXPR reference
|
|
||||||
operator[](size_type __n) noexcept
|
|
||||||
{ return _AT_Type::_S_ref(_M_elems, __n); }
|
|
||||||
|
|
||||||
constexpr const_reference
|
|
||||||
operator[](size_type __n) const noexcept
|
|
||||||
{ return _AT_Type::_S_ref(_M_elems, __n); }
|
|
||||||
|
|
||||||
_GLIBCXX17_CONSTEXPR reference
|
|
||||||
at(size_type __n)
|
|
||||||
{
|
|
||||||
if (__n >= _Nm)
|
|
||||||
std::__throw_out_of_range_fmt(__N("array::at: __n (which is %zu) "
|
|
||||||
">= _Nm (which is %zu)"),
|
|
||||||
__n, _Nm);
|
|
||||||
return _AT_Type::_S_ref(_M_elems, __n);
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr const_reference
|
|
||||||
at(size_type __n) const
|
|
||||||
{
|
|
||||||
// Result of conditional expression must be an lvalue so use
|
|
||||||
// boolean ? lvalue : (throw-expr, lvalue)
|
|
||||||
return __n < _Nm ? _AT_Type::_S_ref(_M_elems, __n)
|
|
||||||
: (std::__throw_out_of_range_fmt(__N("array::at: __n (which is %zu) "
|
|
||||||
">= _Nm (which is %zu)"),
|
|
||||||
__n, _Nm),
|
|
||||||
_AT_Type::_S_ref(_M_elems, 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
_GLIBCXX17_CONSTEXPR reference
|
|
||||||
front() noexcept
|
|
||||||
{ return *begin(); }
|
|
||||||
|
|
||||||
constexpr const_reference
|
|
||||||
front() const noexcept
|
|
||||||
{ return _AT_Type::_S_ref(_M_elems, 0); }
|
|
||||||
|
|
||||||
_GLIBCXX17_CONSTEXPR reference
|
|
||||||
back() noexcept
|
|
||||||
{ return _Nm ? *(end() - 1) : *end(); }
|
|
||||||
|
|
||||||
constexpr const_reference
|
|
||||||
back() const noexcept
|
|
||||||
{
|
|
||||||
return _Nm ? _AT_Type::_S_ref(_M_elems, _Nm - 1)
|
|
||||||
: _AT_Type::_S_ref(_M_elems, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
_GLIBCXX17_CONSTEXPR pointer
|
|
||||||
data() noexcept
|
|
||||||
{ return _AT_Type::_S_ptr(_M_elems); }
|
|
||||||
|
|
||||||
_GLIBCXX17_CONSTEXPR const_pointer
|
|
||||||
data() const noexcept
|
|
||||||
{ return _AT_Type::_S_ptr(_M_elems); }
|
|
||||||
};
|
|
||||||
|
|
||||||
#if __cpp_deduction_guides >= 201606
|
|
||||||
template<typename _Tp, typename... _Up>
|
|
||||||
array(_Tp, _Up...)
|
|
||||||
-> array<enable_if_t<(is_same_v<_Tp, _Up> && ...), _Tp>,
|
|
||||||
1 + sizeof...(_Up)>;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Array comparisons.
|
|
||||||
template<typename _Tp, std::size_t _Nm>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
inline bool
|
|
||||||
operator==(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
|
|
||||||
{ return std::equal(__one.begin(), __one.end(), __two.begin()); }
|
|
||||||
|
|
||||||
#if __cpp_lib_three_way_comparison && __cpp_lib_concepts
|
|
||||||
template<typename _Tp, size_t _Nm>
|
|
||||||
constexpr __detail::__synth3way_t<_Tp>
|
|
||||||
operator<=>(const array<_Tp, _Nm>& __a, const array<_Tp, _Nm>& __b)
|
|
||||||
{
|
|
||||||
#ifdef __cpp_lib_is_constant_evaluated
|
|
||||||
if constexpr (_Nm && __is_memcmp_ordered<_Tp>::__value)
|
|
||||||
if (!std::is_constant_evaluated())
|
|
||||||
{
|
|
||||||
constexpr size_t __n = _Nm * sizeof(_Tp);
|
|
||||||
return __builtin_memcmp(__a.data(), __b.data(), __n) <=> 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (size_t __i = 0; __i < _Nm; ++__i)
|
|
||||||
{
|
|
||||||
auto __c = __detail::__synth3way(__a[__i], __b[__i]);
|
|
||||||
if (__c != 0)
|
|
||||||
return __c;
|
|
||||||
}
|
|
||||||
return strong_ordering::equal;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
template<typename _Tp, std::size_t _Nm>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
inline bool
|
|
||||||
operator!=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
|
|
||||||
{ return !(__one == __two); }
|
|
||||||
|
|
||||||
template<typename _Tp, std::size_t _Nm>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
inline bool
|
|
||||||
operator<(const array<_Tp, _Nm>& __a, const array<_Tp, _Nm>& __b)
|
|
||||||
{
|
|
||||||
return std::lexicographical_compare(__a.begin(), __a.end(),
|
|
||||||
__b.begin(), __b.end());
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename _Tp, std::size_t _Nm>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
inline bool
|
|
||||||
operator>(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
|
|
||||||
{ return __two < __one; }
|
|
||||||
|
|
||||||
template<typename _Tp, std::size_t _Nm>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
inline bool
|
|
||||||
operator<=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
|
|
||||||
{ return !(__one > __two); }
|
|
||||||
|
|
||||||
template<typename _Tp, std::size_t _Nm>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
inline bool
|
|
||||||
operator>=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
|
|
||||||
{ return !(__one < __two); }
|
|
||||||
#endif // three_way_comparison && concepts
|
|
||||||
|
|
||||||
// Specialized algorithms.
|
|
||||||
template<typename _Tp, std::size_t _Nm>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
inline
|
|
||||||
#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11
|
|
||||||
// Constrained free swap overload, see p0185r1
|
|
||||||
typename enable_if<
|
|
||||||
_GLIBCXX_STD_C::__array_traits<_Tp, _Nm>::_Is_swappable::value
|
|
||||||
>::type
|
|
||||||
#else
|
|
||||||
void
|
|
||||||
#endif
|
|
||||||
swap(array<_Tp, _Nm>& __one, array<_Tp, _Nm>& __two)
|
|
||||||
noexcept(noexcept(__one.swap(__two)))
|
|
||||||
{ __one.swap(__two); }
|
|
||||||
|
|
||||||
#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11
|
|
||||||
template<typename _Tp, std::size_t _Nm>
|
|
||||||
typename enable_if<
|
|
||||||
!_GLIBCXX_STD_C::__array_traits<_Tp, _Nm>::_Is_swappable::value>::type
|
|
||||||
swap(array<_Tp, _Nm>&, array<_Tp, _Nm>&) = delete;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template<std::size_t _Int, typename _Tp, std::size_t _Nm>
|
|
||||||
constexpr _Tp&
|
|
||||||
get(array<_Tp, _Nm>& __arr) noexcept
|
|
||||||
{
|
|
||||||
static_assert(_Int < _Nm, "array index is within bounds");
|
|
||||||
return _GLIBCXX_STD_C::__array_traits<_Tp, _Nm>::
|
|
||||||
_S_ref(__arr._M_elems, _Int);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<std::size_t _Int, typename _Tp, std::size_t _Nm>
|
|
||||||
constexpr _Tp&&
|
|
||||||
get(array<_Tp, _Nm>&& __arr) noexcept
|
|
||||||
{
|
|
||||||
static_assert(_Int < _Nm, "array index is within bounds");
|
|
||||||
return std::move(_GLIBCXX_STD_C::get<_Int>(__arr));
|
|
||||||
}
|
|
||||||
|
|
||||||
template<std::size_t _Int, typename _Tp, std::size_t _Nm>
|
|
||||||
constexpr const _Tp&
|
|
||||||
get(const array<_Tp, _Nm>& __arr) noexcept
|
|
||||||
{
|
|
||||||
static_assert(_Int < _Nm, "array index is within bounds");
|
|
||||||
return _GLIBCXX_STD_C::__array_traits<_Tp, _Nm>::
|
|
||||||
_S_ref(__arr._M_elems, _Int);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<std::size_t _Int, typename _Tp, std::size_t _Nm>
|
|
||||||
constexpr const _Tp&&
|
|
||||||
get(const array<_Tp, _Nm>&& __arr) noexcept
|
|
||||||
{
|
|
||||||
static_assert(_Int < _Nm, "array index is within bounds");
|
|
||||||
return std::move(_GLIBCXX_STD_C::get<_Int>(__arr));
|
|
||||||
}
|
|
||||||
|
|
||||||
#if __cplusplus > 201703L
|
|
||||||
#define __cpp_lib_to_array 201907L
|
|
||||||
|
|
||||||
template<bool _Move = false, typename _Tp, size_t... _Idx>
|
|
||||||
constexpr array<remove_cv_t<_Tp>, sizeof...(_Idx)>
|
|
||||||
__to_array(_Tp (&__a)[sizeof...(_Idx)], index_sequence<_Idx...>)
|
|
||||||
{
|
|
||||||
if constexpr (_Move)
|
|
||||||
return {{std::move(__a[_Idx])...}};
|
|
||||||
else
|
|
||||||
return {{__a[_Idx]...}};
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename _Tp, size_t _Nm>
|
|
||||||
constexpr array<remove_cv_t<_Tp>, _Nm>
|
|
||||||
to_array(_Tp (&__a)[_Nm])
|
|
||||||
noexcept(is_nothrow_constructible_v<_Tp, _Tp&>)
|
|
||||||
{
|
|
||||||
static_assert(!is_array_v<_Tp>);
|
|
||||||
static_assert(is_constructible_v<_Tp, _Tp&>);
|
|
||||||
if constexpr (is_constructible_v<_Tp, _Tp&>)
|
|
||||||
return _GLIBCXX_STD_C::__to_array(__a, make_index_sequence<_Nm>{});
|
|
||||||
__builtin_unreachable(); // FIXME: see PR c++/91388
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename _Tp, size_t _Nm>
|
|
||||||
constexpr array<remove_cv_t<_Tp>, _Nm>
|
|
||||||
to_array(_Tp (&&__a)[_Nm])
|
|
||||||
noexcept(is_nothrow_move_constructible_v<_Tp>)
|
|
||||||
{
|
|
||||||
static_assert(!is_array_v<_Tp>);
|
|
||||||
static_assert(is_move_constructible_v<_Tp>);
|
|
||||||
if constexpr (is_move_constructible_v<_Tp>)
|
|
||||||
return _GLIBCXX_STD_C::__to_array<1>(__a, make_index_sequence<_Nm>{});
|
|
||||||
__builtin_unreachable(); // FIXME: see PR c++/91388
|
|
||||||
}
|
|
||||||
#endif // C++20
|
|
||||||
|
|
||||||
_GLIBCXX_END_NAMESPACE_CONTAINER
|
|
||||||
} // namespace std
|
|
||||||
|
|
||||||
namespace std _GLIBCXX_VISIBILITY(default)
|
|
||||||
{
|
|
||||||
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|
||||||
|
|
||||||
// Tuple interface to class template array.
|
|
||||||
|
|
||||||
/// tuple_size
|
|
||||||
template<typename _Tp>
|
|
||||||
struct tuple_size;
|
|
||||||
|
|
||||||
/// Partial specialization for std::array
|
|
||||||
template<typename _Tp, std::size_t _Nm>
|
|
||||||
struct tuple_size<_GLIBCXX_STD_C::array<_Tp, _Nm>>
|
|
||||||
: public integral_constant<std::size_t, _Nm> { };
|
|
||||||
|
|
||||||
/// tuple_element
|
|
||||||
template<std::size_t _Int, typename _Tp>
|
|
||||||
struct tuple_element;
|
|
||||||
|
|
||||||
/// Partial specialization for std::array
|
|
||||||
template<std::size_t _Int, typename _Tp, std::size_t _Nm>
|
|
||||||
struct tuple_element<_Int, _GLIBCXX_STD_C::array<_Tp, _Nm>>
|
|
||||||
{
|
|
||||||
static_assert(_Int < _Nm, "index is out of bounds");
|
|
||||||
typedef _Tp type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename _Tp, std::size_t _Nm>
|
|
||||||
struct __is_tuple_like_impl<_GLIBCXX_STD_C::array<_Tp, _Nm>> : true_type
|
|
||||||
{ };
|
|
||||||
|
|
||||||
_GLIBCXX_END_NAMESPACE_VERSION
|
|
||||||
} // namespace std
|
|
||||||
|
|
||||||
#ifdef _GLIBCXX_DEBUG
|
|
||||||
# include <debug/array>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // C++11
|
|
||||||
|
|
||||||
#endif // _GLIBCXX_ARRAY
|
|
Binary file not shown.
@ -1,337 +0,0 @@
|
|||||||
// auto_ptr implementation -*- C++ -*-
|
|
||||||
|
|
||||||
// Copyright (C) 2007-2020 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.
|
|
||||||
|
|
||||||
// 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 backward/auto_ptr.h
|
|
||||||
* This is an internal header file, included by other library headers.
|
|
||||||
* Do not attempt to use it directly. @headername{memory}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _BACKWARD_AUTO_PTR_H
|
|
||||||
#define _BACKWARD_AUTO_PTR_H 1
|
|
||||||
|
|
||||||
#include <bits/c++config.h>
|
|
||||||
#include <debug/debug.h>
|
|
||||||
|
|
||||||
namespace std _GLIBCXX_VISIBILITY(default)
|
|
||||||
{
|
|
||||||
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A wrapper class to provide auto_ptr with reference semantics.
|
|
||||||
* For example, an auto_ptr can be assigned (or constructed from)
|
|
||||||
* the result of a function which returns an auto_ptr by value.
|
|
||||||
*
|
|
||||||
* All the auto_ptr_ref stuff should happen behind the scenes.
|
|
||||||
*/
|
|
||||||
template<typename _Tp1>
|
|
||||||
struct auto_ptr_ref
|
|
||||||
{
|
|
||||||
_Tp1* _M_ptr;
|
|
||||||
|
|
||||||
explicit
|
|
||||||
auto_ptr_ref(_Tp1* __p): _M_ptr(__p) { }
|
|
||||||
} _GLIBCXX_DEPRECATED;
|
|
||||||
|
|
||||||
#pragma GCC diagnostic push
|
|
||||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief A simple smart pointer providing strict ownership semantics.
|
|
||||||
*
|
|
||||||
* The Standard says:
|
|
||||||
* <pre>
|
|
||||||
* An @c auto_ptr owns the object it holds a pointer to. Copying
|
|
||||||
* an @c auto_ptr copies the pointer and transfers ownership to the
|
|
||||||
* destination. If more than one @c auto_ptr owns the same object
|
|
||||||
* at the same time the behavior of the program is undefined.
|
|
||||||
*
|
|
||||||
* The uses of @c auto_ptr include providing temporary
|
|
||||||
* exception-safety for dynamically allocated memory, passing
|
|
||||||
* ownership of dynamically allocated memory to a function, and
|
|
||||||
* returning dynamically allocated memory from a function. @c
|
|
||||||
* auto_ptr does not meet the CopyConstructible and Assignable
|
|
||||||
* requirements for Standard Library <a
|
|
||||||
* href="tables.html#65">container</a> elements and thus
|
|
||||||
* instantiating a Standard Library container with an @c auto_ptr
|
|
||||||
* results in undefined behavior.
|
|
||||||
* </pre>
|
|
||||||
* Quoted from [20.4.5]/3.
|
|
||||||
*
|
|
||||||
* Good examples of what can and cannot be done with auto_ptr can
|
|
||||||
* be found in the libstdc++ testsuite.
|
|
||||||
*
|
|
||||||
* _GLIBCXX_RESOLVE_LIB_DEFECTS
|
|
||||||
* 127. auto_ptr<> conversion issues
|
|
||||||
* These resolutions have all been incorporated.
|
|
||||||
*/
|
|
||||||
template<typename _Tp>
|
|
||||||
class auto_ptr
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
_Tp* _M_ptr;
|
|
||||||
|
|
||||||
public:
|
|
||||||
/// The pointed-to type.
|
|
||||||
typedef _Tp element_type;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief An %auto_ptr is usually constructed from a raw pointer.
|
|
||||||
* @param __p A pointer (defaults to NULL).
|
|
||||||
*
|
|
||||||
* This object now @e owns the object pointed to by @a __p.
|
|
||||||
*/
|
|
||||||
explicit
|
|
||||||
auto_ptr(element_type* __p = 0) throw() : _M_ptr(__p) { }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief An %auto_ptr can be constructed from another %auto_ptr.
|
|
||||||
* @param __a Another %auto_ptr of the same type.
|
|
||||||
*
|
|
||||||
* This object now @e owns the object previously owned by @a __a,
|
|
||||||
* which has given up ownership.
|
|
||||||
*/
|
|
||||||
auto_ptr(auto_ptr& __a) throw() : _M_ptr(__a.release()) { }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief An %auto_ptr can be constructed from another %auto_ptr.
|
|
||||||
* @param __a Another %auto_ptr of a different but related type.
|
|
||||||
*
|
|
||||||
* A pointer-to-Tp1 must be convertible to a
|
|
||||||
* pointer-to-Tp/element_type.
|
|
||||||
*
|
|
||||||
* This object now @e owns the object previously owned by @a __a,
|
|
||||||
* which has given up ownership.
|
|
||||||
*/
|
|
||||||
template<typename _Tp1>
|
|
||||||
auto_ptr(auto_ptr<_Tp1>& __a) throw() : _M_ptr(__a.release()) { }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief %auto_ptr assignment operator.
|
|
||||||
* @param __a Another %auto_ptr of the same type.
|
|
||||||
*
|
|
||||||
* This object now @e owns the object previously owned by @a __a,
|
|
||||||
* which has given up ownership. The object that this one @e
|
|
||||||
* used to own and track has been deleted.
|
|
||||||
*/
|
|
||||||
auto_ptr&
|
|
||||||
operator=(auto_ptr& __a) throw()
|
|
||||||
{
|
|
||||||
reset(__a.release());
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief %auto_ptr assignment operator.
|
|
||||||
* @param __a Another %auto_ptr of a different but related type.
|
|
||||||
*
|
|
||||||
* A pointer-to-Tp1 must be convertible to a pointer-to-Tp/element_type.
|
|
||||||
*
|
|
||||||
* This object now @e owns the object previously owned by @a __a,
|
|
||||||
* which has given up ownership. The object that this one @e
|
|
||||||
* used to own and track has been deleted.
|
|
||||||
*/
|
|
||||||
template<typename _Tp1>
|
|
||||||
auto_ptr&
|
|
||||||
operator=(auto_ptr<_Tp1>& __a) throw()
|
|
||||||
{
|
|
||||||
reset(__a.release());
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* When the %auto_ptr goes out of scope, the object it owns is
|
|
||||||
* deleted. If it no longer owns anything (i.e., @c get() is
|
|
||||||
* @c NULL), then this has no effect.
|
|
||||||
*
|
|
||||||
* The C++ standard says there is supposed to be an empty throw
|
|
||||||
* specification here, but omitting it is standard conforming. Its
|
|
||||||
* presence can be detected only if _Tp::~_Tp() throws, but this is
|
|
||||||
* prohibited. [17.4.3.6]/2
|
|
||||||
*/
|
|
||||||
~auto_ptr() { delete _M_ptr; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Smart pointer dereferencing.
|
|
||||||
*
|
|
||||||
* If this %auto_ptr no longer owns anything, then this
|
|
||||||
* operation will crash. (For a smart pointer, <em>no longer owns
|
|
||||||
* anything</em> is the same as being a null pointer, and you know
|
|
||||||
* what happens when you dereference one of those...)
|
|
||||||
*/
|
|
||||||
element_type&
|
|
||||||
operator*() const throw()
|
|
||||||
{
|
|
||||||
__glibcxx_assert(_M_ptr != 0);
|
|
||||||
return *_M_ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Smart pointer dereferencing.
|
|
||||||
*
|
|
||||||
* This returns the pointer itself, which the language then will
|
|
||||||
* automatically cause to be dereferenced.
|
|
||||||
*/
|
|
||||||
element_type*
|
|
||||||
operator->() const throw()
|
|
||||||
{
|
|
||||||
__glibcxx_assert(_M_ptr != 0);
|
|
||||||
return _M_ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Bypassing the smart pointer.
|
|
||||||
* @return The raw pointer being managed.
|
|
||||||
*
|
|
||||||
* You can get a copy of the pointer that this object owns, for
|
|
||||||
* situations such as passing to a function which only accepts
|
|
||||||
* a raw pointer.
|
|
||||||
*
|
|
||||||
* @note This %auto_ptr still owns the memory.
|
|
||||||
*/
|
|
||||||
element_type*
|
|
||||||
get() const throw() { return _M_ptr; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Bypassing the smart pointer.
|
|
||||||
* @return The raw pointer being managed.
|
|
||||||
*
|
|
||||||
* You can get a copy of the pointer that this object owns, for
|
|
||||||
* situations such as passing to a function which only accepts
|
|
||||||
* a raw pointer.
|
|
||||||
*
|
|
||||||
* @note This %auto_ptr no longer owns the memory. When this object
|
|
||||||
* goes out of scope, nothing will happen.
|
|
||||||
*/
|
|
||||||
element_type*
|
|
||||||
release() throw()
|
|
||||||
{
|
|
||||||
element_type* __tmp = _M_ptr;
|
|
||||||
_M_ptr = 0;
|
|
||||||
return __tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Forcibly deletes the managed object.
|
|
||||||
* @param __p A pointer (defaults to NULL).
|
|
||||||
*
|
|
||||||
* This object now @e owns the object pointed to by @a __p. The
|
|
||||||
* previous object has been deleted.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
reset(element_type* __p = 0) throw()
|
|
||||||
{
|
|
||||||
if (__p != _M_ptr)
|
|
||||||
{
|
|
||||||
delete _M_ptr;
|
|
||||||
_M_ptr = __p;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Automatic conversions
|
|
||||||
*
|
|
||||||
* These operations are supposed to convert an %auto_ptr into and from
|
|
||||||
* an auto_ptr_ref automatically as needed. This would allow
|
|
||||||
* constructs such as
|
|
||||||
* @code
|
|
||||||
* auto_ptr<Derived> func_returning_auto_ptr(.....);
|
|
||||||
* ...
|
|
||||||
* auto_ptr<Base> ptr = func_returning_auto_ptr(.....);
|
|
||||||
* @endcode
|
|
||||||
*
|
|
||||||
* But it doesn't work, and won't be fixed. For further details see
|
|
||||||
* http://cplusplus.github.io/LWG/lwg-closed.html#463
|
|
||||||
*/
|
|
||||||
auto_ptr(auto_ptr_ref<element_type> __ref) throw()
|
|
||||||
: _M_ptr(__ref._M_ptr) { }
|
|
||||||
|
|
||||||
auto_ptr&
|
|
||||||
operator=(auto_ptr_ref<element_type> __ref) throw()
|
|
||||||
{
|
|
||||||
if (__ref._M_ptr != this->get())
|
|
||||||
{
|
|
||||||
delete _M_ptr;
|
|
||||||
_M_ptr = __ref._M_ptr;
|
|
||||||
}
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename _Tp1>
|
|
||||||
operator auto_ptr_ref<_Tp1>() throw()
|
|
||||||
{ return auto_ptr_ref<_Tp1>(this->release()); }
|
|
||||||
|
|
||||||
template<typename _Tp1>
|
|
||||||
operator auto_ptr<_Tp1>() throw()
|
|
||||||
{ return auto_ptr<_Tp1>(this->release()); }
|
|
||||||
} _GLIBCXX_DEPRECATED;
|
|
||||||
|
|
||||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
|
||||||
// 541. shared_ptr template assignment and void
|
|
||||||
template<>
|
|
||||||
class auto_ptr<void>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef void element_type;
|
|
||||||
} _GLIBCXX_DEPRECATED;
|
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
template<_Lock_policy _Lp>
|
|
||||||
template<typename _Tp>
|
|
||||||
inline
|
|
||||||
__shared_count<_Lp>::__shared_count(std::auto_ptr<_Tp>&& __r)
|
|
||||||
: _M_pi(new _Sp_counted_ptr<_Tp*, _Lp>(__r.get()))
|
|
||||||
{ __r.release(); }
|
|
||||||
|
|
||||||
template<typename _Tp, _Lock_policy _Lp>
|
|
||||||
template<typename _Tp1, typename>
|
|
||||||
inline
|
|
||||||
__shared_ptr<_Tp, _Lp>::__shared_ptr(std::auto_ptr<_Tp1>&& __r)
|
|
||||||
: _M_ptr(__r.get()), _M_refcount()
|
|
||||||
{
|
|
||||||
__glibcxx_function_requires(_ConvertibleConcept<_Tp1*, _Tp*>)
|
|
||||||
static_assert( sizeof(_Tp1) > 0, "incomplete type" );
|
|
||||||
_Tp1* __tmp = __r.get();
|
|
||||||
_M_refcount = __shared_count<_Lp>(std::move(__r));
|
|
||||||
_M_enable_shared_from_this_with(__tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename _Tp>
|
|
||||||
template<typename _Tp1, typename>
|
|
||||||
inline
|
|
||||||
shared_ptr<_Tp>::shared_ptr(std::auto_ptr<_Tp1>&& __r)
|
|
||||||
: __shared_ptr<_Tp>(std::move(__r)) { }
|
|
||||||
|
|
||||||
template<typename _Tp, typename _Dp>
|
|
||||||
template<typename _Up, typename>
|
|
||||||
inline
|
|
||||||
unique_ptr<_Tp, _Dp>::unique_ptr(auto_ptr<_Up>&& __u) noexcept
|
|
||||||
: _M_t(__u.release(), deleter_type()) { }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#pragma GCC diagnostic pop
|
|
||||||
|
|
||||||
_GLIBCXX_END_NAMESPACE_VERSION
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
#endif /* _BACKWARD_AUTO_PTR_H */
|
|
Binary file not shown.
@ -1,182 +0,0 @@
|
|||||||
// Functor implementations -*- C++ -*-
|
|
||||||
|
|
||||||
// Copyright (C) 2001-2020 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.
|
|
||||||
|
|
||||||
// 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/>.
|
|
||||||
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
* Copyright (c) 1994
|
|
||||||
* Hewlett-Packard Company
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, distribute and sell this software
|
|
||||||
* and its documentation for any purpose is hereby granted without fee,
|
|
||||||
* provided that the above copyright notice appear in all copies and
|
|
||||||
* that both that copyright notice and this permission notice appear
|
|
||||||
* in supporting documentation. Hewlett-Packard Company makes no
|
|
||||||
* representations about the suitability of this software for any
|
|
||||||
* purpose. It is provided "as is" without express or implied warranty.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* Copyright (c) 1996-1998
|
|
||||||
* Silicon Graphics Computer Systems, Inc.
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, distribute and sell this software
|
|
||||||
* and its documentation for any purpose is hereby granted without fee,
|
|
||||||
* provided that the above copyright notice appear in all copies and
|
|
||||||
* that both that copyright notice and this permission notice appear
|
|
||||||
* in supporting documentation. Silicon Graphics makes no
|
|
||||||
* representations about the suitability of this software for any
|
|
||||||
* purpose. It is provided "as is" without express or implied warranty.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @file backward/binders.h
|
|
||||||
* This is an internal header file, included by other library headers.
|
|
||||||
* Do not attempt to use it directly. @headername{functional}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _BACKWARD_BINDERS_H
|
|
||||||
#define _BACKWARD_BINDERS_H 1
|
|
||||||
|
|
||||||
// Suppress deprecated warning for this file.
|
|
||||||
#pragma GCC diagnostic push
|
|
||||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
|
||||||
|
|
||||||
namespace std _GLIBCXX_VISIBILITY(default)
|
|
||||||
{
|
|
||||||
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|
||||||
|
|
||||||
// 20.3.6 binders
|
|
||||||
/** @defgroup binders Binder Classes
|
|
||||||
* @ingroup functors
|
|
||||||
*
|
|
||||||
* Binders turn functions/functors with two arguments into functors
|
|
||||||
* with a single argument, storing an argument to be applied later.
|
|
||||||
* For example, a variable @c B of type @c binder1st is constructed
|
|
||||||
* from a functor @c f and an argument @c x. Later, B's @c
|
|
||||||
* operator() is called with a single argument @c y. The return
|
|
||||||
* value is the value of @c f(x,y). @c B can be @a called with
|
|
||||||
* various arguments (y1, y2, ...) and will in turn call @c
|
|
||||||
* f(x,y1), @c f(x,y2), ...
|
|
||||||
*
|
|
||||||
* The function @c bind1st is provided to save some typing. It takes the
|
|
||||||
* function and an argument as parameters, and returns an instance of
|
|
||||||
* @c binder1st.
|
|
||||||
*
|
|
||||||
* The type @c binder2nd and its creator function @c bind2nd do the same
|
|
||||||
* thing, but the stored argument is passed as the second parameter instead
|
|
||||||
* of the first, e.g., @c bind2nd(std::minus<float>(),1.3) will create a
|
|
||||||
* functor whose @c operator() accepts a floating-point number, subtracts
|
|
||||||
* 1.3 from it, and returns the result. (If @c bind1st had been used,
|
|
||||||
* the functor would perform <em>1.3 - x</em> instead.
|
|
||||||
*
|
|
||||||
* Creator-wrapper functions like @c bind1st are intended to be used in
|
|
||||||
* calling algorithms. Their return values will be temporary objects.
|
|
||||||
* (The goal is to not require you to type names like
|
|
||||||
* @c std::binder1st<std::plus<int>> for declaring a variable to hold the
|
|
||||||
* return value from @c bind1st(std::plus<int>(),5).
|
|
||||||
*
|
|
||||||
* These become more useful when combined with the composition functions.
|
|
||||||
*
|
|
||||||
* These functions are deprecated in C++11 and can be replaced by
|
|
||||||
* @c std::bind (or @c std::tr1::bind) which is more powerful and flexible,
|
|
||||||
* supporting functions with any number of arguments. Uses of @c bind1st
|
|
||||||
* can be replaced by @c std::bind(f, x, std::placeholders::_1) and
|
|
||||||
* @c bind2nd by @c std::bind(f, std::placeholders::_1, x).
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
/// One of the @link binders binder functors@endlink.
|
|
||||||
template<typename _Operation>
|
|
||||||
class binder1st
|
|
||||||
: public unary_function<typename _Operation::second_argument_type,
|
|
||||||
typename _Operation::result_type>
|
|
||||||
{
|
|
||||||
protected:
|
|
||||||
_Operation op;
|
|
||||||
typename _Operation::first_argument_type value;
|
|
||||||
|
|
||||||
public:
|
|
||||||
binder1st(const _Operation& __x,
|
|
||||||
const typename _Operation::first_argument_type& __y)
|
|
||||||
: op(__x), value(__y) { }
|
|
||||||
|
|
||||||
typename _Operation::result_type
|
|
||||||
operator()(const typename _Operation::second_argument_type& __x) const
|
|
||||||
{ return op(value, __x); }
|
|
||||||
|
|
||||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
|
||||||
// 109. Missing binders for non-const sequence elements
|
|
||||||
typename _Operation::result_type
|
|
||||||
operator()(typename _Operation::second_argument_type& __x) const
|
|
||||||
{ return op(value, __x); }
|
|
||||||
} _GLIBCXX_DEPRECATED;
|
|
||||||
|
|
||||||
/// One of the @link binders binder functors@endlink.
|
|
||||||
template<typename _Operation, typename _Tp>
|
|
||||||
inline binder1st<_Operation>
|
|
||||||
bind1st(const _Operation& __fn, const _Tp& __x)
|
|
||||||
{
|
|
||||||
typedef typename _Operation::first_argument_type _Arg1_type;
|
|
||||||
return binder1st<_Operation>(__fn, _Arg1_type(__x));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// One of the @link binders binder functors@endlink.
|
|
||||||
template<typename _Operation>
|
|
||||||
class binder2nd
|
|
||||||
: public unary_function<typename _Operation::first_argument_type,
|
|
||||||
typename _Operation::result_type>
|
|
||||||
{
|
|
||||||
protected:
|
|
||||||
_Operation op;
|
|
||||||
typename _Operation::second_argument_type value;
|
|
||||||
|
|
||||||
public:
|
|
||||||
binder2nd(const _Operation& __x,
|
|
||||||
const typename _Operation::second_argument_type& __y)
|
|
||||||
: op(__x), value(__y) { }
|
|
||||||
|
|
||||||
typename _Operation::result_type
|
|
||||||
operator()(const typename _Operation::first_argument_type& __x) const
|
|
||||||
{ return op(__x, value); }
|
|
||||||
|
|
||||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
|
||||||
// 109. Missing binders for non-const sequence elements
|
|
||||||
typename _Operation::result_type
|
|
||||||
operator()(typename _Operation::first_argument_type& __x) const
|
|
||||||
{ return op(__x, value); }
|
|
||||||
} _GLIBCXX_DEPRECATED;
|
|
||||||
|
|
||||||
/// One of the @link binders binder functors@endlink.
|
|
||||||
template<typename _Operation, typename _Tp>
|
|
||||||
inline binder2nd<_Operation>
|
|
||||||
bind2nd(const _Operation& __fn, const _Tp& __x)
|
|
||||||
{
|
|
||||||
typedef typename _Operation::second_argument_type _Arg2_type;
|
|
||||||
return binder2nd<_Operation>(__fn, _Arg2_type(__x));
|
|
||||||
}
|
|
||||||
/** @} */
|
|
||||||
|
|
||||||
_GLIBCXX_END_NAMESPACE_VERSION
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
#pragma GCC diagnostic pop
|
|
||||||
|
|
||||||
#endif /* _BACKWARD_BINDERS_H */
|
|
Binary file not shown.
@ -1,967 +0,0 @@
|
|||||||
// <algorithm> Forward declarations -*- C++ -*-
|
|
||||||
|
|
||||||
// Copyright (C) 2007-2020 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.
|
|
||||||
|
|
||||||
// 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 bits/algorithmfwd.h
|
|
||||||
* This is an internal header file, included by other library headers.
|
|
||||||
* Do not attempt to use it directly. @headername{algorithm}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _GLIBCXX_ALGORITHMFWD_H
|
|
||||||
#define _GLIBCXX_ALGORITHMFWD_H 1
|
|
||||||
|
|
||||||
#pragma GCC system_header
|
|
||||||
|
|
||||||
#include <bits/c++config.h>
|
|
||||||
#include <bits/stl_pair.h>
|
|
||||||
#include <bits/stl_iterator_base_types.h>
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
#include <initializer_list>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace std _GLIBCXX_VISIBILITY(default)
|
|
||||||
{
|
|
||||||
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|
||||||
|
|
||||||
/*
|
|
||||||
adjacent_find
|
|
||||||
all_of (C++11)
|
|
||||||
any_of (C++11)
|
|
||||||
binary_search
|
|
||||||
clamp (C++17)
|
|
||||||
copy
|
|
||||||
copy_backward
|
|
||||||
copy_if (C++11)
|
|
||||||
copy_n (C++11)
|
|
||||||
count
|
|
||||||
count_if
|
|
||||||
equal
|
|
||||||
equal_range
|
|
||||||
fill
|
|
||||||
fill_n
|
|
||||||
find
|
|
||||||
find_end
|
|
||||||
find_first_of
|
|
||||||
find_if
|
|
||||||
find_if_not (C++11)
|
|
||||||
for_each
|
|
||||||
generate
|
|
||||||
generate_n
|
|
||||||
includes
|
|
||||||
inplace_merge
|
|
||||||
is_heap (C++11)
|
|
||||||
is_heap_until (C++11)
|
|
||||||
is_partitioned (C++11)
|
|
||||||
is_sorted (C++11)
|
|
||||||
is_sorted_until (C++11)
|
|
||||||
iter_swap
|
|
||||||
lexicographical_compare
|
|
||||||
lower_bound
|
|
||||||
make_heap
|
|
||||||
max
|
|
||||||
max_element
|
|
||||||
merge
|
|
||||||
min
|
|
||||||
min_element
|
|
||||||
minmax (C++11)
|
|
||||||
minmax_element (C++11)
|
|
||||||
mismatch
|
|
||||||
next_permutation
|
|
||||||
none_of (C++11)
|
|
||||||
nth_element
|
|
||||||
partial_sort
|
|
||||||
partial_sort_copy
|
|
||||||
partition
|
|
||||||
partition_copy (C++11)
|
|
||||||
partition_point (C++11)
|
|
||||||
pop_heap
|
|
||||||
prev_permutation
|
|
||||||
push_heap
|
|
||||||
random_shuffle
|
|
||||||
remove
|
|
||||||
remove_copy
|
|
||||||
remove_copy_if
|
|
||||||
remove_if
|
|
||||||
replace
|
|
||||||
replace_copy
|
|
||||||
replace_copy_if
|
|
||||||
replace_if
|
|
||||||
reverse
|
|
||||||
reverse_copy
|
|
||||||
rotate
|
|
||||||
rotate_copy
|
|
||||||
search
|
|
||||||
search_n
|
|
||||||
set_difference
|
|
||||||
set_intersection
|
|
||||||
set_symmetric_difference
|
|
||||||
set_union
|
|
||||||
shuffle (C++11)
|
|
||||||
sort
|
|
||||||
sort_heap
|
|
||||||
stable_partition
|
|
||||||
stable_sort
|
|
||||||
swap
|
|
||||||
swap_ranges
|
|
||||||
transform
|
|
||||||
unique
|
|
||||||
unique_copy
|
|
||||||
upper_bound
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @defgroup algorithms Algorithms
|
|
||||||
*
|
|
||||||
* Components for performing algorithmic operations. Includes
|
|
||||||
* non-modifying sequence, modifying (mutating) sequence, sorting,
|
|
||||||
* searching, merge, partition, heap, set, minima, maxima, and
|
|
||||||
* permutation operations.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @defgroup mutating_algorithms Mutating
|
|
||||||
* @ingroup algorithms
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @defgroup non_mutating_algorithms Non-Mutating
|
|
||||||
* @ingroup algorithms
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @defgroup sorting_algorithms Sorting
|
|
||||||
* @ingroup algorithms
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @defgroup set_algorithms Set Operations
|
|
||||||
* @ingroup sorting_algorithms
|
|
||||||
*
|
|
||||||
* These algorithms are common set operations performed on sequences
|
|
||||||
* that are already sorted. The number of comparisons will be
|
|
||||||
* linear.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @defgroup binary_search_algorithms Binary Search
|
|
||||||
* @ingroup sorting_algorithms
|
|
||||||
*
|
|
||||||
* These algorithms are variations of a classic binary search, and
|
|
||||||
* all assume that the sequence being searched is already sorted.
|
|
||||||
*
|
|
||||||
* The number of comparisons will be logarithmic (and as few as
|
|
||||||
* possible). The number of steps through the sequence will be
|
|
||||||
* logarithmic for random-access iterators (e.g., pointers), and
|
|
||||||
* linear otherwise.
|
|
||||||
*
|
|
||||||
* The LWG has passed Defect Report 270, which notes: <em>The
|
|
||||||
* proposed resolution reinterprets binary search. Instead of
|
|
||||||
* thinking about searching for a value in a sorted range, we view
|
|
||||||
* that as an important special case of a more general algorithm:
|
|
||||||
* searching for the partition point in a partitioned range. We
|
|
||||||
* also add a guarantee that the old wording did not: we ensure that
|
|
||||||
* the upper bound is no earlier than the lower bound, that the pair
|
|
||||||
* returned by equal_range is a valid range, and that the first part
|
|
||||||
* of that pair is the lower bound.</em>
|
|
||||||
*
|
|
||||||
* The actual effect of the first sentence is that a comparison
|
|
||||||
* functor passed by the user doesn't necessarily need to induce a
|
|
||||||
* strict weak ordering relation. Rather, it partitions the range.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// adjacent_find
|
|
||||||
|
|
||||||
#if __cplusplus > 201703L
|
|
||||||
# define __cpp_lib_constexpr_algorithms 201806L
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
template<typename _IIter, typename _Predicate>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
bool
|
|
||||||
all_of(_IIter, _IIter, _Predicate);
|
|
||||||
|
|
||||||
template<typename _IIter, typename _Predicate>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
bool
|
|
||||||
any_of(_IIter, _IIter, _Predicate);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template<typename _FIter, typename _Tp>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
bool
|
|
||||||
binary_search(_FIter, _FIter, const _Tp&);
|
|
||||||
|
|
||||||
template<typename _FIter, typename _Tp, typename _Compare>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
bool
|
|
||||||
binary_search(_FIter, _FIter, const _Tp&, _Compare);
|
|
||||||
|
|
||||||
#if __cplusplus > 201402L
|
|
||||||
template<typename _Tp>
|
|
||||||
_GLIBCXX14_CONSTEXPR
|
|
||||||
const _Tp&
|
|
||||||
clamp(const _Tp&, const _Tp&, const _Tp&);
|
|
||||||
|
|
||||||
template<typename _Tp, typename _Compare>
|
|
||||||
_GLIBCXX14_CONSTEXPR
|
|
||||||
const _Tp&
|
|
||||||
clamp(const _Tp&, const _Tp&, const _Tp&, _Compare);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template<typename _IIter, typename _OIter>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
_OIter
|
|
||||||
copy(_IIter, _IIter, _OIter);
|
|
||||||
|
|
||||||
template<typename _BIter1, typename _BIter2>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
_BIter2
|
|
||||||
copy_backward(_BIter1, _BIter1, _BIter2);
|
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
template<typename _IIter, typename _OIter, typename _Predicate>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
_OIter
|
|
||||||
copy_if(_IIter, _IIter, _OIter, _Predicate);
|
|
||||||
|
|
||||||
template<typename _IIter, typename _Size, typename _OIter>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
_OIter
|
|
||||||
copy_n(_IIter, _Size, _OIter);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// count
|
|
||||||
// count_if
|
|
||||||
|
|
||||||
template<typename _FIter, typename _Tp>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
pair<_FIter, _FIter>
|
|
||||||
equal_range(_FIter, _FIter, const _Tp&);
|
|
||||||
|
|
||||||
template<typename _FIter, typename _Tp, typename _Compare>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
pair<_FIter, _FIter>
|
|
||||||
equal_range(_FIter, _FIter, const _Tp&, _Compare);
|
|
||||||
|
|
||||||
template<typename _FIter, typename _Tp>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
void
|
|
||||||
fill(_FIter, _FIter, const _Tp&);
|
|
||||||
|
|
||||||
template<typename _OIter, typename _Size, typename _Tp>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
_OIter
|
|
||||||
fill_n(_OIter, _Size, const _Tp&);
|
|
||||||
|
|
||||||
// find
|
|
||||||
|
|
||||||
template<typename _FIter1, typename _FIter2>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
_FIter1
|
|
||||||
find_end(_FIter1, _FIter1, _FIter2, _FIter2);
|
|
||||||
|
|
||||||
template<typename _FIter1, typename _FIter2, typename _BinaryPredicate>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
_FIter1
|
|
||||||
find_end(_FIter1, _FIter1, _FIter2, _FIter2, _BinaryPredicate);
|
|
||||||
|
|
||||||
// find_first_of
|
|
||||||
// find_if
|
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
template<typename _IIter, typename _Predicate>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
_IIter
|
|
||||||
find_if_not(_IIter, _IIter, _Predicate);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// for_each
|
|
||||||
// generate
|
|
||||||
// generate_n
|
|
||||||
|
|
||||||
template<typename _IIter1, typename _IIter2>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
bool
|
|
||||||
includes(_IIter1, _IIter1, _IIter2, _IIter2);
|
|
||||||
|
|
||||||
template<typename _IIter1, typename _IIter2, typename _Compare>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
bool
|
|
||||||
includes(_IIter1, _IIter1, _IIter2, _IIter2, _Compare);
|
|
||||||
|
|
||||||
template<typename _BIter>
|
|
||||||
void
|
|
||||||
inplace_merge(_BIter, _BIter, _BIter);
|
|
||||||
|
|
||||||
template<typename _BIter, typename _Compare>
|
|
||||||
void
|
|
||||||
inplace_merge(_BIter, _BIter, _BIter, _Compare);
|
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
template<typename _RAIter>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
bool
|
|
||||||
is_heap(_RAIter, _RAIter);
|
|
||||||
|
|
||||||
template<typename _RAIter, typename _Compare>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
bool
|
|
||||||
is_heap(_RAIter, _RAIter, _Compare);
|
|
||||||
|
|
||||||
template<typename _RAIter>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
_RAIter
|
|
||||||
is_heap_until(_RAIter, _RAIter);
|
|
||||||
|
|
||||||
template<typename _RAIter, typename _Compare>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
_RAIter
|
|
||||||
is_heap_until(_RAIter, _RAIter, _Compare);
|
|
||||||
|
|
||||||
template<typename _IIter, typename _Predicate>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
bool
|
|
||||||
is_partitioned(_IIter, _IIter, _Predicate);
|
|
||||||
|
|
||||||
template<typename _FIter1, typename _FIter2>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
bool
|
|
||||||
is_permutation(_FIter1, _FIter1, _FIter2);
|
|
||||||
|
|
||||||
template<typename _FIter1, typename _FIter2,
|
|
||||||
typename _BinaryPredicate>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
bool
|
|
||||||
is_permutation(_FIter1, _FIter1, _FIter2, _BinaryPredicate);
|
|
||||||
|
|
||||||
template<typename _FIter>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
bool
|
|
||||||
is_sorted(_FIter, _FIter);
|
|
||||||
|
|
||||||
template<typename _FIter, typename _Compare>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
bool
|
|
||||||
is_sorted(_FIter, _FIter, _Compare);
|
|
||||||
|
|
||||||
template<typename _FIter>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
_FIter
|
|
||||||
is_sorted_until(_FIter, _FIter);
|
|
||||||
|
|
||||||
template<typename _FIter, typename _Compare>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
_FIter
|
|
||||||
is_sorted_until(_FIter, _FIter, _Compare);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template<typename _FIter1, typename _FIter2>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
void
|
|
||||||
iter_swap(_FIter1, _FIter2);
|
|
||||||
|
|
||||||
template<typename _FIter, typename _Tp>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
_FIter
|
|
||||||
lower_bound(_FIter, _FIter, const _Tp&);
|
|
||||||
|
|
||||||
template<typename _FIter, typename _Tp, typename _Compare>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
_FIter
|
|
||||||
lower_bound(_FIter, _FIter, const _Tp&, _Compare);
|
|
||||||
|
|
||||||
template<typename _RAIter>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
void
|
|
||||||
make_heap(_RAIter, _RAIter);
|
|
||||||
|
|
||||||
template<typename _RAIter, typename _Compare>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
void
|
|
||||||
make_heap(_RAIter, _RAIter, _Compare);
|
|
||||||
|
|
||||||
template<typename _Tp>
|
|
||||||
_GLIBCXX14_CONSTEXPR
|
|
||||||
const _Tp&
|
|
||||||
max(const _Tp&, const _Tp&);
|
|
||||||
|
|
||||||
template<typename _Tp, typename _Compare>
|
|
||||||
_GLIBCXX14_CONSTEXPR
|
|
||||||
const _Tp&
|
|
||||||
max(const _Tp&, const _Tp&, _Compare);
|
|
||||||
|
|
||||||
// max_element
|
|
||||||
// merge
|
|
||||||
|
|
||||||
template<typename _Tp>
|
|
||||||
_GLIBCXX14_CONSTEXPR
|
|
||||||
const _Tp&
|
|
||||||
min(const _Tp&, const _Tp&);
|
|
||||||
|
|
||||||
template<typename _Tp, typename _Compare>
|
|
||||||
_GLIBCXX14_CONSTEXPR
|
|
||||||
const _Tp&
|
|
||||||
min(const _Tp&, const _Tp&, _Compare);
|
|
||||||
|
|
||||||
// min_element
|
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
template<typename _Tp>
|
|
||||||
_GLIBCXX14_CONSTEXPR
|
|
||||||
pair<const _Tp&, const _Tp&>
|
|
||||||
minmax(const _Tp&, const _Tp&);
|
|
||||||
|
|
||||||
template<typename _Tp, typename _Compare>
|
|
||||||
_GLIBCXX14_CONSTEXPR
|
|
||||||
pair<const _Tp&, const _Tp&>
|
|
||||||
minmax(const _Tp&, const _Tp&, _Compare);
|
|
||||||
|
|
||||||
template<typename _FIter>
|
|
||||||
_GLIBCXX14_CONSTEXPR
|
|
||||||
pair<_FIter, _FIter>
|
|
||||||
minmax_element(_FIter, _FIter);
|
|
||||||
|
|
||||||
template<typename _FIter, typename _Compare>
|
|
||||||
_GLIBCXX14_CONSTEXPR
|
|
||||||
pair<_FIter, _FIter>
|
|
||||||
minmax_element(_FIter, _FIter, _Compare);
|
|
||||||
|
|
||||||
template<typename _Tp>
|
|
||||||
_GLIBCXX14_CONSTEXPR
|
|
||||||
_Tp
|
|
||||||
min(initializer_list<_Tp>);
|
|
||||||
|
|
||||||
template<typename _Tp, typename _Compare>
|
|
||||||
_GLIBCXX14_CONSTEXPR
|
|
||||||
_Tp
|
|
||||||
min(initializer_list<_Tp>, _Compare);
|
|
||||||
|
|
||||||
template<typename _Tp>
|
|
||||||
_GLIBCXX14_CONSTEXPR
|
|
||||||
_Tp
|
|
||||||
max(initializer_list<_Tp>);
|
|
||||||
|
|
||||||
template<typename _Tp, typename _Compare>
|
|
||||||
_GLIBCXX14_CONSTEXPR
|
|
||||||
_Tp
|
|
||||||
max(initializer_list<_Tp>, _Compare);
|
|
||||||
|
|
||||||
template<typename _Tp>
|
|
||||||
_GLIBCXX14_CONSTEXPR
|
|
||||||
pair<_Tp, _Tp>
|
|
||||||
minmax(initializer_list<_Tp>);
|
|
||||||
|
|
||||||
template<typename _Tp, typename _Compare>
|
|
||||||
_GLIBCXX14_CONSTEXPR
|
|
||||||
pair<_Tp, _Tp>
|
|
||||||
minmax(initializer_list<_Tp>, _Compare);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// mismatch
|
|
||||||
|
|
||||||
template<typename _BIter>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
bool
|
|
||||||
next_permutation(_BIter, _BIter);
|
|
||||||
|
|
||||||
template<typename _BIter, typename _Compare>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
bool
|
|
||||||
next_permutation(_BIter, _BIter, _Compare);
|
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
template<typename _IIter, typename _Predicate>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
bool
|
|
||||||
none_of(_IIter, _IIter, _Predicate);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// nth_element
|
|
||||||
// partial_sort
|
|
||||||
|
|
||||||
template<typename _IIter, typename _RAIter>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
_RAIter
|
|
||||||
partial_sort_copy(_IIter, _IIter, _RAIter, _RAIter);
|
|
||||||
|
|
||||||
template<typename _IIter, typename _RAIter, typename _Compare>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
_RAIter
|
|
||||||
partial_sort_copy(_IIter, _IIter, _RAIter, _RAIter, _Compare);
|
|
||||||
|
|
||||||
// partition
|
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
template<typename _IIter, typename _OIter1,
|
|
||||||
typename _OIter2, typename _Predicate>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
pair<_OIter1, _OIter2>
|
|
||||||
partition_copy(_IIter, _IIter, _OIter1, _OIter2, _Predicate);
|
|
||||||
|
|
||||||
template<typename _FIter, typename _Predicate>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
_FIter
|
|
||||||
partition_point(_FIter, _FIter, _Predicate);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template<typename _RAIter>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
void
|
|
||||||
pop_heap(_RAIter, _RAIter);
|
|
||||||
|
|
||||||
template<typename _RAIter, typename _Compare>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
void
|
|
||||||
pop_heap(_RAIter, _RAIter, _Compare);
|
|
||||||
|
|
||||||
template<typename _BIter>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
bool
|
|
||||||
prev_permutation(_BIter, _BIter);
|
|
||||||
|
|
||||||
template<typename _BIter, typename _Compare>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
bool
|
|
||||||
prev_permutation(_BIter, _BIter, _Compare);
|
|
||||||
|
|
||||||
template<typename _RAIter>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
void
|
|
||||||
push_heap(_RAIter, _RAIter);
|
|
||||||
|
|
||||||
template<typename _RAIter, typename _Compare>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
void
|
|
||||||
push_heap(_RAIter, _RAIter, _Compare);
|
|
||||||
|
|
||||||
// random_shuffle
|
|
||||||
|
|
||||||
template<typename _FIter, typename _Tp>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
_FIter
|
|
||||||
remove(_FIter, _FIter, const _Tp&);
|
|
||||||
|
|
||||||
template<typename _FIter, typename _Predicate>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
_FIter
|
|
||||||
remove_if(_FIter, _FIter, _Predicate);
|
|
||||||
|
|
||||||
template<typename _IIter, typename _OIter, typename _Tp>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
_OIter
|
|
||||||
remove_copy(_IIter, _IIter, _OIter, const _Tp&);
|
|
||||||
|
|
||||||
template<typename _IIter, typename _OIter, typename _Predicate>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
_OIter
|
|
||||||
remove_copy_if(_IIter, _IIter, _OIter, _Predicate);
|
|
||||||
|
|
||||||
// replace
|
|
||||||
|
|
||||||
template<typename _IIter, typename _OIter, typename _Tp>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
_OIter
|
|
||||||
replace_copy(_IIter, _IIter, _OIter, const _Tp&, const _Tp&);
|
|
||||||
|
|
||||||
template<typename _Iter, typename _OIter, typename _Predicate, typename _Tp>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
_OIter
|
|
||||||
replace_copy_if(_Iter, _Iter, _OIter, _Predicate, const _Tp&);
|
|
||||||
|
|
||||||
// replace_if
|
|
||||||
|
|
||||||
template<typename _BIter>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
void
|
|
||||||
reverse(_BIter, _BIter);
|
|
||||||
|
|
||||||
template<typename _BIter, typename _OIter>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
_OIter
|
|
||||||
reverse_copy(_BIter, _BIter, _OIter);
|
|
||||||
|
|
||||||
inline namespace _V2
|
|
||||||
{
|
|
||||||
template<typename _FIter>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
_FIter
|
|
||||||
rotate(_FIter, _FIter, _FIter);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename _FIter, typename _OIter>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
_OIter
|
|
||||||
rotate_copy(_FIter, _FIter, _FIter, _OIter);
|
|
||||||
|
|
||||||
// search
|
|
||||||
// search_n
|
|
||||||
// set_difference
|
|
||||||
// set_intersection
|
|
||||||
// set_symmetric_difference
|
|
||||||
// set_union
|
|
||||||
|
|
||||||
#if (__cplusplus >= 201103L) && defined(_GLIBCXX_USE_C99_STDINT_TR1)
|
|
||||||
template<typename _RAIter, typename _UGenerator>
|
|
||||||
void
|
|
||||||
shuffle(_RAIter, _RAIter, _UGenerator&&);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template<typename _RAIter>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
void
|
|
||||||
sort_heap(_RAIter, _RAIter);
|
|
||||||
|
|
||||||
template<typename _RAIter, typename _Compare>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
void
|
|
||||||
sort_heap(_RAIter, _RAIter, _Compare);
|
|
||||||
|
|
||||||
template<typename _BIter, typename _Predicate>
|
|
||||||
_BIter
|
|
||||||
stable_partition(_BIter, _BIter, _Predicate);
|
|
||||||
|
|
||||||
#if __cplusplus < 201103L
|
|
||||||
// For C++11 swap() is declared in <type_traits>.
|
|
||||||
|
|
||||||
template<typename _Tp, size_t _Nm>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
inline void
|
|
||||||
swap(_Tp& __a, _Tp& __b);
|
|
||||||
|
|
||||||
template<typename _Tp, size_t _Nm>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
inline void
|
|
||||||
swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm]);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template<typename _FIter1, typename _FIter2>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
_FIter2
|
|
||||||
swap_ranges(_FIter1, _FIter1, _FIter2);
|
|
||||||
|
|
||||||
// transform
|
|
||||||
|
|
||||||
template<typename _FIter>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
_FIter
|
|
||||||
unique(_FIter, _FIter);
|
|
||||||
|
|
||||||
template<typename _FIter, typename _BinaryPredicate>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
_FIter
|
|
||||||
unique(_FIter, _FIter, _BinaryPredicate);
|
|
||||||
|
|
||||||
// unique_copy
|
|
||||||
|
|
||||||
template<typename _FIter, typename _Tp>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
_FIter
|
|
||||||
upper_bound(_FIter, _FIter, const _Tp&);
|
|
||||||
|
|
||||||
template<typename _FIter, typename _Tp, typename _Compare>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
_FIter
|
|
||||||
upper_bound(_FIter, _FIter, const _Tp&, _Compare);
|
|
||||||
|
|
||||||
_GLIBCXX_BEGIN_NAMESPACE_ALGO
|
|
||||||
|
|
||||||
template<typename _FIter>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
_FIter
|
|
||||||
adjacent_find(_FIter, _FIter);
|
|
||||||
|
|
||||||
template<typename _FIter, typename _BinaryPredicate>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
_FIter
|
|
||||||
adjacent_find(_FIter, _FIter, _BinaryPredicate);
|
|
||||||
|
|
||||||
template<typename _IIter, typename _Tp>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
typename iterator_traits<_IIter>::difference_type
|
|
||||||
count(_IIter, _IIter, const _Tp&);
|
|
||||||
|
|
||||||
template<typename _IIter, typename _Predicate>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
typename iterator_traits<_IIter>::difference_type
|
|
||||||
count_if(_IIter, _IIter, _Predicate);
|
|
||||||
|
|
||||||
template<typename _IIter1, typename _IIter2>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
bool
|
|
||||||
equal(_IIter1, _IIter1, _IIter2);
|
|
||||||
|
|
||||||
template<typename _IIter1, typename _IIter2, typename _BinaryPredicate>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
bool
|
|
||||||
equal(_IIter1, _IIter1, _IIter2, _BinaryPredicate);
|
|
||||||
|
|
||||||
template<typename _IIter, typename _Tp>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
_IIter
|
|
||||||
find(_IIter, _IIter, const _Tp&);
|
|
||||||
|
|
||||||
template<typename _FIter1, typename _FIter2>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
_FIter1
|
|
||||||
find_first_of(_FIter1, _FIter1, _FIter2, _FIter2);
|
|
||||||
|
|
||||||
template<typename _FIter1, typename _FIter2, typename _BinaryPredicate>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
_FIter1
|
|
||||||
find_first_of(_FIter1, _FIter1, _FIter2, _FIter2, _BinaryPredicate);
|
|
||||||
|
|
||||||
template<typename _IIter, typename _Predicate>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
_IIter
|
|
||||||
find_if(_IIter, _IIter, _Predicate);
|
|
||||||
|
|
||||||
template<typename _IIter, typename _Funct>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
_Funct
|
|
||||||
for_each(_IIter, _IIter, _Funct);
|
|
||||||
|
|
||||||
template<typename _FIter, typename _Generator>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
void
|
|
||||||
generate(_FIter, _FIter, _Generator);
|
|
||||||
|
|
||||||
template<typename _OIter, typename _Size, typename _Generator>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
_OIter
|
|
||||||
generate_n(_OIter, _Size, _Generator);
|
|
||||||
|
|
||||||
template<typename _IIter1, typename _IIter2>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
bool
|
|
||||||
lexicographical_compare(_IIter1, _IIter1, _IIter2, _IIter2);
|
|
||||||
|
|
||||||
template<typename _IIter1, typename _IIter2, typename _Compare>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
bool
|
|
||||||
lexicographical_compare(_IIter1, _IIter1, _IIter2, _IIter2, _Compare);
|
|
||||||
|
|
||||||
template<typename _FIter>
|
|
||||||
_GLIBCXX14_CONSTEXPR
|
|
||||||
_FIter
|
|
||||||
max_element(_FIter, _FIter);
|
|
||||||
|
|
||||||
template<typename _FIter, typename _Compare>
|
|
||||||
_GLIBCXX14_CONSTEXPR
|
|
||||||
_FIter
|
|
||||||
max_element(_FIter, _FIter, _Compare);
|
|
||||||
|
|
||||||
template<typename _IIter1, typename _IIter2, typename _OIter>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
_OIter
|
|
||||||
merge(_IIter1, _IIter1, _IIter2, _IIter2, _OIter);
|
|
||||||
|
|
||||||
template<typename _IIter1, typename _IIter2, typename _OIter,
|
|
||||||
typename _Compare>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
_OIter
|
|
||||||
merge(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare);
|
|
||||||
|
|
||||||
template<typename _FIter>
|
|
||||||
_GLIBCXX14_CONSTEXPR
|
|
||||||
_FIter
|
|
||||||
min_element(_FIter, _FIter);
|
|
||||||
|
|
||||||
template<typename _FIter, typename _Compare>
|
|
||||||
_GLIBCXX14_CONSTEXPR
|
|
||||||
_FIter
|
|
||||||
min_element(_FIter, _FIter, _Compare);
|
|
||||||
|
|
||||||
template<typename _IIter1, typename _IIter2>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
pair<_IIter1, _IIter2>
|
|
||||||
mismatch(_IIter1, _IIter1, _IIter2);
|
|
||||||
|
|
||||||
template<typename _IIter1, typename _IIter2, typename _BinaryPredicate>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
pair<_IIter1, _IIter2>
|
|
||||||
mismatch(_IIter1, _IIter1, _IIter2, _BinaryPredicate);
|
|
||||||
|
|
||||||
template<typename _RAIter>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
void
|
|
||||||
nth_element(_RAIter, _RAIter, _RAIter);
|
|
||||||
|
|
||||||
template<typename _RAIter, typename _Compare>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
void
|
|
||||||
nth_element(_RAIter, _RAIter, _RAIter, _Compare);
|
|
||||||
|
|
||||||
template<typename _RAIter>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
void
|
|
||||||
partial_sort(_RAIter, _RAIter, _RAIter);
|
|
||||||
|
|
||||||
template<typename _RAIter, typename _Compare>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
void
|
|
||||||
partial_sort(_RAIter, _RAIter, _RAIter, _Compare);
|
|
||||||
|
|
||||||
template<typename _BIter, typename _Predicate>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
_BIter
|
|
||||||
partition(_BIter, _BIter, _Predicate);
|
|
||||||
|
|
||||||
template<typename _RAIter>
|
|
||||||
void
|
|
||||||
random_shuffle(_RAIter, _RAIter);
|
|
||||||
|
|
||||||
template<typename _RAIter, typename _Generator>
|
|
||||||
void
|
|
||||||
random_shuffle(_RAIter, _RAIter,
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
_Generator&&);
|
|
||||||
#else
|
|
||||||
_Generator&);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template<typename _FIter, typename _Tp>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
void
|
|
||||||
replace(_FIter, _FIter, const _Tp&, const _Tp&);
|
|
||||||
|
|
||||||
template<typename _FIter, typename _Predicate, typename _Tp>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
void
|
|
||||||
replace_if(_FIter, _FIter, _Predicate, const _Tp&);
|
|
||||||
|
|
||||||
template<typename _FIter1, typename _FIter2>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
_FIter1
|
|
||||||
search(_FIter1, _FIter1, _FIter2, _FIter2);
|
|
||||||
|
|
||||||
template<typename _FIter1, typename _FIter2, typename _BinaryPredicate>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
_FIter1
|
|
||||||
search(_FIter1, _FIter1, _FIter2, _FIter2, _BinaryPredicate);
|
|
||||||
|
|
||||||
template<typename _FIter, typename _Size, typename _Tp>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
_FIter
|
|
||||||
search_n(_FIter, _FIter, _Size, const _Tp&);
|
|
||||||
|
|
||||||
template<typename _FIter, typename _Size, typename _Tp,
|
|
||||||
typename _BinaryPredicate>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
_FIter
|
|
||||||
search_n(_FIter, _FIter, _Size, const _Tp&, _BinaryPredicate);
|
|
||||||
|
|
||||||
template<typename _IIter1, typename _IIter2, typename _OIter>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
_OIter
|
|
||||||
set_difference(_IIter1, _IIter1, _IIter2, _IIter2, _OIter);
|
|
||||||
|
|
||||||
template<typename _IIter1, typename _IIter2, typename _OIter,
|
|
||||||
typename _Compare>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
_OIter
|
|
||||||
set_difference(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare);
|
|
||||||
|
|
||||||
template<typename _IIter1, typename _IIter2, typename _OIter>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
_OIter
|
|
||||||
set_intersection(_IIter1, _IIter1, _IIter2, _IIter2, _OIter);
|
|
||||||
|
|
||||||
template<typename _IIter1, typename _IIter2, typename _OIter,
|
|
||||||
typename _Compare>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
_OIter
|
|
||||||
set_intersection(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare);
|
|
||||||
|
|
||||||
template<typename _IIter1, typename _IIter2, typename _OIter>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
_OIter
|
|
||||||
set_symmetric_difference(_IIter1, _IIter1, _IIter2, _IIter2, _OIter);
|
|
||||||
|
|
||||||
template<typename _IIter1, typename _IIter2, typename _OIter,
|
|
||||||
typename _Compare>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
_OIter
|
|
||||||
set_symmetric_difference(_IIter1, _IIter1, _IIter2, _IIter2,
|
|
||||||
_OIter, _Compare);
|
|
||||||
|
|
||||||
template<typename _IIter1, typename _IIter2, typename _OIter>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
_OIter
|
|
||||||
set_union(_IIter1, _IIter1, _IIter2, _IIter2, _OIter);
|
|
||||||
|
|
||||||
template<typename _IIter1, typename _IIter2, typename _OIter,
|
|
||||||
typename _Compare>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
_OIter
|
|
||||||
set_union(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare);
|
|
||||||
|
|
||||||
template<typename _RAIter>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
void
|
|
||||||
sort(_RAIter, _RAIter);
|
|
||||||
|
|
||||||
template<typename _RAIter, typename _Compare>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
void
|
|
||||||
sort(_RAIter, _RAIter, _Compare);
|
|
||||||
|
|
||||||
template<typename _RAIter>
|
|
||||||
void
|
|
||||||
stable_sort(_RAIter, _RAIter);
|
|
||||||
|
|
||||||
template<typename _RAIter, typename _Compare>
|
|
||||||
void
|
|
||||||
stable_sort(_RAIter, _RAIter, _Compare);
|
|
||||||
|
|
||||||
template<typename _IIter, typename _OIter, typename _UnaryOperation>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
_OIter
|
|
||||||
transform(_IIter, _IIter, _OIter, _UnaryOperation);
|
|
||||||
|
|
||||||
template<typename _IIter1, typename _IIter2, typename _OIter,
|
|
||||||
typename _BinaryOperation>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
_OIter
|
|
||||||
transform(_IIter1, _IIter1, _IIter2, _OIter, _BinaryOperation);
|
|
||||||
|
|
||||||
template<typename _IIter, typename _OIter>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
_OIter
|
|
||||||
unique_copy(_IIter, _IIter, _OIter);
|
|
||||||
|
|
||||||
template<typename _IIter, typename _OIter, typename _BinaryPredicate>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
_OIter
|
|
||||||
unique_copy(_IIter, _IIter, _OIter, _BinaryPredicate);
|
|
||||||
|
|
||||||
_GLIBCXX_END_NAMESPACE_ALGO
|
|
||||||
_GLIBCXX_END_NAMESPACE_VERSION
|
|
||||||
} // namespace std
|
|
||||||
|
|
||||||
#ifdef _GLIBCXX_PARALLEL
|
|
||||||
# include <parallel/algorithmfwd.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
Binary file not shown.
@ -1,743 +0,0 @@
|
|||||||
// Allocator traits -*- C++ -*-
|
|
||||||
|
|
||||||
// Copyright (C) 2011-2020 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.
|
|
||||||
|
|
||||||
// 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 bits/alloc_traits.h
|
|
||||||
* This is an internal header file, included by other library headers.
|
|
||||||
* Do not attempt to use it directly. @headername{memory}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _ALLOC_TRAITS_H
|
|
||||||
#define _ALLOC_TRAITS_H 1
|
|
||||||
|
|
||||||
#include <bits/stl_construct.h>
|
|
||||||
#include <bits/memoryfwd.h>
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
# include <bits/allocator.h>
|
|
||||||
# include <bits/ptr_traits.h>
|
|
||||||
# include <ext/numeric_traits.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace std _GLIBCXX_VISIBILITY(default)
|
|
||||||
{
|
|
||||||
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
#define __cpp_lib_allocator_traits_is_always_equal 201411
|
|
||||||
|
|
||||||
struct __allocator_traits_base
|
|
||||||
{
|
|
||||||
template<typename _Tp, typename _Up, typename = void>
|
|
||||||
struct __rebind : __replace_first_arg<_Tp, _Up> { };
|
|
||||||
|
|
||||||
template<typename _Tp, typename _Up>
|
|
||||||
struct __rebind<_Tp, _Up,
|
|
||||||
__void_t<typename _Tp::template rebind<_Up>::other>>
|
|
||||||
{ using type = typename _Tp::template rebind<_Up>::other; };
|
|
||||||
|
|
||||||
protected:
|
|
||||||
template<typename _Tp>
|
|
||||||
using __pointer = typename _Tp::pointer;
|
|
||||||
template<typename _Tp>
|
|
||||||
using __c_pointer = typename _Tp::const_pointer;
|
|
||||||
template<typename _Tp>
|
|
||||||
using __v_pointer = typename _Tp::void_pointer;
|
|
||||||
template<typename _Tp>
|
|
||||||
using __cv_pointer = typename _Tp::const_void_pointer;
|
|
||||||
template<typename _Tp>
|
|
||||||
using __pocca = typename _Tp::propagate_on_container_copy_assignment;
|
|
||||||
template<typename _Tp>
|
|
||||||
using __pocma = typename _Tp::propagate_on_container_move_assignment;
|
|
||||||
template<typename _Tp>
|
|
||||||
using __pocs = typename _Tp::propagate_on_container_swap;
|
|
||||||
template<typename _Tp>
|
|
||||||
using __equal = typename _Tp::is_always_equal;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename _Alloc, typename _Up>
|
|
||||||
using __alloc_rebind
|
|
||||||
= typename __allocator_traits_base::template __rebind<_Alloc, _Up>::type;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Uniform interface to all allocator types.
|
|
||||||
* @ingroup allocators
|
|
||||||
*/
|
|
||||||
template<typename _Alloc>
|
|
||||||
struct allocator_traits : __allocator_traits_base
|
|
||||||
{
|
|
||||||
/// The allocator type
|
|
||||||
typedef _Alloc allocator_type;
|
|
||||||
/// The allocated type
|
|
||||||
typedef typename _Alloc::value_type value_type;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The allocator's pointer type.
|
|
||||||
*
|
|
||||||
* @c Alloc::pointer if that type exists, otherwise @c value_type*
|
|
||||||
*/
|
|
||||||
using pointer = __detected_or_t<value_type*, __pointer, _Alloc>;
|
|
||||||
|
|
||||||
private:
|
|
||||||
// Select _Func<_Alloc> or pointer_traits<pointer>::rebind<_Tp>
|
|
||||||
template<template<typename> class _Func, typename _Tp, typename = void>
|
|
||||||
struct _Ptr
|
|
||||||
{
|
|
||||||
using type = typename pointer_traits<pointer>::template rebind<_Tp>;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<template<typename> class _Func, typename _Tp>
|
|
||||||
struct _Ptr<_Func, _Tp, __void_t<_Func<_Alloc>>>
|
|
||||||
{
|
|
||||||
using type = _Func<_Alloc>;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Select _A2::difference_type or pointer_traits<_Ptr>::difference_type
|
|
||||||
template<typename _A2, typename _PtrT, typename = void>
|
|
||||||
struct _Diff
|
|
||||||
{ using type = typename pointer_traits<_PtrT>::difference_type; };
|
|
||||||
|
|
||||||
template<typename _A2, typename _PtrT>
|
|
||||||
struct _Diff<_A2, _PtrT, __void_t<typename _A2::difference_type>>
|
|
||||||
{ using type = typename _A2::difference_type; };
|
|
||||||
|
|
||||||
// Select _A2::size_type or make_unsigned<_DiffT>::type
|
|
||||||
template<typename _A2, typename _DiffT, typename = void>
|
|
||||||
struct _Size : make_unsigned<_DiffT> { };
|
|
||||||
|
|
||||||
template<typename _A2, typename _DiffT>
|
|
||||||
struct _Size<_A2, _DiffT, __void_t<typename _A2::size_type>>
|
|
||||||
{ using type = typename _A2::size_type; };
|
|
||||||
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* @brief The allocator's const pointer type.
|
|
||||||
*
|
|
||||||
* @c Alloc::const_pointer if that type exists, otherwise
|
|
||||||
* <tt> pointer_traits<pointer>::rebind<const value_type> </tt>
|
|
||||||
*/
|
|
||||||
using const_pointer = typename _Ptr<__c_pointer, const value_type>::type;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The allocator's void pointer type.
|
|
||||||
*
|
|
||||||
* @c Alloc::void_pointer if that type exists, otherwise
|
|
||||||
* <tt> pointer_traits<pointer>::rebind<void> </tt>
|
|
||||||
*/
|
|
||||||
using void_pointer = typename _Ptr<__v_pointer, void>::type;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The allocator's const void pointer type.
|
|
||||||
*
|
|
||||||
* @c Alloc::const_void_pointer if that type exists, otherwise
|
|
||||||
* <tt> pointer_traits<pointer>::rebind<const void> </tt>
|
|
||||||
*/
|
|
||||||
using const_void_pointer = typename _Ptr<__cv_pointer, const void>::type;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The allocator's difference type
|
|
||||||
*
|
|
||||||
* @c Alloc::difference_type if that type exists, otherwise
|
|
||||||
* <tt> pointer_traits<pointer>::difference_type </tt>
|
|
||||||
*/
|
|
||||||
using difference_type = typename _Diff<_Alloc, pointer>::type;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The allocator's size type
|
|
||||||
*
|
|
||||||
* @c Alloc::size_type if that type exists, otherwise
|
|
||||||
* <tt> make_unsigned<difference_type>::type </tt>
|
|
||||||
*/
|
|
||||||
using size_type = typename _Size<_Alloc, difference_type>::type;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief How the allocator is propagated on copy assignment
|
|
||||||
*
|
|
||||||
* @c Alloc::propagate_on_container_copy_assignment if that type exists,
|
|
||||||
* otherwise @c false_type
|
|
||||||
*/
|
|
||||||
using propagate_on_container_copy_assignment
|
|
||||||
= __detected_or_t<false_type, __pocca, _Alloc>;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief How the allocator is propagated on move assignment
|
|
||||||
*
|
|
||||||
* @c Alloc::propagate_on_container_move_assignment if that type exists,
|
|
||||||
* otherwise @c false_type
|
|
||||||
*/
|
|
||||||
using propagate_on_container_move_assignment
|
|
||||||
= __detected_or_t<false_type, __pocma, _Alloc>;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief How the allocator is propagated on swap
|
|
||||||
*
|
|
||||||
* @c Alloc::propagate_on_container_swap if that type exists,
|
|
||||||
* otherwise @c false_type
|
|
||||||
*/
|
|
||||||
using propagate_on_container_swap
|
|
||||||
= __detected_or_t<false_type, __pocs, _Alloc>;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Whether all instances of the allocator type compare equal.
|
|
||||||
*
|
|
||||||
* @c Alloc::is_always_equal if that type exists,
|
|
||||||
* otherwise @c is_empty<Alloc>::type
|
|
||||||
*/
|
|
||||||
using is_always_equal
|
|
||||||
= __detected_or_t<typename is_empty<_Alloc>::type, __equal, _Alloc>;
|
|
||||||
|
|
||||||
template<typename _Tp>
|
|
||||||
using rebind_alloc = __alloc_rebind<_Alloc, _Tp>;
|
|
||||||
template<typename _Tp>
|
|
||||||
using rebind_traits = allocator_traits<rebind_alloc<_Tp>>;
|
|
||||||
|
|
||||||
private:
|
|
||||||
template<typename _Alloc2>
|
|
||||||
static constexpr auto
|
|
||||||
_S_allocate(_Alloc2& __a, size_type __n, const_void_pointer __hint, int)
|
|
||||||
-> decltype(__a.allocate(__n, __hint))
|
|
||||||
{ return __a.allocate(__n, __hint); }
|
|
||||||
|
|
||||||
template<typename _Alloc2>
|
|
||||||
static constexpr pointer
|
|
||||||
_S_allocate(_Alloc2& __a, size_type __n, const_void_pointer, ...)
|
|
||||||
{ return __a.allocate(__n); }
|
|
||||||
|
|
||||||
template<typename _Tp, typename... _Args>
|
|
||||||
struct __construct_helper
|
|
||||||
{
|
|
||||||
template<typename _Alloc2,
|
|
||||||
typename = decltype(std::declval<_Alloc2*>()->construct(
|
|
||||||
std::declval<_Tp*>(), std::declval<_Args>()...))>
|
|
||||||
static true_type __test(int);
|
|
||||||
|
|
||||||
template<typename>
|
|
||||||
static false_type __test(...);
|
|
||||||
|
|
||||||
using type = decltype(__test<_Alloc>(0));
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename _Tp, typename... _Args>
|
|
||||||
using __has_construct
|
|
||||||
= typename __construct_helper<_Tp, _Args...>::type;
|
|
||||||
|
|
||||||
template<typename _Tp, typename... _Args>
|
|
||||||
static _GLIBCXX14_CONSTEXPR _Require<__has_construct<_Tp, _Args...>>
|
|
||||||
_S_construct(_Alloc& __a, _Tp* __p, _Args&&... __args)
|
|
||||||
noexcept(noexcept(__a.construct(__p, std::forward<_Args>(__args)...)))
|
|
||||||
{ __a.construct(__p, std::forward<_Args>(__args)...); }
|
|
||||||
|
|
||||||
template<typename _Tp, typename... _Args>
|
|
||||||
static _GLIBCXX14_CONSTEXPR
|
|
||||||
_Require<__and_<__not_<__has_construct<_Tp, _Args...>>,
|
|
||||||
is_constructible<_Tp, _Args...>>>
|
|
||||||
_S_construct(_Alloc&, _Tp* __p, _Args&&... __args)
|
|
||||||
noexcept(std::is_nothrow_constructible<_Tp, _Args...>::value)
|
|
||||||
{
|
|
||||||
#if __cplusplus <= 201703L
|
|
||||||
::new((void*)__p) _Tp(std::forward<_Args>(__args)...);
|
|
||||||
#else
|
|
||||||
std::construct_at(__p, std::forward<_Args>(__args)...);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename _Alloc2, typename _Tp>
|
|
||||||
static _GLIBCXX14_CONSTEXPR auto
|
|
||||||
_S_destroy(_Alloc2& __a, _Tp* __p, int)
|
|
||||||
noexcept(noexcept(__a.destroy(__p)))
|
|
||||||
-> decltype(__a.destroy(__p))
|
|
||||||
{ __a.destroy(__p); }
|
|
||||||
|
|
||||||
template<typename _Alloc2, typename _Tp>
|
|
||||||
static _GLIBCXX14_CONSTEXPR void
|
|
||||||
_S_destroy(_Alloc2&, _Tp* __p, ...)
|
|
||||||
noexcept(std::is_nothrow_destructible<_Tp>::value)
|
|
||||||
{ std::_Destroy(__p); }
|
|
||||||
|
|
||||||
template<typename _Alloc2>
|
|
||||||
static constexpr auto
|
|
||||||
_S_max_size(_Alloc2& __a, int)
|
|
||||||
-> decltype(__a.max_size())
|
|
||||||
{ return __a.max_size(); }
|
|
||||||
|
|
||||||
template<typename _Alloc2>
|
|
||||||
static constexpr size_type
|
|
||||||
_S_max_size(_Alloc2&, ...)
|
|
||||||
{
|
|
||||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
|
||||||
// 2466. allocator_traits::max_size() default behavior is incorrect
|
|
||||||
return __gnu_cxx::__numeric_traits<size_type>::__max
|
|
||||||
/ sizeof(value_type);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename _Alloc2>
|
|
||||||
static constexpr auto
|
|
||||||
_S_select(_Alloc2& __a, int)
|
|
||||||
-> decltype(__a.select_on_container_copy_construction())
|
|
||||||
{ return __a.select_on_container_copy_construction(); }
|
|
||||||
|
|
||||||
template<typename _Alloc2>
|
|
||||||
static constexpr _Alloc2
|
|
||||||
_S_select(_Alloc2& __a, ...)
|
|
||||||
{ return __a; }
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Allocate memory.
|
|
||||||
* @param __a An allocator.
|
|
||||||
* @param __n The number of objects to allocate space for.
|
|
||||||
*
|
|
||||||
* Calls @c a.allocate(n)
|
|
||||||
*/
|
|
||||||
_GLIBCXX_NODISCARD static _GLIBCXX20_CONSTEXPR pointer
|
|
||||||
allocate(_Alloc& __a, size_type __n)
|
|
||||||
{ return __a.allocate(__n); }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Allocate memory.
|
|
||||||
* @param __a An allocator.
|
|
||||||
* @param __n The number of objects to allocate space for.
|
|
||||||
* @param __hint Aid to locality.
|
|
||||||
* @return Memory of suitable size and alignment for @a n objects
|
|
||||||
* of type @c value_type
|
|
||||||
*
|
|
||||||
* Returns <tt> a.allocate(n, hint) </tt> if that expression is
|
|
||||||
* well-formed, otherwise returns @c a.allocate(n)
|
|
||||||
*/
|
|
||||||
_GLIBCXX_NODISCARD static _GLIBCXX20_CONSTEXPR pointer
|
|
||||||
allocate(_Alloc& __a, size_type __n, const_void_pointer __hint)
|
|
||||||
{ return _S_allocate(__a, __n, __hint, 0); }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Deallocate memory.
|
|
||||||
* @param __a An allocator.
|
|
||||||
* @param __p Pointer to the memory to deallocate.
|
|
||||||
* @param __n The number of objects space was allocated for.
|
|
||||||
*
|
|
||||||
* Calls <tt> a.deallocate(p, n) </tt>
|
|
||||||
*/
|
|
||||||
static _GLIBCXX20_CONSTEXPR void
|
|
||||||
deallocate(_Alloc& __a, pointer __p, size_type __n)
|
|
||||||
{ __a.deallocate(__p, __n); }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Construct an object of type @a _Tp
|
|
||||||
* @param __a An allocator.
|
|
||||||
* @param __p Pointer to memory of suitable size and alignment for Tp
|
|
||||||
* @param __args Constructor arguments.
|
|
||||||
*
|
|
||||||
* Calls <tt> __a.construct(__p, std::forward<Args>(__args)...) </tt>
|
|
||||||
* if that expression is well-formed, otherwise uses placement-new
|
|
||||||
* to construct an object of type @a _Tp at location @a __p from the
|
|
||||||
* arguments @a __args...
|
|
||||||
*/
|
|
||||||
template<typename _Tp, typename... _Args>
|
|
||||||
static _GLIBCXX20_CONSTEXPR auto
|
|
||||||
construct(_Alloc& __a, _Tp* __p, _Args&&... __args)
|
|
||||||
noexcept(noexcept(_S_construct(__a, __p,
|
|
||||||
std::forward<_Args>(__args)...)))
|
|
||||||
-> decltype(_S_construct(__a, __p, std::forward<_Args>(__args)...))
|
|
||||||
{ _S_construct(__a, __p, std::forward<_Args>(__args)...); }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Destroy an object of type @a _Tp
|
|
||||||
* @param __a An allocator.
|
|
||||||
* @param __p Pointer to the object to destroy
|
|
||||||
*
|
|
||||||
* Calls @c __a.destroy(__p) if that expression is well-formed,
|
|
||||||
* otherwise calls @c __p->~_Tp()
|
|
||||||
*/
|
|
||||||
template<typename _Tp>
|
|
||||||
static _GLIBCXX20_CONSTEXPR void
|
|
||||||
destroy(_Alloc& __a, _Tp* __p)
|
|
||||||
noexcept(noexcept(_S_destroy(__a, __p, 0)))
|
|
||||||
{ _S_destroy(__a, __p, 0); }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The maximum supported allocation size
|
|
||||||
* @param __a An allocator.
|
|
||||||
* @return @c __a.max_size() or @c numeric_limits<size_type>::max()
|
|
||||||
*
|
|
||||||
* Returns @c __a.max_size() if that expression is well-formed,
|
|
||||||
* otherwise returns @c numeric_limits<size_type>::max()
|
|
||||||
*/
|
|
||||||
static _GLIBCXX20_CONSTEXPR size_type
|
|
||||||
max_size(const _Alloc& __a) noexcept
|
|
||||||
{ return _S_max_size(__a, 0); }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Obtain an allocator to use when copying a container.
|
|
||||||
* @param __rhs An allocator.
|
|
||||||
* @return @c __rhs.select_on_container_copy_construction() or @a __rhs
|
|
||||||
*
|
|
||||||
* Returns @c __rhs.select_on_container_copy_construction() if that
|
|
||||||
* expression is well-formed, otherwise returns @a __rhs
|
|
||||||
*/
|
|
||||||
static _GLIBCXX20_CONSTEXPR _Alloc
|
|
||||||
select_on_container_copy_construction(const _Alloc& __rhs)
|
|
||||||
{ return _S_select(__rhs, 0); }
|
|
||||||
};
|
|
||||||
|
|
||||||
#if __cplusplus > 201703L
|
|
||||||
# define __cpp_lib_constexpr_dynamic_alloc 201907L
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/// Partial specialization for std::allocator.
|
|
||||||
template<typename _Tp>
|
|
||||||
struct allocator_traits<allocator<_Tp>>
|
|
||||||
{
|
|
||||||
/// The allocator type
|
|
||||||
using allocator_type = allocator<_Tp>;
|
|
||||||
|
|
||||||
/// The allocated type
|
|
||||||
using value_type = _Tp;
|
|
||||||
|
|
||||||
/// The allocator's pointer type.
|
|
||||||
using pointer = _Tp*;
|
|
||||||
|
|
||||||
/// The allocator's const pointer type.
|
|
||||||
using const_pointer = const _Tp*;
|
|
||||||
|
|
||||||
/// The allocator's void pointer type.
|
|
||||||
using void_pointer = void*;
|
|
||||||
|
|
||||||
/// The allocator's const void pointer type.
|
|
||||||
using const_void_pointer = const void*;
|
|
||||||
|
|
||||||
/// The allocator's difference type
|
|
||||||
using difference_type = std::ptrdiff_t;
|
|
||||||
|
|
||||||
/// The allocator's size type
|
|
||||||
using size_type = std::size_t;
|
|
||||||
|
|
||||||
/// How the allocator is propagated on copy assignment
|
|
||||||
using propagate_on_container_copy_assignment = false_type;
|
|
||||||
|
|
||||||
/// How the allocator is propagated on move assignment
|
|
||||||
using propagate_on_container_move_assignment = true_type;
|
|
||||||
|
|
||||||
/// How the allocator is propagated on swap
|
|
||||||
using propagate_on_container_swap = false_type;
|
|
||||||
|
|
||||||
/// Whether all instances of the allocator type compare equal.
|
|
||||||
using is_always_equal = true_type;
|
|
||||||
|
|
||||||
template<typename _Up>
|
|
||||||
using rebind_alloc = allocator<_Up>;
|
|
||||||
|
|
||||||
template<typename _Up>
|
|
||||||
using rebind_traits = allocator_traits<allocator<_Up>>;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Allocate memory.
|
|
||||||
* @param __a An allocator.
|
|
||||||
* @param __n The number of objects to allocate space for.
|
|
||||||
*
|
|
||||||
* Calls @c a.allocate(n)
|
|
||||||
*/
|
|
||||||
_GLIBCXX_NODISCARD static _GLIBCXX20_CONSTEXPR pointer
|
|
||||||
allocate(allocator_type& __a, size_type __n)
|
|
||||||
{ return __a.allocate(__n); }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Allocate memory.
|
|
||||||
* @param __a An allocator.
|
|
||||||
* @param __n The number of objects to allocate space for.
|
|
||||||
* @param __hint Aid to locality.
|
|
||||||
* @return Memory of suitable size and alignment for @a n objects
|
|
||||||
* of type @c value_type
|
|
||||||
*
|
|
||||||
* Returns <tt> a.allocate(n, hint) </tt>
|
|
||||||
*/
|
|
||||||
_GLIBCXX_NODISCARD static _GLIBCXX20_CONSTEXPR pointer
|
|
||||||
allocate(allocator_type& __a, size_type __n, const_void_pointer __hint)
|
|
||||||
{
|
|
||||||
#if __cplusplus <= 201703L
|
|
||||||
return __a.allocate(__n, __hint);
|
|
||||||
#else
|
|
||||||
return __a.allocate(__n);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Deallocate memory.
|
|
||||||
* @param __a An allocator.
|
|
||||||
* @param __p Pointer to the memory to deallocate.
|
|
||||||
* @param __n The number of objects space was allocated for.
|
|
||||||
*
|
|
||||||
* Calls <tt> a.deallocate(p, n) </tt>
|
|
||||||
*/
|
|
||||||
static _GLIBCXX20_CONSTEXPR void
|
|
||||||
deallocate(allocator_type& __a, pointer __p, size_type __n)
|
|
||||||
{ __a.deallocate(__p, __n); }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Construct an object of type `_Up`
|
|
||||||
* @param __a An allocator.
|
|
||||||
* @param __p Pointer to memory of suitable size and alignment for
|
|
||||||
* an object of type `_Up`.
|
|
||||||
* @param __args Constructor arguments.
|
|
||||||
*
|
|
||||||
* Calls `__a.construct(__p, std::forward<_Args>(__args)...)`
|
|
||||||
* in C++11, C++14 and C++17. Changed in C++20 to call
|
|
||||||
* `std::construct_at(__p, std::forward<_Args>(__args)...)` instead.
|
|
||||||
*/
|
|
||||||
template<typename _Up, typename... _Args>
|
|
||||||
static _GLIBCXX20_CONSTEXPR void
|
|
||||||
construct(allocator_type& __a __attribute__((__unused__)), _Up* __p,
|
|
||||||
_Args&&... __args)
|
|
||||||
noexcept(std::is_nothrow_constructible<_Up, _Args...>::value)
|
|
||||||
{
|
|
||||||
#if __cplusplus <= 201703L
|
|
||||||
__a.construct(__p, std::forward<_Args>(__args)...);
|
|
||||||
#else
|
|
||||||
std::construct_at(__p, std::forward<_Args>(__args)...);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Destroy an object of type @a _Up
|
|
||||||
* @param __a An allocator.
|
|
||||||
* @param __p Pointer to the object to destroy
|
|
||||||
*
|
|
||||||
* Calls @c __a.destroy(__p).
|
|
||||||
*/
|
|
||||||
template<typename _Up>
|
|
||||||
static _GLIBCXX20_CONSTEXPR void
|
|
||||||
destroy(allocator_type& __a __attribute__((__unused__)), _Up* __p)
|
|
||||||
noexcept(is_nothrow_destructible<_Up>::value)
|
|
||||||
{
|
|
||||||
#if __cplusplus <= 201703L
|
|
||||||
__a.destroy(__p);
|
|
||||||
#else
|
|
||||||
std::destroy_at(__p);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The maximum supported allocation size
|
|
||||||
* @param __a An allocator.
|
|
||||||
* @return @c __a.max_size()
|
|
||||||
*/
|
|
||||||
static _GLIBCXX20_CONSTEXPR size_type
|
|
||||||
max_size(const allocator_type& __a __attribute__((__unused__))) noexcept
|
|
||||||
{
|
|
||||||
#if __cplusplus <= 201703L
|
|
||||||
return __a.max_size();
|
|
||||||
#else
|
|
||||||
return size_t(-1) / sizeof(value_type);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Obtain an allocator to use when copying a container.
|
|
||||||
* @param __rhs An allocator.
|
|
||||||
* @return @c __rhs
|
|
||||||
*/
|
|
||||||
static _GLIBCXX20_CONSTEXPR allocator_type
|
|
||||||
select_on_container_copy_construction(const allocator_type& __rhs)
|
|
||||||
{ return __rhs; }
|
|
||||||
};
|
|
||||||
|
|
||||||
#if __cplusplus < 201703L
|
|
||||||
template<typename _Alloc>
|
|
||||||
inline void
|
|
||||||
__do_alloc_on_copy(_Alloc& __one, const _Alloc& __two, true_type)
|
|
||||||
{ __one = __two; }
|
|
||||||
|
|
||||||
template<typename _Alloc>
|
|
||||||
inline void
|
|
||||||
__do_alloc_on_copy(_Alloc&, const _Alloc&, false_type)
|
|
||||||
{ }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template<typename _Alloc>
|
|
||||||
_GLIBCXX14_CONSTEXPR inline void
|
|
||||||
__alloc_on_copy(_Alloc& __one, const _Alloc& __two)
|
|
||||||
{
|
|
||||||
typedef allocator_traits<_Alloc> __traits;
|
|
||||||
typedef typename __traits::propagate_on_container_copy_assignment __pocca;
|
|
||||||
#if __cplusplus >= 201703L
|
|
||||||
if constexpr (__pocca::value)
|
|
||||||
__one = __two;
|
|
||||||
#else
|
|
||||||
__do_alloc_on_copy(__one, __two, __pocca());
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename _Alloc>
|
|
||||||
constexpr _Alloc
|
|
||||||
__alloc_on_copy(const _Alloc& __a)
|
|
||||||
{
|
|
||||||
typedef allocator_traits<_Alloc> __traits;
|
|
||||||
return __traits::select_on_container_copy_construction(__a);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if __cplusplus < 201703L
|
|
||||||
template<typename _Alloc>
|
|
||||||
inline void __do_alloc_on_move(_Alloc& __one, _Alloc& __two, true_type)
|
|
||||||
{ __one = std::move(__two); }
|
|
||||||
|
|
||||||
template<typename _Alloc>
|
|
||||||
inline void __do_alloc_on_move(_Alloc&, _Alloc&, false_type)
|
|
||||||
{ }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template<typename _Alloc>
|
|
||||||
_GLIBCXX14_CONSTEXPR inline void
|
|
||||||
__alloc_on_move(_Alloc& __one, _Alloc& __two)
|
|
||||||
{
|
|
||||||
typedef allocator_traits<_Alloc> __traits;
|
|
||||||
typedef typename __traits::propagate_on_container_move_assignment __pocma;
|
|
||||||
#if __cplusplus >= 201703L
|
|
||||||
if constexpr (__pocma::value)
|
|
||||||
__one = std::move(__two);
|
|
||||||
#else
|
|
||||||
__do_alloc_on_move(__one, __two, __pocma());
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#if __cplusplus < 201703L
|
|
||||||
template<typename _Alloc>
|
|
||||||
inline void __do_alloc_on_swap(_Alloc& __one, _Alloc& __two, true_type)
|
|
||||||
{
|
|
||||||
using std::swap;
|
|
||||||
swap(__one, __two);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename _Alloc>
|
|
||||||
inline void __do_alloc_on_swap(_Alloc&, _Alloc&, false_type)
|
|
||||||
{ }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template<typename _Alloc>
|
|
||||||
_GLIBCXX14_CONSTEXPR inline void
|
|
||||||
__alloc_on_swap(_Alloc& __one, _Alloc& __two)
|
|
||||||
{
|
|
||||||
typedef allocator_traits<_Alloc> __traits;
|
|
||||||
typedef typename __traits::propagate_on_container_swap __pocs;
|
|
||||||
#if __cplusplus >= 201703L
|
|
||||||
if constexpr (__pocs::value)
|
|
||||||
{
|
|
||||||
using std::swap;
|
|
||||||
swap(__one, __two);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
__do_alloc_on_swap(__one, __two, __pocs());
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename _Alloc, typename _Tp,
|
|
||||||
typename _ValueT = __remove_cvref_t<typename _Alloc::value_type>,
|
|
||||||
typename = void>
|
|
||||||
struct __is_alloc_insertable_impl
|
|
||||||
: false_type
|
|
||||||
{ };
|
|
||||||
|
|
||||||
template<typename _Alloc, typename _Tp, typename _ValueT>
|
|
||||||
struct __is_alloc_insertable_impl<_Alloc, _Tp, _ValueT,
|
|
||||||
__void_t<decltype(allocator_traits<_Alloc>::construct(
|
|
||||||
std::declval<_Alloc&>(), std::declval<_ValueT*>(),
|
|
||||||
std::declval<_Tp>()))>>
|
|
||||||
: true_type
|
|
||||||
{ };
|
|
||||||
|
|
||||||
// true if _Alloc::value_type is CopyInsertable into containers using _Alloc
|
|
||||||
// (might be wrong if _Alloc::construct exists but is not constrained,
|
|
||||||
// i.e. actually trying to use it would still be invalid. Use with caution.)
|
|
||||||
template<typename _Alloc>
|
|
||||||
struct __is_copy_insertable
|
|
||||||
: __is_alloc_insertable_impl<_Alloc,
|
|
||||||
typename _Alloc::value_type const&>::type
|
|
||||||
{ };
|
|
||||||
|
|
||||||
// std::allocator<_Tp> just requires CopyConstructible
|
|
||||||
template<typename _Tp>
|
|
||||||
struct __is_copy_insertable<allocator<_Tp>>
|
|
||||||
: is_copy_constructible<_Tp>
|
|
||||||
{ };
|
|
||||||
|
|
||||||
// true if _Alloc::value_type is MoveInsertable into containers using _Alloc
|
|
||||||
// (might be wrong if _Alloc::construct exists but is not constrained,
|
|
||||||
// i.e. actually trying to use it would still be invalid. Use with caution.)
|
|
||||||
template<typename _Alloc>
|
|
||||||
struct __is_move_insertable
|
|
||||||
: __is_alloc_insertable_impl<_Alloc, typename _Alloc::value_type>::type
|
|
||||||
{ };
|
|
||||||
|
|
||||||
// std::allocator<_Tp> just requires MoveConstructible
|
|
||||||
template<typename _Tp>
|
|
||||||
struct __is_move_insertable<allocator<_Tp>>
|
|
||||||
: is_move_constructible<_Tp>
|
|
||||||
{ };
|
|
||||||
|
|
||||||
// Trait to detect Allocator-like types.
|
|
||||||
template<typename _Alloc, typename = void>
|
|
||||||
struct __is_allocator : false_type { };
|
|
||||||
|
|
||||||
template<typename _Alloc>
|
|
||||||
struct __is_allocator<_Alloc,
|
|
||||||
__void_t<typename _Alloc::value_type,
|
|
||||||
decltype(std::declval<_Alloc&>().allocate(size_t{}))>>
|
|
||||||
: true_type { };
|
|
||||||
|
|
||||||
template<typename _Alloc>
|
|
||||||
using _RequireAllocator
|
|
||||||
= typename enable_if<__is_allocator<_Alloc>::value, _Alloc>::type;
|
|
||||||
|
|
||||||
template<typename _Alloc>
|
|
||||||
using _RequireNotAllocator
|
|
||||||
= typename enable_if<!__is_allocator<_Alloc>::value, _Alloc>::type;
|
|
||||||
#endif // C++11
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Destroy a range of objects using the supplied allocator. For
|
|
||||||
* non-default allocators we do not optimize away invocation of
|
|
||||||
* destroy() even if _Tp has a trivial destructor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
template<typename _ForwardIterator, typename _Allocator>
|
|
||||||
void
|
|
||||||
_Destroy(_ForwardIterator __first, _ForwardIterator __last,
|
|
||||||
_Allocator& __alloc)
|
|
||||||
{
|
|
||||||
for (; __first != __last; ++__first)
|
|
||||||
#if __cplusplus < 201103L
|
|
||||||
__alloc.destroy(std::__addressof(*__first));
|
|
||||||
#else
|
|
||||||
allocator_traits<_Allocator>::destroy(__alloc,
|
|
||||||
std::__addressof(*__first));
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename _ForwardIterator, typename _Tp>
|
|
||||||
inline void
|
|
||||||
_Destroy(_ForwardIterator __first, _ForwardIterator __last,
|
|
||||||
allocator<_Tp>&)
|
|
||||||
{
|
|
||||||
_Destroy(__first, __last);
|
|
||||||
}
|
|
||||||
|
|
||||||
_GLIBCXX_END_NAMESPACE_VERSION
|
|
||||||
} // namespace std
|
|
||||||
#endif // _ALLOC_TRAITS_H
|
|
Binary file not shown.
@ -1,104 +0,0 @@
|
|||||||
// Guarded Allocation -*- C++ -*-
|
|
||||||
|
|
||||||
// Copyright (C) 2014-2020 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.
|
|
||||||
|
|
||||||
// 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 bits/allocated_ptr.h
|
|
||||||
* This is an internal header file, included by other library headers.
|
|
||||||
* Do not attempt to use it directly. @headername{memory}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _ALLOCATED_PTR_H
|
|
||||||
#define _ALLOCATED_PTR_H 1
|
|
||||||
|
|
||||||
#if __cplusplus < 201103L
|
|
||||||
# include <bits/c++0xwarning.h>
|
|
||||||
#else
|
|
||||||
# include <type_traits>
|
|
||||||
# include <bits/ptr_traits.h>
|
|
||||||
# include <bits/alloc_traits.h>
|
|
||||||
|
|
||||||
namespace std _GLIBCXX_VISIBILITY(default)
|
|
||||||
{
|
|
||||||
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|
||||||
|
|
||||||
/// Non-standard RAII type for managing pointers obtained from allocators.
|
|
||||||
template<typename _Alloc>
|
|
||||||
struct __allocated_ptr
|
|
||||||
{
|
|
||||||
using pointer = typename allocator_traits<_Alloc>::pointer;
|
|
||||||
using value_type = typename allocator_traits<_Alloc>::value_type;
|
|
||||||
|
|
||||||
/// Take ownership of __ptr
|
|
||||||
__allocated_ptr(_Alloc& __a, pointer __ptr) noexcept
|
|
||||||
: _M_alloc(std::__addressof(__a)), _M_ptr(__ptr)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
/// Convert __ptr to allocator's pointer type and take ownership of it
|
|
||||||
template<typename _Ptr,
|
|
||||||
typename _Req = _Require<is_same<_Ptr, value_type*>>>
|
|
||||||
__allocated_ptr(_Alloc& __a, _Ptr __ptr)
|
|
||||||
: _M_alloc(std::__addressof(__a)),
|
|
||||||
_M_ptr(pointer_traits<pointer>::pointer_to(*__ptr))
|
|
||||||
{ }
|
|
||||||
|
|
||||||
/// Transfer ownership of the owned pointer
|
|
||||||
__allocated_ptr(__allocated_ptr&& __gd) noexcept
|
|
||||||
: _M_alloc(__gd._M_alloc), _M_ptr(__gd._M_ptr)
|
|
||||||
{ __gd._M_ptr = nullptr; }
|
|
||||||
|
|
||||||
/// Deallocate the owned pointer
|
|
||||||
~__allocated_ptr()
|
|
||||||
{
|
|
||||||
if (_M_ptr != nullptr)
|
|
||||||
std::allocator_traits<_Alloc>::deallocate(*_M_alloc, _M_ptr, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Release ownership of the owned pointer
|
|
||||||
__allocated_ptr&
|
|
||||||
operator=(std::nullptr_t) noexcept
|
|
||||||
{
|
|
||||||
_M_ptr = nullptr;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get the address that the owned pointer refers to.
|
|
||||||
value_type* get() { return std::__to_address(_M_ptr); }
|
|
||||||
|
|
||||||
private:
|
|
||||||
_Alloc* _M_alloc;
|
|
||||||
pointer _M_ptr;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Allocate space for a single object using __a
|
|
||||||
template<typename _Alloc>
|
|
||||||
__allocated_ptr<_Alloc>
|
|
||||||
__allocate_guarded(_Alloc& __a)
|
|
||||||
{
|
|
||||||
return { __a, std::allocator_traits<_Alloc>::allocate(__a, 1) };
|
|
||||||
}
|
|
||||||
|
|
||||||
_GLIBCXX_END_NAMESPACE_VERSION
|
|
||||||
} // namespace std
|
|
||||||
|
|
||||||
#endif
|
|
||||||
#endif
|
|
Binary file not shown.
@ -1,323 +0,0 @@
|
|||||||
// Allocators -*- C++ -*-
|
|
||||||
|
|
||||||
// Copyright (C) 2001-2020 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.
|
|
||||||
|
|
||||||
// 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/>.
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 1996-1997
|
|
||||||
* Silicon Graphics Computer Systems, Inc.
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, distribute and sell this software
|
|
||||||
* and its documentation for any purpose is hereby granted without fee,
|
|
||||||
* provided that the above copyright notice appear in all copies and
|
|
||||||
* that both that copyright notice and this permission notice appear
|
|
||||||
* in supporting documentation. Silicon Graphics makes no
|
|
||||||
* representations about the suitability of this software for any
|
|
||||||
* purpose. It is provided "as is" without express or implied warranty.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @file bits/allocator.h
|
|
||||||
* This is an internal header file, included by other library headers.
|
|
||||||
* Do not attempt to use it directly. @headername{memory}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _ALLOCATOR_H
|
|
||||||
#define _ALLOCATOR_H 1
|
|
||||||
|
|
||||||
#include <bits/c++allocator.h> // Define the base class to std::allocator.
|
|
||||||
#include <bits/memoryfwd.h>
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
#include <type_traits>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define __cpp_lib_incomplete_container_elements 201505
|
|
||||||
|
|
||||||
namespace std _GLIBCXX_VISIBILITY(default)
|
|
||||||
{
|
|
||||||
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @addtogroup allocators
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/// allocator<void> specialization.
|
|
||||||
template<>
|
|
||||||
class allocator<void>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef void value_type;
|
|
||||||
typedef size_t size_type;
|
|
||||||
typedef ptrdiff_t difference_type;
|
|
||||||
#if __cplusplus <= 201703L
|
|
||||||
typedef void* pointer;
|
|
||||||
typedef const void* const_pointer;
|
|
||||||
|
|
||||||
template<typename _Tp1>
|
|
||||||
struct rebind
|
|
||||||
{ typedef allocator<_Tp1> other; };
|
|
||||||
#else
|
|
||||||
allocator() = default;
|
|
||||||
|
|
||||||
template<typename _Up>
|
|
||||||
constexpr
|
|
||||||
allocator(const allocator<_Up>&) { }
|
|
||||||
#endif // ! C++20
|
|
||||||
|
|
||||||
#if __cplusplus >= 201103L && __cplusplus <= 201703L
|
|
||||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
|
||||||
// 2103. std::allocator propagate_on_container_move_assignment
|
|
||||||
typedef true_type propagate_on_container_move_assignment;
|
|
||||||
|
|
||||||
typedef true_type is_always_equal;
|
|
||||||
|
|
||||||
template<typename _Up, typename... _Args>
|
|
||||||
void
|
|
||||||
construct(_Up* __p, _Args&&... __args)
|
|
||||||
noexcept(std::is_nothrow_constructible<_Up, _Args...>::value)
|
|
||||||
{ ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
|
|
||||||
|
|
||||||
template<typename _Up>
|
|
||||||
void
|
|
||||||
destroy(_Up* __p)
|
|
||||||
noexcept(std::is_nothrow_destructible<_Up>::value)
|
|
||||||
{ __p->~_Up(); }
|
|
||||||
#endif // C++11 to C++17
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The @a standard allocator, as per [20.4].
|
|
||||||
*
|
|
||||||
* See https://gcc.gnu.org/onlinedocs/libstdc++/manual/memory.html#std.util.memory.allocator
|
|
||||||
* for further details.
|
|
||||||
*
|
|
||||||
* @tparam _Tp Type of allocated object.
|
|
||||||
*/
|
|
||||||
template<typename _Tp>
|
|
||||||
class allocator : public __allocator_base<_Tp>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef _Tp value_type;
|
|
||||||
typedef size_t size_type;
|
|
||||||
typedef ptrdiff_t difference_type;
|
|
||||||
#if __cplusplus <= 201703L
|
|
||||||
typedef _Tp* pointer;
|
|
||||||
typedef const _Tp* const_pointer;
|
|
||||||
typedef _Tp& reference;
|
|
||||||
typedef const _Tp& const_reference;
|
|
||||||
|
|
||||||
template<typename _Tp1>
|
|
||||||
struct rebind
|
|
||||||
{ typedef allocator<_Tp1> other; };
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
|
||||||
// 2103. std::allocator propagate_on_container_move_assignment
|
|
||||||
typedef true_type propagate_on_container_move_assignment;
|
|
||||||
|
|
||||||
typedef true_type is_always_equal;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
|
||||||
// 3035. std::allocator's constructors should be constexpr
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
allocator() _GLIBCXX_NOTHROW { }
|
|
||||||
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
allocator(const allocator& __a) _GLIBCXX_NOTHROW
|
|
||||||
: __allocator_base<_Tp>(__a) { }
|
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
// Avoid implicit deprecation.
|
|
||||||
allocator& operator=(const allocator&) = default;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template<typename _Tp1>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
allocator(const allocator<_Tp1>&) _GLIBCXX_NOTHROW { }
|
|
||||||
|
|
||||||
#if __cpp_constexpr_dynamic_alloc
|
|
||||||
constexpr
|
|
||||||
#endif
|
|
||||||
~allocator() _GLIBCXX_NOTHROW { }
|
|
||||||
|
|
||||||
#if __cplusplus > 201703L
|
|
||||||
[[nodiscard,__gnu__::__always_inline__]]
|
|
||||||
constexpr _Tp*
|
|
||||||
allocate(size_t __n)
|
|
||||||
{
|
|
||||||
#ifdef __cpp_lib_is_constant_evaluated
|
|
||||||
if (std::is_constant_evaluated())
|
|
||||||
return static_cast<_Tp*>(::operator new(__n * sizeof(_Tp)));
|
|
||||||
#endif
|
|
||||||
return __allocator_base<_Tp>::allocate(__n, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
[[__gnu__::__always_inline__]]
|
|
||||||
constexpr void
|
|
||||||
deallocate(_Tp* __p, size_t __n)
|
|
||||||
{
|
|
||||||
#ifdef __cpp_lib_is_constant_evaluated
|
|
||||||
if (std::is_constant_evaluated())
|
|
||||||
{
|
|
||||||
::operator delete(__p);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
__allocator_base<_Tp>::deallocate(__p, __n);
|
|
||||||
}
|
|
||||||
#endif // C++20
|
|
||||||
|
|
||||||
friend _GLIBCXX20_CONSTEXPR bool
|
|
||||||
operator==(const allocator&, const allocator&) _GLIBCXX_NOTHROW
|
|
||||||
{ return true; }
|
|
||||||
|
|
||||||
#if __cpp_impl_three_way_comparison < 201907L
|
|
||||||
friend _GLIBCXX20_CONSTEXPR bool
|
|
||||||
operator!=(const allocator&, const allocator&) _GLIBCXX_NOTHROW
|
|
||||||
{ return false; }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Inherit everything else.
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename _T1, typename _T2>
|
|
||||||
inline _GLIBCXX20_CONSTEXPR bool
|
|
||||||
operator==(const allocator<_T1>&, const allocator<_T2>&)
|
|
||||||
_GLIBCXX_NOTHROW
|
|
||||||
{ return true; }
|
|
||||||
|
|
||||||
#if __cpp_impl_three_way_comparison < 201907L
|
|
||||||
template<typename _T1, typename _T2>
|
|
||||||
inline _GLIBCXX20_CONSTEXPR bool
|
|
||||||
operator!=(const allocator<_T1>&, const allocator<_T2>&)
|
|
||||||
_GLIBCXX_NOTHROW
|
|
||||||
{ return false; }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Invalid allocator<cv T> partial specializations.
|
|
||||||
// allocator_traits::rebind_alloc can be used to form a valid allocator type.
|
|
||||||
template<typename _Tp>
|
|
||||||
class allocator<const _Tp>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef _Tp value_type;
|
|
||||||
template<typename _Up> allocator(const allocator<_Up>&) { }
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename _Tp>
|
|
||||||
class allocator<volatile _Tp>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef _Tp value_type;
|
|
||||||
template<typename _Up> allocator(const allocator<_Up>&) { }
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename _Tp>
|
|
||||||
class allocator<const volatile _Tp>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef _Tp value_type;
|
|
||||||
template<typename _Up> allocator(const allocator<_Up>&) { }
|
|
||||||
};
|
|
||||||
|
|
||||||
/// @} group allocator
|
|
||||||
|
|
||||||
// Inhibit implicit instantiations for required instantiations,
|
|
||||||
// which are defined via explicit instantiations elsewhere.
|
|
||||||
#if _GLIBCXX_EXTERN_TEMPLATE
|
|
||||||
extern template class allocator<char>;
|
|
||||||
extern template class allocator<wchar_t>;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Undefine.
|
|
||||||
#undef __allocator_base
|
|
||||||
|
|
||||||
// To implement Option 3 of DR 431.
|
|
||||||
template<typename _Alloc, bool = __is_empty(_Alloc)>
|
|
||||||
struct __alloc_swap
|
|
||||||
{ static void _S_do_it(_Alloc&, _Alloc&) _GLIBCXX_NOEXCEPT { } };
|
|
||||||
|
|
||||||
template<typename _Alloc>
|
|
||||||
struct __alloc_swap<_Alloc, false>
|
|
||||||
{
|
|
||||||
static void
|
|
||||||
_S_do_it(_Alloc& __one, _Alloc& __two) _GLIBCXX_NOEXCEPT
|
|
||||||
{
|
|
||||||
// Precondition: swappable allocators.
|
|
||||||
if (__one != __two)
|
|
||||||
swap(__one, __two);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Optimize for stateless allocators.
|
|
||||||
template<typename _Alloc, bool = __is_empty(_Alloc)>
|
|
||||||
struct __alloc_neq
|
|
||||||
{
|
|
||||||
static bool
|
|
||||||
_S_do_it(const _Alloc&, const _Alloc&)
|
|
||||||
{ return false; }
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename _Alloc>
|
|
||||||
struct __alloc_neq<_Alloc, false>
|
|
||||||
{
|
|
||||||
static bool
|
|
||||||
_S_do_it(const _Alloc& __one, const _Alloc& __two)
|
|
||||||
{ return __one != __two; }
|
|
||||||
};
|
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
template<typename _Tp, bool
|
|
||||||
= __or_<is_copy_constructible<typename _Tp::value_type>,
|
|
||||||
is_nothrow_move_constructible<typename _Tp::value_type>>::value>
|
|
||||||
struct __shrink_to_fit_aux
|
|
||||||
{ static bool _S_do_it(_Tp&) noexcept { return false; } };
|
|
||||||
|
|
||||||
template<typename _Tp>
|
|
||||||
struct __shrink_to_fit_aux<_Tp, true>
|
|
||||||
{
|
|
||||||
static bool
|
|
||||||
_S_do_it(_Tp& __c) noexcept
|
|
||||||
{
|
|
||||||
#if __cpp_exceptions
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_Tp(__make_move_if_noexcept_iterator(__c.begin()),
|
|
||||||
__make_move_if_noexcept_iterator(__c.end()),
|
|
||||||
__c.get_allocator()).swap(__c);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
catch(...)
|
|
||||||
{ return false; }
|
|
||||||
#else
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
_GLIBCXX_END_NAMESPACE_VERSION
|
|
||||||
} // namespace std
|
|
||||||
|
|
||||||
#endif
|
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@ -1,66 +0,0 @@
|
|||||||
// -*- C++ -*- header.
|
|
||||||
|
|
||||||
// Copyright (C) 2008-2020 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.
|
|
||||||
|
|
||||||
// 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 bits/atomic_lockfree_defines.h
|
|
||||||
* This is an internal header file, included by other library headers.
|
|
||||||
* Do not attempt to use it directly. @headername{atomic}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _GLIBCXX_ATOMIC_LOCK_FREE_H
|
|
||||||
#define _GLIBCXX_ATOMIC_LOCK_FREE_H 1
|
|
||||||
|
|
||||||
#pragma GCC system_header
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @addtogroup atomics
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Lock-free property.
|
|
||||||
*
|
|
||||||
* 0 indicates that the types are never lock-free.
|
|
||||||
* 1 indicates that the types are sometimes lock-free.
|
|
||||||
* 2 indicates that the types are always lock-free.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
#define ATOMIC_BOOL_LOCK_FREE __GCC_ATOMIC_BOOL_LOCK_FREE
|
|
||||||
#define ATOMIC_CHAR_LOCK_FREE __GCC_ATOMIC_CHAR_LOCK_FREE
|
|
||||||
#define ATOMIC_WCHAR_T_LOCK_FREE __GCC_ATOMIC_WCHAR_T_LOCK_FREE
|
|
||||||
#ifdef _GLIBCXX_USE_CHAR8_T
|
|
||||||
#define ATOMIC_CHAR8_T_LOCK_FREE __GCC_ATOMIC_CHAR8_T_LOCK_FREE
|
|
||||||
#endif
|
|
||||||
#define ATOMIC_CHAR16_T_LOCK_FREE __GCC_ATOMIC_CHAR16_T_LOCK_FREE
|
|
||||||
#define ATOMIC_CHAR32_T_LOCK_FREE __GCC_ATOMIC_CHAR32_T_LOCK_FREE
|
|
||||||
#define ATOMIC_SHORT_LOCK_FREE __GCC_ATOMIC_SHORT_LOCK_FREE
|
|
||||||
#define ATOMIC_INT_LOCK_FREE __GCC_ATOMIC_INT_LOCK_FREE
|
|
||||||
#define ATOMIC_LONG_LOCK_FREE __GCC_ATOMIC_LONG_LOCK_FREE
|
|
||||||
#define ATOMIC_LLONG_LOCK_FREE __GCC_ATOMIC_LLONG_LOCK_FREE
|
|
||||||
#define ATOMIC_POINTER_LOCK_FREE __GCC_ATOMIC_POINTER_LOCK_FREE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// @} group atomics
|
|
||||||
|
|
||||||
#endif
|
|
Binary file not shown.
@ -1,518 +0,0 @@
|
|||||||
// Iostreams base classes -*- C++ -*-
|
|
||||||
|
|
||||||
// Copyright (C) 1997-2020 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.
|
|
||||||
|
|
||||||
// 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 bits/basic_ios.h
|
|
||||||
* This is an internal header file, included by other library headers.
|
|
||||||
* Do not attempt to use it directly. @headername{ios}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _BASIC_IOS_H
|
|
||||||
#define _BASIC_IOS_H 1
|
|
||||||
|
|
||||||
#pragma GCC system_header
|
|
||||||
|
|
||||||
#include <bits/localefwd.h>
|
|
||||||
#include <bits/locale_classes.h>
|
|
||||||
#include <bits/locale_facets.h>
|
|
||||||
#include <bits/streambuf_iterator.h>
|
|
||||||
#include <bits/move.h>
|
|
||||||
|
|
||||||
namespace std _GLIBCXX_VISIBILITY(default)
|
|
||||||
{
|
|
||||||
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|
||||||
|
|
||||||
template<typename _Facet>
|
|
||||||
inline const _Facet&
|
|
||||||
__check_facet(const _Facet* __f)
|
|
||||||
{
|
|
||||||
if (!__f)
|
|
||||||
__throw_bad_cast();
|
|
||||||
return *__f;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Template class basic_ios, virtual base class for all
|
|
||||||
* stream classes.
|
|
||||||
* @ingroup io
|
|
||||||
*
|
|
||||||
* @tparam _CharT Type of character stream.
|
|
||||||
* @tparam _Traits Traits for character type, defaults to
|
|
||||||
* char_traits<_CharT>.
|
|
||||||
*
|
|
||||||
* Most of the member functions called dispatched on stream objects
|
|
||||||
* (e.g., @c std::cout.foo(bar);) are consolidated in this class.
|
|
||||||
*/
|
|
||||||
template<typename _CharT, typename _Traits>
|
|
||||||
class basic_ios : public ios_base
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
//@{
|
|
||||||
/**
|
|
||||||
* These are standard types. They permit a standardized way of
|
|
||||||
* referring to names of (or names dependent on) the template
|
|
||||||
* parameters, which are specific to the implementation.
|
|
||||||
*/
|
|
||||||
typedef _CharT char_type;
|
|
||||||
typedef typename _Traits::int_type int_type;
|
|
||||||
typedef typename _Traits::pos_type pos_type;
|
|
||||||
typedef typename _Traits::off_type off_type;
|
|
||||||
typedef _Traits traits_type;
|
|
||||||
//@}
|
|
||||||
|
|
||||||
//@{
|
|
||||||
/**
|
|
||||||
* These are non-standard types.
|
|
||||||
*/
|
|
||||||
typedef ctype<_CharT> __ctype_type;
|
|
||||||
typedef num_put<_CharT, ostreambuf_iterator<_CharT, _Traits> >
|
|
||||||
__num_put_type;
|
|
||||||
typedef num_get<_CharT, istreambuf_iterator<_CharT, _Traits> >
|
|
||||||
__num_get_type;
|
|
||||||
//@}
|
|
||||||
|
|
||||||
// Data members:
|
|
||||||
protected:
|
|
||||||
basic_ostream<_CharT, _Traits>* _M_tie;
|
|
||||||
mutable char_type _M_fill;
|
|
||||||
mutable bool _M_fill_init;
|
|
||||||
basic_streambuf<_CharT, _Traits>* _M_streambuf;
|
|
||||||
|
|
||||||
// Cached use_facet<ctype>, which is based on the current locale info.
|
|
||||||
const __ctype_type* _M_ctype;
|
|
||||||
// For ostream.
|
|
||||||
const __num_put_type* _M_num_put;
|
|
||||||
// For istream.
|
|
||||||
const __num_get_type* _M_num_get;
|
|
||||||
|
|
||||||
public:
|
|
||||||
//@{
|
|
||||||
/**
|
|
||||||
* @brief The quick-and-easy status check.
|
|
||||||
*
|
|
||||||
* This allows you to write constructs such as
|
|
||||||
* <code>if (!a_stream) ...</code> and <code>while (a_stream) ...</code>
|
|
||||||
*/
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
explicit operator bool() const
|
|
||||||
{ return !this->fail(); }
|
|
||||||
#else
|
|
||||||
operator void*() const
|
|
||||||
{ return this->fail() ? 0 : const_cast<basic_ios*>(this); }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool
|
|
||||||
operator!() const
|
|
||||||
{ return this->fail(); }
|
|
||||||
//@}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Returns the error state of the stream buffer.
|
|
||||||
* @return A bit pattern (well, isn't everything?)
|
|
||||||
*
|
|
||||||
* See std::ios_base::iostate for the possible bit values. Most
|
|
||||||
* users will call one of the interpreting wrappers, e.g., good().
|
|
||||||
*/
|
|
||||||
iostate
|
|
||||||
rdstate() const
|
|
||||||
{ return _M_streambuf_state; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief [Re]sets the error state.
|
|
||||||
* @param __state The new state flag(s) to set.
|
|
||||||
*
|
|
||||||
* See std::ios_base::iostate for the possible bit values. Most
|
|
||||||
* users will not need to pass an argument.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
clear(iostate __state = goodbit);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Sets additional flags in the error state.
|
|
||||||
* @param __state The additional state flag(s) to set.
|
|
||||||
*
|
|
||||||
* See std::ios_base::iostate for the possible bit values.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
setstate(iostate __state)
|
|
||||||
{ this->clear(this->rdstate() | __state); }
|
|
||||||
|
|
||||||
// Flip the internal state on for the proper state bits, then
|
|
||||||
// rethrows the propagated exception if bit also set in
|
|
||||||
// exceptions().
|
|
||||||
void
|
|
||||||
_M_setstate(iostate __state)
|
|
||||||
{
|
|
||||||
// 27.6.1.2.1 Common requirements.
|
|
||||||
// Turn this on without causing an ios::failure to be thrown.
|
|
||||||
_M_streambuf_state |= __state;
|
|
||||||
if (this->exceptions() & __state)
|
|
||||||
__throw_exception_again;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Fast error checking.
|
|
||||||
* @return True if no error flags are set.
|
|
||||||
*
|
|
||||||
* A wrapper around rdstate.
|
|
||||||
*/
|
|
||||||
bool
|
|
||||||
good() const
|
|
||||||
{ return this->rdstate() == 0; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Fast error checking.
|
|
||||||
* @return True if the eofbit is set.
|
|
||||||
*
|
|
||||||
* Note that other iostate flags may also be set.
|
|
||||||
*/
|
|
||||||
bool
|
|
||||||
eof() const
|
|
||||||
{ return (this->rdstate() & eofbit) != 0; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Fast error checking.
|
|
||||||
* @return True if either the badbit or the failbit is set.
|
|
||||||
*
|
|
||||||
* Checking the badbit in fail() is historical practice.
|
|
||||||
* Note that other iostate flags may also be set.
|
|
||||||
*/
|
|
||||||
bool
|
|
||||||
fail() const
|
|
||||||
{ return (this->rdstate() & (badbit | failbit)) != 0; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Fast error checking.
|
|
||||||
* @return True if the badbit is set.
|
|
||||||
*
|
|
||||||
* Note that other iostate flags may also be set.
|
|
||||||
*/
|
|
||||||
bool
|
|
||||||
bad() const
|
|
||||||
{ return (this->rdstate() & badbit) != 0; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Throwing exceptions on errors.
|
|
||||||
* @return The current exceptions mask.
|
|
||||||
*
|
|
||||||
* This changes nothing in the stream. See the one-argument version
|
|
||||||
* of exceptions(iostate) for the meaning of the return value.
|
|
||||||
*/
|
|
||||||
iostate
|
|
||||||
exceptions() const
|
|
||||||
{ return _M_exception; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Throwing exceptions on errors.
|
|
||||||
* @param __except The new exceptions mask.
|
|
||||||
*
|
|
||||||
* By default, error flags are set silently. You can set an
|
|
||||||
* exceptions mask for each stream; if a bit in the mask becomes set
|
|
||||||
* in the error flags, then an exception of type
|
|
||||||
* std::ios_base::failure is thrown.
|
|
||||||
*
|
|
||||||
* If the error flag is already set when the exceptions mask is
|
|
||||||
* added, the exception is immediately thrown. Try running the
|
|
||||||
* following under GCC 3.1 or later:
|
|
||||||
* @code
|
|
||||||
* #include <iostream>
|
|
||||||
* #include <fstream>
|
|
||||||
* #include <exception>
|
|
||||||
*
|
|
||||||
* int main()
|
|
||||||
* {
|
|
||||||
* std::set_terminate (__gnu_cxx::__verbose_terminate_handler);
|
|
||||||
*
|
|
||||||
* std::ifstream f ("/etc/motd");
|
|
||||||
*
|
|
||||||
* std::cerr << "Setting badbit\n";
|
|
||||||
* f.setstate (std::ios_base::badbit);
|
|
||||||
*
|
|
||||||
* std::cerr << "Setting exception mask\n";
|
|
||||||
* f.exceptions (std::ios_base::badbit);
|
|
||||||
* }
|
|
||||||
* @endcode
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
exceptions(iostate __except)
|
|
||||||
{
|
|
||||||
_M_exception = __except;
|
|
||||||
this->clear(_M_streambuf_state);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Constructor/destructor:
|
|
||||||
/**
|
|
||||||
* @brief Constructor performs initialization.
|
|
||||||
*
|
|
||||||
* The parameter is passed by derived streams.
|
|
||||||
*/
|
|
||||||
explicit
|
|
||||||
basic_ios(basic_streambuf<_CharT, _Traits>* __sb)
|
|
||||||
: ios_base(), _M_tie(0), _M_fill(), _M_fill_init(false), _M_streambuf(0),
|
|
||||||
_M_ctype(0), _M_num_put(0), _M_num_get(0)
|
|
||||||
{ this->init(__sb); }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Empty.
|
|
||||||
*
|
|
||||||
* The destructor does nothing. More specifically, it does not
|
|
||||||
* destroy the streambuf held by rdbuf().
|
|
||||||
*/
|
|
||||||
virtual
|
|
||||||
~basic_ios() { }
|
|
||||||
|
|
||||||
// Members:
|
|
||||||
/**
|
|
||||||
* @brief Fetches the current @e tied stream.
|
|
||||||
* @return A pointer to the tied stream, or NULL if the stream is
|
|
||||||
* not tied.
|
|
||||||
*
|
|
||||||
* A stream may be @e tied (or synchronized) to a second output
|
|
||||||
* stream. When this stream performs any I/O, the tied stream is
|
|
||||||
* first flushed. For example, @c std::cin is tied to @c std::cout.
|
|
||||||
*/
|
|
||||||
basic_ostream<_CharT, _Traits>*
|
|
||||||
tie() const
|
|
||||||
{ return _M_tie; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Ties this stream to an output stream.
|
|
||||||
* @param __tiestr The output stream.
|
|
||||||
* @return The previously tied output stream, or NULL if the stream
|
|
||||||
* was not tied.
|
|
||||||
*
|
|
||||||
* This sets up a new tie; see tie() for more.
|
|
||||||
*/
|
|
||||||
basic_ostream<_CharT, _Traits>*
|
|
||||||
tie(basic_ostream<_CharT, _Traits>* __tiestr)
|
|
||||||
{
|
|
||||||
basic_ostream<_CharT, _Traits>* __old = _M_tie;
|
|
||||||
_M_tie = __tiestr;
|
|
||||||
return __old;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Accessing the underlying buffer.
|
|
||||||
* @return The current stream buffer.
|
|
||||||
*
|
|
||||||
* This does not change the state of the stream.
|
|
||||||
*/
|
|
||||||
basic_streambuf<_CharT, _Traits>*
|
|
||||||
rdbuf() const
|
|
||||||
{ return _M_streambuf; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Changing the underlying buffer.
|
|
||||||
* @param __sb The new stream buffer.
|
|
||||||
* @return The previous stream buffer.
|
|
||||||
*
|
|
||||||
* Associates a new buffer with the current stream, and clears the
|
|
||||||
* error state.
|
|
||||||
*
|
|
||||||
* Due to historical accidents which the LWG refuses to correct, the
|
|
||||||
* I/O library suffers from a design error: this function is hidden
|
|
||||||
* in derived classes by overrides of the zero-argument @c rdbuf(),
|
|
||||||
* which is non-virtual for hysterical raisins. As a result, you
|
|
||||||
* must use explicit qualifications to access this function via any
|
|
||||||
* derived class. For example:
|
|
||||||
*
|
|
||||||
* @code
|
|
||||||
* std::fstream foo; // or some other derived type
|
|
||||||
* std::streambuf* p = .....;
|
|
||||||
*
|
|
||||||
* foo.ios::rdbuf(p); // ios == basic_ios<char>
|
|
||||||
* @endcode
|
|
||||||
*/
|
|
||||||
basic_streambuf<_CharT, _Traits>*
|
|
||||||
rdbuf(basic_streambuf<_CharT, _Traits>* __sb);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Copies fields of __rhs into this.
|
|
||||||
* @param __rhs The source values for the copies.
|
|
||||||
* @return Reference to this object.
|
|
||||||
*
|
|
||||||
* All fields of __rhs are copied into this object except that rdbuf()
|
|
||||||
* and rdstate() remain unchanged. All values in the pword and iword
|
|
||||||
* arrays are copied. Before copying, each callback is invoked with
|
|
||||||
* erase_event. After copying, each (new) callback is invoked with
|
|
||||||
* copyfmt_event. The final step is to copy exceptions().
|
|
||||||
*/
|
|
||||||
basic_ios&
|
|
||||||
copyfmt(const basic_ios& __rhs);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Retrieves the @a empty character.
|
|
||||||
* @return The current fill character.
|
|
||||||
*
|
|
||||||
* It defaults to a space (' ') in the current locale.
|
|
||||||
*/
|
|
||||||
char_type
|
|
||||||
fill() const
|
|
||||||
{
|
|
||||||
if (!_M_fill_init)
|
|
||||||
{
|
|
||||||
_M_fill = this->widen(' ');
|
|
||||||
_M_fill_init = true;
|
|
||||||
}
|
|
||||||
return _M_fill;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Sets a new @a empty character.
|
|
||||||
* @param __ch The new character.
|
|
||||||
* @return The previous fill character.
|
|
||||||
*
|
|
||||||
* The fill character is used to fill out space when P+ characters
|
|
||||||
* have been requested (e.g., via setw), Q characters are actually
|
|
||||||
* used, and Q<P. It defaults to a space (' ') in the current locale.
|
|
||||||
*/
|
|
||||||
char_type
|
|
||||||
fill(char_type __ch)
|
|
||||||
{
|
|
||||||
char_type __old = this->fill();
|
|
||||||
_M_fill = __ch;
|
|
||||||
return __old;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Locales:
|
|
||||||
/**
|
|
||||||
* @brief Moves to a new locale.
|
|
||||||
* @param __loc The new locale.
|
|
||||||
* @return The previous locale.
|
|
||||||
*
|
|
||||||
* Calls @c ios_base::imbue(loc), and if a stream buffer is associated
|
|
||||||
* with this stream, calls that buffer's @c pubimbue(loc).
|
|
||||||
*
|
|
||||||
* Additional l10n notes are at
|
|
||||||
* http://gcc.gnu.org/onlinedocs/libstdc++/manual/localization.html
|
|
||||||
*/
|
|
||||||
locale
|
|
||||||
imbue(const locale& __loc);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Squeezes characters.
|
|
||||||
* @param __c The character to narrow.
|
|
||||||
* @param __dfault The character to narrow.
|
|
||||||
* @return The narrowed character.
|
|
||||||
*
|
|
||||||
* Maps a character of @c char_type to a character of @c char,
|
|
||||||
* if possible.
|
|
||||||
*
|
|
||||||
* Returns the result of
|
|
||||||
* @code
|
|
||||||
* std::use_facet<ctype<char_type> >(getloc()).narrow(c,dfault)
|
|
||||||
* @endcode
|
|
||||||
*
|
|
||||||
* Additional l10n notes are at
|
|
||||||
* http://gcc.gnu.org/onlinedocs/libstdc++/manual/localization.html
|
|
||||||
*/
|
|
||||||
char
|
|
||||||
narrow(char_type __c, char __dfault) const
|
|
||||||
{ return __check_facet(_M_ctype).narrow(__c, __dfault); }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Widens characters.
|
|
||||||
* @param __c The character to widen.
|
|
||||||
* @return The widened character.
|
|
||||||
*
|
|
||||||
* Maps a character of @c char to a character of @c char_type.
|
|
||||||
*
|
|
||||||
* Returns the result of
|
|
||||||
* @code
|
|
||||||
* std::use_facet<ctype<char_type> >(getloc()).widen(c)
|
|
||||||
* @endcode
|
|
||||||
*
|
|
||||||
* Additional l10n notes are at
|
|
||||||
* http://gcc.gnu.org/onlinedocs/libstdc++/manual/localization.html
|
|
||||||
*/
|
|
||||||
char_type
|
|
||||||
widen(char __c) const
|
|
||||||
{ return __check_facet(_M_ctype).widen(__c); }
|
|
||||||
|
|
||||||
protected:
|
|
||||||
// 27.4.5.1 basic_ios constructors
|
|
||||||
/**
|
|
||||||
* @brief Empty.
|
|
||||||
*
|
|
||||||
* The default constructor does nothing and is not normally
|
|
||||||
* accessible to users.
|
|
||||||
*/
|
|
||||||
basic_ios()
|
|
||||||
: ios_base(), _M_tie(0), _M_fill(char_type()), _M_fill_init(false),
|
|
||||||
_M_streambuf(0), _M_ctype(0), _M_num_put(0), _M_num_get(0)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief All setup is performed here.
|
|
||||||
*
|
|
||||||
* This is called from the public constructor. It is not virtual and
|
|
||||||
* cannot be redefined.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
init(basic_streambuf<_CharT, _Traits>* __sb);
|
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
basic_ios(const basic_ios&) = delete;
|
|
||||||
basic_ios& operator=(const basic_ios&) = delete;
|
|
||||||
|
|
||||||
void
|
|
||||||
move(basic_ios& __rhs)
|
|
||||||
{
|
|
||||||
ios_base::_M_move(__rhs);
|
|
||||||
_M_cache_locale(_M_ios_locale);
|
|
||||||
this->tie(__rhs.tie(nullptr));
|
|
||||||
_M_fill = __rhs._M_fill;
|
|
||||||
_M_fill_init = __rhs._M_fill_init;
|
|
||||||
_M_streambuf = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
move(basic_ios&& __rhs)
|
|
||||||
{ this->move(__rhs); }
|
|
||||||
|
|
||||||
void
|
|
||||||
swap(basic_ios& __rhs) noexcept
|
|
||||||
{
|
|
||||||
ios_base::_M_swap(__rhs);
|
|
||||||
_M_cache_locale(_M_ios_locale);
|
|
||||||
__rhs._M_cache_locale(__rhs._M_ios_locale);
|
|
||||||
std::swap(_M_tie, __rhs._M_tie);
|
|
||||||
std::swap(_M_fill, __rhs._M_fill);
|
|
||||||
std::swap(_M_fill_init, __rhs._M_fill_init);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
set_rdbuf(basic_streambuf<_CharT, _Traits>* __sb)
|
|
||||||
{ _M_streambuf = __sb; }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void
|
|
||||||
_M_cache_locale(const locale& __loc);
|
|
||||||
};
|
|
||||||
|
|
||||||
_GLIBCXX_END_NAMESPACE_VERSION
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
#include <bits/basic_ios.tcc>
|
|
||||||
|
|
||||||
#endif /* _BASIC_IOS_H */
|
|
Binary file not shown.
@ -1,188 +0,0 @@
|
|||||||
// basic_ios member functions -*- C++ -*-
|
|
||||||
|
|
||||||
// Copyright (C) 1999-2020 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.
|
|
||||||
|
|
||||||
// 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 bits/basic_ios.tcc
|
|
||||||
* This is an internal header file, included by other library headers.
|
|
||||||
* Do not attempt to use it directly. @headername{ios}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _BASIC_IOS_TCC
|
|
||||||
#define _BASIC_IOS_TCC 1
|
|
||||||
|
|
||||||
#pragma GCC system_header
|
|
||||||
|
|
||||||
namespace std _GLIBCXX_VISIBILITY(default)
|
|
||||||
{
|
|
||||||
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|
||||||
|
|
||||||
template<typename _CharT, typename _Traits>
|
|
||||||
void
|
|
||||||
basic_ios<_CharT, _Traits>::clear(iostate __state)
|
|
||||||
{
|
|
||||||
if (this->rdbuf())
|
|
||||||
_M_streambuf_state = __state;
|
|
||||||
else
|
|
||||||
_M_streambuf_state = __state | badbit;
|
|
||||||
if (this->exceptions() & this->rdstate())
|
|
||||||
__throw_ios_failure(__N("basic_ios::clear"));
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename _CharT, typename _Traits>
|
|
||||||
basic_streambuf<_CharT, _Traits>*
|
|
||||||
basic_ios<_CharT, _Traits>::rdbuf(basic_streambuf<_CharT, _Traits>* __sb)
|
|
||||||
{
|
|
||||||
basic_streambuf<_CharT, _Traits>* __old = _M_streambuf;
|
|
||||||
_M_streambuf = __sb;
|
|
||||||
this->clear();
|
|
||||||
return __old;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename _CharT, typename _Traits>
|
|
||||||
basic_ios<_CharT, _Traits>&
|
|
||||||
basic_ios<_CharT, _Traits>::copyfmt(const basic_ios& __rhs)
|
|
||||||
{
|
|
||||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
|
||||||
// 292. effects of a.copyfmt (a)
|
|
||||||
if (this != &__rhs)
|
|
||||||
{
|
|
||||||
// Per 27.1.1, do not call imbue, yet must trash all caches
|
|
||||||
// associated with imbue()
|
|
||||||
|
|
||||||
// Alloc any new word array first, so if it fails we have "rollback".
|
|
||||||
_Words* __words = (__rhs._M_word_size <= _S_local_word_size) ?
|
|
||||||
_M_local_word : new _Words[__rhs._M_word_size];
|
|
||||||
|
|
||||||
// Bump refs before doing callbacks, for safety.
|
|
||||||
_Callback_list* __cb = __rhs._M_callbacks;
|
|
||||||
if (__cb)
|
|
||||||
__cb->_M_add_reference();
|
|
||||||
_M_call_callbacks(erase_event);
|
|
||||||
if (_M_word != _M_local_word)
|
|
||||||
{
|
|
||||||
delete [] _M_word;
|
|
||||||
_M_word = 0;
|
|
||||||
}
|
|
||||||
_M_dispose_callbacks();
|
|
||||||
|
|
||||||
// NB: Don't want any added during above.
|
|
||||||
_M_callbacks = __cb;
|
|
||||||
for (int __i = 0; __i < __rhs._M_word_size; ++__i)
|
|
||||||
__words[__i] = __rhs._M_word[__i];
|
|
||||||
_M_word = __words;
|
|
||||||
_M_word_size = __rhs._M_word_size;
|
|
||||||
|
|
||||||
this->flags(__rhs.flags());
|
|
||||||
this->width(__rhs.width());
|
|
||||||
this->precision(__rhs.precision());
|
|
||||||
this->tie(__rhs.tie());
|
|
||||||
this->fill(__rhs.fill());
|
|
||||||
_M_ios_locale = __rhs.getloc();
|
|
||||||
_M_cache_locale(_M_ios_locale);
|
|
||||||
|
|
||||||
_M_call_callbacks(copyfmt_event);
|
|
||||||
|
|
||||||
// The next is required to be the last assignment.
|
|
||||||
this->exceptions(__rhs.exceptions());
|
|
||||||
}
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Locales:
|
|
||||||
template<typename _CharT, typename _Traits>
|
|
||||||
locale
|
|
||||||
basic_ios<_CharT, _Traits>::imbue(const locale& __loc)
|
|
||||||
{
|
|
||||||
locale __old(this->getloc());
|
|
||||||
ios_base::imbue(__loc);
|
|
||||||
_M_cache_locale(__loc);
|
|
||||||
if (this->rdbuf() != 0)
|
|
||||||
this->rdbuf()->pubimbue(__loc);
|
|
||||||
return __old;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename _CharT, typename _Traits>
|
|
||||||
void
|
|
||||||
basic_ios<_CharT, _Traits>::init(basic_streambuf<_CharT, _Traits>* __sb)
|
|
||||||
{
|
|
||||||
// NB: This may be called more than once on the same object.
|
|
||||||
ios_base::_M_init();
|
|
||||||
|
|
||||||
// Cache locale data and specific facets used by iostreams.
|
|
||||||
_M_cache_locale(_M_ios_locale);
|
|
||||||
|
|
||||||
// NB: The 27.4.4.1 Postconditions Table specifies requirements
|
|
||||||
// after basic_ios::init() has been called. As part of this,
|
|
||||||
// fill() must return widen(' ') any time after init() has been
|
|
||||||
// called, which needs an imbued ctype facet of char_type to
|
|
||||||
// return without throwing an exception. Unfortunately,
|
|
||||||
// ctype<char_type> is not necessarily a required facet, so
|
|
||||||
// streams with char_type != [char, wchar_t] will not have it by
|
|
||||||
// default. Because of this, the correct value for _M_fill is
|
|
||||||
// constructed on the first call of fill(). That way,
|
|
||||||
// unformatted input and output with non-required basic_ios
|
|
||||||
// instantiations is possible even without imbuing the expected
|
|
||||||
// ctype<char_type> facet.
|
|
||||||
_M_fill = _CharT();
|
|
||||||
_M_fill_init = false;
|
|
||||||
|
|
||||||
_M_tie = 0;
|
|
||||||
_M_exception = goodbit;
|
|
||||||
_M_streambuf = __sb;
|
|
||||||
_M_streambuf_state = __sb ? goodbit : badbit;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename _CharT, typename _Traits>
|
|
||||||
void
|
|
||||||
basic_ios<_CharT, _Traits>::_M_cache_locale(const locale& __loc)
|
|
||||||
{
|
|
||||||
if (__builtin_expect(has_facet<__ctype_type>(__loc), true))
|
|
||||||
_M_ctype = std::__addressof(use_facet<__ctype_type>(__loc));
|
|
||||||
else
|
|
||||||
_M_ctype = 0;
|
|
||||||
|
|
||||||
if (__builtin_expect(has_facet<__num_put_type>(__loc), true))
|
|
||||||
_M_num_put = std::__addressof(use_facet<__num_put_type>(__loc));
|
|
||||||
else
|
|
||||||
_M_num_put = 0;
|
|
||||||
|
|
||||||
if (__builtin_expect(has_facet<__num_get_type>(__loc), true))
|
|
||||||
_M_num_get = std::__addressof(use_facet<__num_get_type>(__loc));
|
|
||||||
else
|
|
||||||
_M_num_get = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Inhibit implicit instantiations for required instantiations,
|
|
||||||
// which are defined via explicit instantiations elsewhere.
|
|
||||||
#if _GLIBCXX_EXTERN_TEMPLATE
|
|
||||||
extern template class basic_ios<char>;
|
|
||||||
|
|
||||||
#ifdef _GLIBCXX_USE_WCHAR_T
|
|
||||||
extern template class basic_ios<wchar_t>;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
_GLIBCXX_END_NAMESPACE_VERSION
|
|
||||||
} // namespace std
|
|
||||||
|
|
||||||
#endif
|
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@ -1,950 +0,0 @@
|
|||||||
// Character Traits for use by standard string and iostream -*- C++ -*-
|
|
||||||
|
|
||||||
// Copyright (C) 1997-2020 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.
|
|
||||||
|
|
||||||
// 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 bits/char_traits.h
|
|
||||||
* This is an internal header file, included by other library headers.
|
|
||||||
* Do not attempt to use it directly. @headername{string}
|
|
||||||
*/
|
|
||||||
|
|
||||||
//
|
|
||||||
// ISO C++ 14882: 21 Strings library
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef _CHAR_TRAITS_H
|
|
||||||
#define _CHAR_TRAITS_H 1
|
|
||||||
|
|
||||||
#pragma GCC system_header
|
|
||||||
|
|
||||||
#include <bits/stl_algobase.h> // std::copy, std::fill_n
|
|
||||||
#include <bits/postypes.h> // For streampos
|
|
||||||
#include <cwchar> // For WEOF, wmemmove, wmemset, etc.
|
|
||||||
#if __cplusplus > 201703L
|
|
||||||
# include <compare>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _GLIBCXX_ALWAYS_INLINE
|
|
||||||
# define _GLIBCXX_ALWAYS_INLINE inline __attribute__((__always_inline__))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
|
|
||||||
{
|
|
||||||
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Mapping from character type to associated types.
|
|
||||||
*
|
|
||||||
* @note This is an implementation class for the generic version
|
|
||||||
* of char_traits. It defines int_type, off_type, pos_type, and
|
|
||||||
* state_type. By default these are unsigned long, streamoff,
|
|
||||||
* streampos, and mbstate_t. Users who need a different set of
|
|
||||||
* types, but who don't need to change the definitions of any function
|
|
||||||
* defined in char_traits, can specialize __gnu_cxx::_Char_types
|
|
||||||
* while leaving __gnu_cxx::char_traits alone. */
|
|
||||||
template<typename _CharT>
|
|
||||||
struct _Char_types
|
|
||||||
{
|
|
||||||
typedef unsigned long int_type;
|
|
||||||
typedef std::streampos pos_type;
|
|
||||||
typedef std::streamoff off_type;
|
|
||||||
typedef std::mbstate_t state_type;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Base class used to implement std::char_traits.
|
|
||||||
*
|
|
||||||
* @note For any given actual character type, this definition is
|
|
||||||
* probably wrong. (Most of the member functions are likely to be
|
|
||||||
* right, but the int_type and state_type typedefs, and the eof()
|
|
||||||
* member function, are likely to be wrong.) The reason this class
|
|
||||||
* exists is so users can specialize it. Classes in namespace std
|
|
||||||
* may not be specialized for fundamental types, but classes in
|
|
||||||
* namespace __gnu_cxx may be.
|
|
||||||
*
|
|
||||||
* See https://gcc.gnu.org/onlinedocs/libstdc++/manual/strings.html#strings.string.character_types
|
|
||||||
* for advice on how to make use of this class for @a unusual character
|
|
||||||
* types. Also, check out include/ext/pod_char_traits.h.
|
|
||||||
*/
|
|
||||||
template<typename _CharT>
|
|
||||||
struct char_traits
|
|
||||||
{
|
|
||||||
typedef _CharT char_type;
|
|
||||||
typedef typename _Char_types<_CharT>::int_type int_type;
|
|
||||||
typedef typename _Char_types<_CharT>::pos_type pos_type;
|
|
||||||
typedef typename _Char_types<_CharT>::off_type off_type;
|
|
||||||
typedef typename _Char_types<_CharT>::state_type state_type;
|
|
||||||
#if __cpp_lib_three_way_comparison
|
|
||||||
using comparison_category = std::strong_ordering;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static _GLIBCXX14_CONSTEXPR void
|
|
||||||
assign(char_type& __c1, const char_type& __c2)
|
|
||||||
{ __c1 = __c2; }
|
|
||||||
|
|
||||||
static _GLIBCXX_CONSTEXPR bool
|
|
||||||
eq(const char_type& __c1, const char_type& __c2)
|
|
||||||
{ return __c1 == __c2; }
|
|
||||||
|
|
||||||
static _GLIBCXX_CONSTEXPR bool
|
|
||||||
lt(const char_type& __c1, const char_type& __c2)
|
|
||||||
{ return __c1 < __c2; }
|
|
||||||
|
|
||||||
static _GLIBCXX14_CONSTEXPR int
|
|
||||||
compare(const char_type* __s1, const char_type* __s2, std::size_t __n);
|
|
||||||
|
|
||||||
static _GLIBCXX14_CONSTEXPR std::size_t
|
|
||||||
length(const char_type* __s);
|
|
||||||
|
|
||||||
static _GLIBCXX14_CONSTEXPR const char_type*
|
|
||||||
find(const char_type* __s, std::size_t __n, const char_type& __a);
|
|
||||||
|
|
||||||
static _GLIBCXX20_CONSTEXPR char_type*
|
|
||||||
move(char_type* __s1, const char_type* __s2, std::size_t __n);
|
|
||||||
|
|
||||||
static _GLIBCXX20_CONSTEXPR char_type*
|
|
||||||
copy(char_type* __s1, const char_type* __s2, std::size_t __n);
|
|
||||||
|
|
||||||
static _GLIBCXX20_CONSTEXPR char_type*
|
|
||||||
assign(char_type* __s, std::size_t __n, char_type __a);
|
|
||||||
|
|
||||||
static _GLIBCXX_CONSTEXPR char_type
|
|
||||||
to_char_type(const int_type& __c)
|
|
||||||
{ return static_cast<char_type>(__c); }
|
|
||||||
|
|
||||||
static _GLIBCXX_CONSTEXPR int_type
|
|
||||||
to_int_type(const char_type& __c)
|
|
||||||
{ return static_cast<int_type>(__c); }
|
|
||||||
|
|
||||||
static _GLIBCXX_CONSTEXPR bool
|
|
||||||
eq_int_type(const int_type& __c1, const int_type& __c2)
|
|
||||||
{ return __c1 == __c2; }
|
|
||||||
|
|
||||||
static _GLIBCXX_CONSTEXPR int_type
|
|
||||||
eof()
|
|
||||||
{ return static_cast<int_type>(_GLIBCXX_STDIO_EOF); }
|
|
||||||
|
|
||||||
static _GLIBCXX_CONSTEXPR int_type
|
|
||||||
not_eof(const int_type& __c)
|
|
||||||
{ return !eq_int_type(__c, eof()) ? __c : to_int_type(char_type()); }
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename _CharT>
|
|
||||||
_GLIBCXX14_CONSTEXPR int
|
|
||||||
char_traits<_CharT>::
|
|
||||||
compare(const char_type* __s1, const char_type* __s2, std::size_t __n)
|
|
||||||
{
|
|
||||||
for (std::size_t __i = 0; __i < __n; ++__i)
|
|
||||||
if (lt(__s1[__i], __s2[__i]))
|
|
||||||
return -1;
|
|
||||||
else if (lt(__s2[__i], __s1[__i]))
|
|
||||||
return 1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename _CharT>
|
|
||||||
_GLIBCXX14_CONSTEXPR std::size_t
|
|
||||||
char_traits<_CharT>::
|
|
||||||
length(const char_type* __p)
|
|
||||||
{
|
|
||||||
std::size_t __i = 0;
|
|
||||||
while (!eq(__p[__i], char_type()))
|
|
||||||
++__i;
|
|
||||||
return __i;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename _CharT>
|
|
||||||
_GLIBCXX14_CONSTEXPR const typename char_traits<_CharT>::char_type*
|
|
||||||
char_traits<_CharT>::
|
|
||||||
find(const char_type* __s, std::size_t __n, const char_type& __a)
|
|
||||||
{
|
|
||||||
for (std::size_t __i = 0; __i < __n; ++__i)
|
|
||||||
if (eq(__s[__i], __a))
|
|
||||||
return __s + __i;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename _CharT>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
typename char_traits<_CharT>::char_type*
|
|
||||||
char_traits<_CharT>::
|
|
||||||
move(char_type* __s1, const char_type* __s2, std::size_t __n)
|
|
||||||
{
|
|
||||||
if (__n == 0)
|
|
||||||
return __s1;
|
|
||||||
#ifdef __cpp_lib_is_constant_evaluated
|
|
||||||
if (std::is_constant_evaluated())
|
|
||||||
{
|
|
||||||
if (__s1 > __s2 && __s1 < __s2 + __n)
|
|
||||||
std::copy_backward(__s2, __s2 + __n, __s1);
|
|
||||||
else
|
|
||||||
std::copy(__s2, __s2 + __n, __s1);
|
|
||||||
return __s1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return static_cast<_CharT*>(__builtin_memmove(__s1, __s2,
|
|
||||||
__n * sizeof(char_type)));
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename _CharT>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
typename char_traits<_CharT>::char_type*
|
|
||||||
char_traits<_CharT>::
|
|
||||||
copy(char_type* __s1, const char_type* __s2, std::size_t __n)
|
|
||||||
{
|
|
||||||
// NB: Inline std::copy so no recursive dependencies.
|
|
||||||
std::copy(__s2, __s2 + __n, __s1);
|
|
||||||
return __s1;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename _CharT>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
typename char_traits<_CharT>::char_type*
|
|
||||||
char_traits<_CharT>::
|
|
||||||
assign(char_type* __s, std::size_t __n, char_type __a)
|
|
||||||
{
|
|
||||||
// NB: Inline std::fill_n so no recursive dependencies.
|
|
||||||
std::fill_n(__s, __n, __a);
|
|
||||||
return __s;
|
|
||||||
}
|
|
||||||
|
|
||||||
_GLIBCXX_END_NAMESPACE_VERSION
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
namespace std _GLIBCXX_VISIBILITY(default)
|
|
||||||
{
|
|
||||||
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|
||||||
|
|
||||||
#if __cplusplus >= 201703L
|
|
||||||
|
|
||||||
#if __cplusplus == 201703L
|
|
||||||
// Unofficial macro indicating P0426R1 support
|
|
||||||
# define __cpp_lib_constexpr_char_traits 201611L
|
|
||||||
#else
|
|
||||||
// Also support P1032R1 in C++20
|
|
||||||
# define __cpp_lib_constexpr_char_traits 201811L
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Determine whether the characters of a NULL-terminated
|
|
||||||
* string are known at compile time.
|
|
||||||
* @param __s The string.
|
|
||||||
*
|
|
||||||
* Assumes that _CharT is a built-in character type.
|
|
||||||
*/
|
|
||||||
template<typename _CharT>
|
|
||||||
static _GLIBCXX_ALWAYS_INLINE constexpr bool
|
|
||||||
__constant_string_p(const _CharT* __s)
|
|
||||||
{
|
|
||||||
#ifdef _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED
|
|
||||||
(void) __s;
|
|
||||||
// In constexpr contexts all strings should be constant.
|
|
||||||
return __builtin_is_constant_evaluated();
|
|
||||||
#else
|
|
||||||
while (__builtin_constant_p(*__s) && *__s)
|
|
||||||
__s++;
|
|
||||||
return __builtin_constant_p(*__s);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Determine whether the characters of a character array are
|
|
||||||
* known at compile time.
|
|
||||||
* @param __a The character array.
|
|
||||||
* @param __n Number of characters.
|
|
||||||
*
|
|
||||||
* Assumes that _CharT is a built-in character type.
|
|
||||||
*/
|
|
||||||
template<typename _CharT>
|
|
||||||
static _GLIBCXX_ALWAYS_INLINE constexpr bool
|
|
||||||
__constant_char_array_p(const _CharT* __a, size_t __n)
|
|
||||||
{
|
|
||||||
#ifdef _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED
|
|
||||||
(void) __a;
|
|
||||||
(void) __n;
|
|
||||||
// In constexpr contexts all character arrays should be constant.
|
|
||||||
return __builtin_is_constant_evaluated();
|
|
||||||
#else
|
|
||||||
size_t __i = 0;
|
|
||||||
while (__i < __n && __builtin_constant_p(__a[__i]))
|
|
||||||
__i++;
|
|
||||||
return __i == __n;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// 21.1
|
|
||||||
/**
|
|
||||||
* @brief Basis for explicit traits specializations.
|
|
||||||
*
|
|
||||||
* @note For any given actual character type, this definition is
|
|
||||||
* probably wrong. Since this is just a thin wrapper around
|
|
||||||
* __gnu_cxx::char_traits, it is possible to achieve a more
|
|
||||||
* appropriate definition by specializing __gnu_cxx::char_traits.
|
|
||||||
*
|
|
||||||
* See https://gcc.gnu.org/onlinedocs/libstdc++/manual/strings.html#strings.string.character_types
|
|
||||||
* for advice on how to make use of this class for @a unusual character
|
|
||||||
* types. Also, check out include/ext/pod_char_traits.h.
|
|
||||||
*/
|
|
||||||
template<class _CharT>
|
|
||||||
struct char_traits : public __gnu_cxx::char_traits<_CharT>
|
|
||||||
{ };
|
|
||||||
|
|
||||||
|
|
||||||
/// 21.1.3.1 char_traits specializations
|
|
||||||
template<>
|
|
||||||
struct char_traits<char>
|
|
||||||
{
|
|
||||||
typedef char char_type;
|
|
||||||
typedef int int_type;
|
|
||||||
typedef streampos pos_type;
|
|
||||||
typedef streamoff off_type;
|
|
||||||
typedef mbstate_t state_type;
|
|
||||||
#if __cpp_lib_three_way_comparison
|
|
||||||
using comparison_category = strong_ordering;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static _GLIBCXX17_CONSTEXPR void
|
|
||||||
assign(char_type& __c1, const char_type& __c2) _GLIBCXX_NOEXCEPT
|
|
||||||
{ __c1 = __c2; }
|
|
||||||
|
|
||||||
static _GLIBCXX_CONSTEXPR bool
|
|
||||||
eq(const char_type& __c1, const char_type& __c2) _GLIBCXX_NOEXCEPT
|
|
||||||
{ return __c1 == __c2; }
|
|
||||||
|
|
||||||
static _GLIBCXX_CONSTEXPR bool
|
|
||||||
lt(const char_type& __c1, const char_type& __c2) _GLIBCXX_NOEXCEPT
|
|
||||||
{
|
|
||||||
// LWG 467.
|
|
||||||
return (static_cast<unsigned char>(__c1)
|
|
||||||
< static_cast<unsigned char>(__c2));
|
|
||||||
}
|
|
||||||
|
|
||||||
static _GLIBCXX17_CONSTEXPR int
|
|
||||||
compare(const char_type* __s1, const char_type* __s2, size_t __n)
|
|
||||||
{
|
|
||||||
if (__n == 0)
|
|
||||||
return 0;
|
|
||||||
#if __cplusplus >= 201703L
|
|
||||||
if (__builtin_constant_p(__n)
|
|
||||||
&& __constant_char_array_p(__s1, __n)
|
|
||||||
&& __constant_char_array_p(__s2, __n))
|
|
||||||
return __gnu_cxx::char_traits<char_type>::compare(__s1, __s2, __n);
|
|
||||||
#endif
|
|
||||||
return __builtin_memcmp(__s1, __s2, __n);
|
|
||||||
}
|
|
||||||
|
|
||||||
static _GLIBCXX17_CONSTEXPR size_t
|
|
||||||
length(const char_type* __s)
|
|
||||||
{
|
|
||||||
#if __cplusplus >= 201703L
|
|
||||||
if (__constant_string_p(__s))
|
|
||||||
return __gnu_cxx::char_traits<char_type>::length(__s);
|
|
||||||
#endif
|
|
||||||
return __builtin_strlen(__s);
|
|
||||||
}
|
|
||||||
|
|
||||||
static _GLIBCXX17_CONSTEXPR const char_type*
|
|
||||||
find(const char_type* __s, size_t __n, const char_type& __a)
|
|
||||||
{
|
|
||||||
if (__n == 0)
|
|
||||||
return 0;
|
|
||||||
#if __cplusplus >= 201703L
|
|
||||||
if (__builtin_constant_p(__n)
|
|
||||||
&& __builtin_constant_p(__a)
|
|
||||||
&& __constant_char_array_p(__s, __n))
|
|
||||||
return __gnu_cxx::char_traits<char_type>::find(__s, __n, __a);
|
|
||||||
#endif
|
|
||||||
return static_cast<const char_type*>(__builtin_memchr(__s, __a, __n));
|
|
||||||
}
|
|
||||||
|
|
||||||
static _GLIBCXX20_CONSTEXPR char_type*
|
|
||||||
move(char_type* __s1, const char_type* __s2, size_t __n)
|
|
||||||
{
|
|
||||||
if (__n == 0)
|
|
||||||
return __s1;
|
|
||||||
#ifdef __cpp_lib_is_constant_evaluated
|
|
||||||
if (std::is_constant_evaluated())
|
|
||||||
return __gnu_cxx::char_traits<char_type>::move(__s1, __s2, __n);
|
|
||||||
#endif
|
|
||||||
return static_cast<char_type*>(__builtin_memmove(__s1, __s2, __n));
|
|
||||||
}
|
|
||||||
|
|
||||||
static _GLIBCXX20_CONSTEXPR char_type*
|
|
||||||
copy(char_type* __s1, const char_type* __s2, size_t __n)
|
|
||||||
{
|
|
||||||
if (__n == 0)
|
|
||||||
return __s1;
|
|
||||||
#ifdef __cpp_lib_is_constant_evaluated
|
|
||||||
if (std::is_constant_evaluated())
|
|
||||||
return __gnu_cxx::char_traits<char_type>::copy(__s1, __s2, __n);
|
|
||||||
#endif
|
|
||||||
return static_cast<char_type*>(__builtin_memcpy(__s1, __s2, __n));
|
|
||||||
}
|
|
||||||
|
|
||||||
static _GLIBCXX20_CONSTEXPR char_type*
|
|
||||||
assign(char_type* __s, size_t __n, char_type __a)
|
|
||||||
{
|
|
||||||
if (__n == 0)
|
|
||||||
return __s;
|
|
||||||
#ifdef __cpp_lib_is_constant_evaluated
|
|
||||||
if (std::is_constant_evaluated())
|
|
||||||
return __gnu_cxx::char_traits<char_type>::assign(__s, __n, __a);
|
|
||||||
#endif
|
|
||||||
return static_cast<char_type*>(__builtin_memset(__s, __a, __n));
|
|
||||||
}
|
|
||||||
|
|
||||||
static _GLIBCXX_CONSTEXPR char_type
|
|
||||||
to_char_type(const int_type& __c) _GLIBCXX_NOEXCEPT
|
|
||||||
{ return static_cast<char_type>(__c); }
|
|
||||||
|
|
||||||
// To keep both the byte 0xff and the eof symbol 0xffffffff
|
|
||||||
// from ending up as 0xffffffff.
|
|
||||||
static _GLIBCXX_CONSTEXPR int_type
|
|
||||||
to_int_type(const char_type& __c) _GLIBCXX_NOEXCEPT
|
|
||||||
{ return static_cast<int_type>(static_cast<unsigned char>(__c)); }
|
|
||||||
|
|
||||||
static _GLIBCXX_CONSTEXPR bool
|
|
||||||
eq_int_type(const int_type& __c1, const int_type& __c2) _GLIBCXX_NOEXCEPT
|
|
||||||
{ return __c1 == __c2; }
|
|
||||||
|
|
||||||
static _GLIBCXX_CONSTEXPR int_type
|
|
||||||
eof() _GLIBCXX_NOEXCEPT
|
|
||||||
{ return static_cast<int_type>(_GLIBCXX_STDIO_EOF); }
|
|
||||||
|
|
||||||
static _GLIBCXX_CONSTEXPR int_type
|
|
||||||
not_eof(const int_type& __c) _GLIBCXX_NOEXCEPT
|
|
||||||
{ return (__c == eof()) ? 0 : __c; }
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef _GLIBCXX_USE_WCHAR_T
|
|
||||||
/// 21.1.3.2 char_traits specializations
|
|
||||||
template<>
|
|
||||||
struct char_traits<wchar_t>
|
|
||||||
{
|
|
||||||
typedef wchar_t char_type;
|
|
||||||
typedef wint_t int_type;
|
|
||||||
typedef streamoff off_type;
|
|
||||||
typedef wstreampos pos_type;
|
|
||||||
typedef mbstate_t state_type;
|
|
||||||
#if __cpp_lib_three_way_comparison
|
|
||||||
using comparison_category = strong_ordering;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static _GLIBCXX17_CONSTEXPR void
|
|
||||||
assign(char_type& __c1, const char_type& __c2) _GLIBCXX_NOEXCEPT
|
|
||||||
{ __c1 = __c2; }
|
|
||||||
|
|
||||||
static _GLIBCXX_CONSTEXPR bool
|
|
||||||
eq(const char_type& __c1, const char_type& __c2) _GLIBCXX_NOEXCEPT
|
|
||||||
{ return __c1 == __c2; }
|
|
||||||
|
|
||||||
static _GLIBCXX_CONSTEXPR bool
|
|
||||||
lt(const char_type& __c1, const char_type& __c2) _GLIBCXX_NOEXCEPT
|
|
||||||
{ return __c1 < __c2; }
|
|
||||||
|
|
||||||
static _GLIBCXX17_CONSTEXPR int
|
|
||||||
compare(const char_type* __s1, const char_type* __s2, size_t __n)
|
|
||||||
{
|
|
||||||
if (__n == 0)
|
|
||||||
return 0;
|
|
||||||
#if __cplusplus >= 201703L
|
|
||||||
if (__builtin_constant_p(__n)
|
|
||||||
&& __constant_char_array_p(__s1, __n)
|
|
||||||
&& __constant_char_array_p(__s2, __n))
|
|
||||||
return __gnu_cxx::char_traits<char_type>::compare(__s1, __s2, __n);
|
|
||||||
#endif
|
|
||||||
return wmemcmp(__s1, __s2, __n);
|
|
||||||
}
|
|
||||||
|
|
||||||
static _GLIBCXX17_CONSTEXPR size_t
|
|
||||||
length(const char_type* __s)
|
|
||||||
{
|
|
||||||
#if __cplusplus >= 201703L
|
|
||||||
if (__constant_string_p(__s))
|
|
||||||
return __gnu_cxx::char_traits<char_type>::length(__s);
|
|
||||||
#endif
|
|
||||||
return wcslen(__s);
|
|
||||||
}
|
|
||||||
|
|
||||||
static _GLIBCXX17_CONSTEXPR const char_type*
|
|
||||||
find(const char_type* __s, size_t __n, const char_type& __a)
|
|
||||||
{
|
|
||||||
if (__n == 0)
|
|
||||||
return 0;
|
|
||||||
#if __cplusplus >= 201703L
|
|
||||||
if (__builtin_constant_p(__n)
|
|
||||||
&& __builtin_constant_p(__a)
|
|
||||||
&& __constant_char_array_p(__s, __n))
|
|
||||||
return __gnu_cxx::char_traits<char_type>::find(__s, __n, __a);
|
|
||||||
#endif
|
|
||||||
return wmemchr(__s, __a, __n);
|
|
||||||
}
|
|
||||||
|
|
||||||
static _GLIBCXX20_CONSTEXPR char_type*
|
|
||||||
move(char_type* __s1, const char_type* __s2, size_t __n)
|
|
||||||
{
|
|
||||||
if (__n == 0)
|
|
||||||
return __s1;
|
|
||||||
#ifdef __cpp_lib_is_constant_evaluated
|
|
||||||
if (std::is_constant_evaluated())
|
|
||||||
return __gnu_cxx::char_traits<char_type>::move(__s1, __s2, __n);
|
|
||||||
#endif
|
|
||||||
return wmemmove(__s1, __s2, __n);
|
|
||||||
}
|
|
||||||
|
|
||||||
static _GLIBCXX20_CONSTEXPR char_type*
|
|
||||||
copy(char_type* __s1, const char_type* __s2, size_t __n)
|
|
||||||
{
|
|
||||||
if (__n == 0)
|
|
||||||
return __s1;
|
|
||||||
#ifdef __cpp_lib_is_constant_evaluated
|
|
||||||
if (std::is_constant_evaluated())
|
|
||||||
return __gnu_cxx::char_traits<char_type>::copy(__s1, __s2, __n);
|
|
||||||
#endif
|
|
||||||
return wmemcpy(__s1, __s2, __n);
|
|
||||||
}
|
|
||||||
|
|
||||||
static _GLIBCXX20_CONSTEXPR char_type*
|
|
||||||
assign(char_type* __s, size_t __n, char_type __a)
|
|
||||||
{
|
|
||||||
if (__n == 0)
|
|
||||||
return __s;
|
|
||||||
#ifdef __cpp_lib_is_constant_evaluated
|
|
||||||
if (std::is_constant_evaluated())
|
|
||||||
return __gnu_cxx::char_traits<char_type>::assign(__s, __n, __a);
|
|
||||||
#endif
|
|
||||||
return wmemset(__s, __a, __n);
|
|
||||||
}
|
|
||||||
|
|
||||||
static _GLIBCXX_CONSTEXPR char_type
|
|
||||||
to_char_type(const int_type& __c) _GLIBCXX_NOEXCEPT
|
|
||||||
{ return char_type(__c); }
|
|
||||||
|
|
||||||
static _GLIBCXX_CONSTEXPR int_type
|
|
||||||
to_int_type(const char_type& __c) _GLIBCXX_NOEXCEPT
|
|
||||||
{ return int_type(__c); }
|
|
||||||
|
|
||||||
static _GLIBCXX_CONSTEXPR bool
|
|
||||||
eq_int_type(const int_type& __c1, const int_type& __c2) _GLIBCXX_NOEXCEPT
|
|
||||||
{ return __c1 == __c2; }
|
|
||||||
|
|
||||||
static _GLIBCXX_CONSTEXPR int_type
|
|
||||||
eof() _GLIBCXX_NOEXCEPT
|
|
||||||
{ return static_cast<int_type>(WEOF); }
|
|
||||||
|
|
||||||
static _GLIBCXX_CONSTEXPR int_type
|
|
||||||
not_eof(const int_type& __c) _GLIBCXX_NOEXCEPT
|
|
||||||
{ return eq_int_type(__c, eof()) ? 0 : __c; }
|
|
||||||
};
|
|
||||||
#endif //_GLIBCXX_USE_WCHAR_T
|
|
||||||
|
|
||||||
#ifdef _GLIBCXX_USE_CHAR8_T
|
|
||||||
template<>
|
|
||||||
struct char_traits<char8_t>
|
|
||||||
{
|
|
||||||
typedef char8_t char_type;
|
|
||||||
typedef unsigned int int_type;
|
|
||||||
typedef u8streampos pos_type;
|
|
||||||
typedef streamoff off_type;
|
|
||||||
typedef mbstate_t state_type;
|
|
||||||
#if __cpp_lib_three_way_comparison
|
|
||||||
using comparison_category = strong_ordering;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static _GLIBCXX17_CONSTEXPR void
|
|
||||||
assign(char_type& __c1, const char_type& __c2) _GLIBCXX_NOEXCEPT
|
|
||||||
{ __c1 = __c2; }
|
|
||||||
|
|
||||||
static _GLIBCXX_CONSTEXPR bool
|
|
||||||
eq(const char_type& __c1, const char_type& __c2) _GLIBCXX_NOEXCEPT
|
|
||||||
{ return __c1 == __c2; }
|
|
||||||
|
|
||||||
static _GLIBCXX_CONSTEXPR bool
|
|
||||||
lt(const char_type& __c1, const char_type& __c2) _GLIBCXX_NOEXCEPT
|
|
||||||
{ return __c1 < __c2; }
|
|
||||||
|
|
||||||
static _GLIBCXX17_CONSTEXPR int
|
|
||||||
compare(const char_type* __s1, const char_type* __s2, size_t __n)
|
|
||||||
{
|
|
||||||
if (__n == 0)
|
|
||||||
return 0;
|
|
||||||
#if __cplusplus > 201402
|
|
||||||
if (__builtin_constant_p(__n)
|
|
||||||
&& __constant_char_array_p(__s1, __n)
|
|
||||||
&& __constant_char_array_p(__s2, __n))
|
|
||||||
return __gnu_cxx::char_traits<char_type>::compare(__s1, __s2, __n);
|
|
||||||
#endif
|
|
||||||
return __builtin_memcmp(__s1, __s2, __n);
|
|
||||||
}
|
|
||||||
|
|
||||||
static _GLIBCXX17_CONSTEXPR size_t
|
|
||||||
length(const char_type* __s)
|
|
||||||
{
|
|
||||||
#if __cplusplus > 201402
|
|
||||||
if (__constant_string_p(__s))
|
|
||||||
return __gnu_cxx::char_traits<char_type>::length(__s);
|
|
||||||
#endif
|
|
||||||
size_t __i = 0;
|
|
||||||
while (!eq(__s[__i], char_type()))
|
|
||||||
++__i;
|
|
||||||
return __i;
|
|
||||||
}
|
|
||||||
|
|
||||||
static _GLIBCXX17_CONSTEXPR const char_type*
|
|
||||||
find(const char_type* __s, size_t __n, const char_type& __a)
|
|
||||||
{
|
|
||||||
if (__n == 0)
|
|
||||||
return 0;
|
|
||||||
#if __cplusplus > 201402
|
|
||||||
if (__builtin_constant_p(__n)
|
|
||||||
&& __builtin_constant_p(__a)
|
|
||||||
&& __constant_char_array_p(__s, __n))
|
|
||||||
return __gnu_cxx::char_traits<char_type>::find(__s, __n, __a);
|
|
||||||
#endif
|
|
||||||
return static_cast<const char_type*>(__builtin_memchr(__s, __a, __n));
|
|
||||||
}
|
|
||||||
|
|
||||||
static _GLIBCXX20_CONSTEXPR char_type*
|
|
||||||
move(char_type* __s1, const char_type* __s2, size_t __n)
|
|
||||||
{
|
|
||||||
if (__n == 0)
|
|
||||||
return __s1;
|
|
||||||
#ifdef __cpp_lib_is_constant_evaluated
|
|
||||||
if (std::is_constant_evaluated())
|
|
||||||
return __gnu_cxx::char_traits<char_type>::move(__s1, __s2, __n);
|
|
||||||
#endif
|
|
||||||
return static_cast<char_type*>(__builtin_memmove(__s1, __s2, __n));
|
|
||||||
}
|
|
||||||
|
|
||||||
static _GLIBCXX20_CONSTEXPR char_type*
|
|
||||||
copy(char_type* __s1, const char_type* __s2, size_t __n)
|
|
||||||
{
|
|
||||||
if (__n == 0)
|
|
||||||
return __s1;
|
|
||||||
#ifdef __cpp_lib_is_constant_evaluated
|
|
||||||
if (std::is_constant_evaluated())
|
|
||||||
return __gnu_cxx::char_traits<char_type>::copy(__s1, __s2, __n);
|
|
||||||
#endif
|
|
||||||
return static_cast<char_type*>(__builtin_memcpy(__s1, __s2, __n));
|
|
||||||
}
|
|
||||||
|
|
||||||
static _GLIBCXX20_CONSTEXPR char_type*
|
|
||||||
assign(char_type* __s, size_t __n, char_type __a)
|
|
||||||
{
|
|
||||||
if (__n == 0)
|
|
||||||
return __s;
|
|
||||||
#ifdef __cpp_lib_is_constant_evaluated
|
|
||||||
if (std::is_constant_evaluated())
|
|
||||||
return __gnu_cxx::char_traits<char_type>::assign(__s, __n, __a);
|
|
||||||
#endif
|
|
||||||
return static_cast<char_type*>(__builtin_memset(__s, __a, __n));
|
|
||||||
}
|
|
||||||
|
|
||||||
static _GLIBCXX_CONSTEXPR char_type
|
|
||||||
to_char_type(const int_type& __c) _GLIBCXX_NOEXCEPT
|
|
||||||
{ return char_type(__c); }
|
|
||||||
|
|
||||||
static _GLIBCXX_CONSTEXPR int_type
|
|
||||||
to_int_type(const char_type& __c) _GLIBCXX_NOEXCEPT
|
|
||||||
{ return int_type(__c); }
|
|
||||||
|
|
||||||
static _GLIBCXX_CONSTEXPR bool
|
|
||||||
eq_int_type(const int_type& __c1, const int_type& __c2) _GLIBCXX_NOEXCEPT
|
|
||||||
{ return __c1 == __c2; }
|
|
||||||
|
|
||||||
static _GLIBCXX_CONSTEXPR int_type
|
|
||||||
eof() _GLIBCXX_NOEXCEPT
|
|
||||||
{ return static_cast<int_type>(-1); }
|
|
||||||
|
|
||||||
static _GLIBCXX_CONSTEXPR int_type
|
|
||||||
not_eof(const int_type& __c) _GLIBCXX_NOEXCEPT
|
|
||||||
{ return eq_int_type(__c, eof()) ? 0 : __c; }
|
|
||||||
};
|
|
||||||
#endif //_GLIBCXX_USE_CHAR8_T
|
|
||||||
|
|
||||||
_GLIBCXX_END_NAMESPACE_VERSION
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
|
|
||||||
namespace std _GLIBCXX_VISIBILITY(default)
|
|
||||||
{
|
|
||||||
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|
||||||
|
|
||||||
template<>
|
|
||||||
struct char_traits<char16_t>
|
|
||||||
{
|
|
||||||
typedef char16_t char_type;
|
|
||||||
#ifdef _GLIBCXX_USE_C99_STDINT_TR1
|
|
||||||
typedef uint_least16_t int_type;
|
|
||||||
#elif defined __UINT_LEAST16_TYPE__
|
|
||||||
typedef __UINT_LEAST16_TYPE__ int_type;
|
|
||||||
#else
|
|
||||||
typedef make_unsigned<char16_t>::type int_type;
|
|
||||||
#endif
|
|
||||||
typedef streamoff off_type;
|
|
||||||
typedef u16streampos pos_type;
|
|
||||||
typedef mbstate_t state_type;
|
|
||||||
#if __cpp_lib_three_way_comparison
|
|
||||||
using comparison_category = strong_ordering;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static _GLIBCXX17_CONSTEXPR void
|
|
||||||
assign(char_type& __c1, const char_type& __c2) noexcept
|
|
||||||
{ __c1 = __c2; }
|
|
||||||
|
|
||||||
static constexpr bool
|
|
||||||
eq(const char_type& __c1, const char_type& __c2) noexcept
|
|
||||||
{ return __c1 == __c2; }
|
|
||||||
|
|
||||||
static constexpr bool
|
|
||||||
lt(const char_type& __c1, const char_type& __c2) noexcept
|
|
||||||
{ return __c1 < __c2; }
|
|
||||||
|
|
||||||
static _GLIBCXX17_CONSTEXPR int
|
|
||||||
compare(const char_type* __s1, const char_type* __s2, size_t __n)
|
|
||||||
{
|
|
||||||
for (size_t __i = 0; __i < __n; ++__i)
|
|
||||||
if (lt(__s1[__i], __s2[__i]))
|
|
||||||
return -1;
|
|
||||||
else if (lt(__s2[__i], __s1[__i]))
|
|
||||||
return 1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static _GLIBCXX17_CONSTEXPR size_t
|
|
||||||
length(const char_type* __s)
|
|
||||||
{
|
|
||||||
size_t __i = 0;
|
|
||||||
while (!eq(__s[__i], char_type()))
|
|
||||||
++__i;
|
|
||||||
return __i;
|
|
||||||
}
|
|
||||||
|
|
||||||
static _GLIBCXX17_CONSTEXPR const char_type*
|
|
||||||
find(const char_type* __s, size_t __n, const char_type& __a)
|
|
||||||
{
|
|
||||||
for (size_t __i = 0; __i < __n; ++__i)
|
|
||||||
if (eq(__s[__i], __a))
|
|
||||||
return __s + __i;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static _GLIBCXX20_CONSTEXPR char_type*
|
|
||||||
move(char_type* __s1, const char_type* __s2, size_t __n)
|
|
||||||
{
|
|
||||||
if (__n == 0)
|
|
||||||
return __s1;
|
|
||||||
#ifdef __cpp_lib_is_constant_evaluated
|
|
||||||
if (std::is_constant_evaluated())
|
|
||||||
return __gnu_cxx::char_traits<char_type>::move(__s1, __s2, __n);
|
|
||||||
#endif
|
|
||||||
return (static_cast<char_type*>
|
|
||||||
(__builtin_memmove(__s1, __s2, __n * sizeof(char_type))));
|
|
||||||
}
|
|
||||||
|
|
||||||
static _GLIBCXX20_CONSTEXPR char_type*
|
|
||||||
copy(char_type* __s1, const char_type* __s2, size_t __n)
|
|
||||||
{
|
|
||||||
if (__n == 0)
|
|
||||||
return __s1;
|
|
||||||
#ifdef __cpp_lib_is_constant_evaluated
|
|
||||||
if (std::is_constant_evaluated())
|
|
||||||
return __gnu_cxx::char_traits<char_type>::copy(__s1, __s2, __n);
|
|
||||||
#endif
|
|
||||||
return (static_cast<char_type*>
|
|
||||||
(__builtin_memcpy(__s1, __s2, __n * sizeof(char_type))));
|
|
||||||
}
|
|
||||||
|
|
||||||
static _GLIBCXX20_CONSTEXPR char_type*
|
|
||||||
assign(char_type* __s, size_t __n, char_type __a)
|
|
||||||
{
|
|
||||||
for (size_t __i = 0; __i < __n; ++__i)
|
|
||||||
assign(__s[__i], __a);
|
|
||||||
return __s;
|
|
||||||
}
|
|
||||||
|
|
||||||
static constexpr char_type
|
|
||||||
to_char_type(const int_type& __c) noexcept
|
|
||||||
{ return char_type(__c); }
|
|
||||||
|
|
||||||
static constexpr int_type
|
|
||||||
to_int_type(const char_type& __c) noexcept
|
|
||||||
{ return __c == eof() ? int_type(0xfffd) : int_type(__c); }
|
|
||||||
|
|
||||||
static constexpr bool
|
|
||||||
eq_int_type(const int_type& __c1, const int_type& __c2) noexcept
|
|
||||||
{ return __c1 == __c2; }
|
|
||||||
|
|
||||||
static constexpr int_type
|
|
||||||
eof() noexcept
|
|
||||||
{ return static_cast<int_type>(-1); }
|
|
||||||
|
|
||||||
static constexpr int_type
|
|
||||||
not_eof(const int_type& __c) noexcept
|
|
||||||
{ return eq_int_type(__c, eof()) ? 0 : __c; }
|
|
||||||
};
|
|
||||||
|
|
||||||
template<>
|
|
||||||
struct char_traits<char32_t>
|
|
||||||
{
|
|
||||||
typedef char32_t char_type;
|
|
||||||
#ifdef _GLIBCXX_USE_C99_STDINT_TR1
|
|
||||||
typedef uint_least32_t int_type;
|
|
||||||
#elif defined __UINT_LEAST32_TYPE__
|
|
||||||
typedef __UINT_LEAST32_TYPE__ int_type;
|
|
||||||
#else
|
|
||||||
typedef make_unsigned<char32_t>::type int_type;
|
|
||||||
#endif
|
|
||||||
typedef streamoff off_type;
|
|
||||||
typedef u32streampos pos_type;
|
|
||||||
typedef mbstate_t state_type;
|
|
||||||
#if __cpp_lib_three_way_comparison
|
|
||||||
using comparison_category = strong_ordering;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static _GLIBCXX17_CONSTEXPR void
|
|
||||||
assign(char_type& __c1, const char_type& __c2) noexcept
|
|
||||||
{ __c1 = __c2; }
|
|
||||||
|
|
||||||
static constexpr bool
|
|
||||||
eq(const char_type& __c1, const char_type& __c2) noexcept
|
|
||||||
{ return __c1 == __c2; }
|
|
||||||
|
|
||||||
static constexpr bool
|
|
||||||
lt(const char_type& __c1, const char_type& __c2) noexcept
|
|
||||||
{ return __c1 < __c2; }
|
|
||||||
|
|
||||||
static _GLIBCXX17_CONSTEXPR int
|
|
||||||
compare(const char_type* __s1, const char_type* __s2, size_t __n)
|
|
||||||
{
|
|
||||||
for (size_t __i = 0; __i < __n; ++__i)
|
|
||||||
if (lt(__s1[__i], __s2[__i]))
|
|
||||||
return -1;
|
|
||||||
else if (lt(__s2[__i], __s1[__i]))
|
|
||||||
return 1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static _GLIBCXX17_CONSTEXPR size_t
|
|
||||||
length(const char_type* __s)
|
|
||||||
{
|
|
||||||
size_t __i = 0;
|
|
||||||
while (!eq(__s[__i], char_type()))
|
|
||||||
++__i;
|
|
||||||
return __i;
|
|
||||||
}
|
|
||||||
|
|
||||||
static _GLIBCXX17_CONSTEXPR const char_type*
|
|
||||||
find(const char_type* __s, size_t __n, const char_type& __a)
|
|
||||||
{
|
|
||||||
for (size_t __i = 0; __i < __n; ++__i)
|
|
||||||
if (eq(__s[__i], __a))
|
|
||||||
return __s + __i;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static _GLIBCXX20_CONSTEXPR char_type*
|
|
||||||
move(char_type* __s1, const char_type* __s2, size_t __n)
|
|
||||||
{
|
|
||||||
if (__n == 0)
|
|
||||||
return __s1;
|
|
||||||
#ifdef __cpp_lib_is_constant_evaluated
|
|
||||||
if (std::is_constant_evaluated())
|
|
||||||
return __gnu_cxx::char_traits<char_type>::move(__s1, __s2, __n);
|
|
||||||
#endif
|
|
||||||
return (static_cast<char_type*>
|
|
||||||
(__builtin_memmove(__s1, __s2, __n * sizeof(char_type))));
|
|
||||||
}
|
|
||||||
|
|
||||||
static _GLIBCXX20_CONSTEXPR char_type*
|
|
||||||
copy(char_type* __s1, const char_type* __s2, size_t __n)
|
|
||||||
{
|
|
||||||
if (__n == 0)
|
|
||||||
return __s1;
|
|
||||||
#ifdef __cpp_lib_is_constant_evaluated
|
|
||||||
if (std::is_constant_evaluated())
|
|
||||||
return __gnu_cxx::char_traits<char_type>::copy(__s1, __s2, __n);
|
|
||||||
#endif
|
|
||||||
return (static_cast<char_type*>
|
|
||||||
(__builtin_memcpy(__s1, __s2, __n * sizeof(char_type))));
|
|
||||||
}
|
|
||||||
|
|
||||||
static _GLIBCXX20_CONSTEXPR char_type*
|
|
||||||
assign(char_type* __s, size_t __n, char_type __a)
|
|
||||||
{
|
|
||||||
for (size_t __i = 0; __i < __n; ++__i)
|
|
||||||
assign(__s[__i], __a);
|
|
||||||
return __s;
|
|
||||||
}
|
|
||||||
|
|
||||||
static constexpr char_type
|
|
||||||
to_char_type(const int_type& __c) noexcept
|
|
||||||
{ return char_type(__c); }
|
|
||||||
|
|
||||||
static constexpr int_type
|
|
||||||
to_int_type(const char_type& __c) noexcept
|
|
||||||
{ return int_type(__c); }
|
|
||||||
|
|
||||||
static constexpr bool
|
|
||||||
eq_int_type(const int_type& __c1, const int_type& __c2) noexcept
|
|
||||||
{ return __c1 == __c2; }
|
|
||||||
|
|
||||||
static constexpr int_type
|
|
||||||
eof() noexcept
|
|
||||||
{ return static_cast<int_type>(-1); }
|
|
||||||
|
|
||||||
static constexpr int_type
|
|
||||||
not_eof(const int_type& __c) noexcept
|
|
||||||
{ return eq_int_type(__c, eof()) ? 0 : __c; }
|
|
||||||
};
|
|
||||||
|
|
||||||
#if __cpp_lib_three_way_comparison
|
|
||||||
namespace __detail
|
|
||||||
{
|
|
||||||
template<typename _ChTraits>
|
|
||||||
constexpr auto
|
|
||||||
__char_traits_cmp_cat(int __cmp) noexcept
|
|
||||||
{
|
|
||||||
if constexpr (requires { typename _ChTraits::comparison_category; })
|
|
||||||
{
|
|
||||||
using _Cat = typename _ChTraits::comparison_category;
|
|
||||||
static_assert( !is_void_v<common_comparison_category_t<_Cat>> );
|
|
||||||
return static_cast<_Cat>(__cmp <=> 0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return static_cast<weak_ordering>(__cmp <=> 0);
|
|
||||||
}
|
|
||||||
} // namespace __detail
|
|
||||||
#endif // C++20
|
|
||||||
|
|
||||||
_GLIBCXX_END_NAMESPACE_VERSION
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
#endif // C++11
|
|
||||||
|
|
||||||
#endif // _CHAR_TRAITS_H
|
|
Binary file not shown.
@ -1,106 +0,0 @@
|
|||||||
// Numeric conversions (to_string, to_chars) -*- C++ -*-
|
|
||||||
|
|
||||||
// Copyright (C) 2017-2020 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.
|
|
||||||
|
|
||||||
// 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 bits/charconv.h
|
|
||||||
* This is an internal header file, included by other library headers.
|
|
||||||
* Do not attempt to use it directly. @headername{charconv}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _GLIBCXX_CHARCONV_H
|
|
||||||
#define _GLIBCXX_CHARCONV_H 1
|
|
||||||
|
|
||||||
#pragma GCC system_header
|
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
|
|
||||||
#include <type_traits>
|
|
||||||
|
|
||||||
namespace std _GLIBCXX_VISIBILITY(default)
|
|
||||||
{
|
|
||||||
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|
||||||
namespace __detail
|
|
||||||
{
|
|
||||||
// Generic implementation for arbitrary bases.
|
|
||||||
template<typename _Tp>
|
|
||||||
_GLIBCXX14_CONSTEXPR unsigned
|
|
||||||
__to_chars_len(_Tp __value, int __base = 10) noexcept
|
|
||||||
{
|
|
||||||
static_assert(is_integral<_Tp>::value, "implementation bug");
|
|
||||||
static_assert(is_unsigned<_Tp>::value, "implementation bug");
|
|
||||||
|
|
||||||
unsigned __n = 1;
|
|
||||||
const unsigned __b2 = __base * __base;
|
|
||||||
const unsigned __b3 = __b2 * __base;
|
|
||||||
const unsigned long __b4 = __b3 * __base;
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
if (__value < (unsigned)__base) return __n;
|
|
||||||
if (__value < __b2) return __n + 1;
|
|
||||||
if (__value < __b3) return __n + 2;
|
|
||||||
if (__value < __b4) return __n + 3;
|
|
||||||
__value /= __b4;
|
|
||||||
__n += 4;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write an unsigned integer value to the range [first,first+len).
|
|
||||||
// The caller is required to provide a buffer of exactly the right size
|
|
||||||
// (which can be determined by the __to_chars_len function).
|
|
||||||
template<typename _Tp>
|
|
||||||
void
|
|
||||||
__to_chars_10_impl(char* __first, unsigned __len, _Tp __val) noexcept
|
|
||||||
{
|
|
||||||
static_assert(is_integral<_Tp>::value, "implementation bug");
|
|
||||||
static_assert(is_unsigned<_Tp>::value, "implementation bug");
|
|
||||||
|
|
||||||
static constexpr char __digits[201] =
|
|
||||||
"0001020304050607080910111213141516171819"
|
|
||||||
"2021222324252627282930313233343536373839"
|
|
||||||
"4041424344454647484950515253545556575859"
|
|
||||||
"6061626364656667686970717273747576777879"
|
|
||||||
"8081828384858687888990919293949596979899";
|
|
||||||
unsigned __pos = __len - 1;
|
|
||||||
while (__val >= 100)
|
|
||||||
{
|
|
||||||
auto const __num = (__val % 100) * 2;
|
|
||||||
__val /= 100;
|
|
||||||
__first[__pos] = __digits[__num + 1];
|
|
||||||
__first[__pos - 1] = __digits[__num];
|
|
||||||
__pos -= 2;
|
|
||||||
}
|
|
||||||
if (__val >= 10)
|
|
||||||
{
|
|
||||||
auto const __num = __val * 2;
|
|
||||||
__first[1] = __digits[__num + 1];
|
|
||||||
__first[0] = __digits[__num];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
__first[0] = '0' + __val;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace __detail
|
|
||||||
_GLIBCXX_END_NAMESPACE_VERSION
|
|
||||||
} // namespace std
|
|
||||||
#endif // C++11
|
|
||||||
#endif // _GLIBCXX_CHARCONV_H
|
|
Binary file not shown.
@ -1,840 +0,0 @@
|
|||||||
// Locale support (codecvt) -*- C++ -*-
|
|
||||||
|
|
||||||
// Copyright (C) 2000-2020 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.
|
|
||||||
|
|
||||||
// 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 bits/codecvt.h
|
|
||||||
* This is an internal header file, included by other library headers.
|
|
||||||
* Do not attempt to use it directly. @headername{locale}
|
|
||||||
*/
|
|
||||||
|
|
||||||
//
|
|
||||||
// ISO C++ 14882: 22.2.1.5 Template class codecvt
|
|
||||||
//
|
|
||||||
|
|
||||||
// Written by Benjamin Kosnik <bkoz@redhat.com>
|
|
||||||
|
|
||||||
#ifndef _CODECVT_H
|
|
||||||
#define _CODECVT_H 1
|
|
||||||
|
|
||||||
#pragma GCC system_header
|
|
||||||
|
|
||||||
namespace std _GLIBCXX_VISIBILITY(default)
|
|
||||||
{
|
|
||||||
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|
||||||
|
|
||||||
/// Empty base class for codecvt facet [22.2.1.5].
|
|
||||||
class codecvt_base
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
enum result
|
|
||||||
{
|
|
||||||
ok,
|
|
||||||
partial,
|
|
||||||
error,
|
|
||||||
noconv
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Common base for codecvt functions.
|
|
||||||
*
|
|
||||||
* This template class provides implementations of the public functions
|
|
||||||
* that forward to the protected virtual functions.
|
|
||||||
*
|
|
||||||
* This template also provides abstract stubs for the protected virtual
|
|
||||||
* functions.
|
|
||||||
*/
|
|
||||||
template<typename _InternT, typename _ExternT, typename _StateT>
|
|
||||||
class __codecvt_abstract_base
|
|
||||||
: public locale::facet, public codecvt_base
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
// Types:
|
|
||||||
typedef codecvt_base::result result;
|
|
||||||
typedef _InternT intern_type;
|
|
||||||
typedef _ExternT extern_type;
|
|
||||||
typedef _StateT state_type;
|
|
||||||
|
|
||||||
// 22.2.1.5.1 codecvt members
|
|
||||||
/**
|
|
||||||
* @brief Convert from internal to external character set.
|
|
||||||
*
|
|
||||||
* Converts input string of intern_type to output string of
|
|
||||||
* extern_type. This is analogous to wcsrtombs. It does this by
|
|
||||||
* calling codecvt::do_out.
|
|
||||||
*
|
|
||||||
* The source and destination character sets are determined by the
|
|
||||||
* facet's locale, internal and external types.
|
|
||||||
*
|
|
||||||
* The characters in [from,from_end) are converted and written to
|
|
||||||
* [to,to_end). from_next and to_next are set to point to the
|
|
||||||
* character following the last successfully converted character,
|
|
||||||
* respectively. If the result needed no conversion, from_next and
|
|
||||||
* to_next are not affected.
|
|
||||||
*
|
|
||||||
* The @a state argument should be initialized if the input is at the
|
|
||||||
* beginning and carried from a previous call if continuing
|
|
||||||
* conversion. There are no guarantees about how @a state is used.
|
|
||||||
*
|
|
||||||
* The result returned is a member of codecvt_base::result. If
|
|
||||||
* all the input is converted, returns codecvt_base::ok. If no
|
|
||||||
* conversion is necessary, returns codecvt_base::noconv. If
|
|
||||||
* the input ends early or there is insufficient space in the
|
|
||||||
* output, returns codecvt_base::partial. Otherwise the
|
|
||||||
* conversion failed and codecvt_base::error is returned.
|
|
||||||
*
|
|
||||||
* @param __state Persistent conversion state data.
|
|
||||||
* @param __from Start of input.
|
|
||||||
* @param __from_end End of input.
|
|
||||||
* @param __from_next Returns start of unconverted data.
|
|
||||||
* @param __to Start of output buffer.
|
|
||||||
* @param __to_end End of output buffer.
|
|
||||||
* @param __to_next Returns start of unused output area.
|
|
||||||
* @return codecvt_base::result.
|
|
||||||
*/
|
|
||||||
result
|
|
||||||
out(state_type& __state, const intern_type* __from,
|
|
||||||
const intern_type* __from_end, const intern_type*& __from_next,
|
|
||||||
extern_type* __to, extern_type* __to_end,
|
|
||||||
extern_type*& __to_next) const
|
|
||||||
{
|
|
||||||
return this->do_out(__state, __from, __from_end, __from_next,
|
|
||||||
__to, __to_end, __to_next);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Reset conversion state.
|
|
||||||
*
|
|
||||||
* Writes characters to output that would restore @a state to initial
|
|
||||||
* conditions. The idea is that if a partial conversion occurs, then
|
|
||||||
* the converting the characters written by this function would leave
|
|
||||||
* the state in initial conditions, rather than partial conversion
|
|
||||||
* state. It does this by calling codecvt::do_unshift().
|
|
||||||
*
|
|
||||||
* For example, if 4 external characters always converted to 1 internal
|
|
||||||
* character, and input to in() had 6 external characters with state
|
|
||||||
* saved, this function would write two characters to the output and
|
|
||||||
* set the state to initialized conditions.
|
|
||||||
*
|
|
||||||
* The source and destination character sets are determined by the
|
|
||||||
* facet's locale, internal and external types.
|
|
||||||
*
|
|
||||||
* The result returned is a member of codecvt_base::result. If the
|
|
||||||
* state could be reset and data written, returns codecvt_base::ok. If
|
|
||||||
* no conversion is necessary, returns codecvt_base::noconv. If the
|
|
||||||
* output has insufficient space, returns codecvt_base::partial.
|
|
||||||
* Otherwise the reset failed and codecvt_base::error is returned.
|
|
||||||
*
|
|
||||||
* @param __state Persistent conversion state data.
|
|
||||||
* @param __to Start of output buffer.
|
|
||||||
* @param __to_end End of output buffer.
|
|
||||||
* @param __to_next Returns start of unused output area.
|
|
||||||
* @return codecvt_base::result.
|
|
||||||
*/
|
|
||||||
result
|
|
||||||
unshift(state_type& __state, extern_type* __to, extern_type* __to_end,
|
|
||||||
extern_type*& __to_next) const
|
|
||||||
{ return this->do_unshift(__state, __to,__to_end,__to_next); }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Convert from external to internal character set.
|
|
||||||
*
|
|
||||||
* Converts input string of extern_type to output string of
|
|
||||||
* intern_type. This is analogous to mbsrtowcs. It does this by
|
|
||||||
* calling codecvt::do_in.
|
|
||||||
*
|
|
||||||
* The source and destination character sets are determined by the
|
|
||||||
* facet's locale, internal and external types.
|
|
||||||
*
|
|
||||||
* The characters in [from,from_end) are converted and written to
|
|
||||||
* [to,to_end). from_next and to_next are set to point to the
|
|
||||||
* character following the last successfully converted character,
|
|
||||||
* respectively. If the result needed no conversion, from_next and
|
|
||||||
* to_next are not affected.
|
|
||||||
*
|
|
||||||
* The @a state argument should be initialized if the input is at the
|
|
||||||
* beginning and carried from a previous call if continuing
|
|
||||||
* conversion. There are no guarantees about how @a state is used.
|
|
||||||
*
|
|
||||||
* The result returned is a member of codecvt_base::result. If
|
|
||||||
* all the input is converted, returns codecvt_base::ok. If no
|
|
||||||
* conversion is necessary, returns codecvt_base::noconv. If
|
|
||||||
* the input ends early or there is insufficient space in the
|
|
||||||
* output, returns codecvt_base::partial. Otherwise the
|
|
||||||
* conversion failed and codecvt_base::error is returned.
|
|
||||||
*
|
|
||||||
* @param __state Persistent conversion state data.
|
|
||||||
* @param __from Start of input.
|
|
||||||
* @param __from_end End of input.
|
|
||||||
* @param __from_next Returns start of unconverted data.
|
|
||||||
* @param __to Start of output buffer.
|
|
||||||
* @param __to_end End of output buffer.
|
|
||||||
* @param __to_next Returns start of unused output area.
|
|
||||||
* @return codecvt_base::result.
|
|
||||||
*/
|
|
||||||
result
|
|
||||||
in(state_type& __state, const extern_type* __from,
|
|
||||||
const extern_type* __from_end, const extern_type*& __from_next,
|
|
||||||
intern_type* __to, intern_type* __to_end,
|
|
||||||
intern_type*& __to_next) const
|
|
||||||
{
|
|
||||||
return this->do_in(__state, __from, __from_end, __from_next,
|
|
||||||
__to, __to_end, __to_next);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
encoding() const throw()
|
|
||||||
{ return this->do_encoding(); }
|
|
||||||
|
|
||||||
bool
|
|
||||||
always_noconv() const throw()
|
|
||||||
{ return this->do_always_noconv(); }
|
|
||||||
|
|
||||||
int
|
|
||||||
length(state_type& __state, const extern_type* __from,
|
|
||||||
const extern_type* __end, size_t __max) const
|
|
||||||
{ return this->do_length(__state, __from, __end, __max); }
|
|
||||||
|
|
||||||
int
|
|
||||||
max_length() const throw()
|
|
||||||
{ return this->do_max_length(); }
|
|
||||||
|
|
||||||
protected:
|
|
||||||
explicit
|
|
||||||
__codecvt_abstract_base(size_t __refs = 0) : locale::facet(__refs) { }
|
|
||||||
|
|
||||||
virtual
|
|
||||||
~__codecvt_abstract_base() { }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Convert from internal to external character set.
|
|
||||||
*
|
|
||||||
* Converts input string of intern_type to output string of
|
|
||||||
* extern_type. This function is a hook for derived classes to change
|
|
||||||
* the value returned. @see out for more information.
|
|
||||||
*/
|
|
||||||
virtual result
|
|
||||||
do_out(state_type& __state, const intern_type* __from,
|
|
||||||
const intern_type* __from_end, const intern_type*& __from_next,
|
|
||||||
extern_type* __to, extern_type* __to_end,
|
|
||||||
extern_type*& __to_next) const = 0;
|
|
||||||
|
|
||||||
virtual result
|
|
||||||
do_unshift(state_type& __state, extern_type* __to,
|
|
||||||
extern_type* __to_end, extern_type*& __to_next) const = 0;
|
|
||||||
|
|
||||||
virtual result
|
|
||||||
do_in(state_type& __state, const extern_type* __from,
|
|
||||||
const extern_type* __from_end, const extern_type*& __from_next,
|
|
||||||
intern_type* __to, intern_type* __to_end,
|
|
||||||
intern_type*& __to_next) const = 0;
|
|
||||||
|
|
||||||
virtual int
|
|
||||||
do_encoding() const throw() = 0;
|
|
||||||
|
|
||||||
virtual bool
|
|
||||||
do_always_noconv() const throw() = 0;
|
|
||||||
|
|
||||||
virtual int
|
|
||||||
do_length(state_type&, const extern_type* __from,
|
|
||||||
const extern_type* __end, size_t __max) const = 0;
|
|
||||||
|
|
||||||
virtual int
|
|
||||||
do_max_length() const throw() = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Primary class template codecvt.
|
|
||||||
* @ingroup locales
|
|
||||||
*
|
|
||||||
* NB: Generic, mostly useless implementation.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
template<typename _InternT, typename _ExternT, typename _StateT>
|
|
||||||
class codecvt
|
|
||||||
: public __codecvt_abstract_base<_InternT, _ExternT, _StateT>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
// Types:
|
|
||||||
typedef codecvt_base::result result;
|
|
||||||
typedef _InternT intern_type;
|
|
||||||
typedef _ExternT extern_type;
|
|
||||||
typedef _StateT state_type;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
__c_locale _M_c_locale_codecvt;
|
|
||||||
|
|
||||||
public:
|
|
||||||
static locale::id id;
|
|
||||||
|
|
||||||
explicit
|
|
||||||
codecvt(size_t __refs = 0)
|
|
||||||
: __codecvt_abstract_base<_InternT, _ExternT, _StateT> (__refs),
|
|
||||||
_M_c_locale_codecvt(0)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
explicit
|
|
||||||
codecvt(__c_locale __cloc, size_t __refs = 0);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual
|
|
||||||
~codecvt() { }
|
|
||||||
|
|
||||||
virtual result
|
|
||||||
do_out(state_type& __state, const intern_type* __from,
|
|
||||||
const intern_type* __from_end, const intern_type*& __from_next,
|
|
||||||
extern_type* __to, extern_type* __to_end,
|
|
||||||
extern_type*& __to_next) const;
|
|
||||||
|
|
||||||
virtual result
|
|
||||||
do_unshift(state_type& __state, extern_type* __to,
|
|
||||||
extern_type* __to_end, extern_type*& __to_next) const;
|
|
||||||
|
|
||||||
virtual result
|
|
||||||
do_in(state_type& __state, const extern_type* __from,
|
|
||||||
const extern_type* __from_end, const extern_type*& __from_next,
|
|
||||||
intern_type* __to, intern_type* __to_end,
|
|
||||||
intern_type*& __to_next) const;
|
|
||||||
|
|
||||||
virtual int
|
|
||||||
do_encoding() const throw();
|
|
||||||
|
|
||||||
virtual bool
|
|
||||||
do_always_noconv() const throw();
|
|
||||||
|
|
||||||
virtual int
|
|
||||||
do_length(state_type&, const extern_type* __from,
|
|
||||||
const extern_type* __end, size_t __max) const;
|
|
||||||
|
|
||||||
virtual int
|
|
||||||
do_max_length() const throw();
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename _InternT, typename _ExternT, typename _StateT>
|
|
||||||
locale::id codecvt<_InternT, _ExternT, _StateT>::id;
|
|
||||||
|
|
||||||
/// class codecvt<char, char, mbstate_t> specialization.
|
|
||||||
template<>
|
|
||||||
class codecvt<char, char, mbstate_t>
|
|
||||||
: public __codecvt_abstract_base<char, char, mbstate_t>
|
|
||||||
{
|
|
||||||
friend class messages<char>;
|
|
||||||
|
|
||||||
public:
|
|
||||||
// Types:
|
|
||||||
typedef char intern_type;
|
|
||||||
typedef char extern_type;
|
|
||||||
typedef mbstate_t state_type;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
__c_locale _M_c_locale_codecvt;
|
|
||||||
|
|
||||||
public:
|
|
||||||
static locale::id id;
|
|
||||||
|
|
||||||
explicit
|
|
||||||
codecvt(size_t __refs = 0);
|
|
||||||
|
|
||||||
explicit
|
|
||||||
codecvt(__c_locale __cloc, size_t __refs = 0);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual
|
|
||||||
~codecvt();
|
|
||||||
|
|
||||||
virtual result
|
|
||||||
do_out(state_type& __state, const intern_type* __from,
|
|
||||||
const intern_type* __from_end, const intern_type*& __from_next,
|
|
||||||
extern_type* __to, extern_type* __to_end,
|
|
||||||
extern_type*& __to_next) const;
|
|
||||||
|
|
||||||
virtual result
|
|
||||||
do_unshift(state_type& __state, extern_type* __to,
|
|
||||||
extern_type* __to_end, extern_type*& __to_next) const;
|
|
||||||
|
|
||||||
virtual result
|
|
||||||
do_in(state_type& __state, const extern_type* __from,
|
|
||||||
const extern_type* __from_end, const extern_type*& __from_next,
|
|
||||||
intern_type* __to, intern_type* __to_end,
|
|
||||||
intern_type*& __to_next) const;
|
|
||||||
|
|
||||||
virtual int
|
|
||||||
do_encoding() const throw();
|
|
||||||
|
|
||||||
virtual bool
|
|
||||||
do_always_noconv() const throw();
|
|
||||||
|
|
||||||
virtual int
|
|
||||||
do_length(state_type&, const extern_type* __from,
|
|
||||||
const extern_type* __end, size_t __max) const;
|
|
||||||
|
|
||||||
virtual int
|
|
||||||
do_max_length() const throw();
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifdef _GLIBCXX_USE_WCHAR_T
|
|
||||||
/** @brief Class codecvt<wchar_t, char, mbstate_t> specialization.
|
|
||||||
*
|
|
||||||
* Converts between narrow and wide characters in the native character set
|
|
||||||
*/
|
|
||||||
template<>
|
|
||||||
class codecvt<wchar_t, char, mbstate_t>
|
|
||||||
: public __codecvt_abstract_base<wchar_t, char, mbstate_t>
|
|
||||||
{
|
|
||||||
friend class messages<wchar_t>;
|
|
||||||
|
|
||||||
public:
|
|
||||||
// Types:
|
|
||||||
typedef wchar_t intern_type;
|
|
||||||
typedef char extern_type;
|
|
||||||
typedef mbstate_t state_type;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
__c_locale _M_c_locale_codecvt;
|
|
||||||
|
|
||||||
public:
|
|
||||||
static locale::id id;
|
|
||||||
|
|
||||||
explicit
|
|
||||||
codecvt(size_t __refs = 0);
|
|
||||||
|
|
||||||
explicit
|
|
||||||
codecvt(__c_locale __cloc, size_t __refs = 0);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual
|
|
||||||
~codecvt();
|
|
||||||
|
|
||||||
virtual result
|
|
||||||
do_out(state_type& __state, const intern_type* __from,
|
|
||||||
const intern_type* __from_end, const intern_type*& __from_next,
|
|
||||||
extern_type* __to, extern_type* __to_end,
|
|
||||||
extern_type*& __to_next) const;
|
|
||||||
|
|
||||||
virtual result
|
|
||||||
do_unshift(state_type& __state,
|
|
||||||
extern_type* __to, extern_type* __to_end,
|
|
||||||
extern_type*& __to_next) const;
|
|
||||||
|
|
||||||
virtual result
|
|
||||||
do_in(state_type& __state,
|
|
||||||
const extern_type* __from, const extern_type* __from_end,
|
|
||||||
const extern_type*& __from_next,
|
|
||||||
intern_type* __to, intern_type* __to_end,
|
|
||||||
intern_type*& __to_next) const;
|
|
||||||
|
|
||||||
virtual
|
|
||||||
int do_encoding() const throw();
|
|
||||||
|
|
||||||
virtual
|
|
||||||
bool do_always_noconv() const throw();
|
|
||||||
|
|
||||||
virtual
|
|
||||||
int do_length(state_type&, const extern_type* __from,
|
|
||||||
const extern_type* __end, size_t __max) const;
|
|
||||||
|
|
||||||
virtual int
|
|
||||||
do_max_length() const throw();
|
|
||||||
};
|
|
||||||
#endif //_GLIBCXX_USE_WCHAR_T
|
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
/** @brief Class codecvt<char16_t, char, mbstate_t> specialization.
|
|
||||||
*
|
|
||||||
* Converts between UTF-16 and UTF-8.
|
|
||||||
*/
|
|
||||||
template<>
|
|
||||||
class codecvt<char16_t, char, mbstate_t>
|
|
||||||
: public __codecvt_abstract_base<char16_t, char, mbstate_t>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
// Types:
|
|
||||||
typedef char16_t intern_type;
|
|
||||||
typedef char extern_type;
|
|
||||||
typedef mbstate_t state_type;
|
|
||||||
|
|
||||||
public:
|
|
||||||
static locale::id id;
|
|
||||||
|
|
||||||
explicit
|
|
||||||
codecvt(size_t __refs = 0)
|
|
||||||
: __codecvt_abstract_base<char16_t, char, mbstate_t>(__refs) { }
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual
|
|
||||||
~codecvt();
|
|
||||||
|
|
||||||
virtual result
|
|
||||||
do_out(state_type& __state, const intern_type* __from,
|
|
||||||
const intern_type* __from_end, const intern_type*& __from_next,
|
|
||||||
extern_type* __to, extern_type* __to_end,
|
|
||||||
extern_type*& __to_next) const;
|
|
||||||
|
|
||||||
virtual result
|
|
||||||
do_unshift(state_type& __state,
|
|
||||||
extern_type* __to, extern_type* __to_end,
|
|
||||||
extern_type*& __to_next) const;
|
|
||||||
|
|
||||||
virtual result
|
|
||||||
do_in(state_type& __state,
|
|
||||||
const extern_type* __from, const extern_type* __from_end,
|
|
||||||
const extern_type*& __from_next,
|
|
||||||
intern_type* __to, intern_type* __to_end,
|
|
||||||
intern_type*& __to_next) const;
|
|
||||||
|
|
||||||
virtual
|
|
||||||
int do_encoding() const throw();
|
|
||||||
|
|
||||||
virtual
|
|
||||||
bool do_always_noconv() const throw();
|
|
||||||
|
|
||||||
virtual
|
|
||||||
int do_length(state_type&, const extern_type* __from,
|
|
||||||
const extern_type* __end, size_t __max) const;
|
|
||||||
|
|
||||||
virtual int
|
|
||||||
do_max_length() const throw();
|
|
||||||
};
|
|
||||||
|
|
||||||
/** @brief Class codecvt<char32_t, char, mbstate_t> specialization.
|
|
||||||
*
|
|
||||||
* Converts between UTF-32 and UTF-8.
|
|
||||||
*/
|
|
||||||
template<>
|
|
||||||
class codecvt<char32_t, char, mbstate_t>
|
|
||||||
: public __codecvt_abstract_base<char32_t, char, mbstate_t>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
// Types:
|
|
||||||
typedef char32_t intern_type;
|
|
||||||
typedef char extern_type;
|
|
||||||
typedef mbstate_t state_type;
|
|
||||||
|
|
||||||
public:
|
|
||||||
static locale::id id;
|
|
||||||
|
|
||||||
explicit
|
|
||||||
codecvt(size_t __refs = 0)
|
|
||||||
: __codecvt_abstract_base<char32_t, char, mbstate_t>(__refs) { }
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual
|
|
||||||
~codecvt();
|
|
||||||
|
|
||||||
virtual result
|
|
||||||
do_out(state_type& __state, const intern_type* __from,
|
|
||||||
const intern_type* __from_end, const intern_type*& __from_next,
|
|
||||||
extern_type* __to, extern_type* __to_end,
|
|
||||||
extern_type*& __to_next) const;
|
|
||||||
|
|
||||||
virtual result
|
|
||||||
do_unshift(state_type& __state,
|
|
||||||
extern_type* __to, extern_type* __to_end,
|
|
||||||
extern_type*& __to_next) const;
|
|
||||||
|
|
||||||
virtual result
|
|
||||||
do_in(state_type& __state,
|
|
||||||
const extern_type* __from, const extern_type* __from_end,
|
|
||||||
const extern_type*& __from_next,
|
|
||||||
intern_type* __to, intern_type* __to_end,
|
|
||||||
intern_type*& __to_next) const;
|
|
||||||
|
|
||||||
virtual
|
|
||||||
int do_encoding() const throw();
|
|
||||||
|
|
||||||
virtual
|
|
||||||
bool do_always_noconv() const throw();
|
|
||||||
|
|
||||||
virtual
|
|
||||||
int do_length(state_type&, const extern_type* __from,
|
|
||||||
const extern_type* __end, size_t __max) const;
|
|
||||||
|
|
||||||
virtual int
|
|
||||||
do_max_length() const throw();
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifdef _GLIBCXX_USE_CHAR8_T
|
|
||||||
/** @brief Class codecvt<char16_t, char8_t, mbstate_t> specialization.
|
|
||||||
*
|
|
||||||
* Converts between UTF-16 and UTF-8.
|
|
||||||
*/
|
|
||||||
template<>
|
|
||||||
class codecvt<char16_t, char8_t, mbstate_t>
|
|
||||||
: public __codecvt_abstract_base<char16_t, char8_t, mbstate_t>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
// Types:
|
|
||||||
typedef char16_t intern_type;
|
|
||||||
typedef char8_t extern_type;
|
|
||||||
typedef mbstate_t state_type;
|
|
||||||
|
|
||||||
public:
|
|
||||||
static locale::id id;
|
|
||||||
|
|
||||||
explicit
|
|
||||||
codecvt(size_t __refs = 0)
|
|
||||||
: __codecvt_abstract_base<char16_t, char8_t, mbstate_t>(__refs) { }
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual
|
|
||||||
~codecvt();
|
|
||||||
|
|
||||||
virtual result
|
|
||||||
do_out(state_type& __state, const intern_type* __from,
|
|
||||||
const intern_type* __from_end, const intern_type*& __from_next,
|
|
||||||
extern_type* __to, extern_type* __to_end,
|
|
||||||
extern_type*& __to_next) const;
|
|
||||||
|
|
||||||
virtual result
|
|
||||||
do_unshift(state_type& __state,
|
|
||||||
extern_type* __to, extern_type* __to_end,
|
|
||||||
extern_type*& __to_next) const;
|
|
||||||
|
|
||||||
virtual result
|
|
||||||
do_in(state_type& __state,
|
|
||||||
const extern_type* __from, const extern_type* __from_end,
|
|
||||||
const extern_type*& __from_next,
|
|
||||||
intern_type* __to, intern_type* __to_end,
|
|
||||||
intern_type*& __to_next) const;
|
|
||||||
|
|
||||||
virtual
|
|
||||||
int do_encoding() const throw();
|
|
||||||
|
|
||||||
virtual
|
|
||||||
bool do_always_noconv() const throw();
|
|
||||||
|
|
||||||
virtual
|
|
||||||
int do_length(state_type&, const extern_type* __from,
|
|
||||||
const extern_type* __end, size_t __max) const;
|
|
||||||
|
|
||||||
virtual int
|
|
||||||
do_max_length() const throw();
|
|
||||||
};
|
|
||||||
|
|
||||||
/** @brief Class codecvt<char32_t, char8_t, mbstate_t> specialization.
|
|
||||||
*
|
|
||||||
* Converts between UTF-32 and UTF-8.
|
|
||||||
*/
|
|
||||||
template<>
|
|
||||||
class codecvt<char32_t, char8_t, mbstate_t>
|
|
||||||
: public __codecvt_abstract_base<char32_t, char8_t, mbstate_t>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
// Types:
|
|
||||||
typedef char32_t intern_type;
|
|
||||||
typedef char8_t extern_type;
|
|
||||||
typedef mbstate_t state_type;
|
|
||||||
|
|
||||||
public:
|
|
||||||
static locale::id id;
|
|
||||||
|
|
||||||
explicit
|
|
||||||
codecvt(size_t __refs = 0)
|
|
||||||
: __codecvt_abstract_base<char32_t, char8_t, mbstate_t>(__refs) { }
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual
|
|
||||||
~codecvt();
|
|
||||||
|
|
||||||
virtual result
|
|
||||||
do_out(state_type& __state, const intern_type* __from,
|
|
||||||
const intern_type* __from_end, const intern_type*& __from_next,
|
|
||||||
extern_type* __to, extern_type* __to_end,
|
|
||||||
extern_type*& __to_next) const;
|
|
||||||
|
|
||||||
virtual result
|
|
||||||
do_unshift(state_type& __state,
|
|
||||||
extern_type* __to, extern_type* __to_end,
|
|
||||||
extern_type*& __to_next) const;
|
|
||||||
|
|
||||||
virtual result
|
|
||||||
do_in(state_type& __state,
|
|
||||||
const extern_type* __from, const extern_type* __from_end,
|
|
||||||
const extern_type*& __from_next,
|
|
||||||
intern_type* __to, intern_type* __to_end,
|
|
||||||
intern_type*& __to_next) const;
|
|
||||||
|
|
||||||
virtual
|
|
||||||
int do_encoding() const throw();
|
|
||||||
|
|
||||||
virtual
|
|
||||||
bool do_always_noconv() const throw();
|
|
||||||
|
|
||||||
virtual
|
|
||||||
int do_length(state_type&, const extern_type* __from,
|
|
||||||
const extern_type* __end, size_t __max) const;
|
|
||||||
|
|
||||||
virtual int
|
|
||||||
do_max_length() const throw();
|
|
||||||
};
|
|
||||||
#endif // _GLIBCXX_USE_CHAR8_T
|
|
||||||
|
|
||||||
#endif // C++11
|
|
||||||
|
|
||||||
/// class codecvt_byname [22.2.1.6].
|
|
||||||
template<typename _InternT, typename _ExternT, typename _StateT>
|
|
||||||
class codecvt_byname : public codecvt<_InternT, _ExternT, _StateT>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit
|
|
||||||
codecvt_byname(const char* __s, size_t __refs = 0)
|
|
||||||
: codecvt<_InternT, _ExternT, _StateT>(__refs)
|
|
||||||
{
|
|
||||||
if (__builtin_strcmp(__s, "C") != 0
|
|
||||||
&& __builtin_strcmp(__s, "POSIX") != 0)
|
|
||||||
{
|
|
||||||
this->_S_destroy_c_locale(this->_M_c_locale_codecvt);
|
|
||||||
this->_S_create_c_locale(this->_M_c_locale_codecvt, __s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
explicit
|
|
||||||
codecvt_byname(const string& __s, size_t __refs = 0)
|
|
||||||
: codecvt_byname(__s.c_str(), __refs) { }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual
|
|
||||||
~codecvt_byname() { }
|
|
||||||
};
|
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
template<>
|
|
||||||
class codecvt_byname<char16_t, char, mbstate_t>
|
|
||||||
: public codecvt<char16_t, char, mbstate_t>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit
|
|
||||||
codecvt_byname(const char*, size_t __refs = 0)
|
|
||||||
: codecvt<char16_t, char, mbstate_t>(__refs) { }
|
|
||||||
|
|
||||||
explicit
|
|
||||||
codecvt_byname(const string& __s, size_t __refs = 0)
|
|
||||||
: codecvt_byname(__s.c_str(), __refs) { }
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual
|
|
||||||
~codecvt_byname() { }
|
|
||||||
};
|
|
||||||
|
|
||||||
template<>
|
|
||||||
class codecvt_byname<char32_t, char, mbstate_t>
|
|
||||||
: public codecvt<char32_t, char, mbstate_t>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit
|
|
||||||
codecvt_byname(const char*, size_t __refs = 0)
|
|
||||||
: codecvt<char32_t, char, mbstate_t>(__refs) { }
|
|
||||||
|
|
||||||
explicit
|
|
||||||
codecvt_byname(const string& __s, size_t __refs = 0)
|
|
||||||
: codecvt_byname(__s.c_str(), __refs) { }
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual
|
|
||||||
~codecvt_byname() { }
|
|
||||||
};
|
|
||||||
|
|
||||||
#if defined(_GLIBCXX_USE_CHAR8_T)
|
|
||||||
template<>
|
|
||||||
class codecvt_byname<char16_t, char8_t, mbstate_t>
|
|
||||||
: public codecvt<char16_t, char8_t, mbstate_t>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit
|
|
||||||
codecvt_byname(const char* __s, size_t __refs = 0)
|
|
||||||
: codecvt<char16_t, char8_t, mbstate_t>(__refs) { }
|
|
||||||
|
|
||||||
explicit
|
|
||||||
codecvt_byname(const string& __s, size_t __refs = 0)
|
|
||||||
: codecvt_byname(__s.c_str(), __refs) { }
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual
|
|
||||||
~codecvt_byname() { }
|
|
||||||
};
|
|
||||||
|
|
||||||
template<>
|
|
||||||
class codecvt_byname<char32_t, char8_t, mbstate_t>
|
|
||||||
: public codecvt<char32_t, char8_t, mbstate_t>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit
|
|
||||||
codecvt_byname(const char* __s, size_t __refs = 0)
|
|
||||||
: codecvt<char32_t, char8_t, mbstate_t>(__refs) { }
|
|
||||||
|
|
||||||
explicit
|
|
||||||
codecvt_byname(const string& __s, size_t __refs = 0)
|
|
||||||
: codecvt_byname(__s.c_str(), __refs) { }
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual
|
|
||||||
~codecvt_byname() { }
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // C++11
|
|
||||||
|
|
||||||
// Inhibit implicit instantiations for required instantiations,
|
|
||||||
// which are defined via explicit instantiations elsewhere.
|
|
||||||
#if _GLIBCXX_EXTERN_TEMPLATE
|
|
||||||
extern template class codecvt_byname<char, char, mbstate_t>;
|
|
||||||
|
|
||||||
extern template
|
|
||||||
const codecvt<char, char, mbstate_t>&
|
|
||||||
use_facet<codecvt<char, char, mbstate_t> >(const locale&);
|
|
||||||
|
|
||||||
extern template
|
|
||||||
bool
|
|
||||||
has_facet<codecvt<char, char, mbstate_t> >(const locale&);
|
|
||||||
|
|
||||||
#ifdef _GLIBCXX_USE_WCHAR_T
|
|
||||||
extern template class codecvt_byname<wchar_t, char, mbstate_t>;
|
|
||||||
|
|
||||||
extern template
|
|
||||||
const codecvt<wchar_t, char, mbstate_t>&
|
|
||||||
use_facet<codecvt<wchar_t, char, mbstate_t> >(const locale&);
|
|
||||||
|
|
||||||
extern template
|
|
||||||
bool
|
|
||||||
has_facet<codecvt<wchar_t, char, mbstate_t> >(const locale&);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
extern template class codecvt_byname<char16_t, char, mbstate_t>;
|
|
||||||
extern template class codecvt_byname<char32_t, char, mbstate_t>;
|
|
||||||
|
|
||||||
#if defined(_GLIBCXX_USE_CHAR8_T)
|
|
||||||
extern template class codecvt_byname<char16_t, char8_t, mbstate_t>;
|
|
||||||
extern template class codecvt_byname<char32_t, char8_t, mbstate_t>;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
_GLIBCXX_END_NAMESPACE_VERSION
|
|
||||||
} // namespace std
|
|
||||||
|
|
||||||
#endif // _CODECVT_H
|
|
Binary file not shown.
@ -1,81 +0,0 @@
|
|||||||
// Concept-checking control -*- C++ -*-
|
|
||||||
|
|
||||||
// Copyright (C) 2001-2020 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.
|
|
||||||
|
|
||||||
// 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 bits/concept_check.h
|
|
||||||
* This is an internal header file, included by other library headers.
|
|
||||||
* Do not attempt to use it directly. @headername{iterator}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _CONCEPT_CHECK_H
|
|
||||||
#define _CONCEPT_CHECK_H 1
|
|
||||||
|
|
||||||
#pragma GCC system_header
|
|
||||||
|
|
||||||
#include <bits/c++config.h>
|
|
||||||
|
|
||||||
// All places in libstdc++-v3 where these are used, or /might/ be used, or
|
|
||||||
// don't need to be used, or perhaps /should/ be used, are commented with
|
|
||||||
// "concept requirements" (and maybe some more text). So grep like crazy
|
|
||||||
// if you're looking for additional places to use these.
|
|
||||||
|
|
||||||
// Concept-checking code is off by default unless users turn it on via
|
|
||||||
// configure options or editing c++config.h.
|
|
||||||
// It is not supported for freestanding implementations.
|
|
||||||
|
|
||||||
#if !defined(_GLIBCXX_CONCEPT_CHECKS) || !_GLIBCXX_HOSTED
|
|
||||||
|
|
||||||
#define __glibcxx_function_requires(...)
|
|
||||||
#define __glibcxx_class_requires(_a,_b)
|
|
||||||
#define __glibcxx_class_requires2(_a,_b,_c)
|
|
||||||
#define __glibcxx_class_requires3(_a,_b,_c,_d)
|
|
||||||
#define __glibcxx_class_requires4(_a,_b,_c,_d,_e)
|
|
||||||
|
|
||||||
#else // the checks are on
|
|
||||||
|
|
||||||
#include <bits/boost_concept_check.h>
|
|
||||||
|
|
||||||
// Note that the obvious and elegant approach of
|
|
||||||
//
|
|
||||||
//#define glibcxx_function_requires(C) debug::function_requires< debug::C >()
|
|
||||||
//
|
|
||||||
// won't work due to concept templates with more than one parameter, e.g.,
|
|
||||||
// BinaryPredicateConcept. The preprocessor tries to split things up on
|
|
||||||
// the commas in the template argument list. We can't use an inner pair of
|
|
||||||
// parenthesis to hide the commas, because "debug::(Temp<Foo,Bar>)" isn't
|
|
||||||
// a valid instantiation pattern. Thus, we steal a feature from C99.
|
|
||||||
|
|
||||||
#define __glibcxx_function_requires(...) \
|
|
||||||
__gnu_cxx::__function_requires< __gnu_cxx::__VA_ARGS__ >();
|
|
||||||
#define __glibcxx_class_requires(_a,_C) \
|
|
||||||
_GLIBCXX_CLASS_REQUIRES(_a, __gnu_cxx, _C);
|
|
||||||
#define __glibcxx_class_requires2(_a,_b,_C) \
|
|
||||||
_GLIBCXX_CLASS_REQUIRES2(_a, _b, __gnu_cxx, _C);
|
|
||||||
#define __glibcxx_class_requires3(_a,_b,_c,_C) \
|
|
||||||
_GLIBCXX_CLASS_REQUIRES3(_a, _b, _c, __gnu_cxx, _C);
|
|
||||||
#define __glibcxx_class_requires4(_a,_b,_c,_d,_C) \
|
|
||||||
_GLIBCXX_CLASS_REQUIRES4(_a, _b, _c, _d, __gnu_cxx, _C);
|
|
||||||
|
|
||||||
#endif // enable/disable
|
|
||||||
|
|
||||||
#endif // _GLIBCXX_CONCEPT_CHECK
|
|
Binary file not shown.
@ -1,551 +0,0 @@
|
|||||||
// The -*- C++ -*- type traits classes for internal use in libstdc++
|
|
||||||
|
|
||||||
// Copyright (C) 2000-2020 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.
|
|
||||||
|
|
||||||
// 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 bits/cpp_type_traits.h
|
|
||||||
* This is an internal header file, included by other library headers.
|
|
||||||
* Do not attempt to use it directly. @headername{ext/type_traits}
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Written by Gabriel Dos Reis <dosreis@cmla.ens-cachan.fr>
|
|
||||||
|
|
||||||
#ifndef _CPP_TYPE_TRAITS_H
|
|
||||||
#define _CPP_TYPE_TRAITS_H 1
|
|
||||||
|
|
||||||
#pragma GCC system_header
|
|
||||||
|
|
||||||
#include <bits/c++config.h>
|
|
||||||
|
|
||||||
//
|
|
||||||
// This file provides some compile-time information about various types.
|
|
||||||
// These representations were designed, on purpose, to be constant-expressions
|
|
||||||
// and not types as found in <bits/type_traits.h>. In particular, they
|
|
||||||
// can be used in control structures and the optimizer hopefully will do
|
|
||||||
// the obvious thing.
|
|
||||||
//
|
|
||||||
// Why integral expressions, and not functions nor types?
|
|
||||||
// Firstly, these compile-time entities are used as template-arguments
|
|
||||||
// so function return values won't work: We need compile-time entities.
|
|
||||||
// We're left with types and constant integral expressions.
|
|
||||||
// Secondly, from the point of view of ease of use, type-based compile-time
|
|
||||||
// information is -not- *that* convenient. One has to write lots of
|
|
||||||
// overloaded functions and to hope that the compiler will select the right
|
|
||||||
// one. As a net effect, the overall structure isn't very clear at first
|
|
||||||
// glance.
|
|
||||||
// Thirdly, partial ordering and overload resolution (of function templates)
|
|
||||||
// is highly costly in terms of compiler-resource. It is a Good Thing to
|
|
||||||
// keep these resource consumption as least as possible.
|
|
||||||
//
|
|
||||||
// See valarray_array.h for a case use.
|
|
||||||
//
|
|
||||||
// -- Gaby (dosreis@cmla.ens-cachan.fr) 2000-03-06.
|
|
||||||
//
|
|
||||||
// Update 2005: types are also provided and <bits/type_traits.h> has been
|
|
||||||
// removed.
|
|
||||||
//
|
|
||||||
|
|
||||||
extern "C++" {
|
|
||||||
|
|
||||||
namespace std _GLIBCXX_VISIBILITY(default)
|
|
||||||
{
|
|
||||||
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|
||||||
|
|
||||||
struct __true_type { };
|
|
||||||
struct __false_type { };
|
|
||||||
|
|
||||||
template<bool>
|
|
||||||
struct __truth_type
|
|
||||||
{ typedef __false_type __type; };
|
|
||||||
|
|
||||||
template<>
|
|
||||||
struct __truth_type<true>
|
|
||||||
{ typedef __true_type __type; };
|
|
||||||
|
|
||||||
// N.B. The conversions to bool are needed due to the issue
|
|
||||||
// explained in c++/19404.
|
|
||||||
template<class _Sp, class _Tp>
|
|
||||||
struct __traitor
|
|
||||||
{
|
|
||||||
enum { __value = bool(_Sp::__value) || bool(_Tp::__value) };
|
|
||||||
typedef typename __truth_type<__value>::__type __type;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Compare for equality of types.
|
|
||||||
template<typename, typename>
|
|
||||||
struct __are_same
|
|
||||||
{
|
|
||||||
enum { __value = 0 };
|
|
||||||
typedef __false_type __type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename _Tp>
|
|
||||||
struct __are_same<_Tp, _Tp>
|
|
||||||
{
|
|
||||||
enum { __value = 1 };
|
|
||||||
typedef __true_type __type;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Holds if the template-argument is a void type.
|
|
||||||
template<typename _Tp>
|
|
||||||
struct __is_void
|
|
||||||
{
|
|
||||||
enum { __value = 0 };
|
|
||||||
typedef __false_type __type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<>
|
|
||||||
struct __is_void<void>
|
|
||||||
{
|
|
||||||
enum { __value = 1 };
|
|
||||||
typedef __true_type __type;
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
// Integer types
|
|
||||||
//
|
|
||||||
template<typename _Tp>
|
|
||||||
struct __is_integer
|
|
||||||
{
|
|
||||||
enum { __value = 0 };
|
|
||||||
typedef __false_type __type;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Thirteen specializations (yes there are eleven standard integer
|
|
||||||
// types; <em>long long</em> and <em>unsigned long long</em> are
|
|
||||||
// supported as extensions). Up to four target-specific __int<N>
|
|
||||||
// types are supported as well.
|
|
||||||
template<>
|
|
||||||
struct __is_integer<bool>
|
|
||||||
{
|
|
||||||
enum { __value = 1 };
|
|
||||||
typedef __true_type __type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<>
|
|
||||||
struct __is_integer<char>
|
|
||||||
{
|
|
||||||
enum { __value = 1 };
|
|
||||||
typedef __true_type __type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<>
|
|
||||||
struct __is_integer<signed char>
|
|
||||||
{
|
|
||||||
enum { __value = 1 };
|
|
||||||
typedef __true_type __type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<>
|
|
||||||
struct __is_integer<unsigned char>
|
|
||||||
{
|
|
||||||
enum { __value = 1 };
|
|
||||||
typedef __true_type __type;
|
|
||||||
};
|
|
||||||
|
|
||||||
# ifdef _GLIBCXX_USE_WCHAR_T
|
|
||||||
template<>
|
|
||||||
struct __is_integer<wchar_t>
|
|
||||||
{
|
|
||||||
enum { __value = 1 };
|
|
||||||
typedef __true_type __type;
|
|
||||||
};
|
|
||||||
# endif
|
|
||||||
|
|
||||||
#ifdef _GLIBCXX_USE_CHAR8_T
|
|
||||||
template<>
|
|
||||||
struct __is_integer<char8_t>
|
|
||||||
{
|
|
||||||
enum { __value = 1 };
|
|
||||||
typedef __true_type __type;
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
template<>
|
|
||||||
struct __is_integer<char16_t>
|
|
||||||
{
|
|
||||||
enum { __value = 1 };
|
|
||||||
typedef __true_type __type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<>
|
|
||||||
struct __is_integer<char32_t>
|
|
||||||
{
|
|
||||||
enum { __value = 1 };
|
|
||||||
typedef __true_type __type;
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template<>
|
|
||||||
struct __is_integer<short>
|
|
||||||
{
|
|
||||||
enum { __value = 1 };
|
|
||||||
typedef __true_type __type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<>
|
|
||||||
struct __is_integer<unsigned short>
|
|
||||||
{
|
|
||||||
enum { __value = 1 };
|
|
||||||
typedef __true_type __type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<>
|
|
||||||
struct __is_integer<int>
|
|
||||||
{
|
|
||||||
enum { __value = 1 };
|
|
||||||
typedef __true_type __type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<>
|
|
||||||
struct __is_integer<unsigned int>
|
|
||||||
{
|
|
||||||
enum { __value = 1 };
|
|
||||||
typedef __true_type __type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<>
|
|
||||||
struct __is_integer<long>
|
|
||||||
{
|
|
||||||
enum { __value = 1 };
|
|
||||||
typedef __true_type __type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<>
|
|
||||||
struct __is_integer<unsigned long>
|
|
||||||
{
|
|
||||||
enum { __value = 1 };
|
|
||||||
typedef __true_type __type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<>
|
|
||||||
struct __is_integer<long long>
|
|
||||||
{
|
|
||||||
enum { __value = 1 };
|
|
||||||
typedef __true_type __type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<>
|
|
||||||
struct __is_integer<unsigned long long>
|
|
||||||
{
|
|
||||||
enum { __value = 1 };
|
|
||||||
typedef __true_type __type;
|
|
||||||
};
|
|
||||||
|
|
||||||
#define __INT_N(TYPE) \
|
|
||||||
template<> \
|
|
||||||
struct __is_integer<TYPE> \
|
|
||||||
{ \
|
|
||||||
enum { __value = 1 }; \
|
|
||||||
typedef __true_type __type; \
|
|
||||||
}; \
|
|
||||||
template<> \
|
|
||||||
struct __is_integer<unsigned TYPE> \
|
|
||||||
{ \
|
|
||||||
enum { __value = 1 }; \
|
|
||||||
typedef __true_type __type; \
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifdef __GLIBCXX_TYPE_INT_N_0
|
|
||||||
__INT_N(__GLIBCXX_TYPE_INT_N_0)
|
|
||||||
#endif
|
|
||||||
#ifdef __GLIBCXX_TYPE_INT_N_1
|
|
||||||
__INT_N(__GLIBCXX_TYPE_INT_N_1)
|
|
||||||
#endif
|
|
||||||
#ifdef __GLIBCXX_TYPE_INT_N_2
|
|
||||||
__INT_N(__GLIBCXX_TYPE_INT_N_2)
|
|
||||||
#endif
|
|
||||||
#ifdef __GLIBCXX_TYPE_INT_N_3
|
|
||||||
__INT_N(__GLIBCXX_TYPE_INT_N_3)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#undef __INT_N
|
|
||||||
|
|
||||||
//
|
|
||||||
// Floating point types
|
|
||||||
//
|
|
||||||
template<typename _Tp>
|
|
||||||
struct __is_floating
|
|
||||||
{
|
|
||||||
enum { __value = 0 };
|
|
||||||
typedef __false_type __type;
|
|
||||||
};
|
|
||||||
|
|
||||||
// three specializations (float, double and 'long double')
|
|
||||||
template<>
|
|
||||||
struct __is_floating<float>
|
|
||||||
{
|
|
||||||
enum { __value = 1 };
|
|
||||||
typedef __true_type __type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<>
|
|
||||||
struct __is_floating<double>
|
|
||||||
{
|
|
||||||
enum { __value = 1 };
|
|
||||||
typedef __true_type __type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<>
|
|
||||||
struct __is_floating<long double>
|
|
||||||
{
|
|
||||||
enum { __value = 1 };
|
|
||||||
typedef __true_type __type;
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
// Pointer types
|
|
||||||
//
|
|
||||||
template<typename _Tp>
|
|
||||||
struct __is_pointer
|
|
||||||
{
|
|
||||||
enum { __value = 0 };
|
|
||||||
typedef __false_type __type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename _Tp>
|
|
||||||
struct __is_pointer<_Tp*>
|
|
||||||
{
|
|
||||||
enum { __value = 1 };
|
|
||||||
typedef __true_type __type;
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
// An arithmetic type is an integer type or a floating point type
|
|
||||||
//
|
|
||||||
template<typename _Tp>
|
|
||||||
struct __is_arithmetic
|
|
||||||
: public __traitor<__is_integer<_Tp>, __is_floating<_Tp> >
|
|
||||||
{ };
|
|
||||||
|
|
||||||
//
|
|
||||||
// A scalar type is an arithmetic type or a pointer type
|
|
||||||
//
|
|
||||||
template<typename _Tp>
|
|
||||||
struct __is_scalar
|
|
||||||
: public __traitor<__is_arithmetic<_Tp>, __is_pointer<_Tp> >
|
|
||||||
{ };
|
|
||||||
|
|
||||||
//
|
|
||||||
// For use in std::copy and std::find overloads for streambuf iterators.
|
|
||||||
//
|
|
||||||
template<typename _Tp>
|
|
||||||
struct __is_char
|
|
||||||
{
|
|
||||||
enum { __value = 0 };
|
|
||||||
typedef __false_type __type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<>
|
|
||||||
struct __is_char<char>
|
|
||||||
{
|
|
||||||
enum { __value = 1 };
|
|
||||||
typedef __true_type __type;
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifdef _GLIBCXX_USE_WCHAR_T
|
|
||||||
template<>
|
|
||||||
struct __is_char<wchar_t>
|
|
||||||
{
|
|
||||||
enum { __value = 1 };
|
|
||||||
typedef __true_type __type;
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template<typename _Tp>
|
|
||||||
struct __is_byte
|
|
||||||
{
|
|
||||||
enum { __value = 0 };
|
|
||||||
typedef __false_type __type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<>
|
|
||||||
struct __is_byte<char>
|
|
||||||
{
|
|
||||||
enum { __value = 1 };
|
|
||||||
typedef __true_type __type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<>
|
|
||||||
struct __is_byte<signed char>
|
|
||||||
{
|
|
||||||
enum { __value = 1 };
|
|
||||||
typedef __true_type __type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<>
|
|
||||||
struct __is_byte<unsigned char>
|
|
||||||
{
|
|
||||||
enum { __value = 1 };
|
|
||||||
typedef __true_type __type;
|
|
||||||
};
|
|
||||||
|
|
||||||
#if __cplusplus >= 201703L
|
|
||||||
enum class byte : unsigned char;
|
|
||||||
|
|
||||||
template<>
|
|
||||||
struct __is_byte<byte>
|
|
||||||
{
|
|
||||||
enum { __value = 1 };
|
|
||||||
typedef __true_type __type;
|
|
||||||
};
|
|
||||||
#endif // C++17
|
|
||||||
|
|
||||||
#ifdef _GLIBCXX_USE_CHAR8_T
|
|
||||||
template<>
|
|
||||||
struct __is_byte<char8_t>
|
|
||||||
{
|
|
||||||
enum { __value = 1 };
|
|
||||||
typedef __true_type __type;
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template<typename> struct iterator_traits;
|
|
||||||
|
|
||||||
// A type that is safe for use with memcpy, memmove, memcmp etc.
|
|
||||||
template<typename _Tp>
|
|
||||||
struct __is_nonvolatile_trivially_copyable
|
|
||||||
{
|
|
||||||
enum { __value = __is_trivially_copyable(_Tp) };
|
|
||||||
};
|
|
||||||
|
|
||||||
// Cannot use memcpy/memmove/memcmp on volatile types even if they are
|
|
||||||
// trivially copyable, so ensure __memcpyable<volatile int*, volatile int*>
|
|
||||||
// and similar will be false.
|
|
||||||
template<typename _Tp>
|
|
||||||
struct __is_nonvolatile_trivially_copyable<volatile _Tp>
|
|
||||||
{
|
|
||||||
enum { __value = 0 };
|
|
||||||
};
|
|
||||||
|
|
||||||
// Whether two iterator types can be used with memcpy/memmove.
|
|
||||||
template<typename _OutputIter, typename _InputIter>
|
|
||||||
struct __memcpyable
|
|
||||||
{
|
|
||||||
enum { __value = 0 };
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename _Tp>
|
|
||||||
struct __memcpyable<_Tp*, _Tp*>
|
|
||||||
: __is_nonvolatile_trivially_copyable<_Tp>
|
|
||||||
{ };
|
|
||||||
|
|
||||||
template<typename _Tp>
|
|
||||||
struct __memcpyable<_Tp*, const _Tp*>
|
|
||||||
: __is_nonvolatile_trivially_copyable<_Tp>
|
|
||||||
{ };
|
|
||||||
|
|
||||||
// Whether two iterator types can be used with memcmp.
|
|
||||||
// This trait only says it's well-formed to use memcmp, not that it
|
|
||||||
// gives the right answer for a given algorithm. So for example, std::equal
|
|
||||||
// needs to add additional checks that the types are integers or pointers,
|
|
||||||
// because other trivially copyable types can overload operator==.
|
|
||||||
template<typename _Iter1, typename _Iter2>
|
|
||||||
struct __memcmpable
|
|
||||||
{
|
|
||||||
enum { __value = 0 };
|
|
||||||
};
|
|
||||||
|
|
||||||
// OK to use memcmp with pointers to trivially copyable types.
|
|
||||||
template<typename _Tp>
|
|
||||||
struct __memcmpable<_Tp*, _Tp*>
|
|
||||||
: __is_nonvolatile_trivially_copyable<_Tp>
|
|
||||||
{ };
|
|
||||||
|
|
||||||
template<typename _Tp>
|
|
||||||
struct __memcmpable<const _Tp*, _Tp*>
|
|
||||||
: __is_nonvolatile_trivially_copyable<_Tp>
|
|
||||||
{ };
|
|
||||||
|
|
||||||
template<typename _Tp>
|
|
||||||
struct __memcmpable<_Tp*, const _Tp*>
|
|
||||||
: __is_nonvolatile_trivially_copyable<_Tp>
|
|
||||||
{ };
|
|
||||||
|
|
||||||
// Whether memcmp can be used to determine ordering for a type
|
|
||||||
// e.g. in std::lexicographical_compare or three-way comparisons.
|
|
||||||
// True for unsigned narrow character types (and std::byte).
|
|
||||||
template<typename _Tp, bool _TreatAsBytes = __is_byte<_Tp>::__value>
|
|
||||||
struct __is_memcmp_ordered
|
|
||||||
{
|
|
||||||
static const bool __value = _Tp(-1) > _Tp(1); // is unsigned
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename _Tp>
|
|
||||||
struct __is_memcmp_ordered<_Tp, false>
|
|
||||||
{
|
|
||||||
static const bool __value = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Whether two types can be compared using memcmp.
|
|
||||||
template<typename _Tp, typename _Up, bool = sizeof(_Tp) == sizeof(_Up)>
|
|
||||||
struct __is_memcmp_ordered_with
|
|
||||||
{
|
|
||||||
static const bool __value = __is_memcmp_ordered<_Tp>::__value
|
|
||||||
&& __is_memcmp_ordered<_Up>::__value;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename _Tp, typename _Up>
|
|
||||||
struct __is_memcmp_ordered_with<_Tp, _Up, false>
|
|
||||||
{
|
|
||||||
static const bool __value = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
#if __cplusplus >= 201703L
|
|
||||||
// std::byte can only be compared to itself, not to other types.
|
|
||||||
template<>
|
|
||||||
struct __is_memcmp_ordered_with<std::byte, std::byte, true>
|
|
||||||
{ static constexpr bool __value = true; };
|
|
||||||
|
|
||||||
template<typename _Tp, bool _SameSize>
|
|
||||||
struct __is_memcmp_ordered_with<_Tp, std::byte, _SameSize>
|
|
||||||
{ static constexpr bool __value = false; };
|
|
||||||
|
|
||||||
template<typename _Up, bool _SameSize>
|
|
||||||
struct __is_memcmp_ordered_with<std::byte, _Up, _SameSize>
|
|
||||||
{ static constexpr bool __value = false; };
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//
|
|
||||||
// Move iterator type
|
|
||||||
//
|
|
||||||
template<typename _Tp>
|
|
||||||
struct __is_move_iterator
|
|
||||||
{
|
|
||||||
enum { __value = 0 };
|
|
||||||
typedef __false_type __type;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Fallback implementation of the function in bits/stl_iterator.h used to
|
|
||||||
// remove the move_iterator wrapper.
|
|
||||||
template<typename _Iterator>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
inline _Iterator
|
|
||||||
__miter_base(_Iterator __it)
|
|
||||||
{ return __it; }
|
|
||||||
|
|
||||||
_GLIBCXX_END_NAMESPACE_VERSION
|
|
||||||
} // namespace
|
|
||||||
} // extern "C++"
|
|
||||||
|
|
||||||
#endif //_CPP_TYPE_TRAITS_H
|
|
Binary file not shown.
@ -1,60 +0,0 @@
|
|||||||
// cxxabi.h subset for cancellation -*- C++ -*-
|
|
||||||
|
|
||||||
// Copyright (C) 2007-2020 Free Software Foundation, Inc.
|
|
||||||
//
|
|
||||||
// This file is part of GCC.
|
|
||||||
//
|
|
||||||
// GCC 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.
|
|
||||||
//
|
|
||||||
// GCC 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 bits/cxxabi_forced.h
|
|
||||||
* This is an internal header file, included by other library headers.
|
|
||||||
* Do not attempt to use it directly. @headername{cxxabi.h}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _CXXABI_FORCED_H
|
|
||||||
#define _CXXABI_FORCED_H 1
|
|
||||||
|
|
||||||
#pragma GCC system_header
|
|
||||||
|
|
||||||
#pragma GCC visibility push(default)
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
namespace __cxxabiv1
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @brief Thrown as part of forced unwinding.
|
|
||||||
* @ingroup exceptions
|
|
||||||
*
|
|
||||||
* A magic placeholder class that can be caught by reference to
|
|
||||||
* recognize forced unwinding.
|
|
||||||
*/
|
|
||||||
class __forced_unwind
|
|
||||||
{
|
|
||||||
virtual ~__forced_unwind() throw();
|
|
||||||
|
|
||||||
// Prevent catch by value.
|
|
||||||
virtual void __pure_dummy() = 0;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
#endif // __cplusplus
|
|
||||||
|
|
||||||
#pragma GCC visibility pop
|
|
||||||
|
|
||||||
#endif // __CXXABI_FORCED_H
|
|
Binary file not shown.
@ -1,80 +0,0 @@
|
|||||||
// ABI Support -*- C++ -*-
|
|
||||||
|
|
||||||
// Copyright (C) 2016-2020 Free Software Foundation, Inc.
|
|
||||||
//
|
|
||||||
// This file is part of GCC.
|
|
||||||
//
|
|
||||||
// GCC 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.
|
|
||||||
//
|
|
||||||
// GCC 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 bits/cxxabi_init_exception.h
|
|
||||||
* This is an internal header file, included by other library headers.
|
|
||||||
* Do not attempt to use it directly.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _CXXABI_INIT_EXCEPTION_H
|
|
||||||
#define _CXXABI_INIT_EXCEPTION_H 1
|
|
||||||
|
|
||||||
#pragma GCC system_header
|
|
||||||
|
|
||||||
#pragma GCC visibility push(default)
|
|
||||||
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <bits/c++config.h>
|
|
||||||
|
|
||||||
#ifndef _GLIBCXX_CDTOR_CALLABI
|
|
||||||
#define _GLIBCXX_CDTOR_CALLABI
|
|
||||||
#define _GLIBCXX_HAVE_CDTOR_CALLABI 0
|
|
||||||
#else
|
|
||||||
#define _GLIBCXX_HAVE_CDTOR_CALLABI 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
|
|
||||||
namespace std
|
|
||||||
{
|
|
||||||
class type_info;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace __cxxabiv1
|
|
||||||
{
|
|
||||||
struct __cxa_refcounted_exception;
|
|
||||||
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
// Allocate memory for the primary exception plus the thrown object.
|
|
||||||
void*
|
|
||||||
__cxa_allocate_exception(size_t) _GLIBCXX_NOTHROW;
|
|
||||||
|
|
||||||
void
|
|
||||||
__cxa_free_exception(void*) _GLIBCXX_NOTHROW;
|
|
||||||
|
|
||||||
// Initialize exception (this is a GNU extension)
|
|
||||||
__cxa_refcounted_exception*
|
|
||||||
__cxa_init_primary_exception(void *object, std::type_info *tinfo,
|
|
||||||
void (_GLIBCXX_CDTOR_CALLABI *dest) (void *)) _GLIBCXX_NOTHROW;
|
|
||||||
|
|
||||||
}
|
|
||||||
} // namespace __cxxabiv1
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#pragma GCC visibility pop
|
|
||||||
|
|
||||||
#endif // _CXXABI_INIT_EXCEPTION_H
|
|
Binary file not shown.
@ -1,84 +0,0 @@
|
|||||||
// Exception Handling support header for -*- C++ -*-
|
|
||||||
|
|
||||||
// Copyright (C) 2016-2020 Free Software Foundation, Inc.
|
|
||||||
//
|
|
||||||
// This file is part of GCC.
|
|
||||||
//
|
|
||||||
// GCC 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.
|
|
||||||
//
|
|
||||||
// GCC 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 bits/exception.h
|
|
||||||
* This is an internal header file, included by other library headers.
|
|
||||||
* Do not attempt to use it directly.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __EXCEPTION_H
|
|
||||||
#define __EXCEPTION_H 1
|
|
||||||
|
|
||||||
#pragma GCC system_header
|
|
||||||
|
|
||||||
#pragma GCC visibility push(default)
|
|
||||||
|
|
||||||
#include <bits/c++config.h>
|
|
||||||
|
|
||||||
extern "C++" {
|
|
||||||
|
|
||||||
namespace std
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @defgroup exceptions Exceptions
|
|
||||||
* @ingroup diagnostics
|
|
||||||
*
|
|
||||||
* Classes and functions for reporting errors via exception classes.
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Base class for all library exceptions.
|
|
||||||
*
|
|
||||||
* This is the base class for all exceptions thrown by the standard
|
|
||||||
* library, and by certain language expressions. You are free to derive
|
|
||||||
* your own %exception classes, or use a different hierarchy, or to
|
|
||||||
* throw non-class data (e.g., fundamental types).
|
|
||||||
*/
|
|
||||||
class exception
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
exception() _GLIBCXX_NOTHROW { }
|
|
||||||
virtual ~exception() _GLIBCXX_TXN_SAFE_DYN _GLIBCXX_NOTHROW;
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
exception(const exception&) = default;
|
|
||||||
exception& operator=(const exception&) = default;
|
|
||||||
exception(exception&&) = default;
|
|
||||||
exception& operator=(exception&&) = default;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/** Returns a C-style character string describing the general cause
|
|
||||||
* of the current error. */
|
|
||||||
virtual const char*
|
|
||||||
what() const _GLIBCXX_TXN_SAFE_DYN _GLIBCXX_NOTHROW;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace std
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma GCC visibility pop
|
|
||||||
|
|
||||||
#endif
|
|
Binary file not shown.
@ -1,45 +0,0 @@
|
|||||||
// -fno-exceptions Support -*- C++ -*-
|
|
||||||
|
|
||||||
// Copyright (C) 2001-2020 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.
|
|
||||||
|
|
||||||
// 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 bits/exception_defines.h
|
|
||||||
* This is an internal header file, included by other library headers.
|
|
||||||
* Do not attempt to use it directly. @headername{exception}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _EXCEPTION_DEFINES_H
|
|
||||||
#define _EXCEPTION_DEFINES_H 1
|
|
||||||
|
|
||||||
#if ! __cpp_exceptions
|
|
||||||
// Iff -fno-exceptions, transform error handling code to work without it.
|
|
||||||
# define __try if (true)
|
|
||||||
# define __catch(X) if (false)
|
|
||||||
# define __throw_exception_again
|
|
||||||
#else
|
|
||||||
// Else proceed normally.
|
|
||||||
# define __try try
|
|
||||||
# define __catch(X) catch(X)
|
|
||||||
# define __throw_exception_again throw
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
Binary file not shown.
@ -1,224 +0,0 @@
|
|||||||
// Exception Handling support header (exception_ptr class) for -*- C++ -*-
|
|
||||||
|
|
||||||
// Copyright (C) 2008-2020 Free Software Foundation, Inc.
|
|
||||||
//
|
|
||||||
// This file is part of GCC.
|
|
||||||
//
|
|
||||||
// GCC 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.
|
|
||||||
//
|
|
||||||
// GCC 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 bits/exception_ptr.h
|
|
||||||
* This is an internal header file, included by other library headers.
|
|
||||||
* Do not attempt to use it directly. @headername{exception}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _EXCEPTION_PTR_H
|
|
||||||
#define _EXCEPTION_PTR_H
|
|
||||||
|
|
||||||
#pragma GCC visibility push(default)
|
|
||||||
|
|
||||||
#include <bits/c++config.h>
|
|
||||||
#include <bits/exception_defines.h>
|
|
||||||
#include <bits/cxxabi_init_exception.h>
|
|
||||||
#include <typeinfo>
|
|
||||||
#include <new>
|
|
||||||
|
|
||||||
extern "C++" {
|
|
||||||
|
|
||||||
namespace std
|
|
||||||
{
|
|
||||||
class type_info;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @addtogroup exceptions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace __exception_ptr
|
|
||||||
{
|
|
||||||
class exception_ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
using __exception_ptr::exception_ptr;
|
|
||||||
|
|
||||||
/** Obtain an exception_ptr to the currently handled exception. If there
|
|
||||||
* is none, or the currently handled exception is foreign, return the null
|
|
||||||
* value.
|
|
||||||
*/
|
|
||||||
exception_ptr current_exception() _GLIBCXX_USE_NOEXCEPT;
|
|
||||||
|
|
||||||
template<typename _Ex>
|
|
||||||
exception_ptr make_exception_ptr(_Ex) _GLIBCXX_USE_NOEXCEPT;
|
|
||||||
|
|
||||||
/// Throw the object pointed to by the exception_ptr.
|
|
||||||
void rethrow_exception(exception_ptr) __attribute__ ((__noreturn__));
|
|
||||||
|
|
||||||
namespace __exception_ptr
|
|
||||||
{
|
|
||||||
using std::rethrow_exception;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief An opaque pointer to an arbitrary exception.
|
|
||||||
* @ingroup exceptions
|
|
||||||
*/
|
|
||||||
class exception_ptr
|
|
||||||
{
|
|
||||||
void* _M_exception_object;
|
|
||||||
|
|
||||||
explicit exception_ptr(void* __e) _GLIBCXX_USE_NOEXCEPT;
|
|
||||||
|
|
||||||
void _M_addref() _GLIBCXX_USE_NOEXCEPT;
|
|
||||||
void _M_release() _GLIBCXX_USE_NOEXCEPT;
|
|
||||||
|
|
||||||
void *_M_get() const _GLIBCXX_NOEXCEPT __attribute__ ((__pure__));
|
|
||||||
|
|
||||||
friend exception_ptr std::current_exception() _GLIBCXX_USE_NOEXCEPT;
|
|
||||||
friend void std::rethrow_exception(exception_ptr);
|
|
||||||
template<typename _Ex>
|
|
||||||
friend exception_ptr std::make_exception_ptr(_Ex) _GLIBCXX_USE_NOEXCEPT;
|
|
||||||
|
|
||||||
public:
|
|
||||||
exception_ptr() _GLIBCXX_USE_NOEXCEPT;
|
|
||||||
|
|
||||||
exception_ptr(const exception_ptr&) _GLIBCXX_USE_NOEXCEPT;
|
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
exception_ptr(nullptr_t) noexcept
|
|
||||||
: _M_exception_object(0)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
exception_ptr(exception_ptr&& __o) noexcept
|
|
||||||
: _M_exception_object(__o._M_exception_object)
|
|
||||||
{ __o._M_exception_object = 0; }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (__cplusplus < 201103L) || defined (_GLIBCXX_EH_PTR_COMPAT)
|
|
||||||
typedef void (exception_ptr::*__safe_bool)();
|
|
||||||
|
|
||||||
// For construction from nullptr or 0.
|
|
||||||
exception_ptr(__safe_bool) _GLIBCXX_USE_NOEXCEPT;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
exception_ptr&
|
|
||||||
operator=(const exception_ptr&) _GLIBCXX_USE_NOEXCEPT;
|
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
exception_ptr&
|
|
||||||
operator=(exception_ptr&& __o) noexcept
|
|
||||||
{
|
|
||||||
exception_ptr(static_cast<exception_ptr&&>(__o)).swap(*this);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
~exception_ptr() _GLIBCXX_USE_NOEXCEPT;
|
|
||||||
|
|
||||||
void
|
|
||||||
swap(exception_ptr&) _GLIBCXX_USE_NOEXCEPT;
|
|
||||||
|
|
||||||
#ifdef _GLIBCXX_EH_PTR_COMPAT
|
|
||||||
// Retained for compatibility with CXXABI_1.3.
|
|
||||||
void _M_safe_bool_dummy() _GLIBCXX_USE_NOEXCEPT
|
|
||||||
__attribute__ ((__const__));
|
|
||||||
bool operator!() const _GLIBCXX_USE_NOEXCEPT
|
|
||||||
__attribute__ ((__pure__));
|
|
||||||
operator __safe_bool() const _GLIBCXX_USE_NOEXCEPT;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
explicit operator bool() const
|
|
||||||
{ return _M_exception_object; }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
friend bool
|
|
||||||
operator==(const exception_ptr&, const exception_ptr&)
|
|
||||||
_GLIBCXX_USE_NOEXCEPT __attribute__ ((__pure__));
|
|
||||||
|
|
||||||
const class std::type_info*
|
|
||||||
__cxa_exception_type() const _GLIBCXX_USE_NOEXCEPT
|
|
||||||
__attribute__ ((__pure__));
|
|
||||||
};
|
|
||||||
|
|
||||||
/// @relates exception_ptr @{
|
|
||||||
|
|
||||||
bool
|
|
||||||
operator==(const exception_ptr&, const exception_ptr&)
|
|
||||||
_GLIBCXX_USE_NOEXCEPT __attribute__ ((__pure__));
|
|
||||||
|
|
||||||
bool
|
|
||||||
operator!=(const exception_ptr&, const exception_ptr&)
|
|
||||||
_GLIBCXX_USE_NOEXCEPT __attribute__ ((__pure__));
|
|
||||||
|
|
||||||
inline void
|
|
||||||
swap(exception_ptr& __lhs, exception_ptr& __rhs)
|
|
||||||
{ __lhs.swap(__rhs); }
|
|
||||||
|
|
||||||
// @}
|
|
||||||
|
|
||||||
/// @cond undocumented
|
|
||||||
template<typename _Ex>
|
|
||||||
inline void
|
|
||||||
__dest_thunk(void* __x)
|
|
||||||
{ static_cast<_Ex*>(__x)->~_Ex(); }
|
|
||||||
/// @endcond
|
|
||||||
|
|
||||||
} // namespace __exception_ptr
|
|
||||||
|
|
||||||
/// Obtain an exception_ptr pointing to a copy of the supplied object.
|
|
||||||
template<typename _Ex>
|
|
||||||
exception_ptr
|
|
||||||
make_exception_ptr(_Ex __ex) _GLIBCXX_USE_NOEXCEPT
|
|
||||||
{
|
|
||||||
#if __cpp_exceptions && __cpp_rtti && !_GLIBCXX_HAVE_CDTOR_CALLABI
|
|
||||||
void* __e = __cxxabiv1::__cxa_allocate_exception(sizeof(_Ex));
|
|
||||||
(void) __cxxabiv1::__cxa_init_primary_exception(
|
|
||||||
__e, const_cast<std::type_info*>(&typeid(__ex)),
|
|
||||||
__exception_ptr::__dest_thunk<_Ex>);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
::new (__e) _Ex(__ex);
|
|
||||||
return exception_ptr(__e);
|
|
||||||
}
|
|
||||||
catch(...)
|
|
||||||
{
|
|
||||||
__cxxabiv1::__cxa_free_exception(__e);
|
|
||||||
return current_exception();
|
|
||||||
}
|
|
||||||
#elif __cpp_exceptions
|
|
||||||
try
|
|
||||||
{
|
|
||||||
throw __ex;
|
|
||||||
}
|
|
||||||
catch(...)
|
|
||||||
{
|
|
||||||
return current_exception();
|
|
||||||
}
|
|
||||||
#else // no RTTI and no exceptions
|
|
||||||
return exception_ptr();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
// @} group exceptions
|
|
||||||
} // namespace std
|
|
||||||
|
|
||||||
} // extern "C++"
|
|
||||||
|
|
||||||
#pragma GCC visibility pop
|
|
||||||
|
|
||||||
#endif
|
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@ -1,115 +0,0 @@
|
|||||||
// Function-Based Exception Support -*- C++ -*-
|
|
||||||
|
|
||||||
// Copyright (C) 2001-2020 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.
|
|
||||||
|
|
||||||
// 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 bits/functexcept.h
|
|
||||||
* This is an internal header file, included by other library headers.
|
|
||||||
* Do not attempt to use it directly. @headername{exception}
|
|
||||||
*
|
|
||||||
* This header provides support for -fno-exceptions.
|
|
||||||
*/
|
|
||||||
|
|
||||||
//
|
|
||||||
// ISO C++ 14882: 19.1 Exception classes
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef _FUNCTEXCEPT_H
|
|
||||||
#define _FUNCTEXCEPT_H 1
|
|
||||||
|
|
||||||
#include <bits/c++config.h>
|
|
||||||
#include <bits/exception_defines.h>
|
|
||||||
|
|
||||||
namespace std _GLIBCXX_VISIBILITY(default)
|
|
||||||
{
|
|
||||||
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|
||||||
|
|
||||||
// Helper for exception objects in <except>
|
|
||||||
void
|
|
||||||
__throw_bad_exception(void) __attribute__((__noreturn__));
|
|
||||||
|
|
||||||
// Helper for exception objects in <new>
|
|
||||||
void
|
|
||||||
__throw_bad_alloc(void) __attribute__((__noreturn__));
|
|
||||||
|
|
||||||
// Helper for exception objects in <typeinfo>
|
|
||||||
void
|
|
||||||
__throw_bad_cast(void) __attribute__((__noreturn__));
|
|
||||||
|
|
||||||
void
|
|
||||||
__throw_bad_typeid(void) __attribute__((__noreturn__));
|
|
||||||
|
|
||||||
// Helpers for exception objects in <stdexcept>
|
|
||||||
void
|
|
||||||
__throw_logic_error(const char*) __attribute__((__noreturn__));
|
|
||||||
|
|
||||||
void
|
|
||||||
__throw_domain_error(const char*) __attribute__((__noreturn__));
|
|
||||||
|
|
||||||
void
|
|
||||||
__throw_invalid_argument(const char*) __attribute__((__noreturn__));
|
|
||||||
|
|
||||||
void
|
|
||||||
__throw_length_error(const char*) __attribute__((__noreturn__));
|
|
||||||
|
|
||||||
void
|
|
||||||
__throw_out_of_range(const char*) __attribute__((__noreturn__));
|
|
||||||
|
|
||||||
void
|
|
||||||
__throw_out_of_range_fmt(const char*, ...) __attribute__((__noreturn__))
|
|
||||||
__attribute__((__format__(__gnu_printf__, 1, 2)));
|
|
||||||
|
|
||||||
void
|
|
||||||
__throw_runtime_error(const char*) __attribute__((__noreturn__));
|
|
||||||
|
|
||||||
void
|
|
||||||
__throw_range_error(const char*) __attribute__((__noreturn__));
|
|
||||||
|
|
||||||
void
|
|
||||||
__throw_overflow_error(const char*) __attribute__((__noreturn__));
|
|
||||||
|
|
||||||
void
|
|
||||||
__throw_underflow_error(const char*) __attribute__((__noreturn__));
|
|
||||||
|
|
||||||
// Helpers for exception objects in <ios>
|
|
||||||
void
|
|
||||||
__throw_ios_failure(const char*) __attribute__((__noreturn__));
|
|
||||||
|
|
||||||
void
|
|
||||||
__throw_ios_failure(const char*, int) __attribute__((__noreturn__));
|
|
||||||
|
|
||||||
// Helpers for exception objects in <system_error>
|
|
||||||
void
|
|
||||||
__throw_system_error(int) __attribute__((__noreturn__));
|
|
||||||
|
|
||||||
// Helpers for exception objects in <future>
|
|
||||||
void
|
|
||||||
__throw_future_error(int) __attribute__((__noreturn__));
|
|
||||||
|
|
||||||
// Helpers for exception objects in <functional>
|
|
||||||
void
|
|
||||||
__throw_bad_function_call() __attribute__((__noreturn__));
|
|
||||||
|
|
||||||
_GLIBCXX_END_NAMESPACE_VERSION
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
#endif
|
|
Binary file not shown.
@ -1,289 +0,0 @@
|
|||||||
// functional_hash.h header -*- C++ -*-
|
|
||||||
|
|
||||||
// Copyright (C) 2007-2020 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.
|
|
||||||
|
|
||||||
// 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 bits/functional_hash.h
|
|
||||||
* This is an internal header file, included by other library headers.
|
|
||||||
* Do not attempt to use it directly. @headername{functional}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _FUNCTIONAL_HASH_H
|
|
||||||
#define _FUNCTIONAL_HASH_H 1
|
|
||||||
|
|
||||||
#pragma GCC system_header
|
|
||||||
|
|
||||||
#include <bits/hash_bytes.h>
|
|
||||||
|
|
||||||
namespace std _GLIBCXX_VISIBILITY(default)
|
|
||||||
{
|
|
||||||
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|
||||||
|
|
||||||
/** @defgroup hashes Hashes
|
|
||||||
* @ingroup functors
|
|
||||||
*
|
|
||||||
* Hashing functors taking a variable type and returning a @c std::size_t.
|
|
||||||
*
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
template<typename _Result, typename _Arg>
|
|
||||||
struct __hash_base
|
|
||||||
{
|
|
||||||
typedef _Result result_type _GLIBCXX17_DEPRECATED;
|
|
||||||
typedef _Arg argument_type _GLIBCXX17_DEPRECATED;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Primary class template hash.
|
|
||||||
template<typename _Tp>
|
|
||||||
struct hash;
|
|
||||||
|
|
||||||
template<typename _Tp, typename = void>
|
|
||||||
struct __poison_hash
|
|
||||||
{
|
|
||||||
static constexpr bool __enable_hash_call = false;
|
|
||||||
private:
|
|
||||||
// Private rather than deleted to be non-trivially-copyable.
|
|
||||||
__poison_hash(__poison_hash&&);
|
|
||||||
~__poison_hash();
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename _Tp>
|
|
||||||
struct __poison_hash<_Tp, __void_t<decltype(hash<_Tp>()(declval<_Tp>()))>>
|
|
||||||
{
|
|
||||||
static constexpr bool __enable_hash_call = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Helper struct for SFINAE-poisoning non-enum types.
|
|
||||||
template<typename _Tp, bool = is_enum<_Tp>::value>
|
|
||||||
struct __hash_enum
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
// Private rather than deleted to be non-trivially-copyable.
|
|
||||||
__hash_enum(__hash_enum&&);
|
|
||||||
~__hash_enum();
|
|
||||||
};
|
|
||||||
|
|
||||||
// Helper struct for hash with enum types.
|
|
||||||
template<typename _Tp>
|
|
||||||
struct __hash_enum<_Tp, true> : public __hash_base<size_t, _Tp>
|
|
||||||
{
|
|
||||||
size_t
|
|
||||||
operator()(_Tp __val) const noexcept
|
|
||||||
{
|
|
||||||
using __type = typename underlying_type<_Tp>::type;
|
|
||||||
return hash<__type>{}(static_cast<__type>(__val));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Primary class template hash, usable for enum types only.
|
|
||||||
// Use with non-enum types still SFINAES.
|
|
||||||
template<typename _Tp>
|
|
||||||
struct hash : __hash_enum<_Tp>
|
|
||||||
{ };
|
|
||||||
|
|
||||||
/// Partial specializations for pointer types.
|
|
||||||
template<typename _Tp>
|
|
||||||
struct hash<_Tp*> : public __hash_base<size_t, _Tp*>
|
|
||||||
{
|
|
||||||
size_t
|
|
||||||
operator()(_Tp* __p) const noexcept
|
|
||||||
{ return reinterpret_cast<size_t>(__p); }
|
|
||||||
};
|
|
||||||
|
|
||||||
// Explicit specializations for integer types.
|
|
||||||
#define _Cxx_hashtable_define_trivial_hash(_Tp) \
|
|
||||||
template<> \
|
|
||||||
struct hash<_Tp> : public __hash_base<size_t, _Tp> \
|
|
||||||
{ \
|
|
||||||
size_t \
|
|
||||||
operator()(_Tp __val) const noexcept \
|
|
||||||
{ return static_cast<size_t>(__val); } \
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Explicit specialization for bool.
|
|
||||||
_Cxx_hashtable_define_trivial_hash(bool)
|
|
||||||
|
|
||||||
/// Explicit specialization for char.
|
|
||||||
_Cxx_hashtable_define_trivial_hash(char)
|
|
||||||
|
|
||||||
/// Explicit specialization for signed char.
|
|
||||||
_Cxx_hashtable_define_trivial_hash(signed char)
|
|
||||||
|
|
||||||
/// Explicit specialization for unsigned char.
|
|
||||||
_Cxx_hashtable_define_trivial_hash(unsigned char)
|
|
||||||
|
|
||||||
/// Explicit specialization for wchar_t.
|
|
||||||
_Cxx_hashtable_define_trivial_hash(wchar_t)
|
|
||||||
|
|
||||||
#ifdef _GLIBCXX_USE_CHAR8_T
|
|
||||||
/// Explicit specialization for char8_t.
|
|
||||||
_Cxx_hashtable_define_trivial_hash(char8_t)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/// Explicit specialization for char16_t.
|
|
||||||
_Cxx_hashtable_define_trivial_hash(char16_t)
|
|
||||||
|
|
||||||
/// Explicit specialization for char32_t.
|
|
||||||
_Cxx_hashtable_define_trivial_hash(char32_t)
|
|
||||||
|
|
||||||
/// Explicit specialization for short.
|
|
||||||
_Cxx_hashtable_define_trivial_hash(short)
|
|
||||||
|
|
||||||
/// Explicit specialization for int.
|
|
||||||
_Cxx_hashtable_define_trivial_hash(int)
|
|
||||||
|
|
||||||
/// Explicit specialization for long.
|
|
||||||
_Cxx_hashtable_define_trivial_hash(long)
|
|
||||||
|
|
||||||
/// Explicit specialization for long long.
|
|
||||||
_Cxx_hashtable_define_trivial_hash(long long)
|
|
||||||
|
|
||||||
/// Explicit specialization for unsigned short.
|
|
||||||
_Cxx_hashtable_define_trivial_hash(unsigned short)
|
|
||||||
|
|
||||||
/// Explicit specialization for unsigned int.
|
|
||||||
_Cxx_hashtable_define_trivial_hash(unsigned int)
|
|
||||||
|
|
||||||
/// Explicit specialization for unsigned long.
|
|
||||||
_Cxx_hashtable_define_trivial_hash(unsigned long)
|
|
||||||
|
|
||||||
/// Explicit specialization for unsigned long long.
|
|
||||||
_Cxx_hashtable_define_trivial_hash(unsigned long long)
|
|
||||||
|
|
||||||
#ifdef __GLIBCXX_TYPE_INT_N_0
|
|
||||||
_Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_0)
|
|
||||||
_Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_0 unsigned)
|
|
||||||
#endif
|
|
||||||
#ifdef __GLIBCXX_TYPE_INT_N_1
|
|
||||||
_Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_1)
|
|
||||||
_Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_1 unsigned)
|
|
||||||
#endif
|
|
||||||
#ifdef __GLIBCXX_TYPE_INT_N_2
|
|
||||||
_Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_2)
|
|
||||||
_Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_2 unsigned)
|
|
||||||
#endif
|
|
||||||
#ifdef __GLIBCXX_TYPE_INT_N_3
|
|
||||||
_Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_3)
|
|
||||||
_Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_3 unsigned)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#undef _Cxx_hashtable_define_trivial_hash
|
|
||||||
|
|
||||||
struct _Hash_impl
|
|
||||||
{
|
|
||||||
static size_t
|
|
||||||
hash(const void* __ptr, size_t __clength,
|
|
||||||
size_t __seed = static_cast<size_t>(0xc70f6907UL))
|
|
||||||
{ return _Hash_bytes(__ptr, __clength, __seed); }
|
|
||||||
|
|
||||||
template<typename _Tp>
|
|
||||||
static size_t
|
|
||||||
hash(const _Tp& __val)
|
|
||||||
{ return hash(&__val, sizeof(__val)); }
|
|
||||||
|
|
||||||
template<typename _Tp>
|
|
||||||
static size_t
|
|
||||||
__hash_combine(const _Tp& __val, size_t __hash)
|
|
||||||
{ return hash(&__val, sizeof(__val), __hash); }
|
|
||||||
};
|
|
||||||
|
|
||||||
// A hash function similar to FNV-1a (see PR59406 for how it differs).
|
|
||||||
struct _Fnv_hash_impl
|
|
||||||
{
|
|
||||||
static size_t
|
|
||||||
hash(const void* __ptr, size_t __clength,
|
|
||||||
size_t __seed = static_cast<size_t>(2166136261UL))
|
|
||||||
{ return _Fnv_hash_bytes(__ptr, __clength, __seed); }
|
|
||||||
|
|
||||||
template<typename _Tp>
|
|
||||||
static size_t
|
|
||||||
hash(const _Tp& __val)
|
|
||||||
{ return hash(&__val, sizeof(__val)); }
|
|
||||||
|
|
||||||
template<typename _Tp>
|
|
||||||
static size_t
|
|
||||||
__hash_combine(const _Tp& __val, size_t __hash)
|
|
||||||
{ return hash(&__val, sizeof(__val), __hash); }
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Specialization for float.
|
|
||||||
template<>
|
|
||||||
struct hash<float> : public __hash_base<size_t, float>
|
|
||||||
{
|
|
||||||
size_t
|
|
||||||
operator()(float __val) const noexcept
|
|
||||||
{
|
|
||||||
// 0 and -0 both hash to zero.
|
|
||||||
return __val != 0.0f ? std::_Hash_impl::hash(__val) : 0;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Specialization for double.
|
|
||||||
template<>
|
|
||||||
struct hash<double> : public __hash_base<size_t, double>
|
|
||||||
{
|
|
||||||
size_t
|
|
||||||
operator()(double __val) const noexcept
|
|
||||||
{
|
|
||||||
// 0 and -0 both hash to zero.
|
|
||||||
return __val != 0.0 ? std::_Hash_impl::hash(__val) : 0;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Specialization for long double.
|
|
||||||
template<>
|
|
||||||
struct hash<long double>
|
|
||||||
: public __hash_base<size_t, long double>
|
|
||||||
{
|
|
||||||
_GLIBCXX_PURE size_t
|
|
||||||
operator()(long double __val) const noexcept;
|
|
||||||
};
|
|
||||||
|
|
||||||
#if __cplusplus >= 201703L
|
|
||||||
template<>
|
|
||||||
struct hash<nullptr_t> : public __hash_base<size_t, nullptr_t>
|
|
||||||
{
|
|
||||||
size_t
|
|
||||||
operator()(nullptr_t) const noexcept
|
|
||||||
{ return 0; }
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// @} group hashes
|
|
||||||
|
|
||||||
// Hint about performance of hash functor. If not fast the hash-based
|
|
||||||
// containers will cache the hash code.
|
|
||||||
// Default behavior is to consider that hashers are fast unless specified
|
|
||||||
// otherwise.
|
|
||||||
template<typename _Hash>
|
|
||||||
struct __is_fast_hash : public std::true_type
|
|
||||||
{ };
|
|
||||||
|
|
||||||
template<>
|
|
||||||
struct __is_fast_hash<hash<long double>> : public std::false_type
|
|
||||||
{ };
|
|
||||||
|
|
||||||
_GLIBCXX_END_NAMESPACE_VERSION
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
#endif // _FUNCTIONAL_HASH_H
|
|
Binary file not shown.
@ -1,59 +0,0 @@
|
|||||||
// Declarations for hash functions. -*- C++ -*-
|
|
||||||
|
|
||||||
// Copyright (C) 2010-2020 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.
|
|
||||||
|
|
||||||
// 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 bits/hash_bytes.h
|
|
||||||
* This is an internal header file, included by other library headers.
|
|
||||||
* Do not attempt to use it directly. @headername{functional}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _HASH_BYTES_H
|
|
||||||
#define _HASH_BYTES_H 1
|
|
||||||
|
|
||||||
#pragma GCC system_header
|
|
||||||
|
|
||||||
#include <bits/c++config.h>
|
|
||||||
|
|
||||||
namespace std
|
|
||||||
{
|
|
||||||
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|
||||||
|
|
||||||
// Hash function implementation for the nontrivial specialization.
|
|
||||||
// All of them are based on a primitive that hashes a pointer to a
|
|
||||||
// byte array. The actual hash algorithm is not guaranteed to stay
|
|
||||||
// the same from release to release -- it may be updated or tuned to
|
|
||||||
// improve hash quality or speed.
|
|
||||||
size_t
|
|
||||||
_Hash_bytes(const void* __ptr, size_t __len, size_t __seed);
|
|
||||||
|
|
||||||
// A similar hash primitive, using the FNV hash algorithm. This
|
|
||||||
// algorithm is guaranteed to stay the same from release to release.
|
|
||||||
// (although it might not produce the same values on different
|
|
||||||
// machines.)
|
|
||||||
size_t
|
|
||||||
_Fnv_hash_bytes(const void* __ptr, size_t __len, size_t __seed);
|
|
||||||
|
|
||||||
_GLIBCXX_END_NAMESPACE_VERSION
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
#endif
|
|
Binary file not shown.
@ -1,163 +0,0 @@
|
|||||||
// Implementation of INVOKE -*- C++ -*-
|
|
||||||
|
|
||||||
// Copyright (C) 2016-2020 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.
|
|
||||||
|
|
||||||
// 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 include/bits/invoke.h
|
|
||||||
* This is an internal header file, included by other library headers.
|
|
||||||
* Do not attempt to use it directly. @headername{functional}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _GLIBCXX_INVOKE_H
|
|
||||||
#define _GLIBCXX_INVOKE_H 1
|
|
||||||
|
|
||||||
#pragma GCC system_header
|
|
||||||
|
|
||||||
#if __cplusplus < 201103L
|
|
||||||
# include <bits/c++0x_warning.h>
|
|
||||||
#else
|
|
||||||
|
|
||||||
#include <type_traits>
|
|
||||||
|
|
||||||
namespace std _GLIBCXX_VISIBILITY(default)
|
|
||||||
{
|
|
||||||
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @addtogroup utilities
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Used by __invoke_impl instead of std::forward<_Tp> so that a
|
|
||||||
// reference_wrapper is converted to an lvalue-reference.
|
|
||||||
template<typename _Tp, typename _Up = typename __inv_unwrap<_Tp>::type>
|
|
||||||
constexpr _Up&&
|
|
||||||
__invfwd(typename remove_reference<_Tp>::type& __t) noexcept
|
|
||||||
{ return static_cast<_Up&&>(__t); }
|
|
||||||
|
|
||||||
template<typename _Res, typename _Fn, typename... _Args>
|
|
||||||
constexpr _Res
|
|
||||||
__invoke_impl(__invoke_other, _Fn&& __f, _Args&&... __args)
|
|
||||||
{ return std::forward<_Fn>(__f)(std::forward<_Args>(__args)...); }
|
|
||||||
|
|
||||||
template<typename _Res, typename _MemFun, typename _Tp, typename... _Args>
|
|
||||||
constexpr _Res
|
|
||||||
__invoke_impl(__invoke_memfun_ref, _MemFun&& __f, _Tp&& __t,
|
|
||||||
_Args&&... __args)
|
|
||||||
{ return (__invfwd<_Tp>(__t).*__f)(std::forward<_Args>(__args)...); }
|
|
||||||
|
|
||||||
template<typename _Res, typename _MemFun, typename _Tp, typename... _Args>
|
|
||||||
constexpr _Res
|
|
||||||
__invoke_impl(__invoke_memfun_deref, _MemFun&& __f, _Tp&& __t,
|
|
||||||
_Args&&... __args)
|
|
||||||
{
|
|
||||||
return ((*std::forward<_Tp>(__t)).*__f)(std::forward<_Args>(__args)...);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename _Res, typename _MemPtr, typename _Tp>
|
|
||||||
constexpr _Res
|
|
||||||
__invoke_impl(__invoke_memobj_ref, _MemPtr&& __f, _Tp&& __t)
|
|
||||||
{ return __invfwd<_Tp>(__t).*__f; }
|
|
||||||
|
|
||||||
template<typename _Res, typename _MemPtr, typename _Tp>
|
|
||||||
constexpr _Res
|
|
||||||
__invoke_impl(__invoke_memobj_deref, _MemPtr&& __f, _Tp&& __t)
|
|
||||||
{ return (*std::forward<_Tp>(__t)).*__f; }
|
|
||||||
|
|
||||||
/// Invoke a callable object.
|
|
||||||
template<typename _Callable, typename... _Args>
|
|
||||||
constexpr typename __invoke_result<_Callable, _Args...>::type
|
|
||||||
__invoke(_Callable&& __fn, _Args&&... __args)
|
|
||||||
noexcept(__is_nothrow_invocable<_Callable, _Args...>::value)
|
|
||||||
{
|
|
||||||
using __result = __invoke_result<_Callable, _Args...>;
|
|
||||||
using __type = typename __result::type;
|
|
||||||
using __tag = typename __result::__invoke_type;
|
|
||||||
return std::__invoke_impl<__type>(__tag{}, std::forward<_Callable>(__fn),
|
|
||||||
std::forward<_Args>(__args)...);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if __cplusplus >= 201703L
|
|
||||||
// INVOKE<R>: Invoke a callable object and convert the result to R.
|
|
||||||
template<typename _Res, typename _Callable, typename... _Args>
|
|
||||||
constexpr enable_if_t<is_invocable_r_v<_Res, _Callable, _Args...>, _Res>
|
|
||||||
__invoke_r(_Callable&& __fn, _Args&&... __args)
|
|
||||||
noexcept(is_nothrow_invocable_r_v<_Res, _Callable, _Args...>)
|
|
||||||
{
|
|
||||||
using __result = __invoke_result<_Callable, _Args...>;
|
|
||||||
using __type = typename __result::type;
|
|
||||||
using __tag = typename __result::__invoke_type;
|
|
||||||
if constexpr (is_void_v<_Res>)
|
|
||||||
std::__invoke_impl<__type>(__tag{}, std::forward<_Callable>(__fn),
|
|
||||||
std::forward<_Args>(__args)...);
|
|
||||||
else
|
|
||||||
return std::__invoke_impl<__type>(__tag{},
|
|
||||||
std::forward<_Callable>(__fn),
|
|
||||||
std::forward<_Args>(__args)...);
|
|
||||||
}
|
|
||||||
#else // C++11
|
|
||||||
template<typename _Res, typename _Callable, typename... _Args>
|
|
||||||
using __can_invoke_as_void = __enable_if_t<
|
|
||||||
__and_<is_void<_Res>, __is_invocable<_Callable, _Args...>>::value,
|
|
||||||
_Res
|
|
||||||
>;
|
|
||||||
|
|
||||||
template<typename _Res, typename _Callable, typename... _Args>
|
|
||||||
using __can_invoke_as_nonvoid = __enable_if_t<
|
|
||||||
__and_<__not_<is_void<_Res>>,
|
|
||||||
is_convertible<typename __invoke_result<_Callable, _Args...>::type,
|
|
||||||
_Res>
|
|
||||||
>::value,
|
|
||||||
_Res
|
|
||||||
>;
|
|
||||||
|
|
||||||
// INVOKE<R>: Invoke a callable object and convert the result to R.
|
|
||||||
template<typename _Res, typename _Callable, typename... _Args>
|
|
||||||
constexpr __can_invoke_as_nonvoid<_Res, _Callable, _Args...>
|
|
||||||
__invoke_r(_Callable&& __fn, _Args&&... __args)
|
|
||||||
{
|
|
||||||
using __result = __invoke_result<_Callable, _Args...>;
|
|
||||||
using __type = typename __result::type;
|
|
||||||
using __tag = typename __result::__invoke_type;
|
|
||||||
return std::__invoke_impl<__type>(__tag{}, std::forward<_Callable>(__fn),
|
|
||||||
std::forward<_Args>(__args)...);
|
|
||||||
}
|
|
||||||
|
|
||||||
// INVOKE<R> when R is cv void
|
|
||||||
template<typename _Res, typename _Callable, typename... _Args>
|
|
||||||
_GLIBCXX14_CONSTEXPR __can_invoke_as_void<_Res, _Callable, _Args...>
|
|
||||||
__invoke_r(_Callable&& __fn, _Args&&... __args)
|
|
||||||
{
|
|
||||||
using __result = __invoke_result<_Callable, _Args...>;
|
|
||||||
using __type = typename __result::type;
|
|
||||||
using __tag = typename __result::__invoke_type;
|
|
||||||
std::__invoke_impl<__type>(__tag{}, std::forward<_Callable>(__fn),
|
|
||||||
std::forward<_Args>(__args)...);
|
|
||||||
}
|
|
||||||
#endif // C++11
|
|
||||||
|
|
||||||
_GLIBCXX_END_NAMESPACE_VERSION
|
|
||||||
} // namespace std
|
|
||||||
|
|
||||||
#endif // C++11
|
|
||||||
|
|
||||||
#endif // _GLIBCXX_INVOKE_H
|
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@ -1,934 +0,0 @@
|
|||||||
// Concepts and traits for use with iterators -*- C++ -*-
|
|
||||||
|
|
||||||
// Copyright (C) 2019-2020 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.
|
|
||||||
|
|
||||||
// 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 bits/iterator_concepts.h
|
|
||||||
* This is an internal header file, included by other library headers.
|
|
||||||
* Do not attempt to use it directly. @headername{iterator}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _ITERATOR_CONCEPTS_H
|
|
||||||
#define _ITERATOR_CONCEPTS_H 1
|
|
||||||
|
|
||||||
#pragma GCC system_header
|
|
||||||
|
|
||||||
#include <concepts>
|
|
||||||
#include <bits/ptr_traits.h> // to_address
|
|
||||||
#include <bits/range_cmp.h> // identity, ranges::less
|
|
||||||
|
|
||||||
#if __cpp_lib_concepts
|
|
||||||
namespace std _GLIBCXX_VISIBILITY(default)
|
|
||||||
{
|
|
||||||
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|
||||||
|
|
||||||
struct input_iterator_tag;
|
|
||||||
struct output_iterator_tag;
|
|
||||||
struct forward_iterator_tag;
|
|
||||||
struct bidirectional_iterator_tag;
|
|
||||||
struct random_access_iterator_tag;
|
|
||||||
struct contiguous_iterator_tag;
|
|
||||||
|
|
||||||
template<typename _Iterator>
|
|
||||||
struct iterator_traits;
|
|
||||||
|
|
||||||
template<typename _Tp> requires is_object_v<_Tp>
|
|
||||||
struct iterator_traits<_Tp*>;
|
|
||||||
|
|
||||||
template<typename _Iterator, typename>
|
|
||||||
struct __iterator_traits;
|
|
||||||
|
|
||||||
namespace __detail
|
|
||||||
{
|
|
||||||
template<typename _Tp>
|
|
||||||
using __with_ref = _Tp&;
|
|
||||||
|
|
||||||
template<typename _Tp>
|
|
||||||
concept __can_reference = requires { typename __with_ref<_Tp>; };
|
|
||||||
|
|
||||||
template<typename _Tp>
|
|
||||||
concept __dereferenceable = requires(_Tp& __t)
|
|
||||||
{
|
|
||||||
{ *__t } -> __can_reference;
|
|
||||||
};
|
|
||||||
} // namespace __detail
|
|
||||||
|
|
||||||
template<__detail::__dereferenceable _Tp>
|
|
||||||
using iter_reference_t = decltype(*std::declval<_Tp&>());
|
|
||||||
|
|
||||||
namespace ranges
|
|
||||||
{
|
|
||||||
namespace __cust_imove
|
|
||||||
{
|
|
||||||
void iter_move();
|
|
||||||
|
|
||||||
template<typename _Tp>
|
|
||||||
concept __adl_imove
|
|
||||||
= (std::__detail::__class_or_enum<remove_reference_t<_Tp>>)
|
|
||||||
&& requires(_Tp&& __t) { iter_move(static_cast<_Tp&&>(__t)); };
|
|
||||||
|
|
||||||
struct _IMove
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
template<typename _Tp>
|
|
||||||
struct __result
|
|
||||||
{ using type = iter_reference_t<_Tp>; };
|
|
||||||
|
|
||||||
template<typename _Tp>
|
|
||||||
requires __adl_imove<_Tp>
|
|
||||||
struct __result<_Tp>
|
|
||||||
{ using type = decltype(iter_move(std::declval<_Tp>())); };
|
|
||||||
|
|
||||||
template<typename _Tp>
|
|
||||||
requires (!__adl_imove<_Tp>)
|
|
||||||
&& is_lvalue_reference_v<iter_reference_t<_Tp>>
|
|
||||||
struct __result<_Tp>
|
|
||||||
{ using type = remove_reference_t<iter_reference_t<_Tp>>&&; };
|
|
||||||
|
|
||||||
template<typename _Tp>
|
|
||||||
static constexpr bool
|
|
||||||
_S_noexcept()
|
|
||||||
{
|
|
||||||
if constexpr (__adl_imove<_Tp>)
|
|
||||||
return noexcept(iter_move(std::declval<_Tp>()));
|
|
||||||
else
|
|
||||||
return noexcept(*std::declval<_Tp>());
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
// The result type of iter_move(std::declval<_Tp>())
|
|
||||||
template<std::__detail::__dereferenceable _Tp>
|
|
||||||
using __type = typename __result<_Tp>::type;
|
|
||||||
|
|
||||||
template<std::__detail::__dereferenceable _Tp>
|
|
||||||
constexpr __type<_Tp>
|
|
||||||
operator()(_Tp&& __e) const
|
|
||||||
noexcept(_S_noexcept<_Tp>())
|
|
||||||
{
|
|
||||||
if constexpr (__adl_imove<_Tp>)
|
|
||||||
return iter_move(static_cast<_Tp&&>(__e));
|
|
||||||
else if constexpr (is_lvalue_reference_v<iter_reference_t<_Tp>>)
|
|
||||||
return static_cast<__type<_Tp>>(*__e);
|
|
||||||
else
|
|
||||||
return *__e;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} // namespace __cust_imove
|
|
||||||
|
|
||||||
inline namespace __cust
|
|
||||||
{
|
|
||||||
inline constexpr __cust_imove::_IMove iter_move{};
|
|
||||||
} // inline namespace __cust
|
|
||||||
} // namespace ranges
|
|
||||||
|
|
||||||
template<__detail::__dereferenceable _Tp>
|
|
||||||
requires requires(_Tp& __t)
|
|
||||||
{ { ranges::iter_move(__t) } -> __detail::__can_reference; }
|
|
||||||
using iter_rvalue_reference_t
|
|
||||||
= decltype(ranges::iter_move(std::declval<_Tp&>()));
|
|
||||||
|
|
||||||
template<typename> struct incrementable_traits { };
|
|
||||||
|
|
||||||
template<typename _Tp> requires is_object_v<_Tp>
|
|
||||||
struct incrementable_traits<_Tp*>
|
|
||||||
{ using difference_type = ptrdiff_t; };
|
|
||||||
|
|
||||||
template<typename _Iter>
|
|
||||||
struct incrementable_traits<const _Iter>
|
|
||||||
: incrementable_traits<_Iter> { };
|
|
||||||
|
|
||||||
template<typename _Tp> requires requires { typename _Tp::difference_type; }
|
|
||||||
struct incrementable_traits<_Tp>
|
|
||||||
{ using difference_type = typename _Tp::difference_type; };
|
|
||||||
|
|
||||||
template<typename _Tp>
|
|
||||||
requires (!requires { typename _Tp::difference_type; }
|
|
||||||
&& requires(const _Tp& __a, const _Tp& __b)
|
|
||||||
{
|
|
||||||
requires (!is_void_v<remove_pointer_t<_Tp>>); // PR c++/78173
|
|
||||||
{ __a - __b } -> integral;
|
|
||||||
})
|
|
||||||
struct incrementable_traits<_Tp>
|
|
||||||
{
|
|
||||||
using difference_type
|
|
||||||
= make_signed_t<decltype(std::declval<_Tp>() - std::declval<_Tp>())>;
|
|
||||||
};
|
|
||||||
|
|
||||||
#if defined __STRICT_ANSI__ && defined __SIZEOF_INT128__
|
|
||||||
// __int128 is incrementable even if !integral<__int128>
|
|
||||||
template<>
|
|
||||||
struct incrementable_traits<__int128>
|
|
||||||
{ using difference_type = __int128; };
|
|
||||||
|
|
||||||
template<>
|
|
||||||
struct incrementable_traits<unsigned __int128>
|
|
||||||
{ using difference_type = __int128; };
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace __detail
|
|
||||||
{
|
|
||||||
// An iterator such that iterator_traits<_Iter> names a specialization
|
|
||||||
// generated from the primary template.
|
|
||||||
template<typename _Iter>
|
|
||||||
concept __primary_traits_iter
|
|
||||||
= __is_base_of(__iterator_traits<_Iter, void>, iterator_traits<_Iter>);
|
|
||||||
|
|
||||||
template<typename _Iter, typename _Tp>
|
|
||||||
struct __iter_traits_impl
|
|
||||||
{ using type = iterator_traits<_Iter>; };
|
|
||||||
|
|
||||||
template<typename _Iter, typename _Tp>
|
|
||||||
requires __primary_traits_iter<_Iter>
|
|
||||||
struct __iter_traits_impl<_Iter, _Tp>
|
|
||||||
{ using type = _Tp; };
|
|
||||||
|
|
||||||
// ITER_TRAITS
|
|
||||||
template<typename _Iter, typename _Tp = _Iter>
|
|
||||||
using __iter_traits = typename __iter_traits_impl<_Iter, _Tp>::type;
|
|
||||||
|
|
||||||
template<typename _Tp>
|
|
||||||
using __iter_diff_t = typename
|
|
||||||
__iter_traits<_Tp, incrementable_traits<_Tp>>::difference_type;
|
|
||||||
} // namespace __detail
|
|
||||||
|
|
||||||
template<typename _Tp>
|
|
||||||
using iter_difference_t = __detail::__iter_diff_t<remove_cvref_t<_Tp>>;
|
|
||||||
|
|
||||||
namespace __detail
|
|
||||||
{
|
|
||||||
template<typename> struct __cond_value_type { };
|
|
||||||
|
|
||||||
template<typename _Tp> requires is_object_v<_Tp>
|
|
||||||
struct __cond_value_type<_Tp>
|
|
||||||
{ using value_type = remove_cv_t<_Tp>; };
|
|
||||||
} // namespace __detail
|
|
||||||
|
|
||||||
template<typename> struct indirectly_readable_traits { };
|
|
||||||
|
|
||||||
template<typename _Tp>
|
|
||||||
struct indirectly_readable_traits<_Tp*>
|
|
||||||
: __detail::__cond_value_type<_Tp>
|
|
||||||
{ };
|
|
||||||
|
|
||||||
template<typename _Iter> requires is_array_v<_Iter>
|
|
||||||
struct indirectly_readable_traits<_Iter>
|
|
||||||
{ using value_type = remove_cv_t<remove_extent_t<_Iter>>; };
|
|
||||||
|
|
||||||
template<typename _Iter>
|
|
||||||
struct indirectly_readable_traits<const _Iter>
|
|
||||||
: indirectly_readable_traits<_Iter>
|
|
||||||
{ };
|
|
||||||
|
|
||||||
template<typename _Tp> requires requires { typename _Tp::value_type; }
|
|
||||||
struct indirectly_readable_traits<_Tp>
|
|
||||||
: __detail::__cond_value_type<typename _Tp::value_type>
|
|
||||||
{ };
|
|
||||||
|
|
||||||
template<typename _Tp> requires requires { typename _Tp::element_type; }
|
|
||||||
struct indirectly_readable_traits<_Tp>
|
|
||||||
: __detail::__cond_value_type<typename _Tp::element_type>
|
|
||||||
{ };
|
|
||||||
|
|
||||||
namespace __detail
|
|
||||||
{
|
|
||||||
template<typename _Tp>
|
|
||||||
using __iter_value_t = typename
|
|
||||||
__iter_traits<_Tp, indirectly_readable_traits<_Tp>>::value_type;
|
|
||||||
} // namespace __detail
|
|
||||||
|
|
||||||
template<typename _Tp>
|
|
||||||
using iter_value_t = __detail::__iter_value_t<remove_cvref_t<_Tp>>;
|
|
||||||
|
|
||||||
namespace __detail
|
|
||||||
{
|
|
||||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
|
||||||
// 3420. cpp17-iterator should check [type] looks like an iterator first
|
|
||||||
template<typename _Iter>
|
|
||||||
concept __cpp17_iterator = requires(_Iter __it)
|
|
||||||
{
|
|
||||||
{ *__it } -> __can_reference;
|
|
||||||
{ ++__it } -> same_as<_Iter&>;
|
|
||||||
{ *__it++ } -> __can_reference;
|
|
||||||
} && copyable<_Iter>;
|
|
||||||
|
|
||||||
template<typename _Iter>
|
|
||||||
concept __cpp17_input_iterator = __cpp17_iterator<_Iter>
|
|
||||||
&& equality_comparable<_Iter>
|
|
||||||
&& requires(_Iter __it)
|
|
||||||
{
|
|
||||||
typename incrementable_traits<_Iter>::difference_type;
|
|
||||||
typename indirectly_readable_traits<_Iter>::value_type;
|
|
||||||
typename common_reference_t<iter_reference_t<_Iter>&&,
|
|
||||||
typename indirectly_readable_traits<_Iter>::value_type&>;
|
|
||||||
typename common_reference_t<decltype(*__it++)&&,
|
|
||||||
typename indirectly_readable_traits<_Iter>::value_type&>;
|
|
||||||
requires signed_integral<
|
|
||||||
typename incrementable_traits<_Iter>::difference_type>;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename _Iter>
|
|
||||||
concept __cpp17_fwd_iterator = __cpp17_input_iterator<_Iter>
|
|
||||||
&& constructible_from<_Iter>
|
|
||||||
&& is_lvalue_reference_v<iter_reference_t<_Iter>>
|
|
||||||
&& same_as<remove_cvref_t<iter_reference_t<_Iter>>,
|
|
||||||
typename indirectly_readable_traits<_Iter>::value_type>
|
|
||||||
&& requires(_Iter __it)
|
|
||||||
{
|
|
||||||
{ __it++ } -> convertible_to<const _Iter&>;
|
|
||||||
{ *__it++ } -> same_as<iter_reference_t<_Iter>>;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename _Iter>
|
|
||||||
concept __cpp17_bidi_iterator = __cpp17_fwd_iterator<_Iter>
|
|
||||||
&& requires(_Iter __it)
|
|
||||||
{
|
|
||||||
{ --__it } -> same_as<_Iter&>;
|
|
||||||
{ __it-- } -> convertible_to<const _Iter&>;
|
|
||||||
{ *__it-- } -> same_as<iter_reference_t<_Iter>>;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename _Iter>
|
|
||||||
concept __cpp17_randacc_iterator = __cpp17_bidi_iterator<_Iter>
|
|
||||||
&& totally_ordered<_Iter>
|
|
||||||
&& requires(_Iter __it,
|
|
||||||
typename incrementable_traits<_Iter>::difference_type __n)
|
|
||||||
{
|
|
||||||
{ __it += __n } -> same_as<_Iter&>;
|
|
||||||
{ __it -= __n } -> same_as<_Iter&>;
|
|
||||||
{ __it + __n } -> same_as<_Iter>;
|
|
||||||
{ __n + __it } -> same_as<_Iter>;
|
|
||||||
{ __it - __n } -> same_as<_Iter>;
|
|
||||||
{ __it - __it } -> same_as<decltype(__n)>;
|
|
||||||
{ __it[__n] } -> convertible_to<iter_reference_t<_Iter>>;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename _Iter>
|
|
||||||
concept __iter_with_nested_types = requires {
|
|
||||||
typename _Iter::iterator_category;
|
|
||||||
typename _Iter::value_type;
|
|
||||||
typename _Iter::difference_type;
|
|
||||||
typename _Iter::reference;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename _Iter>
|
|
||||||
concept __iter_without_nested_types = !__iter_with_nested_types<_Iter>;
|
|
||||||
|
|
||||||
template<typename _Iter>
|
|
||||||
concept __iter_without_category
|
|
||||||
= !requires { typename _Iter::iterator_category; };
|
|
||||||
|
|
||||||
} // namespace __detail
|
|
||||||
|
|
||||||
template<typename _Iterator>
|
|
||||||
requires __detail::__iter_with_nested_types<_Iterator>
|
|
||||||
struct __iterator_traits<_Iterator, void>
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
template<typename _Iter>
|
|
||||||
struct __ptr
|
|
||||||
{ using type = void; };
|
|
||||||
|
|
||||||
template<typename _Iter> requires requires { typename _Iter::pointer; }
|
|
||||||
struct __ptr<_Iter>
|
|
||||||
{ using type = typename _Iter::pointer; };
|
|
||||||
|
|
||||||
public:
|
|
||||||
using iterator_category = typename _Iterator::iterator_category;
|
|
||||||
using value_type = typename _Iterator::value_type;
|
|
||||||
using difference_type = typename _Iterator::difference_type;
|
|
||||||
using pointer = typename __ptr<_Iterator>::type;
|
|
||||||
using reference = typename _Iterator::reference;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename _Iterator>
|
|
||||||
requires __detail::__iter_without_nested_types<_Iterator>
|
|
||||||
&& __detail::__cpp17_input_iterator<_Iterator>
|
|
||||||
struct __iterator_traits<_Iterator, void>
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
template<typename _Iter>
|
|
||||||
struct __cat
|
|
||||||
{ using type = input_iterator_tag; };
|
|
||||||
|
|
||||||
template<typename _Iter>
|
|
||||||
requires requires { typename _Iter::iterator_category; }
|
|
||||||
struct __cat<_Iter>
|
|
||||||
{ using type = typename _Iter::iterator_category; };
|
|
||||||
|
|
||||||
template<typename _Iter>
|
|
||||||
requires __detail::__iter_without_category<_Iter>
|
|
||||||
&& __detail::__cpp17_randacc_iterator<_Iter>
|
|
||||||
struct __cat<_Iter>
|
|
||||||
{ using type = random_access_iterator_tag; };
|
|
||||||
|
|
||||||
template<typename _Iter>
|
|
||||||
requires __detail::__iter_without_category<_Iter>
|
|
||||||
&& __detail::__cpp17_bidi_iterator<_Iter>
|
|
||||||
struct __cat<_Iter>
|
|
||||||
{ using type = bidirectional_iterator_tag; };
|
|
||||||
|
|
||||||
template<typename _Iter>
|
|
||||||
requires __detail::__iter_without_category<_Iter>
|
|
||||||
&& __detail::__cpp17_fwd_iterator<_Iter>
|
|
||||||
struct __cat<_Iter>
|
|
||||||
{ using type = forward_iterator_tag; };
|
|
||||||
|
|
||||||
template<typename _Iter>
|
|
||||||
struct __ptr
|
|
||||||
{ using type = void; };
|
|
||||||
|
|
||||||
template<typename _Iter> requires requires { typename _Iter::pointer; }
|
|
||||||
struct __ptr<_Iter>
|
|
||||||
{ using type = typename _Iter::pointer; };
|
|
||||||
|
|
||||||
template<typename _Iter>
|
|
||||||
requires (!requires { typename _Iter::pointer; }
|
|
||||||
&& requires(_Iter& __it) { __it.operator->(); })
|
|
||||||
struct __ptr<_Iter>
|
|
||||||
{ using type = decltype(std::declval<_Iter&>().operator->()); };
|
|
||||||
|
|
||||||
template<typename _Iter>
|
|
||||||
struct __ref
|
|
||||||
{ using type = iter_reference_t<_Iter>; };
|
|
||||||
|
|
||||||
template<typename _Iter> requires requires { typename _Iter::reference; }
|
|
||||||
struct __ref<_Iter>
|
|
||||||
{ using type = typename _Iter::reference; };
|
|
||||||
|
|
||||||
public:
|
|
||||||
using iterator_category = typename __cat<_Iterator>::type;
|
|
||||||
using value_type
|
|
||||||
= typename indirectly_readable_traits<_Iterator>::value_type;
|
|
||||||
using difference_type
|
|
||||||
= typename incrementable_traits<_Iterator>::difference_type;
|
|
||||||
using pointer = typename __ptr<_Iterator>::type;
|
|
||||||
using reference = typename __ref<_Iterator>::type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename _Iterator>
|
|
||||||
requires __detail::__iter_without_nested_types<_Iterator>
|
|
||||||
&& __detail::__cpp17_iterator<_Iterator>
|
|
||||||
struct __iterator_traits<_Iterator, void>
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
template<typename _Iter>
|
|
||||||
struct __diff
|
|
||||||
{ using type = void; };
|
|
||||||
|
|
||||||
template<typename _Iter>
|
|
||||||
requires requires
|
|
||||||
{ typename incrementable_traits<_Iter>::difference_type; }
|
|
||||||
struct __diff<_Iter>
|
|
||||||
{
|
|
||||||
using type = typename incrementable_traits<_Iter>::difference_type;
|
|
||||||
};
|
|
||||||
|
|
||||||
public:
|
|
||||||
using iterator_category = output_iterator_tag;
|
|
||||||
using value_type = void;
|
|
||||||
using difference_type = typename __diff<_Iterator>::type;
|
|
||||||
using pointer = void;
|
|
||||||
using reference = void;
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace __detail
|
|
||||||
{
|
|
||||||
template<typename _Iter>
|
|
||||||
struct __iter_concept_impl;
|
|
||||||
|
|
||||||
// ITER_CONCEPT(I) is ITER_TRAITS(I)::iterator_concept if that is valid.
|
|
||||||
template<typename _Iter>
|
|
||||||
requires requires { typename __iter_traits<_Iter>::iterator_concept; }
|
|
||||||
struct __iter_concept_impl<_Iter>
|
|
||||||
{ using type = typename __iter_traits<_Iter>::iterator_concept; };
|
|
||||||
|
|
||||||
// Otherwise, ITER_TRAITS(I)::iterator_category if that is valid.
|
|
||||||
template<typename _Iter>
|
|
||||||
requires (!requires { typename __iter_traits<_Iter>::iterator_concept; }
|
|
||||||
&& requires { typename __iter_traits<_Iter>::iterator_category; })
|
|
||||||
struct __iter_concept_impl<_Iter>
|
|
||||||
{ using type = typename __iter_traits<_Iter>::iterator_category; };
|
|
||||||
|
|
||||||
// Otherwise, random_access_tag if iterator_traits<I> is not specialized.
|
|
||||||
template<typename _Iter>
|
|
||||||
requires (!requires { typename __iter_traits<_Iter>::iterator_concept; }
|
|
||||||
&& !requires { typename __iter_traits<_Iter>::iterator_category; }
|
|
||||||
&& __primary_traits_iter<_Iter>)
|
|
||||||
struct __iter_concept_impl<_Iter>
|
|
||||||
{ using type = random_access_iterator_tag; };
|
|
||||||
|
|
||||||
// Otherwise, there is no ITER_CONCEPT(I) type.
|
|
||||||
template<typename _Iter>
|
|
||||||
struct __iter_concept_impl
|
|
||||||
{ };
|
|
||||||
|
|
||||||
// ITER_CONCEPT
|
|
||||||
template<typename _Iter>
|
|
||||||
using __iter_concept = typename __iter_concept_impl<_Iter>::type;
|
|
||||||
|
|
||||||
template<typename _In>
|
|
||||||
concept __indirectly_readable_impl = requires(const _In __in)
|
|
||||||
{
|
|
||||||
typename iter_value_t<_In>;
|
|
||||||
typename iter_reference_t<_In>;
|
|
||||||
typename iter_rvalue_reference_t<_In>;
|
|
||||||
{ *__in } -> same_as<iter_reference_t<_In>>;
|
|
||||||
{ ranges::iter_move(__in) } -> same_as<iter_rvalue_reference_t<_In>>;
|
|
||||||
}
|
|
||||||
&& common_reference_with<iter_reference_t<_In>&&, iter_value_t<_In>&>
|
|
||||||
&& common_reference_with<iter_reference_t<_In>&&,
|
|
||||||
iter_rvalue_reference_t<_In>&&>
|
|
||||||
&& common_reference_with<iter_rvalue_reference_t<_In>&&,
|
|
||||||
const iter_value_t<_In>&>;
|
|
||||||
|
|
||||||
} // namespace __detail
|
|
||||||
|
|
||||||
/// Requirements for types that are readable by applying operator*.
|
|
||||||
template<typename _In>
|
|
||||||
concept indirectly_readable
|
|
||||||
= __detail::__indirectly_readable_impl<remove_cvref_t<_In>>;
|
|
||||||
|
|
||||||
template<indirectly_readable _Tp>
|
|
||||||
using iter_common_reference_t
|
|
||||||
= common_reference_t<iter_reference_t<_Tp>, iter_value_t<_Tp>&>;
|
|
||||||
|
|
||||||
/// Requirements for writing a value into an iterator's referenced object.
|
|
||||||
template<typename _Out, typename _Tp>
|
|
||||||
concept indirectly_writable = requires(_Out&& __o, _Tp&& __t)
|
|
||||||
{
|
|
||||||
*__o = std::forward<_Tp>(__t);
|
|
||||||
*std::forward<_Out>(__o) = std::forward<_Tp>(__t);
|
|
||||||
const_cast<const iter_reference_t<_Out>&&>(*__o)
|
|
||||||
= std::forward<_Tp>(__t);
|
|
||||||
const_cast<const iter_reference_t<_Out>&&>(*std::forward<_Out>(__o))
|
|
||||||
= std::forward<_Tp>(__t);
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace ranges::__detail
|
|
||||||
{
|
|
||||||
#if __SIZEOF_INT128__
|
|
||||||
using __max_diff_type = __int128;
|
|
||||||
using __max_size_type = unsigned __int128;
|
|
||||||
#else
|
|
||||||
using __max_diff_type = long long;
|
|
||||||
using __max_size_type = unsigned long long;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template<typename _Tp>
|
|
||||||
concept __is_integer_like = integral<_Tp>
|
|
||||||
|| same_as<_Tp, __max_diff_type> || same_as<_Tp, __max_size_type>;
|
|
||||||
|
|
||||||
template<typename _Tp>
|
|
||||||
concept __is_signed_integer_like = signed_integral<_Tp>
|
|
||||||
|| same_as<_Tp, __max_diff_type>;
|
|
||||||
|
|
||||||
} // namespace ranges::__detail
|
|
||||||
|
|
||||||
namespace __detail { using ranges::__detail::__is_signed_integer_like; }
|
|
||||||
|
|
||||||
/// Requirements on types that can be incremented with ++.
|
|
||||||
template<typename _Iter>
|
|
||||||
concept weakly_incrementable = default_initializable<_Iter>
|
|
||||||
&& movable<_Iter>
|
|
||||||
&& requires(_Iter __i)
|
|
||||||
{
|
|
||||||
typename iter_difference_t<_Iter>;
|
|
||||||
requires __detail::__is_signed_integer_like<iter_difference_t<_Iter>>;
|
|
||||||
{ ++__i } -> same_as<_Iter&>;
|
|
||||||
__i++;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename _Iter>
|
|
||||||
concept incrementable = regular<_Iter> && weakly_incrementable<_Iter>
|
|
||||||
&& requires(_Iter __i) { { __i++ } -> same_as<_Iter>; };
|
|
||||||
|
|
||||||
template<typename _Iter>
|
|
||||||
concept input_or_output_iterator
|
|
||||||
= requires(_Iter __i) { { *__i } -> __detail::__can_reference; }
|
|
||||||
&& weakly_incrementable<_Iter>;
|
|
||||||
|
|
||||||
template<typename _Sent, typename _Iter>
|
|
||||||
concept sentinel_for = semiregular<_Sent>
|
|
||||||
&& input_or_output_iterator<_Iter>
|
|
||||||
&& __detail::__weakly_eq_cmp_with<_Sent, _Iter>;
|
|
||||||
|
|
||||||
template<typename _Sent, typename _Iter>
|
|
||||||
inline constexpr bool disable_sized_sentinel_for = false;
|
|
||||||
|
|
||||||
template<typename _Sent, typename _Iter>
|
|
||||||
concept sized_sentinel_for = sentinel_for<_Sent, _Iter>
|
|
||||||
&& !disable_sized_sentinel_for<remove_cv_t<_Sent>, remove_cv_t<_Iter>>
|
|
||||||
&& requires(const _Iter& __i, const _Sent& __s)
|
|
||||||
{
|
|
||||||
{ __s - __i } -> same_as<iter_difference_t<_Iter>>;
|
|
||||||
{ __i - __s } -> same_as<iter_difference_t<_Iter>>;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename _Iter>
|
|
||||||
concept input_iterator = input_or_output_iterator<_Iter>
|
|
||||||
&& indirectly_readable<_Iter>
|
|
||||||
&& requires { typename __detail::__iter_concept<_Iter>; }
|
|
||||||
&& derived_from<__detail::__iter_concept<_Iter>, input_iterator_tag>;
|
|
||||||
|
|
||||||
template<typename _Iter, typename _Tp>
|
|
||||||
concept output_iterator = input_or_output_iterator<_Iter>
|
|
||||||
&& indirectly_writable<_Iter, _Tp>
|
|
||||||
&& requires(_Iter __i, _Tp&& __t) { *__i++ = std::forward<_Tp>(__t); };
|
|
||||||
|
|
||||||
template<typename _Iter>
|
|
||||||
concept forward_iterator = input_iterator<_Iter>
|
|
||||||
&& derived_from<__detail::__iter_concept<_Iter>, forward_iterator_tag>
|
|
||||||
&& incrementable<_Iter> && sentinel_for<_Iter, _Iter>;
|
|
||||||
|
|
||||||
template<typename _Iter>
|
|
||||||
concept bidirectional_iterator = forward_iterator<_Iter>
|
|
||||||
&& derived_from<__detail::__iter_concept<_Iter>,
|
|
||||||
bidirectional_iterator_tag>
|
|
||||||
&& requires(_Iter __i)
|
|
||||||
{
|
|
||||||
{ --__i } -> same_as<_Iter&>;
|
|
||||||
{ __i-- } -> same_as<_Iter>;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename _Iter>
|
|
||||||
concept random_access_iterator = bidirectional_iterator<_Iter>
|
|
||||||
&& derived_from<__detail::__iter_concept<_Iter>,
|
|
||||||
random_access_iterator_tag>
|
|
||||||
&& totally_ordered<_Iter> && sized_sentinel_for<_Iter, _Iter>
|
|
||||||
&& requires(_Iter __i, const _Iter __j,
|
|
||||||
const iter_difference_t<_Iter> __n)
|
|
||||||
{
|
|
||||||
{ __i += __n } -> same_as<_Iter&>;
|
|
||||||
{ __j + __n } -> same_as<_Iter>;
|
|
||||||
{ __n + __j } -> same_as<_Iter>;
|
|
||||||
{ __i -= __n } -> same_as<_Iter&>;
|
|
||||||
{ __j - __n } -> same_as<_Iter>;
|
|
||||||
{ __j[__n] } -> same_as<iter_reference_t<_Iter>>;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename _Iter>
|
|
||||||
concept contiguous_iterator = random_access_iterator<_Iter>
|
|
||||||
&& derived_from<__detail::__iter_concept<_Iter>, contiguous_iterator_tag>
|
|
||||||
&& is_lvalue_reference_v<iter_reference_t<_Iter>>
|
|
||||||
&& same_as<iter_value_t<_Iter>, remove_cvref_t<iter_reference_t<_Iter>>>
|
|
||||||
&& requires(const _Iter& __i)
|
|
||||||
{
|
|
||||||
{ std::to_address(__i) }
|
|
||||||
-> same_as<add_pointer_t<iter_reference_t<_Iter>>>;
|
|
||||||
};
|
|
||||||
|
|
||||||
// [indirectcallable], indirect callable requirements
|
|
||||||
|
|
||||||
// [indirectcallable.indirectinvocable], indirect callables
|
|
||||||
|
|
||||||
template<typename _Fn, typename _Iter>
|
|
||||||
concept indirectly_unary_invocable = indirectly_readable<_Iter>
|
|
||||||
&& copy_constructible<_Fn> && invocable<_Fn&, iter_value_t<_Iter>&>
|
|
||||||
&& invocable<_Fn&, iter_reference_t<_Iter>>
|
|
||||||
&& invocable<_Fn&, iter_common_reference_t<_Iter>>
|
|
||||||
&& common_reference_with<invoke_result_t<_Fn&, iter_value_t<_Iter>&>,
|
|
||||||
invoke_result_t<_Fn&, iter_reference_t<_Iter>>>;
|
|
||||||
|
|
||||||
template<typename _Fn, typename _Iter>
|
|
||||||
concept indirectly_regular_unary_invocable = indirectly_readable<_Iter>
|
|
||||||
&& copy_constructible<_Fn>
|
|
||||||
&& regular_invocable<_Fn&, iter_value_t<_Iter>&>
|
|
||||||
&& regular_invocable<_Fn&, iter_reference_t<_Iter>>
|
|
||||||
&& regular_invocable<_Fn&, iter_common_reference_t<_Iter>>
|
|
||||||
&& common_reference_with<invoke_result_t<_Fn&, iter_value_t<_Iter>&>,
|
|
||||||
invoke_result_t<_Fn&, iter_reference_t<_Iter>>>;
|
|
||||||
|
|
||||||
template<typename _Fn, typename _Iter>
|
|
||||||
concept indirect_unary_predicate = indirectly_readable<_Iter>
|
|
||||||
&& copy_constructible<_Fn> && predicate<_Fn&, iter_value_t<_Iter>&>
|
|
||||||
&& predicate<_Fn&, iter_reference_t<_Iter>>
|
|
||||||
&& predicate<_Fn&, iter_common_reference_t<_Iter>>;
|
|
||||||
|
|
||||||
template<typename _Fn, typename _I1, typename _I2>
|
|
||||||
concept indirect_binary_predicate
|
|
||||||
= indirectly_readable<_I1> && indirectly_readable<_I2>
|
|
||||||
&& copy_constructible<_Fn>
|
|
||||||
&& predicate<_Fn&, iter_value_t<_I1>&, iter_value_t<_I2>&>
|
|
||||||
&& predicate<_Fn&, iter_value_t<_I1>&, iter_reference_t<_I2>>
|
|
||||||
&& predicate<_Fn&, iter_reference_t<_I1>, iter_value_t<_I2>&>
|
|
||||||
&& predicate<_Fn&, iter_reference_t<_I1>, iter_reference_t<_I2>>
|
|
||||||
&& predicate<_Fn&, iter_common_reference_t<_I1>,
|
|
||||||
iter_common_reference_t<_I2>>;
|
|
||||||
|
|
||||||
template<typename _Fn, typename _I1, typename _I2 = _I1>
|
|
||||||
concept indirect_equivalence_relation
|
|
||||||
= indirectly_readable<_I1> && indirectly_readable<_I2>
|
|
||||||
&& copy_constructible<_Fn>
|
|
||||||
&& equivalence_relation<_Fn&, iter_value_t<_I1>&, iter_value_t<_I2>&>
|
|
||||||
&& equivalence_relation<_Fn&, iter_value_t<_I1>&, iter_reference_t<_I2>>
|
|
||||||
&& equivalence_relation<_Fn&, iter_reference_t<_I1>, iter_value_t<_I2>&>
|
|
||||||
&& equivalence_relation<_Fn&, iter_reference_t<_I1>,
|
|
||||||
iter_reference_t<_I2>>
|
|
||||||
&& equivalence_relation<_Fn&, iter_common_reference_t<_I1>,
|
|
||||||
iter_common_reference_t<_I2>>;
|
|
||||||
|
|
||||||
template<typename _Fn, typename _I1, typename _I2 = _I1>
|
|
||||||
concept indirect_strict_weak_order
|
|
||||||
= indirectly_readable<_I1> && indirectly_readable<_I2>
|
|
||||||
&& copy_constructible<_Fn>
|
|
||||||
&& strict_weak_order<_Fn&, iter_value_t<_I1>&, iter_value_t<_I2>&>
|
|
||||||
&& strict_weak_order<_Fn&, iter_value_t<_I1>&, iter_reference_t<_I2>>
|
|
||||||
&& strict_weak_order<_Fn&, iter_reference_t<_I1>, iter_value_t<_I2>&>
|
|
||||||
&& strict_weak_order<_Fn&, iter_reference_t<_I1>, iter_reference_t<_I2>>
|
|
||||||
&& strict_weak_order<_Fn&, iter_common_reference_t<_I1>,
|
|
||||||
iter_common_reference_t<_I2>>;
|
|
||||||
|
|
||||||
template<typename _Fn, typename... _Is>
|
|
||||||
requires (indirectly_readable<_Is> && ...)
|
|
||||||
&& invocable<_Fn, iter_reference_t<_Is>...>
|
|
||||||
using indirect_result_t = invoke_result_t<_Fn, iter_reference_t<_Is>...>;
|
|
||||||
|
|
||||||
/// [projected], projected
|
|
||||||
template<indirectly_readable _Iter,
|
|
||||||
indirectly_regular_unary_invocable<_Iter> _Proj>
|
|
||||||
struct projected
|
|
||||||
{
|
|
||||||
using value_type = remove_cvref_t<indirect_result_t<_Proj&, _Iter>>;
|
|
||||||
|
|
||||||
indirect_result_t<_Proj&, _Iter> operator*() const; // not defined
|
|
||||||
};
|
|
||||||
|
|
||||||
template<weakly_incrementable _Iter, typename _Proj>
|
|
||||||
struct incrementable_traits<projected<_Iter, _Proj>>
|
|
||||||
{ using difference_type = iter_difference_t<_Iter>; };
|
|
||||||
|
|
||||||
// [alg.req], common algorithm requirements
|
|
||||||
|
|
||||||
/// [alg.req.ind.move], concept `indirectly_movable`
|
|
||||||
|
|
||||||
template<typename _In, typename _Out>
|
|
||||||
concept indirectly_movable = indirectly_readable<_In>
|
|
||||||
&& indirectly_writable<_Out, iter_rvalue_reference_t<_In>>;
|
|
||||||
|
|
||||||
template<typename _In, typename _Out>
|
|
||||||
concept indirectly_movable_storable = indirectly_movable<_In, _Out>
|
|
||||||
&& indirectly_writable<_Out, iter_value_t<_In>>
|
|
||||||
&& movable<iter_value_t<_In>>
|
|
||||||
&& constructible_from<iter_value_t<_In>, iter_rvalue_reference_t<_In>>
|
|
||||||
&& assignable_from<iter_value_t<_In>&, iter_rvalue_reference_t<_In>>;
|
|
||||||
|
|
||||||
/// [alg.req.ind.copy], concept `indirectly_copyable`
|
|
||||||
template<typename _In, typename _Out>
|
|
||||||
concept indirectly_copyable = indirectly_readable<_In>
|
|
||||||
&& indirectly_writable<_Out, iter_reference_t<_In>>;
|
|
||||||
|
|
||||||
template<typename _In, typename _Out>
|
|
||||||
concept indirectly_copyable_storable = indirectly_copyable<_In, _Out>
|
|
||||||
&& indirectly_writable<_Out, iter_value_t<_In>&>
|
|
||||||
&& indirectly_writable<_Out, const iter_value_t<_In>&>
|
|
||||||
&& indirectly_writable<_Out, iter_value_t<_In>&&>
|
|
||||||
&& indirectly_writable<_Out, const iter_value_t<_In>&&>
|
|
||||||
&& copyable<iter_value_t<_In>>
|
|
||||||
&& constructible_from<iter_value_t<_In>, iter_reference_t<_In>>
|
|
||||||
&& assignable_from<iter_value_t<_In>&, iter_reference_t<_In>>;
|
|
||||||
|
|
||||||
namespace ranges
|
|
||||||
{
|
|
||||||
namespace __cust_iswap
|
|
||||||
{
|
|
||||||
template<typename _It1, typename _It2>
|
|
||||||
void iter_swap(_It1, _It2) = delete;
|
|
||||||
|
|
||||||
template<typename _Tp, typename _Up>
|
|
||||||
concept __adl_iswap
|
|
||||||
= (std::__detail::__class_or_enum<remove_reference_t<_Tp>>
|
|
||||||
|| std::__detail::__class_or_enum<remove_reference_t<_Up>>)
|
|
||||||
&& requires(_Tp&& __t, _Up&& __u) {
|
|
||||||
iter_swap(static_cast<_Tp&&>(__t), static_cast<_Up&&>(__u));
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename _Xp, typename _Yp>
|
|
||||||
constexpr iter_value_t<_Xp>
|
|
||||||
__iter_exchange_move(_Xp&& __x, _Yp&& __y)
|
|
||||||
noexcept(noexcept(iter_value_t<_Xp>(iter_move(__x)))
|
|
||||||
&& noexcept(*__x = iter_move(__y)))
|
|
||||||
{
|
|
||||||
iter_value_t<_Xp> __old_value(iter_move(__x));
|
|
||||||
*__x = iter_move(__y);
|
|
||||||
return __old_value;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct _IterSwap
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
template<typename _Tp, typename _Up>
|
|
||||||
static constexpr bool
|
|
||||||
_S_noexcept()
|
|
||||||
{
|
|
||||||
if constexpr (__adl_iswap<_Tp, _Up>)
|
|
||||||
return noexcept(iter_swap(std::declval<_Tp>(),
|
|
||||||
std::declval<_Up>()));
|
|
||||||
else if constexpr (indirectly_readable<_Tp>
|
|
||||||
&& indirectly_readable<_Up>
|
|
||||||
&& swappable_with<iter_reference_t<_Tp>, iter_reference_t<_Up>>)
|
|
||||||
return noexcept(ranges::swap(*std::declval<_Tp>(),
|
|
||||||
*std::declval<_Up>()));
|
|
||||||
else
|
|
||||||
return noexcept(*std::declval<_Tp>()
|
|
||||||
= __iter_exchange_move(std::declval<_Up>(),
|
|
||||||
std::declval<_Tp>()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
template<typename _Tp, typename _Up>
|
|
||||||
requires __adl_iswap<_Tp, _Up>
|
|
||||||
|| (indirectly_readable<remove_reference_t<_Tp>>
|
|
||||||
&& indirectly_readable<remove_reference_t<_Up>>
|
|
||||||
&& swappable_with<iter_reference_t<_Tp>, iter_reference_t<_Up>>)
|
|
||||||
|| (indirectly_movable_storable<_Tp, _Up>
|
|
||||||
&& indirectly_movable_storable<_Up, _Tp>)
|
|
||||||
constexpr void
|
|
||||||
operator()(_Tp&& __e1, _Up&& __e2) const
|
|
||||||
noexcept(_S_noexcept<_Tp, _Up>())
|
|
||||||
{
|
|
||||||
if constexpr (__adl_iswap<_Tp, _Up>)
|
|
||||||
iter_swap(static_cast<_Tp&&>(__e1), static_cast<_Up&&>(__e2));
|
|
||||||
else if constexpr (indirectly_readable<_Tp>
|
|
||||||
&& indirectly_readable<_Up>
|
|
||||||
&& swappable_with<iter_reference_t<_Tp>, iter_reference_t<_Up>>)
|
|
||||||
ranges::swap(*__e1, *__e2);
|
|
||||||
else
|
|
||||||
*__e1 = __iter_exchange_move(__e2, __e1);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} // namespace __cust_iswap
|
|
||||||
|
|
||||||
inline namespace __cust
|
|
||||||
{
|
|
||||||
inline constexpr __cust_iswap::_IterSwap iter_swap{};
|
|
||||||
} // inline namespace __cust
|
|
||||||
|
|
||||||
} // namespace ranges
|
|
||||||
|
|
||||||
/// [alg.req.ind.swap], concept `indirectly_swappable`
|
|
||||||
template<typename _I1, typename _I2 = _I1>
|
|
||||||
concept indirectly_swappable
|
|
||||||
= indirectly_readable<_I1> && indirectly_readable<_I2>
|
|
||||||
&& requires(const _I1 __i1, const _I2 __i2)
|
|
||||||
{
|
|
||||||
ranges::iter_swap(__i1, __i1);
|
|
||||||
ranges::iter_swap(__i2, __i2);
|
|
||||||
ranges::iter_swap(__i1, __i2);
|
|
||||||
ranges::iter_swap(__i2, __i1);
|
|
||||||
};
|
|
||||||
|
|
||||||
/// [alg.req.ind.cmp], concept `indirectly_comparable`
|
|
||||||
template<typename _I1, typename _I2, typename _Rel, typename _P1 = identity,
|
|
||||||
typename _P2 = identity>
|
|
||||||
concept indirectly_comparable
|
|
||||||
= indirect_binary_predicate<_Rel, projected<_I1, _P1>,
|
|
||||||
projected<_I2, _P2>>;
|
|
||||||
|
|
||||||
/// [alg.req.permutable], concept `permutable`
|
|
||||||
template<typename _Iter>
|
|
||||||
concept permutable = forward_iterator<_Iter>
|
|
||||||
&& indirectly_movable_storable<_Iter, _Iter>
|
|
||||||
&& indirectly_swappable<_Iter, _Iter>;
|
|
||||||
|
|
||||||
/// [alg.req.mergeable], concept `mergeable`
|
|
||||||
template<typename _I1, typename _I2, typename _Out,
|
|
||||||
typename _Rel = ranges::less, typename _P1 = identity,
|
|
||||||
typename _P2 = identity>
|
|
||||||
concept mergeable = input_iterator<_I1> && input_iterator<_I2>
|
|
||||||
&& weakly_incrementable<_Out> && indirectly_copyable<_I1, _Out>
|
|
||||||
&& indirectly_copyable<_I2, _Out>
|
|
||||||
&& indirect_strict_weak_order<_Rel, projected<_I1, _P1>,
|
|
||||||
projected<_I2, _P2>>;
|
|
||||||
|
|
||||||
/// [alg.req.sortable], concept `sortable`
|
|
||||||
template<typename _Iter, typename _Rel = ranges::less,
|
|
||||||
typename _Proj = identity>
|
|
||||||
concept sortable = permutable<_Iter>
|
|
||||||
&& indirect_strict_weak_order<_Rel, projected<_Iter, _Proj>>;
|
|
||||||
|
|
||||||
struct unreachable_sentinel_t
|
|
||||||
{
|
|
||||||
template<weakly_incrementable _It>
|
|
||||||
friend constexpr bool
|
|
||||||
operator==(unreachable_sentinel_t, const _It&) noexcept
|
|
||||||
{ return false; }
|
|
||||||
};
|
|
||||||
|
|
||||||
inline constexpr unreachable_sentinel_t unreachable_sentinel{};
|
|
||||||
|
|
||||||
struct default_sentinel_t { };
|
|
||||||
inline constexpr default_sentinel_t default_sentinel{};
|
|
||||||
|
|
||||||
namespace __detail
|
|
||||||
{
|
|
||||||
template<typename _Tp>
|
|
||||||
constexpr decay_t<_Tp>
|
|
||||||
__decay_copy(_Tp&& __t)
|
|
||||||
noexcept(is_nothrow_convertible_v<_Tp, decay_t<_Tp>>)
|
|
||||||
{ return std::forward<_Tp>(__t); }
|
|
||||||
|
|
||||||
template<typename _Tp>
|
|
||||||
concept __member_begin = requires(_Tp& __t)
|
|
||||||
{
|
|
||||||
{ __detail::__decay_copy(__t.begin()) } -> input_or_output_iterator;
|
|
||||||
};
|
|
||||||
|
|
||||||
void begin(auto&) = delete;
|
|
||||||
void begin(const auto&) = delete;
|
|
||||||
|
|
||||||
template<typename _Tp>
|
|
||||||
concept __adl_begin = __class_or_enum<remove_reference_t<_Tp>>
|
|
||||||
&& requires(_Tp& __t)
|
|
||||||
{
|
|
||||||
{ __detail::__decay_copy(begin(__t)) } -> input_or_output_iterator;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Simplified version of std::ranges::begin that only supports lvalues,
|
|
||||||
// for use by __range_iter_t below.
|
|
||||||
template<typename _Tp>
|
|
||||||
requires is_array_v<_Tp> || __member_begin<_Tp&> || __adl_begin<_Tp&>
|
|
||||||
auto
|
|
||||||
__ranges_begin(_Tp& __t)
|
|
||||||
{
|
|
||||||
if constexpr (is_array_v<_Tp>)
|
|
||||||
{
|
|
||||||
static_assert(sizeof(remove_all_extents_t<_Tp>) != 0,
|
|
||||||
"not array of incomplete type");
|
|
||||||
return __t + 0;
|
|
||||||
}
|
|
||||||
else if constexpr (__member_begin<_Tp&>)
|
|
||||||
return __t.begin();
|
|
||||||
else
|
|
||||||
return begin(__t);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Implementation of std::ranges::iterator_t, without using ranges::begin.
|
|
||||||
template<typename _Tp>
|
|
||||||
using __range_iter_t
|
|
||||||
= decltype(__detail::__ranges_begin(std::declval<_Tp&>()));
|
|
||||||
|
|
||||||
} // namespace __detail
|
|
||||||
|
|
||||||
_GLIBCXX_END_NAMESPACE_VERSION
|
|
||||||
} // namespace std
|
|
||||||
#endif // C++20 library concepts
|
|
||||||
#endif // _ITERATOR_CONCEPTS_H
|
|
Binary file not shown.
@ -1,855 +0,0 @@
|
|||||||
// Locale support -*- C++ -*-
|
|
||||||
|
|
||||||
// Copyright (C) 1997-2020 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.
|
|
||||||
|
|
||||||
// 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 bits/locale_classes.h
|
|
||||||
* This is an internal header file, included by other library headers.
|
|
||||||
* Do not attempt to use it directly. @headername{locale}
|
|
||||||
*/
|
|
||||||
|
|
||||||
//
|
|
||||||
// ISO C++ 14882: 22.1 Locales
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef _LOCALE_CLASSES_H
|
|
||||||
#define _LOCALE_CLASSES_H 1
|
|
||||||
|
|
||||||
#pragma GCC system_header
|
|
||||||
|
|
||||||
#include <bits/localefwd.h>
|
|
||||||
#include <string>
|
|
||||||
#include <ext/atomicity.h>
|
|
||||||
|
|
||||||
namespace std _GLIBCXX_VISIBILITY(default)
|
|
||||||
{
|
|
||||||
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|
||||||
|
|
||||||
// 22.1.1 Class locale
|
|
||||||
/**
|
|
||||||
* @brief Container class for localization functionality.
|
|
||||||
* @ingroup locales
|
|
||||||
*
|
|
||||||
* The locale class is first a class wrapper for C library locales. It is
|
|
||||||
* also an extensible container for user-defined localization. A locale is
|
|
||||||
* a collection of facets that implement various localization features such
|
|
||||||
* as money, time, and number printing.
|
|
||||||
*
|
|
||||||
* Constructing C++ locales does not change the C library locale.
|
|
||||||
*
|
|
||||||
* This library supports efficient construction and copying of locales
|
|
||||||
* through a reference counting implementation of the locale class.
|
|
||||||
*/
|
|
||||||
class locale
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
// Types:
|
|
||||||
/// Definition of locale::category.
|
|
||||||
typedef int category;
|
|
||||||
|
|
||||||
// Forward decls and friends:
|
|
||||||
class facet;
|
|
||||||
class id;
|
|
||||||
class _Impl;
|
|
||||||
|
|
||||||
friend class facet;
|
|
||||||
friend class _Impl;
|
|
||||||
|
|
||||||
template<typename _Facet>
|
|
||||||
friend bool
|
|
||||||
has_facet(const locale&) throw();
|
|
||||||
|
|
||||||
template<typename _Facet>
|
|
||||||
friend const _Facet&
|
|
||||||
use_facet(const locale&);
|
|
||||||
|
|
||||||
template<typename _Cache>
|
|
||||||
friend struct __use_cache;
|
|
||||||
|
|
||||||
//@{
|
|
||||||
/**
|
|
||||||
* @brief Category values.
|
|
||||||
*
|
|
||||||
* The standard category values are none, ctype, numeric, collate, time,
|
|
||||||
* monetary, and messages. They form a bitmask that supports union and
|
|
||||||
* intersection. The category all is the union of these values.
|
|
||||||
*
|
|
||||||
* NB: Order must match _S_facet_categories definition in locale.cc
|
|
||||||
*/
|
|
||||||
static const category none = 0;
|
|
||||||
static const category ctype = 1L << 0;
|
|
||||||
static const category numeric = 1L << 1;
|
|
||||||
static const category collate = 1L << 2;
|
|
||||||
static const category time = 1L << 3;
|
|
||||||
static const category monetary = 1L << 4;
|
|
||||||
static const category messages = 1L << 5;
|
|
||||||
static const category all = (ctype | numeric | collate |
|
|
||||||
time | monetary | messages);
|
|
||||||
//@}
|
|
||||||
|
|
||||||
// Construct/copy/destroy:
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Default constructor.
|
|
||||||
*
|
|
||||||
* Constructs a copy of the global locale. If no locale has been
|
|
||||||
* explicitly set, this is the C locale.
|
|
||||||
*/
|
|
||||||
locale() throw();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Copy constructor.
|
|
||||||
*
|
|
||||||
* Constructs a copy of @a other.
|
|
||||||
*
|
|
||||||
* @param __other The locale to copy.
|
|
||||||
*/
|
|
||||||
locale(const locale& __other) throw();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Named locale constructor.
|
|
||||||
*
|
|
||||||
* Constructs a copy of the named C library locale.
|
|
||||||
*
|
|
||||||
* @param __s Name of the locale to construct.
|
|
||||||
* @throw std::runtime_error if __s is null or an undefined locale.
|
|
||||||
*/
|
|
||||||
explicit
|
|
||||||
locale(const char* __s);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Construct locale with facets from another locale.
|
|
||||||
*
|
|
||||||
* Constructs a copy of the locale @a base. The facets specified by @a
|
|
||||||
* cat are replaced with those from the locale named by @a s. If base is
|
|
||||||
* named, this locale instance will also be named.
|
|
||||||
*
|
|
||||||
* @param __base The locale to copy.
|
|
||||||
* @param __s Name of the locale to use facets from.
|
|
||||||
* @param __cat Set of categories defining the facets to use from __s.
|
|
||||||
* @throw std::runtime_error if __s is null or an undefined locale.
|
|
||||||
*/
|
|
||||||
locale(const locale& __base, const char* __s, category __cat);
|
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
/**
|
|
||||||
* @brief Named locale constructor.
|
|
||||||
*
|
|
||||||
* Constructs a copy of the named C library locale.
|
|
||||||
*
|
|
||||||
* @param __s Name of the locale to construct.
|
|
||||||
* @throw std::runtime_error if __s is an undefined locale.
|
|
||||||
*/
|
|
||||||
explicit
|
|
||||||
locale(const std::string& __s) : locale(__s.c_str()) { }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Construct locale with facets from another locale.
|
|
||||||
*
|
|
||||||
* Constructs a copy of the locale @a base. The facets specified by @a
|
|
||||||
* cat are replaced with those from the locale named by @a s. If base is
|
|
||||||
* named, this locale instance will also be named.
|
|
||||||
*
|
|
||||||
* @param __base The locale to copy.
|
|
||||||
* @param __s Name of the locale to use facets from.
|
|
||||||
* @param __cat Set of categories defining the facets to use from __s.
|
|
||||||
* @throw std::runtime_error if __s is an undefined locale.
|
|
||||||
*/
|
|
||||||
locale(const locale& __base, const std::string& __s, category __cat)
|
|
||||||
: locale(__base, __s.c_str(), __cat) { }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Construct locale with facets from another locale.
|
|
||||||
*
|
|
||||||
* Constructs a copy of the locale @a base. The facets specified by @a
|
|
||||||
* cat are replaced with those from the locale @a add. If @a base and @a
|
|
||||||
* add are named, this locale instance will also be named.
|
|
||||||
*
|
|
||||||
* @param __base The locale to copy.
|
|
||||||
* @param __add The locale to use facets from.
|
|
||||||
* @param __cat Set of categories defining the facets to use from add.
|
|
||||||
*/
|
|
||||||
locale(const locale& __base, const locale& __add, category __cat);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Construct locale with another facet.
|
|
||||||
*
|
|
||||||
* Constructs a copy of the locale @a __other. The facet @a __f
|
|
||||||
* is added to @a __other, replacing an existing facet of type
|
|
||||||
* Facet if there is one. If @a __f is null, this locale is a
|
|
||||||
* copy of @a __other.
|
|
||||||
*
|
|
||||||
* @param __other The locale to copy.
|
|
||||||
* @param __f The facet to add in.
|
|
||||||
*/
|
|
||||||
template<typename _Facet>
|
|
||||||
locale(const locale& __other, _Facet* __f);
|
|
||||||
|
|
||||||
/// Locale destructor.
|
|
||||||
~locale() throw();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Assignment operator.
|
|
||||||
*
|
|
||||||
* Set this locale to be a copy of @a other.
|
|
||||||
*
|
|
||||||
* @param __other The locale to copy.
|
|
||||||
* @return A reference to this locale.
|
|
||||||
*/
|
|
||||||
const locale&
|
|
||||||
operator=(const locale& __other) throw();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Construct locale with another facet.
|
|
||||||
*
|
|
||||||
* Constructs and returns a new copy of this locale. Adds or replaces an
|
|
||||||
* existing facet of type Facet from the locale @a other into the new
|
|
||||||
* locale.
|
|
||||||
*
|
|
||||||
* @tparam _Facet The facet type to copy from other
|
|
||||||
* @param __other The locale to copy from.
|
|
||||||
* @return Newly constructed locale.
|
|
||||||
* @throw std::runtime_error if __other has no facet of type _Facet.
|
|
||||||
*/
|
|
||||||
template<typename _Facet>
|
|
||||||
locale
|
|
||||||
combine(const locale& __other) const;
|
|
||||||
|
|
||||||
// Locale operations:
|
|
||||||
/**
|
|
||||||
* @brief Return locale name.
|
|
||||||
* @return Locale name or "*" if unnamed.
|
|
||||||
*/
|
|
||||||
_GLIBCXX_DEFAULT_ABI_TAG
|
|
||||||
string
|
|
||||||
name() const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Locale equality.
|
|
||||||
*
|
|
||||||
* @param __other The locale to compare against.
|
|
||||||
* @return True if other and this refer to the same locale instance, are
|
|
||||||
* copies, or have the same name. False otherwise.
|
|
||||||
*/
|
|
||||||
bool
|
|
||||||
operator==(const locale& __other) const throw();
|
|
||||||
|
|
||||||
#if __cpp_impl_three_way_comparison < 201907L
|
|
||||||
/**
|
|
||||||
* @brief Locale inequality.
|
|
||||||
*
|
|
||||||
* @param __other The locale to compare against.
|
|
||||||
* @return ! (*this == __other)
|
|
||||||
*/
|
|
||||||
bool
|
|
||||||
operator!=(const locale& __other) const throw()
|
|
||||||
{ return !(this->operator==(__other)); }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Compare two strings according to collate.
|
|
||||||
*
|
|
||||||
* Template operator to compare two strings using the compare function of
|
|
||||||
* the collate facet in this locale. One use is to provide the locale to
|
|
||||||
* the sort function. For example, a vector v of strings could be sorted
|
|
||||||
* according to locale loc by doing:
|
|
||||||
* @code
|
|
||||||
* std::sort(v.begin(), v.end(), loc);
|
|
||||||
* @endcode
|
|
||||||
*
|
|
||||||
* @param __s1 First string to compare.
|
|
||||||
* @param __s2 Second string to compare.
|
|
||||||
* @return True if collate<_Char> facet compares __s1 < __s2, else false.
|
|
||||||
*/
|
|
||||||
template<typename _Char, typename _Traits, typename _Alloc>
|
|
||||||
bool
|
|
||||||
operator()(const basic_string<_Char, _Traits, _Alloc>& __s1,
|
|
||||||
const basic_string<_Char, _Traits, _Alloc>& __s2) const;
|
|
||||||
|
|
||||||
// Global locale objects:
|
|
||||||
/**
|
|
||||||
* @brief Set global locale
|
|
||||||
*
|
|
||||||
* This function sets the global locale to the argument and returns a
|
|
||||||
* copy of the previous global locale. If the argument has a name, it
|
|
||||||
* will also call std::setlocale(LC_ALL, loc.name()).
|
|
||||||
*
|
|
||||||
* @param __loc The new locale to make global.
|
|
||||||
* @return Copy of the old global locale.
|
|
||||||
*/
|
|
||||||
static locale
|
|
||||||
global(const locale& __loc);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Return reference to the C locale.
|
|
||||||
*/
|
|
||||||
static const locale&
|
|
||||||
classic();
|
|
||||||
|
|
||||||
private:
|
|
||||||
// The (shared) implementation
|
|
||||||
_Impl* _M_impl;
|
|
||||||
|
|
||||||
// The "C" reference locale
|
|
||||||
static _Impl* _S_classic;
|
|
||||||
|
|
||||||
// Current global locale
|
|
||||||
static _Impl* _S_global;
|
|
||||||
|
|
||||||
// Names of underlying locale categories.
|
|
||||||
// NB: locale::global() has to know how to modify all the
|
|
||||||
// underlying categories, not just the ones required by the C++
|
|
||||||
// standard.
|
|
||||||
static const char* const* const _S_categories;
|
|
||||||
|
|
||||||
// Number of standard categories. For C++, these categories are
|
|
||||||
// collate, ctype, monetary, numeric, time, and messages. These
|
|
||||||
// directly correspond to ISO C99 macros LC_COLLATE, LC_CTYPE,
|
|
||||||
// LC_MONETARY, LC_NUMERIC, and LC_TIME. In addition, POSIX (IEEE
|
|
||||||
// 1003.1-2001) specifies LC_MESSAGES.
|
|
||||||
// In addition to the standard categories, the underlying
|
|
||||||
// operating system is allowed to define extra LC_*
|
|
||||||
// macros. For GNU systems, the following are also valid:
|
|
||||||
// LC_PAPER, LC_NAME, LC_ADDRESS, LC_TELEPHONE, LC_MEASUREMENT,
|
|
||||||
// and LC_IDENTIFICATION.
|
|
||||||
enum { _S_categories_size = 6 + _GLIBCXX_NUM_CATEGORIES };
|
|
||||||
|
|
||||||
#ifdef __GTHREADS
|
|
||||||
static __gthread_once_t _S_once;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
explicit
|
|
||||||
locale(_Impl*) throw();
|
|
||||||
|
|
||||||
static void
|
|
||||||
_S_initialize();
|
|
||||||
|
|
||||||
static void
|
|
||||||
_S_initialize_once() throw();
|
|
||||||
|
|
||||||
static category
|
|
||||||
_S_normalize_category(category);
|
|
||||||
|
|
||||||
void
|
|
||||||
_M_coalesce(const locale& __base, const locale& __add, category __cat);
|
|
||||||
|
|
||||||
#if _GLIBCXX_USE_CXX11_ABI
|
|
||||||
static const id* const _S_twinned_facets[];
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// 22.1.1.1.2 Class locale::facet
|
|
||||||
/**
|
|
||||||
* @brief Localization functionality base class.
|
|
||||||
* @ingroup locales
|
|
||||||
*
|
|
||||||
* The facet class is the base class for a localization feature, such as
|
|
||||||
* money, time, and number printing. It provides common support for facets
|
|
||||||
* and reference management.
|
|
||||||
*
|
|
||||||
* Facets may not be copied or assigned.
|
|
||||||
*/
|
|
||||||
class locale::facet
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
friend class locale;
|
|
||||||
friend class locale::_Impl;
|
|
||||||
|
|
||||||
mutable _Atomic_word _M_refcount;
|
|
||||||
|
|
||||||
// Contains data from the underlying "C" library for the classic locale.
|
|
||||||
static __c_locale _S_c_locale;
|
|
||||||
|
|
||||||
// String literal for the name of the classic locale.
|
|
||||||
static const char _S_c_name[2];
|
|
||||||
|
|
||||||
#ifdef __GTHREADS
|
|
||||||
static __gthread_once_t _S_once;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void
|
|
||||||
_S_initialize_once();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
/**
|
|
||||||
* @brief Facet constructor.
|
|
||||||
*
|
|
||||||
* This is the constructor provided by the standard. If refs is 0, the
|
|
||||||
* facet is destroyed when the last referencing locale is destroyed.
|
|
||||||
* Otherwise the facet will never be destroyed.
|
|
||||||
*
|
|
||||||
* @param __refs The initial value for reference count.
|
|
||||||
*/
|
|
||||||
explicit
|
|
||||||
facet(size_t __refs = 0) throw() : _M_refcount(__refs ? 1 : 0)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
/// Facet destructor.
|
|
||||||
virtual
|
|
||||||
~facet();
|
|
||||||
|
|
||||||
static void
|
|
||||||
_S_create_c_locale(__c_locale& __cloc, const char* __s,
|
|
||||||
__c_locale __old = 0);
|
|
||||||
|
|
||||||
static __c_locale
|
|
||||||
_S_clone_c_locale(__c_locale& __cloc) throw();
|
|
||||||
|
|
||||||
static void
|
|
||||||
_S_destroy_c_locale(__c_locale& __cloc);
|
|
||||||
|
|
||||||
static __c_locale
|
|
||||||
_S_lc_ctype_c_locale(__c_locale __cloc, const char* __s);
|
|
||||||
|
|
||||||
// Returns data from the underlying "C" library data for the
|
|
||||||
// classic locale.
|
|
||||||
static __c_locale
|
|
||||||
_S_get_c_locale();
|
|
||||||
|
|
||||||
_GLIBCXX_CONST static const char*
|
|
||||||
_S_get_c_name() throw();
|
|
||||||
|
|
||||||
#if __cplusplus < 201103L
|
|
||||||
private:
|
|
||||||
facet(const facet&); // Not defined.
|
|
||||||
|
|
||||||
facet&
|
|
||||||
operator=(const facet&); // Not defined.
|
|
||||||
#else
|
|
||||||
facet(const facet&) = delete;
|
|
||||||
|
|
||||||
facet&
|
|
||||||
operator=(const facet&) = delete;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
private:
|
|
||||||
void
|
|
||||||
_M_add_reference() const throw()
|
|
||||||
{ __gnu_cxx::__atomic_add_dispatch(&_M_refcount, 1); }
|
|
||||||
|
|
||||||
void
|
|
||||||
_M_remove_reference() const throw()
|
|
||||||
{
|
|
||||||
// Be race-detector-friendly. For more info see bits/c++config.
|
|
||||||
_GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_refcount);
|
|
||||||
if (__gnu_cxx::__exchange_and_add_dispatch(&_M_refcount, -1) == 1)
|
|
||||||
{
|
|
||||||
_GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_refcount);
|
|
||||||
__try
|
|
||||||
{ delete this; }
|
|
||||||
__catch(...)
|
|
||||||
{ }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const facet* _M_sso_shim(const id*) const;
|
|
||||||
const facet* _M_cow_shim(const id*) const;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
class __shim; // For internal use only.
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// 22.1.1.1.3 Class locale::id
|
|
||||||
/**
|
|
||||||
* @brief Facet ID class.
|
|
||||||
* @ingroup locales
|
|
||||||
*
|
|
||||||
* The ID class provides facets with an index used to identify them.
|
|
||||||
* Every facet class must define a public static member locale::id, or be
|
|
||||||
* derived from a facet that provides this member, otherwise the facet
|
|
||||||
* cannot be used in a locale. The locale::id ensures that each class
|
|
||||||
* type gets a unique identifier.
|
|
||||||
*/
|
|
||||||
class locale::id
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
friend class locale;
|
|
||||||
friend class locale::_Impl;
|
|
||||||
|
|
||||||
template<typename _Facet>
|
|
||||||
friend const _Facet&
|
|
||||||
use_facet(const locale&);
|
|
||||||
|
|
||||||
template<typename _Facet>
|
|
||||||
friend bool
|
|
||||||
has_facet(const locale&) throw();
|
|
||||||
|
|
||||||
// NB: There is no accessor for _M_index because it may be used
|
|
||||||
// before the constructor is run; the effect of calling a member
|
|
||||||
// function (even an inline) would be undefined.
|
|
||||||
mutable size_t _M_index;
|
|
||||||
|
|
||||||
// Last id number assigned.
|
|
||||||
static _Atomic_word _S_refcount;
|
|
||||||
|
|
||||||
void
|
|
||||||
operator=(const id&); // Not defined.
|
|
||||||
|
|
||||||
id(const id&); // Not defined.
|
|
||||||
|
|
||||||
public:
|
|
||||||
// NB: This class is always a static data member, and thus can be
|
|
||||||
// counted on to be zero-initialized.
|
|
||||||
/// Constructor.
|
|
||||||
id() { }
|
|
||||||
|
|
||||||
size_t
|
|
||||||
_M_id() const throw();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// Implementation object for locale.
|
|
||||||
class locale::_Impl
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
// Friends.
|
|
||||||
friend class locale;
|
|
||||||
friend class locale::facet;
|
|
||||||
|
|
||||||
template<typename _Facet>
|
|
||||||
friend bool
|
|
||||||
has_facet(const locale&) throw();
|
|
||||||
|
|
||||||
template<typename _Facet>
|
|
||||||
friend const _Facet&
|
|
||||||
use_facet(const locale&);
|
|
||||||
|
|
||||||
template<typename _Cache>
|
|
||||||
friend struct __use_cache;
|
|
||||||
|
|
||||||
private:
|
|
||||||
// Data Members.
|
|
||||||
_Atomic_word _M_refcount;
|
|
||||||
const facet** _M_facets;
|
|
||||||
size_t _M_facets_size;
|
|
||||||
const facet** _M_caches;
|
|
||||||
char** _M_names;
|
|
||||||
static const locale::id* const _S_id_ctype[];
|
|
||||||
static const locale::id* const _S_id_numeric[];
|
|
||||||
static const locale::id* const _S_id_collate[];
|
|
||||||
static const locale::id* const _S_id_time[];
|
|
||||||
static const locale::id* const _S_id_monetary[];
|
|
||||||
static const locale::id* const _S_id_messages[];
|
|
||||||
static const locale::id* const* const _S_facet_categories[];
|
|
||||||
|
|
||||||
void
|
|
||||||
_M_add_reference() throw()
|
|
||||||
{ __gnu_cxx::__atomic_add_dispatch(&_M_refcount, 1); }
|
|
||||||
|
|
||||||
void
|
|
||||||
_M_remove_reference() throw()
|
|
||||||
{
|
|
||||||
// Be race-detector-friendly. For more info see bits/c++config.
|
|
||||||
_GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_refcount);
|
|
||||||
if (__gnu_cxx::__exchange_and_add_dispatch(&_M_refcount, -1) == 1)
|
|
||||||
{
|
|
||||||
_GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_refcount);
|
|
||||||
__try
|
|
||||||
{ delete this; }
|
|
||||||
__catch(...)
|
|
||||||
{ }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_Impl(const _Impl&, size_t);
|
|
||||||
_Impl(const char*, size_t);
|
|
||||||
_Impl(size_t) throw();
|
|
||||||
|
|
||||||
~_Impl() throw();
|
|
||||||
|
|
||||||
_Impl(const _Impl&); // Not defined.
|
|
||||||
|
|
||||||
void
|
|
||||||
operator=(const _Impl&); // Not defined.
|
|
||||||
|
|
||||||
bool
|
|
||||||
_M_check_same_name()
|
|
||||||
{
|
|
||||||
bool __ret = true;
|
|
||||||
if (_M_names[1])
|
|
||||||
// We must actually compare all the _M_names: can be all equal!
|
|
||||||
for (size_t __i = 0; __ret && __i < _S_categories_size - 1; ++__i)
|
|
||||||
__ret = __builtin_strcmp(_M_names[__i], _M_names[__i + 1]) == 0;
|
|
||||||
return __ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
_M_replace_categories(const _Impl*, category);
|
|
||||||
|
|
||||||
void
|
|
||||||
_M_replace_category(const _Impl*, const locale::id* const*);
|
|
||||||
|
|
||||||
void
|
|
||||||
_M_replace_facet(const _Impl*, const locale::id*);
|
|
||||||
|
|
||||||
void
|
|
||||||
_M_install_facet(const locale::id*, const facet*);
|
|
||||||
|
|
||||||
template<typename _Facet>
|
|
||||||
void
|
|
||||||
_M_init_facet(_Facet* __facet)
|
|
||||||
{ _M_install_facet(&_Facet::id, __facet); }
|
|
||||||
|
|
||||||
template<typename _Facet>
|
|
||||||
void
|
|
||||||
_M_init_facet_unchecked(_Facet* __facet)
|
|
||||||
{
|
|
||||||
__facet->_M_add_reference();
|
|
||||||
_M_facets[_Facet::id._M_id()] = __facet;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
_M_install_cache(const facet*, size_t);
|
|
||||||
|
|
||||||
void _M_init_extra(facet**);
|
|
||||||
void _M_init_extra(void*, void*, const char*, const char*);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Facet for localized string comparison.
|
|
||||||
*
|
|
||||||
* This facet encapsulates the code to compare strings in a localized
|
|
||||||
* manner.
|
|
||||||
*
|
|
||||||
* The collate template uses protected virtual functions to provide
|
|
||||||
* the actual results. The public accessors forward the call to
|
|
||||||
* the virtual functions. These virtual functions are hooks for
|
|
||||||
* developers to implement the behavior they require from the
|
|
||||||
* collate facet.
|
|
||||||
*/
|
|
||||||
template<typename _CharT>
|
|
||||||
class _GLIBCXX_NAMESPACE_CXX11 collate : public locale::facet
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
// Types:
|
|
||||||
//@{
|
|
||||||
/// Public typedefs
|
|
||||||
typedef _CharT char_type;
|
|
||||||
typedef basic_string<_CharT> string_type;
|
|
||||||
//@}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
// Underlying "C" library locale information saved from
|
|
||||||
// initialization, needed by collate_byname as well.
|
|
||||||
__c_locale _M_c_locale_collate;
|
|
||||||
|
|
||||||
public:
|
|
||||||
/// Numpunct facet id.
|
|
||||||
static locale::id id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Constructor performs initialization.
|
|
||||||
*
|
|
||||||
* This is the constructor provided by the standard.
|
|
||||||
*
|
|
||||||
* @param __refs Passed to the base facet class.
|
|
||||||
*/
|
|
||||||
explicit
|
|
||||||
collate(size_t __refs = 0)
|
|
||||||
: facet(__refs), _M_c_locale_collate(_S_get_c_locale())
|
|
||||||
{ }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Internal constructor. Not for general use.
|
|
||||||
*
|
|
||||||
* This is a constructor for use by the library itself to set up new
|
|
||||||
* locales.
|
|
||||||
*
|
|
||||||
* @param __cloc The C locale.
|
|
||||||
* @param __refs Passed to the base facet class.
|
|
||||||
*/
|
|
||||||
explicit
|
|
||||||
collate(__c_locale __cloc, size_t __refs = 0)
|
|
||||||
: facet(__refs), _M_c_locale_collate(_S_clone_c_locale(__cloc))
|
|
||||||
{ }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Compare two strings.
|
|
||||||
*
|
|
||||||
* This function compares two strings and returns the result by calling
|
|
||||||
* collate::do_compare().
|
|
||||||
*
|
|
||||||
* @param __lo1 Start of string 1.
|
|
||||||
* @param __hi1 End of string 1.
|
|
||||||
* @param __lo2 Start of string 2.
|
|
||||||
* @param __hi2 End of string 2.
|
|
||||||
* @return 1 if string1 > string2, -1 if string1 < string2, else 0.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
compare(const _CharT* __lo1, const _CharT* __hi1,
|
|
||||||
const _CharT* __lo2, const _CharT* __hi2) const
|
|
||||||
{ return this->do_compare(__lo1, __hi1, __lo2, __hi2); }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Transform string to comparable form.
|
|
||||||
*
|
|
||||||
* This function is a wrapper for strxfrm functionality. It takes the
|
|
||||||
* input string and returns a modified string that can be directly
|
|
||||||
* compared to other transformed strings. In the C locale, this
|
|
||||||
* function just returns a copy of the input string. In some other
|
|
||||||
* locales, it may replace two chars with one, change a char for
|
|
||||||
* another, etc. It does so by returning collate::do_transform().
|
|
||||||
*
|
|
||||||
* @param __lo Start of string.
|
|
||||||
* @param __hi End of string.
|
|
||||||
* @return Transformed string_type.
|
|
||||||
*/
|
|
||||||
string_type
|
|
||||||
transform(const _CharT* __lo, const _CharT* __hi) const
|
|
||||||
{ return this->do_transform(__lo, __hi); }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Return hash of a string.
|
|
||||||
*
|
|
||||||
* This function computes and returns a hash on the input string. It
|
|
||||||
* does so by returning collate::do_hash().
|
|
||||||
*
|
|
||||||
* @param __lo Start of string.
|
|
||||||
* @param __hi End of string.
|
|
||||||
* @return Hash value.
|
|
||||||
*/
|
|
||||||
long
|
|
||||||
hash(const _CharT* __lo, const _CharT* __hi) const
|
|
||||||
{ return this->do_hash(__lo, __hi); }
|
|
||||||
|
|
||||||
// Used to abstract out _CharT bits in virtual member functions, below.
|
|
||||||
int
|
|
||||||
_M_compare(const _CharT*, const _CharT*) const throw();
|
|
||||||
|
|
||||||
size_t
|
|
||||||
_M_transform(_CharT*, const _CharT*, size_t) const throw();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
/// Destructor.
|
|
||||||
virtual
|
|
||||||
~collate()
|
|
||||||
{ _S_destroy_c_locale(_M_c_locale_collate); }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Compare two strings.
|
|
||||||
*
|
|
||||||
* This function is a hook for derived classes to change the value
|
|
||||||
* returned. @see compare().
|
|
||||||
*
|
|
||||||
* @param __lo1 Start of string 1.
|
|
||||||
* @param __hi1 End of string 1.
|
|
||||||
* @param __lo2 Start of string 2.
|
|
||||||
* @param __hi2 End of string 2.
|
|
||||||
* @return 1 if string1 > string2, -1 if string1 < string2, else 0.
|
|
||||||
*/
|
|
||||||
virtual int
|
|
||||||
do_compare(const _CharT* __lo1, const _CharT* __hi1,
|
|
||||||
const _CharT* __lo2, const _CharT* __hi2) const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Transform string to comparable form.
|
|
||||||
*
|
|
||||||
* This function is a hook for derived classes to change the value
|
|
||||||
* returned.
|
|
||||||
*
|
|
||||||
* @param __lo Start.
|
|
||||||
* @param __hi End.
|
|
||||||
* @return transformed string.
|
|
||||||
*/
|
|
||||||
virtual string_type
|
|
||||||
do_transform(const _CharT* __lo, const _CharT* __hi) const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Return hash of a string.
|
|
||||||
*
|
|
||||||
* This function computes and returns a hash on the input string. This
|
|
||||||
* function is a hook for derived classes to change the value returned.
|
|
||||||
*
|
|
||||||
* @param __lo Start of string.
|
|
||||||
* @param __hi End of string.
|
|
||||||
* @return Hash value.
|
|
||||||
*/
|
|
||||||
virtual long
|
|
||||||
do_hash(const _CharT* __lo, const _CharT* __hi) const;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename _CharT>
|
|
||||||
locale::id collate<_CharT>::id;
|
|
||||||
|
|
||||||
// Specializations.
|
|
||||||
template<>
|
|
||||||
int
|
|
||||||
collate<char>::_M_compare(const char*, const char*) const throw();
|
|
||||||
|
|
||||||
template<>
|
|
||||||
size_t
|
|
||||||
collate<char>::_M_transform(char*, const char*, size_t) const throw();
|
|
||||||
|
|
||||||
#ifdef _GLIBCXX_USE_WCHAR_T
|
|
||||||
template<>
|
|
||||||
int
|
|
||||||
collate<wchar_t>::_M_compare(const wchar_t*, const wchar_t*) const throw();
|
|
||||||
|
|
||||||
template<>
|
|
||||||
size_t
|
|
||||||
collate<wchar_t>::_M_transform(wchar_t*, const wchar_t*, size_t) const throw();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/// class collate_byname [22.2.4.2].
|
|
||||||
template<typename _CharT>
|
|
||||||
class _GLIBCXX_NAMESPACE_CXX11 collate_byname : public collate<_CharT>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
//@{
|
|
||||||
/// Public typedefs
|
|
||||||
typedef _CharT char_type;
|
|
||||||
typedef basic_string<_CharT> string_type;
|
|
||||||
//@}
|
|
||||||
|
|
||||||
explicit
|
|
||||||
collate_byname(const char* __s, size_t __refs = 0)
|
|
||||||
: collate<_CharT>(__refs)
|
|
||||||
{
|
|
||||||
if (__builtin_strcmp(__s, "C") != 0
|
|
||||||
&& __builtin_strcmp(__s, "POSIX") != 0)
|
|
||||||
{
|
|
||||||
this->_S_destroy_c_locale(this->_M_c_locale_collate);
|
|
||||||
this->_S_create_c_locale(this->_M_c_locale_collate, __s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
explicit
|
|
||||||
collate_byname(const string& __s, size_t __refs = 0)
|
|
||||||
: collate_byname(__s.c_str(), __refs) { }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual
|
|
||||||
~collate_byname() { }
|
|
||||||
};
|
|
||||||
|
|
||||||
_GLIBCXX_END_NAMESPACE_VERSION
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
# include <bits/locale_classes.tcc>
|
|
||||||
|
|
||||||
#endif
|
|
Binary file not shown.
@ -1,298 +0,0 @@
|
|||||||
// Locale support -*- C++ -*-
|
|
||||||
|
|
||||||
// Copyright (C) 2007-2020 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.
|
|
||||||
|
|
||||||
// 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 bits/locale_classes.tcc
|
|
||||||
* This is an internal header file, included by other library headers.
|
|
||||||
* Do not attempt to use it directly. @headername{locale}
|
|
||||||
*/
|
|
||||||
|
|
||||||
//
|
|
||||||
// ISO C++ 14882: 22.1 Locales
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef _LOCALE_CLASSES_TCC
|
|
||||||
#define _LOCALE_CLASSES_TCC 1
|
|
||||||
|
|
||||||
#pragma GCC system_header
|
|
||||||
|
|
||||||
namespace std _GLIBCXX_VISIBILITY(default)
|
|
||||||
{
|
|
||||||
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|
||||||
|
|
||||||
template<typename _Facet>
|
|
||||||
locale::
|
|
||||||
locale(const locale& __other, _Facet* __f)
|
|
||||||
{
|
|
||||||
_M_impl = new _Impl(*__other._M_impl, 1);
|
|
||||||
|
|
||||||
__try
|
|
||||||
{ _M_impl->_M_install_facet(&_Facet::id, __f); }
|
|
||||||
__catch(...)
|
|
||||||
{
|
|
||||||
_M_impl->_M_remove_reference();
|
|
||||||
__throw_exception_again;
|
|
||||||
}
|
|
||||||
delete [] _M_impl->_M_names[0];
|
|
||||||
_M_impl->_M_names[0] = 0; // Unnamed.
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename _Facet>
|
|
||||||
locale
|
|
||||||
locale::
|
|
||||||
combine(const locale& __other) const
|
|
||||||
{
|
|
||||||
_Impl* __tmp = new _Impl(*_M_impl, 1);
|
|
||||||
__try
|
|
||||||
{
|
|
||||||
__tmp->_M_replace_facet(__other._M_impl, &_Facet::id);
|
|
||||||
}
|
|
||||||
__catch(...)
|
|
||||||
{
|
|
||||||
__tmp->_M_remove_reference();
|
|
||||||
__throw_exception_again;
|
|
||||||
}
|
|
||||||
return locale(__tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename _CharT, typename _Traits, typename _Alloc>
|
|
||||||
bool
|
|
||||||
locale::
|
|
||||||
operator()(const basic_string<_CharT, _Traits, _Alloc>& __s1,
|
|
||||||
const basic_string<_CharT, _Traits, _Alloc>& __s2) const
|
|
||||||
{
|
|
||||||
typedef std::collate<_CharT> __collate_type;
|
|
||||||
const __collate_type& __collate = use_facet<__collate_type>(*this);
|
|
||||||
return (__collate.compare(__s1.data(), __s1.data() + __s1.length(),
|
|
||||||
__s2.data(), __s2.data() + __s2.length()) < 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Test for the presence of a facet.
|
|
||||||
* @ingroup locales
|
|
||||||
*
|
|
||||||
* has_facet tests the locale argument for the presence of the facet type
|
|
||||||
* provided as the template parameter. Facets derived from the facet
|
|
||||||
* parameter will also return true.
|
|
||||||
*
|
|
||||||
* @tparam _Facet The facet type to test the presence of.
|
|
||||||
* @param __loc The locale to test.
|
|
||||||
* @return true if @p __loc contains a facet of type _Facet, else false.
|
|
||||||
*/
|
|
||||||
template<typename _Facet>
|
|
||||||
bool
|
|
||||||
has_facet(const locale& __loc) throw()
|
|
||||||
{
|
|
||||||
const size_t __i = _Facet::id._M_id();
|
|
||||||
const locale::facet** __facets = __loc._M_impl->_M_facets;
|
|
||||||
return (__i < __loc._M_impl->_M_facets_size
|
|
||||||
#if __cpp_rtti
|
|
||||||
&& dynamic_cast<const _Facet*>(__facets[__i]));
|
|
||||||
#else
|
|
||||||
&& static_cast<const _Facet*>(__facets[__i]));
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Return a facet.
|
|
||||||
* @ingroup locales
|
|
||||||
*
|
|
||||||
* use_facet looks for and returns a reference to a facet of type Facet
|
|
||||||
* where Facet is the template parameter. If has_facet(locale) is true,
|
|
||||||
* there is a suitable facet to return. It throws std::bad_cast if the
|
|
||||||
* locale doesn't contain a facet of type Facet.
|
|
||||||
*
|
|
||||||
* @tparam _Facet The facet type to access.
|
|
||||||
* @param __loc The locale to use.
|
|
||||||
* @return Reference to facet of type Facet.
|
|
||||||
* @throw std::bad_cast if @p __loc doesn't contain a facet of type _Facet.
|
|
||||||
*/
|
|
||||||
template<typename _Facet>
|
|
||||||
const _Facet&
|
|
||||||
use_facet(const locale& __loc)
|
|
||||||
{
|
|
||||||
const size_t __i = _Facet::id._M_id();
|
|
||||||
const locale::facet** __facets = __loc._M_impl->_M_facets;
|
|
||||||
if (__i >= __loc._M_impl->_M_facets_size || !__facets[__i])
|
|
||||||
__throw_bad_cast();
|
|
||||||
#if __cpp_rtti
|
|
||||||
return dynamic_cast<const _Facet&>(*__facets[__i]);
|
|
||||||
#else
|
|
||||||
return static_cast<const _Facet&>(*__facets[__i]);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Generic version does nothing.
|
|
||||||
template<typename _CharT>
|
|
||||||
int
|
|
||||||
collate<_CharT>::_M_compare(const _CharT*, const _CharT*) const throw ()
|
|
||||||
{ return 0; }
|
|
||||||
|
|
||||||
// Generic version does nothing.
|
|
||||||
template<typename _CharT>
|
|
||||||
size_t
|
|
||||||
collate<_CharT>::_M_transform(_CharT*, const _CharT*, size_t) const throw ()
|
|
||||||
{ return 0; }
|
|
||||||
|
|
||||||
template<typename _CharT>
|
|
||||||
int
|
|
||||||
collate<_CharT>::
|
|
||||||
do_compare(const _CharT* __lo1, const _CharT* __hi1,
|
|
||||||
const _CharT* __lo2, const _CharT* __hi2) const
|
|
||||||
{
|
|
||||||
// strcoll assumes zero-terminated strings so we make a copy
|
|
||||||
// and then put a zero at the end.
|
|
||||||
const string_type __one(__lo1, __hi1);
|
|
||||||
const string_type __two(__lo2, __hi2);
|
|
||||||
|
|
||||||
const _CharT* __p = __one.c_str();
|
|
||||||
const _CharT* __pend = __one.data() + __one.length();
|
|
||||||
const _CharT* __q = __two.c_str();
|
|
||||||
const _CharT* __qend = __two.data() + __two.length();
|
|
||||||
|
|
||||||
// strcoll stops when it sees a nul character so we break
|
|
||||||
// the strings into zero-terminated substrings and pass those
|
|
||||||
// to strcoll.
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
const int __res = _M_compare(__p, __q);
|
|
||||||
if (__res)
|
|
||||||
return __res;
|
|
||||||
|
|
||||||
__p += char_traits<_CharT>::length(__p);
|
|
||||||
__q += char_traits<_CharT>::length(__q);
|
|
||||||
if (__p == __pend && __q == __qend)
|
|
||||||
return 0;
|
|
||||||
else if (__p == __pend)
|
|
||||||
return -1;
|
|
||||||
else if (__q == __qend)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
__p++;
|
|
||||||
__q++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename _CharT>
|
|
||||||
typename collate<_CharT>::string_type
|
|
||||||
collate<_CharT>::
|
|
||||||
do_transform(const _CharT* __lo, const _CharT* __hi) const
|
|
||||||
{
|
|
||||||
string_type __ret;
|
|
||||||
|
|
||||||
// strxfrm assumes zero-terminated strings so we make a copy
|
|
||||||
const string_type __str(__lo, __hi);
|
|
||||||
|
|
||||||
const _CharT* __p = __str.c_str();
|
|
||||||
const _CharT* __pend = __str.data() + __str.length();
|
|
||||||
|
|
||||||
size_t __len = (__hi - __lo) * 2;
|
|
||||||
|
|
||||||
_CharT* __c = new _CharT[__len];
|
|
||||||
|
|
||||||
__try
|
|
||||||
{
|
|
||||||
// strxfrm stops when it sees a nul character so we break
|
|
||||||
// the string into zero-terminated substrings and pass those
|
|
||||||
// to strxfrm.
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
// First try a buffer perhaps big enough.
|
|
||||||
size_t __res = _M_transform(__c, __p, __len);
|
|
||||||
// If the buffer was not large enough, try again with the
|
|
||||||
// correct size.
|
|
||||||
if (__res >= __len)
|
|
||||||
{
|
|
||||||
__len = __res + 1;
|
|
||||||
delete [] __c, __c = 0;
|
|
||||||
__c = new _CharT[__len];
|
|
||||||
__res = _M_transform(__c, __p, __len);
|
|
||||||
}
|
|
||||||
|
|
||||||
__ret.append(__c, __res);
|
|
||||||
__p += char_traits<_CharT>::length(__p);
|
|
||||||
if (__p == __pend)
|
|
||||||
break;
|
|
||||||
|
|
||||||
__p++;
|
|
||||||
__ret.push_back(_CharT());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
__catch(...)
|
|
||||||
{
|
|
||||||
delete [] __c;
|
|
||||||
__throw_exception_again;
|
|
||||||
}
|
|
||||||
|
|
||||||
delete [] __c;
|
|
||||||
|
|
||||||
return __ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename _CharT>
|
|
||||||
long
|
|
||||||
collate<_CharT>::
|
|
||||||
do_hash(const _CharT* __lo, const _CharT* __hi) const
|
|
||||||
{
|
|
||||||
unsigned long __val = 0;
|
|
||||||
for (; __lo < __hi; ++__lo)
|
|
||||||
__val =
|
|
||||||
*__lo + ((__val << 7)
|
|
||||||
| (__val >> (__gnu_cxx::__numeric_traits<unsigned long>::
|
|
||||||
__digits - 7)));
|
|
||||||
return static_cast<long>(__val);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Inhibit implicit instantiations for required instantiations,
|
|
||||||
// which are defined via explicit instantiations elsewhere.
|
|
||||||
#if _GLIBCXX_EXTERN_TEMPLATE
|
|
||||||
extern template class collate<char>;
|
|
||||||
extern template class collate_byname<char>;
|
|
||||||
|
|
||||||
extern template
|
|
||||||
const collate<char>&
|
|
||||||
use_facet<collate<char> >(const locale&);
|
|
||||||
|
|
||||||
extern template
|
|
||||||
bool
|
|
||||||
has_facet<collate<char> >(const locale&);
|
|
||||||
|
|
||||||
#ifdef _GLIBCXX_USE_WCHAR_T
|
|
||||||
extern template class collate<wchar_t>;
|
|
||||||
extern template class collate_byname<wchar_t>;
|
|
||||||
|
|
||||||
extern template
|
|
||||||
const collate<wchar_t>&
|
|
||||||
use_facet<collate<wchar_t> >(const locale&);
|
|
||||||
|
|
||||||
extern template
|
|
||||||
bool
|
|
||||||
has_facet<collate<wchar_t> >(const locale&);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
_GLIBCXX_END_NAMESPACE_VERSION
|
|
||||||
} // namespace std
|
|
||||||
|
|
||||||
#endif
|
|
Binary file not shown.
@ -1,618 +0,0 @@
|
|||||||
// wstring_convert implementation -*- C++ -*-
|
|
||||||
|
|
||||||
// Copyright (C) 2015-2020 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.
|
|
||||||
|
|
||||||
// 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 bits/locale_conv.h
|
|
||||||
* This is an internal header file, included by other library headers.
|
|
||||||
* Do not attempt to use it directly. @headername{locale}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _LOCALE_CONV_H
|
|
||||||
#define _LOCALE_CONV_H 1
|
|
||||||
|
|
||||||
#if __cplusplus < 201103L
|
|
||||||
# include <bits/c++0x_warning.h>
|
|
||||||
#else
|
|
||||||
|
|
||||||
#include <streambuf>
|
|
||||||
#include <bits/stringfwd.h>
|
|
||||||
#include <bits/allocator.h>
|
|
||||||
#include <bits/codecvt.h>
|
|
||||||
#include <bits/unique_ptr.h>
|
|
||||||
|
|
||||||
namespace std _GLIBCXX_VISIBILITY(default)
|
|
||||||
{
|
|
||||||
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @addtogroup locales
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
template<typename _OutStr, typename _InChar, typename _Codecvt,
|
|
||||||
typename _State, typename _Fn>
|
|
||||||
bool
|
|
||||||
__do_str_codecvt(const _InChar* __first, const _InChar* __last,
|
|
||||||
_OutStr& __outstr, const _Codecvt& __cvt, _State& __state,
|
|
||||||
size_t& __count, _Fn __fn)
|
|
||||||
{
|
|
||||||
if (__first == __last)
|
|
||||||
{
|
|
||||||
__outstr.clear();
|
|
||||||
__count = 0;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t __outchars = 0;
|
|
||||||
auto __next = __first;
|
|
||||||
const auto __maxlen = __cvt.max_length() + 1;
|
|
||||||
|
|
||||||
codecvt_base::result __result;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
__outstr.resize(__outstr.size() + (__last - __next) * __maxlen);
|
|
||||||
auto __outnext = &__outstr.front() + __outchars;
|
|
||||||
auto const __outlast = &__outstr.back() + 1;
|
|
||||||
__result = (__cvt.*__fn)(__state, __next, __last, __next,
|
|
||||||
__outnext, __outlast, __outnext);
|
|
||||||
__outchars = __outnext - &__outstr.front();
|
|
||||||
}
|
|
||||||
while (__result == codecvt_base::partial && __next != __last
|
|
||||||
&& (__outstr.size() - __outchars) < __maxlen);
|
|
||||||
|
|
||||||
if (__result == codecvt_base::error)
|
|
||||||
{
|
|
||||||
__count = __next - __first;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// The codecvt facet will only return noconv when the types are
|
|
||||||
// the same, so avoid instantiating basic_string::assign otherwise
|
|
||||||
if _GLIBCXX17_CONSTEXPR (is_same<typename _Codecvt::intern_type,
|
|
||||||
typename _Codecvt::extern_type>())
|
|
||||||
if (__result == codecvt_base::noconv)
|
|
||||||
{
|
|
||||||
__outstr.assign(__first, __last);
|
|
||||||
__count = __last - __first;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
__outstr.resize(__outchars);
|
|
||||||
__count = __next - __first;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert narrow character string to wide.
|
|
||||||
template<typename _CharT, typename _Traits, typename _Alloc, typename _State>
|
|
||||||
inline bool
|
|
||||||
__str_codecvt_in(const char* __first, const char* __last,
|
|
||||||
basic_string<_CharT, _Traits, _Alloc>& __outstr,
|
|
||||||
const codecvt<_CharT, char, _State>& __cvt,
|
|
||||||
_State& __state, size_t& __count)
|
|
||||||
{
|
|
||||||
using _Codecvt = codecvt<_CharT, char, _State>;
|
|
||||||
using _ConvFn
|
|
||||||
= codecvt_base::result
|
|
||||||
(_Codecvt::*)(_State&, const char*, const char*, const char*&,
|
|
||||||
_CharT*, _CharT*, _CharT*&) const;
|
|
||||||
_ConvFn __fn = &codecvt<_CharT, char, _State>::in;
|
|
||||||
return __do_str_codecvt(__first, __last, __outstr, __cvt, __state,
|
|
||||||
__count, __fn);
|
|
||||||
}
|
|
||||||
|
|
||||||
// As above, but with no __count parameter
|
|
||||||
template<typename _CharT, typename _Traits, typename _Alloc, typename _State>
|
|
||||||
inline bool
|
|
||||||
__str_codecvt_in(const char* __first, const char* __last,
|
|
||||||
basic_string<_CharT, _Traits, _Alloc>& __outstr,
|
|
||||||
const codecvt<_CharT, char, _State>& __cvt)
|
|
||||||
{
|
|
||||||
_State __state = {};
|
|
||||||
size_t __n;
|
|
||||||
return __str_codecvt_in(__first, __last, __outstr, __cvt, __state, __n);
|
|
||||||
}
|
|
||||||
|
|
||||||
// As above, but returns false for partial conversion
|
|
||||||
template<typename _CharT, typename _Traits, typename _Alloc, typename _State>
|
|
||||||
inline bool
|
|
||||||
__str_codecvt_in_all(const char* __first, const char* __last,
|
|
||||||
basic_string<_CharT, _Traits, _Alloc>& __outstr,
|
|
||||||
const codecvt<_CharT, char, _State>& __cvt)
|
|
||||||
{
|
|
||||||
_State __state = {};
|
|
||||||
size_t __n;
|
|
||||||
return __str_codecvt_in(__first, __last, __outstr, __cvt, __state, __n)
|
|
||||||
&& (__n == (__last - __first));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert wide character string to narrow.
|
|
||||||
template<typename _CharT, typename _Traits, typename _Alloc, typename _State>
|
|
||||||
inline bool
|
|
||||||
__str_codecvt_out(const _CharT* __first, const _CharT* __last,
|
|
||||||
basic_string<char, _Traits, _Alloc>& __outstr,
|
|
||||||
const codecvt<_CharT, char, _State>& __cvt,
|
|
||||||
_State& __state, size_t& __count)
|
|
||||||
{
|
|
||||||
using _Codecvt = codecvt<_CharT, char, _State>;
|
|
||||||
using _ConvFn
|
|
||||||
= codecvt_base::result
|
|
||||||
(_Codecvt::*)(_State&, const _CharT*, const _CharT*, const _CharT*&,
|
|
||||||
char*, char*, char*&) const;
|
|
||||||
_ConvFn __fn = &codecvt<_CharT, char, _State>::out;
|
|
||||||
return __do_str_codecvt(__first, __last, __outstr, __cvt, __state,
|
|
||||||
__count, __fn);
|
|
||||||
}
|
|
||||||
|
|
||||||
// As above, but with no __count parameter
|
|
||||||
template<typename _CharT, typename _Traits, typename _Alloc, typename _State>
|
|
||||||
inline bool
|
|
||||||
__str_codecvt_out(const _CharT* __first, const _CharT* __last,
|
|
||||||
basic_string<char, _Traits, _Alloc>& __outstr,
|
|
||||||
const codecvt<_CharT, char, _State>& __cvt)
|
|
||||||
{
|
|
||||||
_State __state = {};
|
|
||||||
size_t __n;
|
|
||||||
return __str_codecvt_out(__first, __last, __outstr, __cvt, __state, __n);
|
|
||||||
}
|
|
||||||
|
|
||||||
// As above, but returns false for partial conversions
|
|
||||||
template<typename _CharT, typename _Traits, typename _Alloc, typename _State>
|
|
||||||
inline bool
|
|
||||||
__str_codecvt_out_all(const _CharT* __first, const _CharT* __last,
|
|
||||||
basic_string<char, _Traits, _Alloc>& __outstr,
|
|
||||||
const codecvt<_CharT, char, _State>& __cvt)
|
|
||||||
{
|
|
||||||
_State __state = {};
|
|
||||||
size_t __n;
|
|
||||||
return __str_codecvt_out(__first, __last, __outstr, __cvt, __state, __n)
|
|
||||||
&& (__n == (__last - __first));
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef _GLIBCXX_USE_CHAR8_T
|
|
||||||
|
|
||||||
// Convert wide character string to narrow.
|
|
||||||
template<typename _CharT, typename _Traits, typename _Alloc, typename _State>
|
|
||||||
inline bool
|
|
||||||
__str_codecvt_out(const _CharT* __first, const _CharT* __last,
|
|
||||||
basic_string<char8_t, _Traits, _Alloc>& __outstr,
|
|
||||||
const codecvt<_CharT, char8_t, _State>& __cvt,
|
|
||||||
_State& __state, size_t& __count)
|
|
||||||
{
|
|
||||||
using _Codecvt = codecvt<_CharT, char8_t, _State>;
|
|
||||||
using _ConvFn
|
|
||||||
= codecvt_base::result
|
|
||||||
(_Codecvt::*)(_State&, const _CharT*, const _CharT*, const _CharT*&,
|
|
||||||
char8_t*, char8_t*, char8_t*&) const;
|
|
||||||
_ConvFn __fn = &codecvt<_CharT, char8_t, _State>::out;
|
|
||||||
return __do_str_codecvt(__first, __last, __outstr, __cvt, __state,
|
|
||||||
__count, __fn);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename _CharT, typename _Traits, typename _Alloc, typename _State>
|
|
||||||
inline bool
|
|
||||||
__str_codecvt_out(const _CharT* __first, const _CharT* __last,
|
|
||||||
basic_string<char8_t, _Traits, _Alloc>& __outstr,
|
|
||||||
const codecvt<_CharT, char8_t, _State>& __cvt)
|
|
||||||
{
|
|
||||||
_State __state = {};
|
|
||||||
size_t __n;
|
|
||||||
return __str_codecvt_out(__first, __last, __outstr, __cvt, __state, __n);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // _GLIBCXX_USE_CHAR8_T
|
|
||||||
|
|
||||||
#ifdef _GLIBCXX_USE_WCHAR_T
|
|
||||||
|
|
||||||
_GLIBCXX_BEGIN_NAMESPACE_CXX11
|
|
||||||
|
|
||||||
/// String conversions
|
|
||||||
template<typename _Codecvt, typename _Elem = wchar_t,
|
|
||||||
typename _Wide_alloc = allocator<_Elem>,
|
|
||||||
typename _Byte_alloc = allocator<char>>
|
|
||||||
class wstring_convert
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef basic_string<char, char_traits<char>, _Byte_alloc> byte_string;
|
|
||||||
typedef basic_string<_Elem, char_traits<_Elem>, _Wide_alloc> wide_string;
|
|
||||||
typedef typename _Codecvt::state_type state_type;
|
|
||||||
typedef typename wide_string::traits_type::int_type int_type;
|
|
||||||
|
|
||||||
/// Default constructor.
|
|
||||||
wstring_convert() : _M_cvt(new _Codecvt()) { }
|
|
||||||
|
|
||||||
/** Constructor.
|
|
||||||
*
|
|
||||||
* @param __pcvt The facet to use for conversions.
|
|
||||||
*
|
|
||||||
* Takes ownership of @p __pcvt and will delete it in the destructor.
|
|
||||||
*/
|
|
||||||
explicit
|
|
||||||
wstring_convert(_Codecvt* __pcvt) : _M_cvt(__pcvt)
|
|
||||||
{
|
|
||||||
if (!_M_cvt)
|
|
||||||
__throw_logic_error("wstring_convert");
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Construct with an initial converstion state.
|
|
||||||
*
|
|
||||||
* @param __pcvt The facet to use for conversions.
|
|
||||||
* @param __state Initial conversion state.
|
|
||||||
*
|
|
||||||
* Takes ownership of @p __pcvt and will delete it in the destructor.
|
|
||||||
* The object's conversion state will persist between conversions.
|
|
||||||
*/
|
|
||||||
wstring_convert(_Codecvt* __pcvt, state_type __state)
|
|
||||||
: _M_cvt(__pcvt), _M_state(__state), _M_with_cvtstate(true)
|
|
||||||
{
|
|
||||||
if (!_M_cvt)
|
|
||||||
__throw_logic_error("wstring_convert");
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Construct with error strings.
|
|
||||||
*
|
|
||||||
* @param __byte_err A string to return on failed conversions.
|
|
||||||
* @param __wide_err A wide string to return on failed conversions.
|
|
||||||
*/
|
|
||||||
explicit
|
|
||||||
wstring_convert(const byte_string& __byte_err,
|
|
||||||
const wide_string& __wide_err = wide_string())
|
|
||||||
: _M_cvt(new _Codecvt),
|
|
||||||
_M_byte_err_string(__byte_err), _M_wide_err_string(__wide_err),
|
|
||||||
_M_with_strings(true)
|
|
||||||
{
|
|
||||||
if (!_M_cvt)
|
|
||||||
__throw_logic_error("wstring_convert");
|
|
||||||
}
|
|
||||||
|
|
||||||
~wstring_convert() = default;
|
|
||||||
|
|
||||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
|
||||||
// 2176. Special members for wstring_convert and wbuffer_convert
|
|
||||||
wstring_convert(const wstring_convert&) = delete;
|
|
||||||
wstring_convert& operator=(const wstring_convert&) = delete;
|
|
||||||
|
|
||||||
/// @{ Convert from bytes.
|
|
||||||
wide_string
|
|
||||||
from_bytes(char __byte)
|
|
||||||
{
|
|
||||||
char __bytes[2] = { __byte };
|
|
||||||
return from_bytes(__bytes, __bytes+1);
|
|
||||||
}
|
|
||||||
|
|
||||||
wide_string
|
|
||||||
from_bytes(const char* __ptr)
|
|
||||||
{ return from_bytes(__ptr, __ptr+char_traits<char>::length(__ptr)); }
|
|
||||||
|
|
||||||
wide_string
|
|
||||||
from_bytes(const byte_string& __str)
|
|
||||||
{
|
|
||||||
auto __ptr = __str.data();
|
|
||||||
return from_bytes(__ptr, __ptr + __str.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
wide_string
|
|
||||||
from_bytes(const char* __first, const char* __last)
|
|
||||||
{
|
|
||||||
if (!_M_with_cvtstate)
|
|
||||||
_M_state = state_type();
|
|
||||||
wide_string __out{ _M_wide_err_string.get_allocator() };
|
|
||||||
if (__str_codecvt_in(__first, __last, __out, *_M_cvt, _M_state,
|
|
||||||
_M_count))
|
|
||||||
return __out;
|
|
||||||
if (_M_with_strings)
|
|
||||||
return _M_wide_err_string;
|
|
||||||
__throw_range_error("wstring_convert::from_bytes");
|
|
||||||
}
|
|
||||||
/// @}
|
|
||||||
|
|
||||||
/// @{ Convert to bytes.
|
|
||||||
byte_string
|
|
||||||
to_bytes(_Elem __wchar)
|
|
||||||
{
|
|
||||||
_Elem __wchars[2] = { __wchar };
|
|
||||||
return to_bytes(__wchars, __wchars+1);
|
|
||||||
}
|
|
||||||
|
|
||||||
byte_string
|
|
||||||
to_bytes(const _Elem* __ptr)
|
|
||||||
{
|
|
||||||
return to_bytes(__ptr, __ptr+wide_string::traits_type::length(__ptr));
|
|
||||||
}
|
|
||||||
|
|
||||||
byte_string
|
|
||||||
to_bytes(const wide_string& __wstr)
|
|
||||||
{
|
|
||||||
auto __ptr = __wstr.data();
|
|
||||||
return to_bytes(__ptr, __ptr + __wstr.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
byte_string
|
|
||||||
to_bytes(const _Elem* __first, const _Elem* __last)
|
|
||||||
{
|
|
||||||
if (!_M_with_cvtstate)
|
|
||||||
_M_state = state_type();
|
|
||||||
byte_string __out{ _M_byte_err_string.get_allocator() };
|
|
||||||
if (__str_codecvt_out(__first, __last, __out, *_M_cvt, _M_state,
|
|
||||||
_M_count))
|
|
||||||
return __out;
|
|
||||||
if (_M_with_strings)
|
|
||||||
return _M_byte_err_string;
|
|
||||||
__throw_range_error("wstring_convert::to_bytes");
|
|
||||||
}
|
|
||||||
/// @}
|
|
||||||
|
|
||||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
|
||||||
// 2174. wstring_convert::converted() should be noexcept
|
|
||||||
/// The number of elements successfully converted in the last conversion.
|
|
||||||
size_t converted() const noexcept { return _M_count; }
|
|
||||||
|
|
||||||
/// The final conversion state of the last conversion.
|
|
||||||
state_type state() const { return _M_state; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
unique_ptr<_Codecvt> _M_cvt;
|
|
||||||
byte_string _M_byte_err_string;
|
|
||||||
wide_string _M_wide_err_string;
|
|
||||||
state_type _M_state = state_type();
|
|
||||||
size_t _M_count = 0;
|
|
||||||
bool _M_with_cvtstate = false;
|
|
||||||
bool _M_with_strings = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
_GLIBCXX_END_NAMESPACE_CXX11
|
|
||||||
|
|
||||||
/// Buffer conversions
|
|
||||||
template<typename _Codecvt, typename _Elem = wchar_t,
|
|
||||||
typename _Tr = char_traits<_Elem>>
|
|
||||||
class wbuffer_convert : public basic_streambuf<_Elem, _Tr>
|
|
||||||
{
|
|
||||||
typedef basic_streambuf<_Elem, _Tr> _Wide_streambuf;
|
|
||||||
|
|
||||||
public:
|
|
||||||
typedef typename _Codecvt::state_type state_type;
|
|
||||||
|
|
||||||
/// Default constructor.
|
|
||||||
wbuffer_convert() : wbuffer_convert(nullptr) { }
|
|
||||||
|
|
||||||
/** Constructor.
|
|
||||||
*
|
|
||||||
* @param __bytebuf The underlying byte stream buffer.
|
|
||||||
* @param __pcvt The facet to use for conversions.
|
|
||||||
* @param __state Initial conversion state.
|
|
||||||
*
|
|
||||||
* Takes ownership of @p __pcvt and will delete it in the destructor.
|
|
||||||
*/
|
|
||||||
explicit
|
|
||||||
wbuffer_convert(streambuf* __bytebuf, _Codecvt* __pcvt = new _Codecvt,
|
|
||||||
state_type __state = state_type())
|
|
||||||
: _M_buf(__bytebuf), _M_cvt(__pcvt), _M_state(__state)
|
|
||||||
{
|
|
||||||
if (!_M_cvt)
|
|
||||||
__throw_logic_error("wbuffer_convert");
|
|
||||||
|
|
||||||
_M_always_noconv = _M_cvt->always_noconv();
|
|
||||||
|
|
||||||
if (_M_buf)
|
|
||||||
{
|
|
||||||
this->setp(_M_put_area, _M_put_area + _S_buffer_length);
|
|
||||||
this->setg(_M_get_area + _S_putback_length,
|
|
||||||
_M_get_area + _S_putback_length,
|
|
||||||
_M_get_area + _S_putback_length);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
~wbuffer_convert() = default;
|
|
||||||
|
|
||||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
|
||||||
// 2176. Special members for wstring_convert and wbuffer_convert
|
|
||||||
wbuffer_convert(const wbuffer_convert&) = delete;
|
|
||||||
wbuffer_convert& operator=(const wbuffer_convert&) = delete;
|
|
||||||
|
|
||||||
streambuf* rdbuf() const noexcept { return _M_buf; }
|
|
||||||
|
|
||||||
streambuf*
|
|
||||||
rdbuf(streambuf *__bytebuf) noexcept
|
|
||||||
{
|
|
||||||
auto __prev = _M_buf;
|
|
||||||
_M_buf = __bytebuf;
|
|
||||||
return __prev;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The conversion state following the last conversion.
|
|
||||||
state_type state() const noexcept { return _M_state; }
|
|
||||||
|
|
||||||
protected:
|
|
||||||
int
|
|
||||||
sync()
|
|
||||||
{ return _M_buf && _M_conv_put() && !_M_buf->pubsync() ? 0 : -1; }
|
|
||||||
|
|
||||||
typename _Wide_streambuf::int_type
|
|
||||||
overflow(typename _Wide_streambuf::int_type __out)
|
|
||||||
{
|
|
||||||
if (!_M_buf || !_M_conv_put())
|
|
||||||
return _Tr::eof();
|
|
||||||
else if (!_Tr::eq_int_type(__out, _Tr::eof()))
|
|
||||||
return this->sputc(__out);
|
|
||||||
return _Tr::not_eof(__out);
|
|
||||||
}
|
|
||||||
|
|
||||||
typename _Wide_streambuf::int_type
|
|
||||||
underflow()
|
|
||||||
{
|
|
||||||
if (!_M_buf)
|
|
||||||
return _Tr::eof();
|
|
||||||
|
|
||||||
if (this->gptr() < this->egptr() || (_M_buf && _M_conv_get()))
|
|
||||||
return _Tr::to_int_type(*this->gptr());
|
|
||||||
else
|
|
||||||
return _Tr::eof();
|
|
||||||
}
|
|
||||||
|
|
||||||
streamsize
|
|
||||||
xsputn(const typename _Wide_streambuf::char_type* __s, streamsize __n)
|
|
||||||
{
|
|
||||||
if (!_M_buf || __n == 0)
|
|
||||||
return 0;
|
|
||||||
streamsize __done = 0;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
auto __nn = std::min<streamsize>(this->epptr() - this->pptr(),
|
|
||||||
__n - __done);
|
|
||||||
_Tr::copy(this->pptr(), __s + __done, __nn);
|
|
||||||
this->pbump(__nn);
|
|
||||||
__done += __nn;
|
|
||||||
} while (__done < __n && _M_conv_put());
|
|
||||||
return __done;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
// fill the get area from converted contents of the byte stream buffer
|
|
||||||
bool
|
|
||||||
_M_conv_get()
|
|
||||||
{
|
|
||||||
const streamsize __pb1 = this->gptr() - this->eback();
|
|
||||||
const streamsize __pb2 = _S_putback_length;
|
|
||||||
const streamsize __npb = std::min(__pb1, __pb2);
|
|
||||||
|
|
||||||
_Tr::move(_M_get_area + _S_putback_length - __npb,
|
|
||||||
this->gptr() - __npb, __npb);
|
|
||||||
|
|
||||||
streamsize __nbytes = sizeof(_M_get_buf) - _M_unconv;
|
|
||||||
__nbytes = std::min(__nbytes, _M_buf->in_avail());
|
|
||||||
if (__nbytes < 1)
|
|
||||||
__nbytes = 1;
|
|
||||||
__nbytes = _M_buf->sgetn(_M_get_buf + _M_unconv, __nbytes);
|
|
||||||
if (__nbytes < 1)
|
|
||||||
return false;
|
|
||||||
__nbytes += _M_unconv;
|
|
||||||
|
|
||||||
// convert _M_get_buf into _M_get_area
|
|
||||||
|
|
||||||
_Elem* __outbuf = _M_get_area + _S_putback_length;
|
|
||||||
_Elem* __outnext = __outbuf;
|
|
||||||
const char* __bnext = _M_get_buf;
|
|
||||||
|
|
||||||
codecvt_base::result __result;
|
|
||||||
if (_M_always_noconv)
|
|
||||||
__result = codecvt_base::noconv;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_Elem* __outend = _M_get_area + _S_buffer_length;
|
|
||||||
|
|
||||||
__result = _M_cvt->in(_M_state,
|
|
||||||
__bnext, __bnext + __nbytes, __bnext,
|
|
||||||
__outbuf, __outend, __outnext);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (__result == codecvt_base::noconv)
|
|
||||||
{
|
|
||||||
// cast is safe because noconv means _Elem is same type as char
|
|
||||||
auto __get_buf = reinterpret_cast<const _Elem*>(_M_get_buf);
|
|
||||||
_Tr::copy(__outbuf, __get_buf, __nbytes);
|
|
||||||
_M_unconv = 0;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((_M_unconv = _M_get_buf + __nbytes - __bnext))
|
|
||||||
char_traits<char>::move(_M_get_buf, __bnext, _M_unconv);
|
|
||||||
|
|
||||||
this->setg(__outbuf, __outbuf, __outnext);
|
|
||||||
|
|
||||||
return __result != codecvt_base::error;
|
|
||||||
}
|
|
||||||
|
|
||||||
// unused
|
|
||||||
bool
|
|
||||||
_M_put(...)
|
|
||||||
{ return false; }
|
|
||||||
|
|
||||||
bool
|
|
||||||
_M_put(const char* __p, streamsize __n)
|
|
||||||
{
|
|
||||||
if (_M_buf->sputn(__p, __n) < __n)
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// convert the put area and write to the byte stream buffer
|
|
||||||
bool
|
|
||||||
_M_conv_put()
|
|
||||||
{
|
|
||||||
_Elem* const __first = this->pbase();
|
|
||||||
const _Elem* const __last = this->pptr();
|
|
||||||
const streamsize __pending = __last - __first;
|
|
||||||
|
|
||||||
if (_M_always_noconv)
|
|
||||||
return _M_put(__first, __pending);
|
|
||||||
|
|
||||||
char __outbuf[2 * _S_buffer_length];
|
|
||||||
|
|
||||||
const _Elem* __next = __first;
|
|
||||||
const _Elem* __start;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
__start = __next;
|
|
||||||
char* __outnext = __outbuf;
|
|
||||||
char* const __outlast = __outbuf + sizeof(__outbuf);
|
|
||||||
auto __result = _M_cvt->out(_M_state, __next, __last, __next,
|
|
||||||
__outnext, __outlast, __outnext);
|
|
||||||
if (__result == codecvt_base::error)
|
|
||||||
return false;
|
|
||||||
else if (__result == codecvt_base::noconv)
|
|
||||||
return _M_put(__next, __pending);
|
|
||||||
|
|
||||||
if (!_M_put(__outbuf, __outnext - __outbuf))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
while (__next != __last && __next != __start);
|
|
||||||
|
|
||||||
if (__next != __last)
|
|
||||||
_Tr::move(__first, __next, __last - __next);
|
|
||||||
|
|
||||||
this->pbump(__first - __next);
|
|
||||||
return __next != __first;
|
|
||||||
}
|
|
||||||
|
|
||||||
streambuf* _M_buf;
|
|
||||||
unique_ptr<_Codecvt> _M_cvt;
|
|
||||||
state_type _M_state;
|
|
||||||
|
|
||||||
static const streamsize _S_buffer_length = 32;
|
|
||||||
static const streamsize _S_putback_length = 3;
|
|
||||||
_Elem _M_put_area[_S_buffer_length];
|
|
||||||
_Elem _M_get_area[_S_buffer_length];
|
|
||||||
streamsize _M_unconv = 0;
|
|
||||||
char _M_get_buf[_S_buffer_length-_S_putback_length];
|
|
||||||
bool _M_always_noconv;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // _GLIBCXX_USE_WCHAR_T
|
|
||||||
|
|
||||||
/// @} group locales
|
|
||||||
|
|
||||||
_GLIBCXX_END_NAMESPACE_VERSION
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
#endif // __cplusplus
|
|
||||||
|
|
||||||
#endif /* _LOCALE_CONV_H */
|
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@ -1,214 +0,0 @@
|
|||||||
// <locale> Forward declarations -*- C++ -*-
|
|
||||||
|
|
||||||
// Copyright (C) 1997-2020 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.
|
|
||||||
|
|
||||||
// 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 bits/localefwd.h
|
|
||||||
* This is an internal header file, included by other library headers.
|
|
||||||
* Do not attempt to use it directly. @headername{locale}
|
|
||||||
*/
|
|
||||||
|
|
||||||
//
|
|
||||||
// ISO C++ 14882: 22.1 Locales
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef _LOCALE_FWD_H
|
|
||||||
#define _LOCALE_FWD_H 1
|
|
||||||
|
|
||||||
#pragma GCC system_header
|
|
||||||
|
|
||||||
#include <bits/c++config.h>
|
|
||||||
#include <bits/c++locale.h> // Defines __c_locale, config-specific include
|
|
||||||
#include <iosfwd> // For ostreambuf_iterator, istreambuf_iterator
|
|
||||||
#include <cctype>
|
|
||||||
|
|
||||||
namespace std _GLIBCXX_VISIBILITY(default)
|
|
||||||
{
|
|
||||||
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @defgroup locales Locales
|
|
||||||
*
|
|
||||||
* Classes and functions for internationalization and localization.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// 22.1.1 Locale
|
|
||||||
class locale;
|
|
||||||
|
|
||||||
template<typename _Facet>
|
|
||||||
bool
|
|
||||||
has_facet(const locale&) throw();
|
|
||||||
|
|
||||||
template<typename _Facet>
|
|
||||||
const _Facet&
|
|
||||||
use_facet(const locale&);
|
|
||||||
|
|
||||||
// 22.1.3 Convenience interfaces
|
|
||||||
template<typename _CharT>
|
|
||||||
bool
|
|
||||||
isspace(_CharT, const locale&);
|
|
||||||
|
|
||||||
template<typename _CharT>
|
|
||||||
bool
|
|
||||||
isprint(_CharT, const locale&);
|
|
||||||
|
|
||||||
template<typename _CharT>
|
|
||||||
bool
|
|
||||||
iscntrl(_CharT, const locale&);
|
|
||||||
|
|
||||||
template<typename _CharT>
|
|
||||||
bool
|
|
||||||
isupper(_CharT, const locale&);
|
|
||||||
|
|
||||||
template<typename _CharT>
|
|
||||||
bool
|
|
||||||
islower(_CharT, const locale&);
|
|
||||||
|
|
||||||
template<typename _CharT>
|
|
||||||
bool
|
|
||||||
isalpha(_CharT, const locale&);
|
|
||||||
|
|
||||||
template<typename _CharT>
|
|
||||||
bool
|
|
||||||
isdigit(_CharT, const locale&);
|
|
||||||
|
|
||||||
template<typename _CharT>
|
|
||||||
bool
|
|
||||||
ispunct(_CharT, const locale&);
|
|
||||||
|
|
||||||
template<typename _CharT>
|
|
||||||
bool
|
|
||||||
isxdigit(_CharT, const locale&);
|
|
||||||
|
|
||||||
template<typename _CharT>
|
|
||||||
bool
|
|
||||||
isalnum(_CharT, const locale&);
|
|
||||||
|
|
||||||
template<typename _CharT>
|
|
||||||
bool
|
|
||||||
isgraph(_CharT, const locale&);
|
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
template<typename _CharT>
|
|
||||||
bool
|
|
||||||
isblank(_CharT, const locale&);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template<typename _CharT>
|
|
||||||
_CharT
|
|
||||||
toupper(_CharT, const locale&);
|
|
||||||
|
|
||||||
template<typename _CharT>
|
|
||||||
_CharT
|
|
||||||
tolower(_CharT, const locale&);
|
|
||||||
|
|
||||||
// 22.2.1 and 22.2.1.3 ctype
|
|
||||||
class ctype_base;
|
|
||||||
template<typename _CharT>
|
|
||||||
class ctype;
|
|
||||||
template<> class ctype<char>;
|
|
||||||
#ifdef _GLIBCXX_USE_WCHAR_T
|
|
||||||
template<> class ctype<wchar_t>;
|
|
||||||
#endif
|
|
||||||
template<typename _CharT>
|
|
||||||
class ctype_byname;
|
|
||||||
// NB: Specialized for char and wchar_t in locale_facets.h.
|
|
||||||
|
|
||||||
class codecvt_base;
|
|
||||||
template<typename _InternT, typename _ExternT, typename _StateT>
|
|
||||||
class codecvt;
|
|
||||||
template<> class codecvt<char, char, mbstate_t>;
|
|
||||||
#ifdef _GLIBCXX_USE_WCHAR_T
|
|
||||||
template<> class codecvt<wchar_t, char, mbstate_t>;
|
|
||||||
#endif
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
template<> class codecvt<char16_t, char, mbstate_t>;
|
|
||||||
template<> class codecvt<char32_t, char, mbstate_t>;
|
|
||||||
#ifdef _GLIBCXX_USE_CHAR8_T
|
|
||||||
template<> class codecvt<char16_t, char8_t, mbstate_t>;
|
|
||||||
template<> class codecvt<char32_t, char8_t, mbstate_t>;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
template<typename _InternT, typename _ExternT, typename _StateT>
|
|
||||||
class codecvt_byname;
|
|
||||||
|
|
||||||
// 22.2.2 and 22.2.3 numeric
|
|
||||||
_GLIBCXX_BEGIN_NAMESPACE_LDBL
|
|
||||||
template<typename _CharT, typename _InIter = istreambuf_iterator<_CharT> >
|
|
||||||
class num_get;
|
|
||||||
template<typename _CharT, typename _OutIter = ostreambuf_iterator<_CharT> >
|
|
||||||
class num_put;
|
|
||||||
_GLIBCXX_END_NAMESPACE_LDBL
|
|
||||||
_GLIBCXX_BEGIN_NAMESPACE_CXX11
|
|
||||||
template<typename _CharT> class numpunct;
|
|
||||||
template<typename _CharT> class numpunct_byname;
|
|
||||||
_GLIBCXX_END_NAMESPACE_CXX11
|
|
||||||
|
|
||||||
_GLIBCXX_BEGIN_NAMESPACE_CXX11
|
|
||||||
// 22.2.4 collation
|
|
||||||
template<typename _CharT>
|
|
||||||
class collate;
|
|
||||||
template<typename _CharT>
|
|
||||||
class collate_byname;
|
|
||||||
_GLIBCXX_END_NAMESPACE_CXX11
|
|
||||||
|
|
||||||
// 22.2.5 date and time
|
|
||||||
class time_base;
|
|
||||||
_GLIBCXX_BEGIN_NAMESPACE_CXX11
|
|
||||||
template<typename _CharT, typename _InIter = istreambuf_iterator<_CharT> >
|
|
||||||
class time_get;
|
|
||||||
template<typename _CharT, typename _InIter = istreambuf_iterator<_CharT> >
|
|
||||||
class time_get_byname;
|
|
||||||
_GLIBCXX_END_NAMESPACE_CXX11
|
|
||||||
template<typename _CharT, typename _OutIter = ostreambuf_iterator<_CharT> >
|
|
||||||
class time_put;
|
|
||||||
template<typename _CharT, typename _OutIter = ostreambuf_iterator<_CharT> >
|
|
||||||
class time_put_byname;
|
|
||||||
|
|
||||||
// 22.2.6 money
|
|
||||||
class money_base;
|
|
||||||
_GLIBCXX_BEGIN_NAMESPACE_LDBL_OR_CXX11
|
|
||||||
template<typename _CharT, typename _InIter = istreambuf_iterator<_CharT> >
|
|
||||||
class money_get;
|
|
||||||
template<typename _CharT, typename _OutIter = ostreambuf_iterator<_CharT> >
|
|
||||||
class money_put;
|
|
||||||
_GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
|
|
||||||
_GLIBCXX_BEGIN_NAMESPACE_CXX11
|
|
||||||
template<typename _CharT, bool _Intl = false>
|
|
||||||
class moneypunct;
|
|
||||||
template<typename _CharT, bool _Intl = false>
|
|
||||||
class moneypunct_byname;
|
|
||||||
_GLIBCXX_END_NAMESPACE_CXX11
|
|
||||||
|
|
||||||
// 22.2.7 message retrieval
|
|
||||||
class messages_base;
|
|
||||||
_GLIBCXX_BEGIN_NAMESPACE_CXX11
|
|
||||||
template<typename _CharT>
|
|
||||||
class messages;
|
|
||||||
template<typename _CharT>
|
|
||||||
class messages_byname;
|
|
||||||
_GLIBCXX_END_NAMESPACE_CXX11
|
|
||||||
|
|
||||||
_GLIBCXX_END_NAMESPACE_VERSION
|
|
||||||
} // namespace std
|
|
||||||
|
|
||||||
#endif
|
|
Binary file not shown.
@ -1,82 +0,0 @@
|
|||||||
// <memory> Forward declarations -*- C++ -*-
|
|
||||||
|
|
||||||
// Copyright (C) 2001-2020 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.
|
|
||||||
|
|
||||||
// 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/>.
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 1996-1997
|
|
||||||
* Silicon Graphics Computer Systems, Inc.
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, distribute and sell this software
|
|
||||||
* and its documentation for any purpose is hereby granted without fee,
|
|
||||||
* provided that the above copyright notice appear in all copies and
|
|
||||||
* that both that copyright notice and this permission notice appear
|
|
||||||
* in supporting documentation. Silicon Graphics makes no
|
|
||||||
* representations about the suitability of this software for any
|
|
||||||
* purpose. It is provided "as is" without express or implied warranty.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @file bits/memoryfwd.h
|
|
||||||
* This is an internal header file, included by other library headers.
|
|
||||||
* Do not attempt to use it directly. @headername{memory}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _MEMORYFWD_H
|
|
||||||
#define _MEMORYFWD_H 1
|
|
||||||
|
|
||||||
#pragma GCC system_header
|
|
||||||
|
|
||||||
#include <bits/c++config.h>
|
|
||||||
|
|
||||||
namespace std _GLIBCXX_VISIBILITY(default)
|
|
||||||
{
|
|
||||||
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @defgroup allocators Allocators
|
|
||||||
* @ingroup memory
|
|
||||||
*
|
|
||||||
* Classes encapsulating memory operations.
|
|
||||||
*
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
template<typename>
|
|
||||||
class allocator;
|
|
||||||
|
|
||||||
#if __cplusplus <= 201703L
|
|
||||||
template<>
|
|
||||||
class allocator<void>;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
/// Declare uses_allocator so it can be specialized in \<queue\> etc.
|
|
||||||
template<typename, typename>
|
|
||||||
struct uses_allocator;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/// @} group memory
|
|
||||||
|
|
||||||
_GLIBCXX_END_NAMESPACE_VERSION
|
|
||||||
} // namespace std
|
|
||||||
|
|
||||||
#endif
|
|
Binary file not shown.
@ -1,224 +0,0 @@
|
|||||||
// Move, forward and identity for C++11 + swap -*- C++ -*-
|
|
||||||
|
|
||||||
// Copyright (C) 2007-2020 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.
|
|
||||||
|
|
||||||
// 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 bits/move.h
|
|
||||||
* This is an internal header file, included by other library headers.
|
|
||||||
* Do not attempt to use it directly. @headername{utility}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _MOVE_H
|
|
||||||
#define _MOVE_H 1
|
|
||||||
|
|
||||||
#include <bits/c++config.h>
|
|
||||||
#if __cplusplus < 201103L
|
|
||||||
# include <bits/concept_check.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace std _GLIBCXX_VISIBILITY(default)
|
|
||||||
{
|
|
||||||
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|
||||||
|
|
||||||
// Used, in C++03 mode too, by allocators, etc.
|
|
||||||
/**
|
|
||||||
* @brief Same as C++11 std::addressof
|
|
||||||
* @ingroup utilities
|
|
||||||
*/
|
|
||||||
template<typename _Tp>
|
|
||||||
inline _GLIBCXX_CONSTEXPR _Tp*
|
|
||||||
__addressof(_Tp& __r) _GLIBCXX_NOEXCEPT
|
|
||||||
{ return __builtin_addressof(__r); }
|
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
|
|
||||||
_GLIBCXX_END_NAMESPACE_VERSION
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
#include <type_traits> // Brings in std::declval too.
|
|
||||||
|
|
||||||
namespace std _GLIBCXX_VISIBILITY(default)
|
|
||||||
{
|
|
||||||
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @addtogroup utilities
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Forward an lvalue.
|
|
||||||
* @return The parameter cast to the specified type.
|
|
||||||
*
|
|
||||||
* This function is used to implement "perfect forwarding".
|
|
||||||
*/
|
|
||||||
template<typename _Tp>
|
|
||||||
constexpr _Tp&&
|
|
||||||
forward(typename std::remove_reference<_Tp>::type& __t) noexcept
|
|
||||||
{ return static_cast<_Tp&&>(__t); }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Forward an rvalue.
|
|
||||||
* @return The parameter cast to the specified type.
|
|
||||||
*
|
|
||||||
* This function is used to implement "perfect forwarding".
|
|
||||||
*/
|
|
||||||
template<typename _Tp>
|
|
||||||
constexpr _Tp&&
|
|
||||||
forward(typename std::remove_reference<_Tp>::type&& __t) noexcept
|
|
||||||
{
|
|
||||||
static_assert(!std::is_lvalue_reference<_Tp>::value, "template argument"
|
|
||||||
" substituting _Tp is an lvalue reference type");
|
|
||||||
return static_cast<_Tp&&>(__t);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Convert a value to an rvalue.
|
|
||||||
* @param __t A thing of arbitrary type.
|
|
||||||
* @return The parameter cast to an rvalue-reference to allow moving it.
|
|
||||||
*/
|
|
||||||
template<typename _Tp>
|
|
||||||
constexpr typename std::remove_reference<_Tp>::type&&
|
|
||||||
move(_Tp&& __t) noexcept
|
|
||||||
{ return static_cast<typename std::remove_reference<_Tp>::type&&>(__t); }
|
|
||||||
|
|
||||||
|
|
||||||
template<typename _Tp>
|
|
||||||
struct __move_if_noexcept_cond
|
|
||||||
: public __and_<__not_<is_nothrow_move_constructible<_Tp>>,
|
|
||||||
is_copy_constructible<_Tp>>::type { };
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Conditionally convert a value to an rvalue.
|
|
||||||
* @param __x A thing of arbitrary type.
|
|
||||||
* @return The parameter, possibly cast to an rvalue-reference.
|
|
||||||
*
|
|
||||||
* Same as std::move unless the type's move constructor could throw and the
|
|
||||||
* type is copyable, in which case an lvalue-reference is returned instead.
|
|
||||||
*/
|
|
||||||
template<typename _Tp>
|
|
||||||
constexpr typename
|
|
||||||
conditional<__move_if_noexcept_cond<_Tp>::value, const _Tp&, _Tp&&>::type
|
|
||||||
move_if_noexcept(_Tp& __x) noexcept
|
|
||||||
{ return std::move(__x); }
|
|
||||||
|
|
||||||
// declval, from type_traits.
|
|
||||||
|
|
||||||
#if __cplusplus > 201402L
|
|
||||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
|
||||||
// 2296. std::addressof should be constexpr
|
|
||||||
# define __cpp_lib_addressof_constexpr 201603
|
|
||||||
#endif
|
|
||||||
/**
|
|
||||||
* @brief Returns the actual address of the object or function
|
|
||||||
* referenced by r, even in the presence of an overloaded
|
|
||||||
* operator&.
|
|
||||||
* @param __r Reference to an object or function.
|
|
||||||
* @return The actual address.
|
|
||||||
*/
|
|
||||||
template<typename _Tp>
|
|
||||||
inline _GLIBCXX17_CONSTEXPR _Tp*
|
|
||||||
addressof(_Tp& __r) noexcept
|
|
||||||
{ return std::__addressof(__r); }
|
|
||||||
|
|
||||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
|
||||||
// 2598. addressof works on temporaries
|
|
||||||
template<typename _Tp>
|
|
||||||
const _Tp* addressof(const _Tp&&) = delete;
|
|
||||||
|
|
||||||
// C++11 version of std::exchange for internal use.
|
|
||||||
template <typename _Tp, typename _Up = _Tp>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
inline _Tp
|
|
||||||
__exchange(_Tp& __obj, _Up&& __new_val)
|
|
||||||
{
|
|
||||||
_Tp __old_val = std::move(__obj);
|
|
||||||
__obj = std::forward<_Up>(__new_val);
|
|
||||||
return __old_val;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @} group utilities
|
|
||||||
|
|
||||||
#define _GLIBCXX_MOVE(__val) std::move(__val)
|
|
||||||
#define _GLIBCXX_FORWARD(_Tp, __val) std::forward<_Tp>(__val)
|
|
||||||
#else
|
|
||||||
#define _GLIBCXX_MOVE(__val) (__val)
|
|
||||||
#define _GLIBCXX_FORWARD(_Tp, __val) (__val)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @addtogroup utilities
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Swaps two values.
|
|
||||||
* @param __a A thing of arbitrary type.
|
|
||||||
* @param __b Another thing of arbitrary type.
|
|
||||||
* @return Nothing.
|
|
||||||
*/
|
|
||||||
template<typename _Tp>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
inline
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
typename enable_if<__and_<__not_<__is_tuple_like<_Tp>>,
|
|
||||||
is_move_constructible<_Tp>,
|
|
||||||
is_move_assignable<_Tp>>::value>::type
|
|
||||||
#else
|
|
||||||
void
|
|
||||||
#endif
|
|
||||||
swap(_Tp& __a, _Tp& __b)
|
|
||||||
_GLIBCXX_NOEXCEPT_IF(__and_<is_nothrow_move_constructible<_Tp>,
|
|
||||||
is_nothrow_move_assignable<_Tp>>::value)
|
|
||||||
{
|
|
||||||
#if __cplusplus < 201103L
|
|
||||||
// concept requirements
|
|
||||||
__glibcxx_function_requires(_SGIAssignableConcept<_Tp>)
|
|
||||||
#endif
|
|
||||||
_Tp __tmp = _GLIBCXX_MOVE(__a);
|
|
||||||
__a = _GLIBCXX_MOVE(__b);
|
|
||||||
__b = _GLIBCXX_MOVE(__tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
|
||||||
// DR 809. std::swap should be overloaded for array types.
|
|
||||||
/// Swap the contents of two arrays.
|
|
||||||
template<typename _Tp, size_t _Nm>
|
|
||||||
_GLIBCXX20_CONSTEXPR
|
|
||||||
inline
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
typename enable_if<__is_swappable<_Tp>::value>::type
|
|
||||||
#else
|
|
||||||
void
|
|
||||||
#endif
|
|
||||||
swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm])
|
|
||||||
_GLIBCXX_NOEXCEPT_IF(__is_nothrow_swappable<_Tp>::value)
|
|
||||||
{
|
|
||||||
for (size_t __n = 0; __n < _Nm; ++__n)
|
|
||||||
swap(__a[__n], __b[__n]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @} group utilities
|
|
||||||
_GLIBCXX_END_NAMESPACE_VERSION
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
#endif /* _MOVE_H */
|
|
Binary file not shown.
@ -1,171 +0,0 @@
|
|||||||
// Nested Exception support header (nested_exception class) for -*- C++ -*-
|
|
||||||
|
|
||||||
// Copyright (C) 2009-2020 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.
|
|
||||||
|
|
||||||
// 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 bits/nested_exception.h
|
|
||||||
* This is an internal header file, included by other library headers.
|
|
||||||
* Do not attempt to use it directly. @headername{exception}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _GLIBCXX_NESTED_EXCEPTION_H
|
|
||||||
#define _GLIBCXX_NESTED_EXCEPTION_H 1
|
|
||||||
|
|
||||||
#pragma GCC visibility push(default)
|
|
||||||
|
|
||||||
#if __cplusplus < 201103L
|
|
||||||
# include <bits/c++0x_warning.h>
|
|
||||||
#else
|
|
||||||
|
|
||||||
#include <bits/c++config.h>
|
|
||||||
#include <bits/move.h>
|
|
||||||
|
|
||||||
extern "C++" {
|
|
||||||
|
|
||||||
namespace std
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @addtogroup exceptions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/// Exception class with exception_ptr data member.
|
|
||||||
class nested_exception
|
|
||||||
{
|
|
||||||
exception_ptr _M_ptr;
|
|
||||||
|
|
||||||
public:
|
|
||||||
nested_exception() noexcept : _M_ptr(current_exception()) { }
|
|
||||||
|
|
||||||
nested_exception(const nested_exception&) noexcept = default;
|
|
||||||
|
|
||||||
nested_exception& operator=(const nested_exception&) noexcept = default;
|
|
||||||
|
|
||||||
virtual ~nested_exception() noexcept;
|
|
||||||
|
|
||||||
[[noreturn]]
|
|
||||||
void
|
|
||||||
rethrow_nested() const
|
|
||||||
{
|
|
||||||
if (_M_ptr)
|
|
||||||
rethrow_exception(_M_ptr);
|
|
||||||
std::terminate();
|
|
||||||
}
|
|
||||||
|
|
||||||
exception_ptr
|
|
||||||
nested_ptr() const noexcept
|
|
||||||
{ return _M_ptr; }
|
|
||||||
};
|
|
||||||
|
|
||||||
/// @cond undocumented
|
|
||||||
|
|
||||||
template<typename _Except>
|
|
||||||
struct _Nested_exception : public _Except, public nested_exception
|
|
||||||
{
|
|
||||||
explicit _Nested_exception(const _Except& __ex)
|
|
||||||
: _Except(__ex)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
explicit _Nested_exception(_Except&& __ex)
|
|
||||||
: _Except(static_cast<_Except&&>(__ex))
|
|
||||||
{ }
|
|
||||||
};
|
|
||||||
|
|
||||||
// [except.nested]/8
|
|
||||||
// Throw an exception of unspecified type that is publicly derived from
|
|
||||||
// both remove_reference_t<_Tp> and nested_exception.
|
|
||||||
template<typename _Tp>
|
|
||||||
[[noreturn]]
|
|
||||||
inline void
|
|
||||||
__throw_with_nested_impl(_Tp&& __t, true_type)
|
|
||||||
{
|
|
||||||
using _Up = typename remove_reference<_Tp>::type;
|
|
||||||
throw _Nested_exception<_Up>{std::forward<_Tp>(__t)};
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename _Tp>
|
|
||||||
[[noreturn]]
|
|
||||||
inline void
|
|
||||||
__throw_with_nested_impl(_Tp&& __t, false_type)
|
|
||||||
{ throw std::forward<_Tp>(__t); }
|
|
||||||
|
|
||||||
/// @endcond
|
|
||||||
|
|
||||||
/// If @p __t is derived from nested_exception, throws @p __t.
|
|
||||||
/// Else, throws an implementation-defined object derived from both.
|
|
||||||
template<typename _Tp>
|
|
||||||
[[noreturn]]
|
|
||||||
inline void
|
|
||||||
throw_with_nested(_Tp&& __t)
|
|
||||||
{
|
|
||||||
using _Up = typename decay<_Tp>::type;
|
|
||||||
using _CopyConstructible
|
|
||||||
= __and_<is_copy_constructible<_Up>, is_move_constructible<_Up>>;
|
|
||||||
static_assert(_CopyConstructible::value,
|
|
||||||
"throw_with_nested argument must be CopyConstructible");
|
|
||||||
using __nest = __and_<is_class<_Up>, __bool_constant<!__is_final(_Up)>,
|
|
||||||
__not_<is_base_of<nested_exception, _Up>>>;
|
|
||||||
std::__throw_with_nested_impl(std::forward<_Tp>(__t), __nest{});
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @cond undocumented
|
|
||||||
|
|
||||||
// Determine if dynamic_cast<const nested_exception&> would be well-formed.
|
|
||||||
template<typename _Tp>
|
|
||||||
using __rethrow_if_nested_cond = typename enable_if<
|
|
||||||
__and_<is_polymorphic<_Tp>,
|
|
||||||
__or_<__not_<is_base_of<nested_exception, _Tp>>,
|
|
||||||
is_convertible<_Tp*, nested_exception*>>>::value
|
|
||||||
>::type;
|
|
||||||
|
|
||||||
// Attempt dynamic_cast to nested_exception and call rethrow_nested().
|
|
||||||
template<typename _Ex>
|
|
||||||
inline __rethrow_if_nested_cond<_Ex>
|
|
||||||
__rethrow_if_nested_impl(const _Ex* __ptr)
|
|
||||||
{
|
|
||||||
if (auto __ne_ptr = dynamic_cast<const nested_exception*>(__ptr))
|
|
||||||
__ne_ptr->rethrow_nested();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Otherwise, no effects.
|
|
||||||
inline void
|
|
||||||
__rethrow_if_nested_impl(const void*)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
/// @endcond
|
|
||||||
|
|
||||||
/// If @p __ex is derived from nested_exception, @p __ex.rethrow_nested().
|
|
||||||
template<typename _Ex>
|
|
||||||
inline void
|
|
||||||
rethrow_if_nested(const _Ex& __ex)
|
|
||||||
{ std::__rethrow_if_nested_impl(std::__addressof(__ex)); }
|
|
||||||
|
|
||||||
// @} group exceptions
|
|
||||||
} // namespace std
|
|
||||||
|
|
||||||
} // extern "C++"
|
|
||||||
|
|
||||||
#endif // C++11
|
|
||||||
|
|
||||||
#pragma GCC visibility pop
|
|
||||||
|
|
||||||
#endif // _GLIBCXX_NESTED_EXCEPTION_H
|
|
Binary file not shown.
@ -1,407 +0,0 @@
|
|||||||
// ostream classes -*- C++ -*-
|
|
||||||
|
|
||||||
// Copyright (C) 1997-2020 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.
|
|
||||||
|
|
||||||
// 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 bits/ostream.tcc
|
|
||||||
* This is an internal header file, included by other library headers.
|
|
||||||
* Do not attempt to use it directly. @headername{ostream}
|
|
||||||
*/
|
|
||||||
|
|
||||||
//
|
|
||||||
// ISO C++ 14882: 27.6.2 Output streams
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef _OSTREAM_TCC
|
|
||||||
#define _OSTREAM_TCC 1
|
|
||||||
|
|
||||||
#pragma GCC system_header
|
|
||||||
|
|
||||||
#include <bits/cxxabi_forced.h>
|
|
||||||
|
|
||||||
namespace std _GLIBCXX_VISIBILITY(default)
|
|
||||||
{
|
|
||||||
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|
||||||
|
|
||||||
template<typename _CharT, typename _Traits>
|
|
||||||
basic_ostream<_CharT, _Traits>::sentry::
|
|
||||||
sentry(basic_ostream<_CharT, _Traits>& __os)
|
|
||||||
: _M_ok(false), _M_os(__os)
|
|
||||||
{
|
|
||||||
// XXX MT
|
|
||||||
if (__os.tie() && __os.good())
|
|
||||||
__os.tie()->flush();
|
|
||||||
|
|
||||||
if (__os.good())
|
|
||||||
_M_ok = true;
|
|
||||||
else
|
|
||||||
__os.setstate(ios_base::failbit);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename _CharT, typename _Traits>
|
|
||||||
template<typename _ValueT>
|
|
||||||
basic_ostream<_CharT, _Traits>&
|
|
||||||
basic_ostream<_CharT, _Traits>::
|
|
||||||
_M_insert(_ValueT __v)
|
|
||||||
{
|
|
||||||
sentry __cerb(*this);
|
|
||||||
if (__cerb)
|
|
||||||
{
|
|
||||||
ios_base::iostate __err = ios_base::goodbit;
|
|
||||||
__try
|
|
||||||
{
|
|
||||||
const __num_put_type& __np = __check_facet(this->_M_num_put);
|
|
||||||
if (__np.put(*this, *this, this->fill(), __v).failed())
|
|
||||||
__err |= ios_base::badbit;
|
|
||||||
}
|
|
||||||
__catch(__cxxabiv1::__forced_unwind&)
|
|
||||||
{
|
|
||||||
this->_M_setstate(ios_base::badbit);
|
|
||||||
__throw_exception_again;
|
|
||||||
}
|
|
||||||
__catch(...)
|
|
||||||
{ this->_M_setstate(ios_base::badbit); }
|
|
||||||
if (__err)
|
|
||||||
this->setstate(__err);
|
|
||||||
}
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename _CharT, typename _Traits>
|
|
||||||
basic_ostream<_CharT, _Traits>&
|
|
||||||
basic_ostream<_CharT, _Traits>::
|
|
||||||
operator<<(short __n)
|
|
||||||
{
|
|
||||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
|
||||||
// 117. basic_ostream uses nonexistent num_put member functions.
|
|
||||||
const ios_base::fmtflags __fmt = this->flags() & ios_base::basefield;
|
|
||||||
if (__fmt == ios_base::oct || __fmt == ios_base::hex)
|
|
||||||
return _M_insert(static_cast<long>(static_cast<unsigned short>(__n)));
|
|
||||||
else
|
|
||||||
return _M_insert(static_cast<long>(__n));
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename _CharT, typename _Traits>
|
|
||||||
basic_ostream<_CharT, _Traits>&
|
|
||||||
basic_ostream<_CharT, _Traits>::
|
|
||||||
operator<<(int __n)
|
|
||||||
{
|
|
||||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
|
||||||
// 117. basic_ostream uses nonexistent num_put member functions.
|
|
||||||
const ios_base::fmtflags __fmt = this->flags() & ios_base::basefield;
|
|
||||||
if (__fmt == ios_base::oct || __fmt == ios_base::hex)
|
|
||||||
return _M_insert(static_cast<long>(static_cast<unsigned int>(__n)));
|
|
||||||
else
|
|
||||||
return _M_insert(static_cast<long>(__n));
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename _CharT, typename _Traits>
|
|
||||||
basic_ostream<_CharT, _Traits>&
|
|
||||||
basic_ostream<_CharT, _Traits>::
|
|
||||||
operator<<(__streambuf_type* __sbin)
|
|
||||||
{
|
|
||||||
ios_base::iostate __err = ios_base::goodbit;
|
|
||||||
sentry __cerb(*this);
|
|
||||||
if (__cerb && __sbin)
|
|
||||||
{
|
|
||||||
__try
|
|
||||||
{
|
|
||||||
if (!__copy_streambufs(__sbin, this->rdbuf()))
|
|
||||||
__err |= ios_base::failbit;
|
|
||||||
}
|
|
||||||
__catch(__cxxabiv1::__forced_unwind&)
|
|
||||||
{
|
|
||||||
this->_M_setstate(ios_base::badbit);
|
|
||||||
__throw_exception_again;
|
|
||||||
}
|
|
||||||
__catch(...)
|
|
||||||
{ this->_M_setstate(ios_base::failbit); }
|
|
||||||
}
|
|
||||||
else if (!__sbin)
|
|
||||||
__err |= ios_base::badbit;
|
|
||||||
if (__err)
|
|
||||||
this->setstate(__err);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename _CharT, typename _Traits>
|
|
||||||
basic_ostream<_CharT, _Traits>&
|
|
||||||
basic_ostream<_CharT, _Traits>::
|
|
||||||
put(char_type __c)
|
|
||||||
{
|
|
||||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
|
||||||
// DR 60. What is a formatted input function?
|
|
||||||
// basic_ostream::put(char_type) is an unformatted output function.
|
|
||||||
// DR 63. Exception-handling policy for unformatted output.
|
|
||||||
// Unformatted output functions should catch exceptions thrown
|
|
||||||
// from streambuf members.
|
|
||||||
sentry __cerb(*this);
|
|
||||||
if (__cerb)
|
|
||||||
{
|
|
||||||
ios_base::iostate __err = ios_base::goodbit;
|
|
||||||
__try
|
|
||||||
{
|
|
||||||
const int_type __put = this->rdbuf()->sputc(__c);
|
|
||||||
if (traits_type::eq_int_type(__put, traits_type::eof()))
|
|
||||||
__err |= ios_base::badbit;
|
|
||||||
}
|
|
||||||
__catch(__cxxabiv1::__forced_unwind&)
|
|
||||||
{
|
|
||||||
this->_M_setstate(ios_base::badbit);
|
|
||||||
__throw_exception_again;
|
|
||||||
}
|
|
||||||
__catch(...)
|
|
||||||
{ this->_M_setstate(ios_base::badbit); }
|
|
||||||
if (__err)
|
|
||||||
this->setstate(__err);
|
|
||||||
}
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename _CharT, typename _Traits>
|
|
||||||
basic_ostream<_CharT, _Traits>&
|
|
||||||
basic_ostream<_CharT, _Traits>::
|
|
||||||
write(const _CharT* __s, streamsize __n)
|
|
||||||
{
|
|
||||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
|
||||||
// DR 60. What is a formatted input function?
|
|
||||||
// basic_ostream::write(const char_type*, streamsize) is an
|
|
||||||
// unformatted output function.
|
|
||||||
// DR 63. Exception-handling policy for unformatted output.
|
|
||||||
// Unformatted output functions should catch exceptions thrown
|
|
||||||
// from streambuf members.
|
|
||||||
sentry __cerb(*this);
|
|
||||||
if (__cerb)
|
|
||||||
{
|
|
||||||
__try
|
|
||||||
{ _M_write(__s, __n); }
|
|
||||||
__catch(__cxxabiv1::__forced_unwind&)
|
|
||||||
{
|
|
||||||
this->_M_setstate(ios_base::badbit);
|
|
||||||
__throw_exception_again;
|
|
||||||
}
|
|
||||||
__catch(...)
|
|
||||||
{ this->_M_setstate(ios_base::badbit); }
|
|
||||||
}
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename _CharT, typename _Traits>
|
|
||||||
basic_ostream<_CharT, _Traits>&
|
|
||||||
basic_ostream<_CharT, _Traits>::
|
|
||||||
flush()
|
|
||||||
{
|
|
||||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
|
||||||
// DR 60. What is a formatted input function?
|
|
||||||
// basic_ostream::flush() is *not* an unformatted output function.
|
|
||||||
ios_base::iostate __err = ios_base::goodbit;
|
|
||||||
__try
|
|
||||||
{
|
|
||||||
if (this->rdbuf() && this->rdbuf()->pubsync() == -1)
|
|
||||||
__err |= ios_base::badbit;
|
|
||||||
}
|
|
||||||
__catch(__cxxabiv1::__forced_unwind&)
|
|
||||||
{
|
|
||||||
this->_M_setstate(ios_base::badbit);
|
|
||||||
__throw_exception_again;
|
|
||||||
}
|
|
||||||
__catch(...)
|
|
||||||
{ this->_M_setstate(ios_base::badbit); }
|
|
||||||
if (__err)
|
|
||||||
this->setstate(__err);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename _CharT, typename _Traits>
|
|
||||||
typename basic_ostream<_CharT, _Traits>::pos_type
|
|
||||||
basic_ostream<_CharT, _Traits>::
|
|
||||||
tellp()
|
|
||||||
{
|
|
||||||
pos_type __ret = pos_type(-1);
|
|
||||||
__try
|
|
||||||
{
|
|
||||||
if (!this->fail())
|
|
||||||
__ret = this->rdbuf()->pubseekoff(0, ios_base::cur, ios_base::out);
|
|
||||||
}
|
|
||||||
__catch(__cxxabiv1::__forced_unwind&)
|
|
||||||
{
|
|
||||||
this->_M_setstate(ios_base::badbit);
|
|
||||||
__throw_exception_again;
|
|
||||||
}
|
|
||||||
__catch(...)
|
|
||||||
{ this->_M_setstate(ios_base::badbit); }
|
|
||||||
return __ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename _CharT, typename _Traits>
|
|
||||||
basic_ostream<_CharT, _Traits>&
|
|
||||||
basic_ostream<_CharT, _Traits>::
|
|
||||||
seekp(pos_type __pos)
|
|
||||||
{
|
|
||||||
ios_base::iostate __err = ios_base::goodbit;
|
|
||||||
__try
|
|
||||||
{
|
|
||||||
if (!this->fail())
|
|
||||||
{
|
|
||||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
|
||||||
// 136. seekp, seekg setting wrong streams?
|
|
||||||
const pos_type __p = this->rdbuf()->pubseekpos(__pos,
|
|
||||||
ios_base::out);
|
|
||||||
|
|
||||||
// 129. Need error indication from seekp() and seekg()
|
|
||||||
if (__p == pos_type(off_type(-1)))
|
|
||||||
__err |= ios_base::failbit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
__catch(__cxxabiv1::__forced_unwind&)
|
|
||||||
{
|
|
||||||
this->_M_setstate(ios_base::badbit);
|
|
||||||
__throw_exception_again;
|
|
||||||
}
|
|
||||||
__catch(...)
|
|
||||||
{ this->_M_setstate(ios_base::badbit); }
|
|
||||||
if (__err)
|
|
||||||
this->setstate(__err);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename _CharT, typename _Traits>
|
|
||||||
basic_ostream<_CharT, _Traits>&
|
|
||||||
basic_ostream<_CharT, _Traits>::
|
|
||||||
seekp(off_type __off, ios_base::seekdir __dir)
|
|
||||||
{
|
|
||||||
ios_base::iostate __err = ios_base::goodbit;
|
|
||||||
__try
|
|
||||||
{
|
|
||||||
if (!this->fail())
|
|
||||||
{
|
|
||||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
|
||||||
// 136. seekp, seekg setting wrong streams?
|
|
||||||
const pos_type __p = this->rdbuf()->pubseekoff(__off, __dir,
|
|
||||||
ios_base::out);
|
|
||||||
|
|
||||||
// 129. Need error indication from seekp() and seekg()
|
|
||||||
if (__p == pos_type(off_type(-1)))
|
|
||||||
__err |= ios_base::failbit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
__catch(__cxxabiv1::__forced_unwind&)
|
|
||||||
{
|
|
||||||
this->_M_setstate(ios_base::badbit);
|
|
||||||
__throw_exception_again;
|
|
||||||
}
|
|
||||||
__catch(...)
|
|
||||||
{ this->_M_setstate(ios_base::badbit); }
|
|
||||||
if (__err)
|
|
||||||
this->setstate(__err);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename _CharT, typename _Traits>
|
|
||||||
basic_ostream<_CharT, _Traits>&
|
|
||||||
operator<<(basic_ostream<_CharT, _Traits>& __out, const char* __s)
|
|
||||||
{
|
|
||||||
if (!__s)
|
|
||||||
__out.setstate(ios_base::badbit);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
|
||||||
// 167. Improper use of traits_type::length()
|
|
||||||
const size_t __clen = char_traits<char>::length(__s);
|
|
||||||
__try
|
|
||||||
{
|
|
||||||
struct __ptr_guard
|
|
||||||
{
|
|
||||||
_CharT *__p;
|
|
||||||
__ptr_guard (_CharT *__ip): __p(__ip) { }
|
|
||||||
~__ptr_guard() { delete[] __p; }
|
|
||||||
_CharT* __get() { return __p; }
|
|
||||||
} __pg (new _CharT[__clen]);
|
|
||||||
|
|
||||||
_CharT *__ws = __pg.__get();
|
|
||||||
for (size_t __i = 0; __i < __clen; ++__i)
|
|
||||||
__ws[__i] = __out.widen(__s[__i]);
|
|
||||||
__ostream_insert(__out, __ws, __clen);
|
|
||||||
}
|
|
||||||
__catch(__cxxabiv1::__forced_unwind&)
|
|
||||||
{
|
|
||||||
__out._M_setstate(ios_base::badbit);
|
|
||||||
__throw_exception_again;
|
|
||||||
}
|
|
||||||
__catch(...)
|
|
||||||
{ __out._M_setstate(ios_base::badbit); }
|
|
||||||
}
|
|
||||||
return __out;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Inhibit implicit instantiations for required instantiations,
|
|
||||||
// which are defined via explicit instantiations elsewhere.
|
|
||||||
#if _GLIBCXX_EXTERN_TEMPLATE
|
|
||||||
extern template class basic_ostream<char>;
|
|
||||||
extern template ostream& endl(ostream&);
|
|
||||||
extern template ostream& ends(ostream&);
|
|
||||||
extern template ostream& flush(ostream&);
|
|
||||||
extern template ostream& operator<<(ostream&, char);
|
|
||||||
extern template ostream& operator<<(ostream&, unsigned char);
|
|
||||||
extern template ostream& operator<<(ostream&, signed char);
|
|
||||||
extern template ostream& operator<<(ostream&, const char*);
|
|
||||||
extern template ostream& operator<<(ostream&, const unsigned char*);
|
|
||||||
extern template ostream& operator<<(ostream&, const signed char*);
|
|
||||||
|
|
||||||
extern template ostream& ostream::_M_insert(long);
|
|
||||||
extern template ostream& ostream::_M_insert(unsigned long);
|
|
||||||
extern template ostream& ostream::_M_insert(bool);
|
|
||||||
#ifdef _GLIBCXX_USE_LONG_LONG
|
|
||||||
extern template ostream& ostream::_M_insert(long long);
|
|
||||||
extern template ostream& ostream::_M_insert(unsigned long long);
|
|
||||||
#endif
|
|
||||||
extern template ostream& ostream::_M_insert(double);
|
|
||||||
extern template ostream& ostream::_M_insert(long double);
|
|
||||||
extern template ostream& ostream::_M_insert(const void*);
|
|
||||||
|
|
||||||
#ifdef _GLIBCXX_USE_WCHAR_T
|
|
||||||
extern template class basic_ostream<wchar_t>;
|
|
||||||
extern template wostream& endl(wostream&);
|
|
||||||
extern template wostream& ends(wostream&);
|
|
||||||
extern template wostream& flush(wostream&);
|
|
||||||
extern template wostream& operator<<(wostream&, wchar_t);
|
|
||||||
extern template wostream& operator<<(wostream&, char);
|
|
||||||
extern template wostream& operator<<(wostream&, const wchar_t*);
|
|
||||||
extern template wostream& operator<<(wostream&, const char*);
|
|
||||||
|
|
||||||
extern template wostream& wostream::_M_insert(long);
|
|
||||||
extern template wostream& wostream::_M_insert(unsigned long);
|
|
||||||
extern template wostream& wostream::_M_insert(bool);
|
|
||||||
#ifdef _GLIBCXX_USE_LONG_LONG
|
|
||||||
extern template wostream& wostream::_M_insert(long long);
|
|
||||||
extern template wostream& wostream::_M_insert(unsigned long long);
|
|
||||||
#endif
|
|
||||||
extern template wostream& wostream::_M_insert(double);
|
|
||||||
extern template wostream& wostream::_M_insert(long double);
|
|
||||||
extern template wostream& wostream::_M_insert(const void*);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
_GLIBCXX_END_NAMESPACE_VERSION
|
|
||||||
} // namespace std
|
|
||||||
|
|
||||||
#endif
|
|
Binary file not shown.
@ -1,129 +0,0 @@
|
|||||||
// Helpers for ostream inserters -*- C++ -*-
|
|
||||||
|
|
||||||
// Copyright (C) 2007-2020 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.
|
|
||||||
|
|
||||||
// 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 bits/ostream_insert.h
|
|
||||||
* This is an internal header file, included by other library headers.
|
|
||||||
* Do not attempt to use it directly. @headername{ostream}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _OSTREAM_INSERT_H
|
|
||||||
#define _OSTREAM_INSERT_H 1
|
|
||||||
|
|
||||||
#pragma GCC system_header
|
|
||||||
|
|
||||||
#include <iosfwd>
|
|
||||||
#include <bits/cxxabi_forced.h>
|
|
||||||
|
|
||||||
namespace std _GLIBCXX_VISIBILITY(default)
|
|
||||||
{
|
|
||||||
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|
||||||
|
|
||||||
template<typename _CharT, typename _Traits>
|
|
||||||
inline void
|
|
||||||
__ostream_write(basic_ostream<_CharT, _Traits>& __out,
|
|
||||||
const _CharT* __s, streamsize __n)
|
|
||||||
{
|
|
||||||
typedef basic_ostream<_CharT, _Traits> __ostream_type;
|
|
||||||
typedef typename __ostream_type::ios_base __ios_base;
|
|
||||||
|
|
||||||
const streamsize __put = __out.rdbuf()->sputn(__s, __n);
|
|
||||||
if (__put != __n)
|
|
||||||
__out.setstate(__ios_base::badbit);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename _CharT, typename _Traits>
|
|
||||||
inline void
|
|
||||||
__ostream_fill(basic_ostream<_CharT, _Traits>& __out, streamsize __n)
|
|
||||||
{
|
|
||||||
typedef basic_ostream<_CharT, _Traits> __ostream_type;
|
|
||||||
typedef typename __ostream_type::ios_base __ios_base;
|
|
||||||
|
|
||||||
const _CharT __c = __out.fill();
|
|
||||||
for (; __n > 0; --__n)
|
|
||||||
{
|
|
||||||
const typename _Traits::int_type __put = __out.rdbuf()->sputc(__c);
|
|
||||||
if (_Traits::eq_int_type(__put, _Traits::eof()))
|
|
||||||
{
|
|
||||||
__out.setstate(__ios_base::badbit);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename _CharT, typename _Traits>
|
|
||||||
basic_ostream<_CharT, _Traits>&
|
|
||||||
__ostream_insert(basic_ostream<_CharT, _Traits>& __out,
|
|
||||||
const _CharT* __s, streamsize __n)
|
|
||||||
{
|
|
||||||
typedef basic_ostream<_CharT, _Traits> __ostream_type;
|
|
||||||
typedef typename __ostream_type::ios_base __ios_base;
|
|
||||||
|
|
||||||
typename __ostream_type::sentry __cerb(__out);
|
|
||||||
if (__cerb)
|
|
||||||
{
|
|
||||||
__try
|
|
||||||
{
|
|
||||||
const streamsize __w = __out.width();
|
|
||||||
if (__w > __n)
|
|
||||||
{
|
|
||||||
const bool __left = ((__out.flags()
|
|
||||||
& __ios_base::adjustfield)
|
|
||||||
== __ios_base::left);
|
|
||||||
if (!__left)
|
|
||||||
__ostream_fill(__out, __w - __n);
|
|
||||||
if (__out.good())
|
|
||||||
__ostream_write(__out, __s, __n);
|
|
||||||
if (__left && __out.good())
|
|
||||||
__ostream_fill(__out, __w - __n);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
__ostream_write(__out, __s, __n);
|
|
||||||
__out.width(0);
|
|
||||||
}
|
|
||||||
__catch(__cxxabiv1::__forced_unwind&)
|
|
||||||
{
|
|
||||||
__out._M_setstate(__ios_base::badbit);
|
|
||||||
__throw_exception_again;
|
|
||||||
}
|
|
||||||
__catch(...)
|
|
||||||
{ __out._M_setstate(__ios_base::badbit); }
|
|
||||||
}
|
|
||||||
return __out;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Inhibit implicit instantiations for required instantiations,
|
|
||||||
// which are defined via explicit instantiations elsewhere.
|
|
||||||
#if _GLIBCXX_EXTERN_TEMPLATE
|
|
||||||
extern template ostream& __ostream_insert(ostream&, const char*, streamsize);
|
|
||||||
|
|
||||||
#ifdef _GLIBCXX_USE_WCHAR_T
|
|
||||||
extern template wostream& __ostream_insert(wostream&, const wchar_t*,
|
|
||||||
streamsize);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
_GLIBCXX_END_NAMESPACE_VERSION
|
|
||||||
} // namespace std
|
|
||||||
|
|
||||||
#endif /* _OSTREAM_INSERT_H */
|
|
Binary file not shown.
@ -1,253 +0,0 @@
|
|||||||
// Position types -*- C++ -*-
|
|
||||||
|
|
||||||
// Copyright (C) 1997-2020 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.
|
|
||||||
|
|
||||||
// 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 bits/postypes.h
|
|
||||||
* This is an internal header file, included by other library headers.
|
|
||||||
* Do not attempt to use it directly. @headername{iosfwd}
|
|
||||||
*/
|
|
||||||
|
|
||||||
//
|
|
||||||
// ISO C++ 14882: 27.4.1 - Types
|
|
||||||
// ISO C++ 14882: 27.4.3 - Template class fpos
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef _GLIBCXX_POSTYPES_H
|
|
||||||
#define _GLIBCXX_POSTYPES_H 1
|
|
||||||
|
|
||||||
#pragma GCC system_header
|
|
||||||
|
|
||||||
#include <cwchar> // For mbstate_t
|
|
||||||
|
|
||||||
// XXX If <stdint.h> is really needed, make sure to define the macros
|
|
||||||
// before including it, in order not to break <tr1/cstdint> (and <cstdint>
|
|
||||||
// in C++11). Reconsider all this as soon as possible...
|
|
||||||
#if (defined(_GLIBCXX_HAVE_INT64_T) && !defined(_GLIBCXX_HAVE_INT64_T_LONG) \
|
|
||||||
&& !defined(_GLIBCXX_HAVE_INT64_T_LONG_LONG))
|
|
||||||
|
|
||||||
#ifndef __STDC_LIMIT_MACROS
|
|
||||||
# define _UNDEF__STDC_LIMIT_MACROS
|
|
||||||
# define __STDC_LIMIT_MACROS
|
|
||||||
#endif
|
|
||||||
#ifndef __STDC_CONSTANT_MACROS
|
|
||||||
# define _UNDEF__STDC_CONSTANT_MACROS
|
|
||||||
# define __STDC_CONSTANT_MACROS
|
|
||||||
#endif
|
|
||||||
#include <stdint.h> // For int64_t
|
|
||||||
#ifdef _UNDEF__STDC_LIMIT_MACROS
|
|
||||||
# undef __STDC_LIMIT_MACROS
|
|
||||||
# undef _UNDEF__STDC_LIMIT_MACROS
|
|
||||||
#endif
|
|
||||||
#ifdef _UNDEF__STDC_CONSTANT_MACROS
|
|
||||||
# undef __STDC_CONSTANT_MACROS
|
|
||||||
# undef _UNDEF__STDC_CONSTANT_MACROS
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace std _GLIBCXX_VISIBILITY(default)
|
|
||||||
{
|
|
||||||
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|
||||||
|
|
||||||
// The types streamoff, streampos and wstreampos and the class
|
|
||||||
// template fpos<> are described in clauses 21.1.2, 21.1.3, 27.1.2,
|
|
||||||
// 27.2, 27.4.1, 27.4.3 and D.6. Despite all this verbiage, the
|
|
||||||
// behaviour of these types is mostly implementation defined or
|
|
||||||
// unspecified. The behaviour in this implementation is as noted
|
|
||||||
// below.
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Type used by fpos, char_traits<char>, and char_traits<wchar_t>.
|
|
||||||
*
|
|
||||||
* In clauses 21.1.3.1 and 27.4.1 streamoff is described as an
|
|
||||||
* implementation defined type.
|
|
||||||
* Note: In versions of GCC up to and including GCC 3.3, streamoff
|
|
||||||
* was typedef long.
|
|
||||||
*/
|
|
||||||
#ifdef _GLIBCXX_HAVE_INT64_T_LONG
|
|
||||||
typedef long streamoff;
|
|
||||||
#elif defined(_GLIBCXX_HAVE_INT64_T_LONG_LONG)
|
|
||||||
typedef long long streamoff;
|
|
||||||
#elif defined(_GLIBCXX_HAVE_INT64_T)
|
|
||||||
typedef int64_t streamoff;
|
|
||||||
#else
|
|
||||||
typedef long long streamoff;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/// Integral type for I/O operation counts and buffer sizes.
|
|
||||||
typedef ptrdiff_t streamsize; // Signed integral type
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Class representing stream positions.
|
|
||||||
*
|
|
||||||
* The standard places no requirements upon the template parameter StateT.
|
|
||||||
* In this implementation StateT must be DefaultConstructible,
|
|
||||||
* CopyConstructible and Assignable. The standard only requires that fpos
|
|
||||||
* should contain a member of type StateT. In this implementation it also
|
|
||||||
* contains an offset stored as a signed integer.
|
|
||||||
*
|
|
||||||
* @param StateT Type passed to and returned from state().
|
|
||||||
*/
|
|
||||||
template<typename _StateT>
|
|
||||||
class fpos
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
streamoff _M_off;
|
|
||||||
_StateT _M_state;
|
|
||||||
|
|
||||||
public:
|
|
||||||
// The standard doesn't require that fpos objects can be default
|
|
||||||
// constructed. This implementation provides a default
|
|
||||||
// constructor that initializes the offset to 0 and default
|
|
||||||
// constructs the state.
|
|
||||||
fpos()
|
|
||||||
: _M_off(0), _M_state() { }
|
|
||||||
|
|
||||||
// The standard requires that fpos objects can be constructed
|
|
||||||
// from streamoff objects using the constructor syntax, and
|
|
||||||
// fails to give any meaningful semantics. In this
|
|
||||||
// implementation implicit conversion is also allowed, and this
|
|
||||||
// constructor stores the streamoff as the offset and default
|
|
||||||
// constructs the state.
|
|
||||||
/// Construct position from offset.
|
|
||||||
fpos(streamoff __off)
|
|
||||||
: _M_off(__off), _M_state() { }
|
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
fpos(const fpos&) = default;
|
|
||||||
fpos& operator=(const fpos&) = default;
|
|
||||||
~fpos() = default;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/// Convert to streamoff.
|
|
||||||
operator streamoff() const { return _M_off; }
|
|
||||||
|
|
||||||
/// Remember the value of @a st.
|
|
||||||
void
|
|
||||||
state(_StateT __st)
|
|
||||||
{ _M_state = __st; }
|
|
||||||
|
|
||||||
/// Return the last set value of @a st.
|
|
||||||
_StateT
|
|
||||||
state() const
|
|
||||||
{ return _M_state; }
|
|
||||||
|
|
||||||
// The standard requires that this operator must be defined, but
|
|
||||||
// gives no semantics. In this implementation it just adds its
|
|
||||||
// argument to the stored offset and returns *this.
|
|
||||||
/// Add offset to this position.
|
|
||||||
fpos&
|
|
||||||
operator+=(streamoff __off)
|
|
||||||
{
|
|
||||||
_M_off += __off;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
// The standard requires that this operator must be defined, but
|
|
||||||
// gives no semantics. In this implementation it just subtracts
|
|
||||||
// its argument from the stored offset and returns *this.
|
|
||||||
/// Subtract offset from this position.
|
|
||||||
fpos&
|
|
||||||
operator-=(streamoff __off)
|
|
||||||
{
|
|
||||||
_M_off -= __off;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
// The standard requires that this operator must be defined, but
|
|
||||||
// defines its semantics only in terms of operator-. In this
|
|
||||||
// implementation it constructs a copy of *this, adds the
|
|
||||||
// argument to that copy using operator+= and then returns the
|
|
||||||
// copy.
|
|
||||||
/// Add position and offset.
|
|
||||||
fpos
|
|
||||||
operator+(streamoff __off) const
|
|
||||||
{
|
|
||||||
fpos __pos(*this);
|
|
||||||
__pos += __off;
|
|
||||||
return __pos;
|
|
||||||
}
|
|
||||||
|
|
||||||
// The standard requires that this operator must be defined, but
|
|
||||||
// defines its semantics only in terms of operator+. In this
|
|
||||||
// implementation it constructs a copy of *this, subtracts the
|
|
||||||
// argument from that copy using operator-= and then returns the
|
|
||||||
// copy.
|
|
||||||
/// Subtract offset from position.
|
|
||||||
fpos
|
|
||||||
operator-(streamoff __off) const
|
|
||||||
{
|
|
||||||
fpos __pos(*this);
|
|
||||||
__pos -= __off;
|
|
||||||
return __pos;
|
|
||||||
}
|
|
||||||
|
|
||||||
// The standard requires that this operator must be defined, but
|
|
||||||
// defines its semantics only in terms of operator+. In this
|
|
||||||
// implementation it returns the difference between the offset
|
|
||||||
// stored in *this and in the argument.
|
|
||||||
/// Subtract position to return offset.
|
|
||||||
streamoff
|
|
||||||
operator-(const fpos& __other) const
|
|
||||||
{ return _M_off - __other._M_off; }
|
|
||||||
};
|
|
||||||
|
|
||||||
// The standard only requires that operator== must be an
|
|
||||||
// equivalence relation. In this implementation two fpos<StateT>
|
|
||||||
// objects belong to the same equivalence class if the contained
|
|
||||||
// offsets compare equal.
|
|
||||||
/// Test if equivalent to another position.
|
|
||||||
template<typename _StateT>
|
|
||||||
inline bool
|
|
||||||
operator==(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs)
|
|
||||||
{ return streamoff(__lhs) == streamoff(__rhs); }
|
|
||||||
|
|
||||||
template<typename _StateT>
|
|
||||||
inline bool
|
|
||||||
operator!=(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs)
|
|
||||||
{ return streamoff(__lhs) != streamoff(__rhs); }
|
|
||||||
|
|
||||||
// Clauses 21.1.3.1 and 21.1.3.2 describe streampos and wstreampos
|
|
||||||
// as implementation defined types, but clause 27.2 requires that
|
|
||||||
// they must both be typedefs for fpos<mbstate_t>
|
|
||||||
/// File position for char streams.
|
|
||||||
typedef fpos<mbstate_t> streampos;
|
|
||||||
/// File position for wchar_t streams.
|
|
||||||
typedef fpos<mbstate_t> wstreampos;
|
|
||||||
|
|
||||||
#ifdef _GLIBCXX_USE_CHAR8_T
|
|
||||||
/// File position for char8_t streams.
|
|
||||||
typedef fpos<mbstate_t> u8streampos;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
/// File position for char16_t streams.
|
|
||||||
typedef fpos<mbstate_t> u16streampos;
|
|
||||||
/// File position for char32_t streams.
|
|
||||||
typedef fpos<mbstate_t> u32streampos;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
_GLIBCXX_END_NAMESPACE_VERSION
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
#endif
|
|
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user