Thanks for using Compiler Explorer
Sponsors
Jakt
C++
Ada
Analysis
Android Java
Android Kotlin
Assembly
C
C3
Carbon
C++ (Circle)
CIRCT
Clean
CMake
CMakeScript
COBOL
C++ for OpenCL
MLIR
Cppx
Cppx-Blue
Cppx-Gold
Cpp2-cppfront
Crystal
C#
CUDA C++
D
Dart
Elixir
Erlang
Fortran
F#
Go
Haskell
HLSL
Hook
Hylo
ispc
Java
Julia
Kotlin
LLVM IR
LLVM MIR
Modula-2
Nim
Objective-C
Objective-C++
OCaml
OpenCL C
Pascal
Pony
Python
Racket
Ruby
Rust
Snowball
Scala
Solidity
Spice
Swift
LLVM TableGen
Toit
TypeScript Native
V
Vala
Visual Basic
WASM
Zig
Javascript
GIMPLE
c++ source #1
Output
Compile to binary object
Link to binary
Execute the code
Intel asm syntax
Demangle identifiers
Verbose demangling
Filters
Unused labels
Library functions
Directives
Comments
Horizontal whitespace
Debug intrinsics
Compiler
6502-c++ 11.1.0
ARM GCC 10.2.0
ARM GCC 10.3.0
ARM GCC 10.4.0
ARM GCC 10.5.0
ARM GCC 11.1.0
ARM GCC 11.2.0
ARM GCC 11.3.0
ARM GCC 11.4.0
ARM GCC 12.1.0
ARM GCC 12.2.0
ARM GCC 12.3.0
ARM GCC 12.4.0
ARM GCC 13.1.0
ARM GCC 13.2.0
ARM GCC 13.2.0 (unknown-eabi)
ARM GCC 13.3.0
ARM GCC 14.1.0
ARM GCC 4.5.4
ARM GCC 4.6.4
ARM GCC 5.4
ARM GCC 6.3.0
ARM GCC 6.4.0
ARM GCC 7.3.0
ARM GCC 7.5.0
ARM GCC 8.2.0
ARM GCC 8.5.0
ARM GCC 9.3.0
ARM GCC 9.4.0
ARM GCC 9.5.0
ARM GCC trunk
ARM gcc 10.2.1 (none)
ARM gcc 10.3.1 (2021.07 none)
ARM gcc 10.3.1 (2021.10 none)
ARM gcc 11.2.1 (none)
ARM gcc 5.4.1 (none)
ARM gcc 7.2.1 (none)
ARM gcc 8.2 (WinCE)
ARM gcc 8.3.1 (none)
ARM gcc 9.2.1 (none)
ARM msvc v19.0 (WINE)
ARM msvc v19.10 (WINE)
ARM msvc v19.14 (WINE)
ARM64 Morello gcc 10.1 Alpha 2
ARM64 gcc 10.2
ARM64 gcc 10.3
ARM64 gcc 10.4
ARM64 gcc 10.5.0
ARM64 gcc 11.1
ARM64 gcc 11.2
ARM64 gcc 11.3
ARM64 gcc 11.4.0
ARM64 gcc 12.1
ARM64 gcc 12.2.0
ARM64 gcc 12.3.0
ARM64 gcc 12.4.0
ARM64 gcc 13.1.0
ARM64 gcc 13.2.0
ARM64 gcc 13.3.0
ARM64 gcc 14.1.0
ARM64 gcc 4.9.4
ARM64 gcc 5.4
ARM64 gcc 5.5.0
ARM64 gcc 6.3
ARM64 gcc 6.4
ARM64 gcc 7.3
ARM64 gcc 7.5
ARM64 gcc 8.2
ARM64 gcc 8.5
ARM64 gcc 9.3
ARM64 gcc 9.4
ARM64 gcc 9.5
ARM64 gcc trunk
ARM64 msvc v19.14 (WINE)
AVR gcc 10.3.0
AVR gcc 11.1.0
AVR gcc 12.1.0
AVR gcc 12.2.0
AVR gcc 12.3.0
AVR gcc 12.4.0
AVR gcc 13.1.0
AVR gcc 13.2.0
AVR gcc 13.3.0
AVR gcc 14.1.0
AVR gcc 4.5.4
AVR gcc 4.6.4
AVR gcc 5.4.0
AVR gcc 9.2.0
AVR gcc 9.3.0
Arduino Mega (1.8.9)
Arduino Uno (1.8.9)
BPF clang (trunk)
BPF clang 13.0.0
BPF clang 14.0.0
BPF clang 15.0.0
BPF clang 16.0.0
BPF clang 17.0.1
BPF clang 18.1.0
BPF gcc 13.1.0
BPF gcc 13.2.0
BPF gcc 13.3.0
BPF gcc trunk
EDG (experimental reflection)
EDG 6.5
EDG 6.5 (GNU mode gcc 13)
EDG 6.6
EDG 6.6 (GNU mode gcc 13)
FRC 2019
FRC 2020
FRC 2023
KVX ACB 4.1.0 (GCC 7.5.0)
KVX ACB 4.1.0-cd1 (GCC 7.5.0)
KVX ACB 4.10.0 (GCC 10.3.1)
KVX ACB 4.11.1 (GCC 10.3.1)
KVX ACB 4.12.0 (GCC 11.3.0)
KVX ACB 4.2.0 (GCC 7.5.0)
KVX ACB 4.3.0 (GCC 7.5.0)
KVX ACB 4.4.0 (GCC 7.5.0)
KVX ACB 4.6.0 (GCC 9.4.1)
KVX ACB 4.8.0 (GCC 9.4.1)
KVX ACB 4.9.0 (GCC 9.4.1)
KVX ACB 5.0.0 (GCC 12.2.1)
M68K gcc 13.1.0
M68K gcc 13.2.0
M68K gcc 13.3.0
M68K gcc 14.1.0
M68k clang (trunk)
MRISC32 gcc (trunk)
MSP430 gcc 4.5.3
MSP430 gcc 5.3.0
MSP430 gcc 6.2.1
MinGW clang 14.0.3
MinGW clang 14.0.6
MinGW clang 15.0.7
MinGW clang 16.0.0
MinGW clang 16.0.2
MinGW gcc 11.3.0
MinGW gcc 12.1.0
MinGW gcc 12.2.0
MinGW gcc 13.1.0
RISC-V (32-bits) gcc (trunk)
RISC-V (32-bits) gcc 10.2.0
RISC-V (32-bits) gcc 10.3.0
RISC-V (32-bits) gcc 11.2.0
RISC-V (32-bits) gcc 11.3.0
RISC-V (32-bits) gcc 11.4.0
RISC-V (32-bits) gcc 12.1.0
RISC-V (32-bits) gcc 12.2.0
RISC-V (32-bits) gcc 12.3.0
RISC-V (32-bits) gcc 12.4.0
RISC-V (32-bits) gcc 13.1.0
RISC-V (32-bits) gcc 13.2.0
RISC-V (32-bits) gcc 13.3.0
RISC-V (32-bits) gcc 14.1.0
RISC-V (32-bits) gcc 8.2.0
RISC-V (32-bits) gcc 8.5.0
RISC-V (32-bits) gcc 9.4.0
RISC-V (64-bits) gcc (trunk)
RISC-V (64-bits) gcc 10.2.0
RISC-V (64-bits) gcc 10.3.0
RISC-V (64-bits) gcc 11.2.0
RISC-V (64-bits) gcc 11.3.0
RISC-V (64-bits) gcc 11.4.0
RISC-V (64-bits) gcc 12.1.0
RISC-V (64-bits) gcc 12.2.0
RISC-V (64-bits) gcc 12.3.0
RISC-V (64-bits) gcc 12.4.0
RISC-V (64-bits) gcc 13.1.0
RISC-V (64-bits) gcc 13.2.0
RISC-V (64-bits) gcc 13.3.0
RISC-V (64-bits) gcc 14.1.0
RISC-V (64-bits) gcc 8.2.0
RISC-V (64-bits) gcc 8.5.0
RISC-V (64-bits) gcc 9.4.0
RISC-V rv32gc clang (trunk)
RISC-V rv32gc clang 10.0.0
RISC-V rv32gc clang 10.0.1
RISC-V rv32gc clang 11.0.0
RISC-V rv32gc clang 11.0.1
RISC-V rv32gc clang 12.0.0
RISC-V rv32gc clang 12.0.1
RISC-V rv32gc clang 13.0.0
RISC-V rv32gc clang 13.0.1
RISC-V rv32gc clang 14.0.0
RISC-V rv32gc clang 15.0.0
RISC-V rv32gc clang 16.0.0
RISC-V rv32gc clang 17.0.1
RISC-V rv32gc clang 18.1.0
RISC-V rv32gc clang 9.0.0
RISC-V rv32gc clang 9.0.1
RISC-V rv64gc clang (trunk)
RISC-V rv64gc clang 10.0.0
RISC-V rv64gc clang 10.0.1
RISC-V rv64gc clang 11.0.0
RISC-V rv64gc clang 11.0.1
RISC-V rv64gc clang 12.0.0
RISC-V rv64gc clang 12.0.1
RISC-V rv64gc clang 13.0.0
RISC-V rv64gc clang 13.0.1
RISC-V rv64gc clang 14.0.0
RISC-V rv64gc clang 15.0.0
RISC-V rv64gc clang 16.0.0
RISC-V rv64gc clang 17.0.1
RISC-V rv64gc clang 18.1.0
RISC-V rv64gc clang 9.0.0
RISC-V rv64gc clang 9.0.1
Raspbian Buster
Raspbian Stretch
SPARC LEON gcc 12.2.0
SPARC LEON gcc 12.3.0
SPARC LEON gcc 12.4.0
SPARC LEON gcc 13.1.0
SPARC LEON gcc 13.2.0
SPARC LEON gcc 13.3.0
SPARC LEON gcc 14.1.0
SPARC gcc 12.2.0
SPARC gcc 12.3.0
SPARC gcc 12.4.0
SPARC gcc 13.1.0
SPARC gcc 13.2.0
SPARC gcc 13.3.0
SPARC gcc 14.1.0
SPARC64 gcc 12.2.0
SPARC64 gcc 12.3.0
SPARC64 gcc 12.4.0
SPARC64 gcc 13.1.0
SPARC64 gcc 13.2.0
SPARC64 gcc 13.3.0
SPARC64 gcc 14.1.0
TI C6x gcc 12.2.0
TI C6x gcc 12.3.0
TI C6x gcc 12.4.0
TI C6x gcc 13.1.0
TI C6x gcc 13.2.0
TI C6x gcc 13.3.0
TI C6x gcc 14.1.0
TI CL430 21.6.1
VAX gcc NetBSDELF 10.4.0
VAX gcc NetBSDELF 10.5.0 (Nov 15 03:50:22 2023)
WebAssembly clang (trunk)
Xtensa ESP32 gcc 11.2.0 (2022r1)
Xtensa ESP32 gcc 12.2.0 (20230208)
Xtensa ESP32 gcc 8.2.0 (2019r2)
Xtensa ESP32 gcc 8.2.0 (2020r1)
Xtensa ESP32 gcc 8.2.0 (2020r2)
Xtensa ESP32 gcc 8.4.0 (2020r3)
Xtensa ESP32 gcc 8.4.0 (2021r1)
Xtensa ESP32 gcc 8.4.0 (2021r2)
Xtensa ESP32-S2 gcc 11.2.0 (2022r1)
Xtensa ESP32-S2 gcc 12.2.0 (20230208)
Xtensa ESP32-S2 gcc 8.2.0 (2019r2)
Xtensa ESP32-S2 gcc 8.2.0 (2020r1)
Xtensa ESP32-S2 gcc 8.2.0 (2020r2)
Xtensa ESP32-S2 gcc 8.4.0 (2020r3)
Xtensa ESP32-S2 gcc 8.4.0 (2021r1)
Xtensa ESP32-S2 gcc 8.4.0 (2021r2)
Xtensa ESP32-S3 gcc 11.2.0 (2022r1)
Xtensa ESP32-S3 gcc 12.2.0 (20230208)
Xtensa ESP32-S3 gcc 8.4.0 (2020r3)
Xtensa ESP32-S3 gcc 8.4.0 (2021r1)
Xtensa ESP32-S3 gcc 8.4.0 (2021r2)
arm64 msvc v19.20 VS16.0
arm64 msvc v19.21 VS16.1
arm64 msvc v19.22 VS16.2
arm64 msvc v19.23 VS16.3
arm64 msvc v19.24 VS16.4
arm64 msvc v19.25 VS16.5
arm64 msvc v19.27 VS16.7
arm64 msvc v19.28 VS16.8
arm64 msvc v19.28 VS16.9
arm64 msvc v19.29 VS16.10
arm64 msvc v19.29 VS16.11
arm64 msvc v19.30 VS17.0
arm64 msvc v19.31 VS17.1
arm64 msvc v19.32 VS17.2
arm64 msvc v19.33 VS17.3
arm64 msvc v19.34 VS17.4
arm64 msvc v19.35 VS17.5
arm64 msvc v19.36 VS17.6
arm64 msvc v19.37 VS17.7
arm64 msvc v19.38 VS17.8
arm64 msvc v19.39 VS17.9
arm64 msvc v19.40 VS17.10
arm64 msvc v19.latest
armv7-a clang (trunk)
armv7-a clang 10.0.0
armv7-a clang 10.0.1
armv7-a clang 11.0.0
armv7-a clang 11.0.1
armv7-a clang 12.0.0
armv7-a clang 12.0.1
armv7-a clang 13.0.0
armv7-a clang 13.0.1
armv7-a clang 14.0.0
armv7-a clang 15.0.0
armv7-a clang 16.0.0
armv7-a clang 17.0.1
armv7-a clang 18.1.0
armv7-a clang 9.0.0
armv7-a clang 9.0.1
armv8-a clang (all architectural features, trunk)
armv8-a clang (trunk)
armv8-a clang 10.0.0
armv8-a clang 10.0.1
armv8-a clang 11.0.0
armv8-a clang 11.0.1
armv8-a clang 12.0.0
armv8-a clang 13.0.0
armv8-a clang 14.0.0
armv8-a clang 15.0.0
armv8-a clang 16.0.0
armv8-a clang 17.0.1
armv8-a clang 18.1.0
armv8-a clang 9.0.0
armv8-a clang 9.0.1
ellcc 0.1.33
ellcc 0.1.34
ellcc 2017-07-16
hexagon-clang 16.0.5
llvm-mos atari2600-3e
llvm-mos atari2600-4k
llvm-mos atari2600-common
llvm-mos atari5200-supercart
llvm-mos atari8-cart-megacart
llvm-mos atari8-cart-std
llvm-mos atari8-cart-xegs
llvm-mos atari8-common
llvm-mos atari8-dos
llvm-mos c128
llvm-mos c64
llvm-mos commodore
llvm-mos cpm65
llvm-mos cx16
llvm-mos dodo
llvm-mos eater
llvm-mos mega65
llvm-mos nes
llvm-mos nes-action53
llvm-mos nes-cnrom
llvm-mos nes-gtrom
llvm-mos nes-mmc1
llvm-mos nes-mmc3
llvm-mos nes-nrom
llvm-mos nes-unrom
llvm-mos nes-unrom-512
llvm-mos osi-c1p
llvm-mos pce
llvm-mos pce-cd
llvm-mos pce-common
llvm-mos pet
llvm-mos rp6502
llvm-mos rpc8e
llvm-mos supervision
llvm-mos vic20
loongarch64 gcc 12.2.0
loongarch64 gcc 12.3.0
loongarch64 gcc 12.4.0
loongarch64 gcc 13.1.0
loongarch64 gcc 13.2.0
loongarch64 gcc 13.3.0
loongarch64 gcc 14.1.0
mips clang 13.0.0
mips clang 14.0.0
mips clang 15.0.0
mips clang 16.0.0
mips clang 17.0.1
mips clang 18.1.0
mips gcc 11.2.0
mips gcc 12.1.0
mips gcc 12.2.0
mips gcc 12.3.0
mips gcc 12.4.0
mips gcc 13.1.0
mips gcc 13.2.0
mips gcc 13.3.0
mips gcc 14.1.0
mips gcc 4.9.4
mips gcc 5.4
mips gcc 5.5.0
mips gcc 9.3.0 (codescape)
mips gcc 9.5.0
mips64 (el) gcc 12.1.0
mips64 (el) gcc 12.2.0
mips64 (el) gcc 12.3.0
mips64 (el) gcc 12.4.0
mips64 (el) gcc 13.1.0
mips64 (el) gcc 13.2.0
mips64 (el) gcc 13.3.0
mips64 (el) gcc 14.1.0
mips64 (el) gcc 4.9.4
mips64 (el) gcc 5.4.0
mips64 (el) gcc 5.5.0
mips64 (el) gcc 9.5.0
mips64 clang 13.0.0
mips64 clang 14.0.0
mips64 clang 15.0.0
mips64 clang 16.0.0
mips64 clang 17.0.1
mips64 clang 18.1.0
mips64 gcc 11.2.0
mips64 gcc 12.1.0
mips64 gcc 12.2.0
mips64 gcc 12.3.0
mips64 gcc 12.4.0
mips64 gcc 13.1.0
mips64 gcc 13.2.0
mips64 gcc 13.3.0
mips64 gcc 14.1.0
mips64 gcc 4.9.4
mips64 gcc 5.4.0
mips64 gcc 5.5.0
mips64 gcc 9.5.0
mips64el clang 13.0.0
mips64el clang 14.0.0
mips64el clang 15.0.0
mips64el clang 16.0.0
mips64el clang 17.0.1
mips64el clang 18.1.0
mipsel clang 13.0.0
mipsel clang 14.0.0
mipsel clang 15.0.0
mipsel clang 16.0.0
mipsel clang 17.0.1
mipsel clang 18.1.0
mipsel gcc 12.1.0
mipsel gcc 12.2.0
mipsel gcc 12.3.0
mipsel gcc 12.4.0
mipsel gcc 13.1.0
mipsel gcc 13.2.0
mipsel gcc 13.3.0
mipsel gcc 14.1.0
mipsel gcc 4.9.4
mipsel gcc 5.4.0
mipsel gcc 5.5.0
mipsel gcc 9.5.0
nanoMIPS gcc 6.3.0 (mtk)
power gcc 11.2.0
power gcc 12.1.0
power gcc 12.2.0
power gcc 12.3.0
power gcc 12.4.0
power gcc 13.1.0
power gcc 13.2.0
power gcc 13.3.0
power gcc 14.1.0
power gcc 4.8.5
power64 AT12.0 (gcc8)
power64 AT13.0 (gcc9)
power64 gcc 11.2.0
power64 gcc 12.1.0
power64 gcc 12.2.0
power64 gcc 12.3.0
power64 gcc 12.4.0
power64 gcc 13.1.0
power64 gcc 13.2.0
power64 gcc 13.3.0
power64 gcc 14.1.0
power64 gcc trunk
power64le AT12.0 (gcc8)
power64le AT13.0 (gcc9)
power64le clang (trunk)
power64le gcc 11.2.0
power64le gcc 12.1.0
power64le gcc 12.2.0
power64le gcc 12.3.0
power64le gcc 12.4.0
power64le gcc 13.1.0
power64le gcc 13.2.0
power64le gcc 13.3.0
power64le gcc 14.1.0
power64le gcc 6.3.0
power64le gcc trunk
powerpc64 clang (trunk)
s390x gcc 11.2.0
s390x gcc 12.1.0
s390x gcc 12.2.0
s390x gcc 12.3.0
s390x gcc 12.4.0
s390x gcc 13.1.0
s390x gcc 13.2.0
s390x gcc 13.3.0
s390x gcc 14.1.0
sh gcc 12.2.0
sh gcc 12.3.0
sh gcc 12.4.0
sh gcc 13.1.0
sh gcc 13.2.0
sh gcc 13.3.0
sh gcc 14.1.0
sh gcc 4.9.4
sh gcc 9.5.0
vast (trunk)
x64 msvc v19.0 (WINE)
x64 msvc v19.10 (WINE)
x64 msvc v19.14 (WINE)
x64 msvc v19.20 VS16.0
x64 msvc v19.21 VS16.1
x64 msvc v19.22 VS16.2
x64 msvc v19.23 VS16.3
x64 msvc v19.24 VS16.4
x64 msvc v19.25 VS16.5
x64 msvc v19.27 VS16.7
x64 msvc v19.28 VS16.8
x64 msvc v19.28 VS16.9
x64 msvc v19.29 VS16.10
x64 msvc v19.29 VS16.11
x64 msvc v19.30 VS17.0
x64 msvc v19.31 VS17.1
x64 msvc v19.32 VS17.2
x64 msvc v19.33 VS17.3
x64 msvc v19.34 VS17.4
x64 msvc v19.35 VS17.5
x64 msvc v19.36 VS17.6
x64 msvc v19.37 VS17.7
x64 msvc v19.38 VS17.8
x64 msvc v19.39 VS17.9
x64 msvc v19.40 VS17.10
x64 msvc v19.latest
x86 djgpp 4.9.4
x86 djgpp 5.5.0
x86 djgpp 6.4.0
x86 djgpp 7.2.0
x86 msvc v19.0 (WINE)
x86 msvc v19.10 (WINE)
x86 msvc v19.14 (WINE)
x86 msvc v19.20 VS16.0
x86 msvc v19.21 VS16.1
x86 msvc v19.22 VS16.2
x86 msvc v19.23 VS16.3
x86 msvc v19.24 VS16.4
x86 msvc v19.25 VS16.5
x86 msvc v19.27 VS16.7
x86 msvc v19.28 VS16.8
x86 msvc v19.28 VS16.9
x86 msvc v19.29 VS16.10
x86 msvc v19.29 VS16.11
x86 msvc v19.30 VS17.0
x86 msvc v19.31 VS17.1
x86 msvc v19.32 VS17.2
x86 msvc v19.33 VS17.3
x86 msvc v19.34 VS17.4
x86 msvc v19.35 VS17.5
x86 msvc v19.36 VS17.6
x86 msvc v19.37 VS17.7
x86 msvc v19.38 VS17.8
x86 msvc v19.39 VS17.9
x86 msvc v19.40 VS17.10
x86 msvc v19.latest
x86 nvc++ 22.11
x86 nvc++ 22.7
x86 nvc++ 22.9
x86 nvc++ 23.1
x86 nvc++ 23.11
x86 nvc++ 23.3
x86 nvc++ 23.5
x86 nvc++ 23.7
x86 nvc++ 23.9
x86 nvc++ 24.1
x86 nvc++ 24.3
x86 nvc++ 24.5
x86-64 Zapcc 190308
x86-64 clang (amd-staging)
x86-64 clang (assertions trunk)
x86-64 clang (clangir)
x86-64 clang (dascandy contracts)
x86-64 clang (experimental -Wlifetime)
x86-64 clang (experimental P1061)
x86-64 clang (experimental P1144)
x86-64 clang (experimental P1221)
x86-64 clang (experimental P2996)
x86-64 clang (experimental P3068)
x86-64 clang (experimental metaprogramming - P2632)
x86-64 clang (experimental pattern matching)
x86-64 clang (old concepts branch)
x86-64 clang (p1974)
x86-64 clang (reflection)
x86-64 clang (resugar)
x86-64 clang (thephd.dev)
x86-64 clang (trunk)
x86-64 clang (variadic friends - P2893)
x86-64 clang (widberg)
x86-64 clang 10.0.0
x86-64 clang 10.0.0 (assertions)
x86-64 clang 10.0.1
x86-64 clang 11.0.0
x86-64 clang 11.0.0 (assertions)
x86-64 clang 11.0.1
x86-64 clang 12.0.0
x86-64 clang 12.0.0 (assertions)
x86-64 clang 12.0.1
x86-64 clang 13.0.0
x86-64 clang 13.0.0 (assertions)
x86-64 clang 13.0.1
x86-64 clang 14.0.0
x86-64 clang 14.0.0 (assertions)
x86-64 clang 15.0.0
x86-64 clang 15.0.0 (assertions)
x86-64 clang 16.0.0
x86-64 clang 16.0.0 (assertions)
x86-64 clang 17.0.1
x86-64 clang 17.0.1 (assertions)
x86-64 clang 18.1.0
x86-64 clang 18.1.0 (assertions)
x86-64 clang 2.6.0 (assertions)
x86-64 clang 2.7.0 (assertions)
x86-64 clang 2.8.0 (assertions)
x86-64 clang 2.9.0 (assertions)
x86-64 clang 3.0.0
x86-64 clang 3.0.0 (assertions)
x86-64 clang 3.1
x86-64 clang 3.1 (assertions)
x86-64 clang 3.2
x86-64 clang 3.2 (assertions)
x86-64 clang 3.3
x86-64 clang 3.3 (assertions)
x86-64 clang 3.4 (assertions)
x86-64 clang 3.4.1
x86-64 clang 3.5
x86-64 clang 3.5 (assertions)
x86-64 clang 3.5.1
x86-64 clang 3.5.2
x86-64 clang 3.6
x86-64 clang 3.6 (assertions)
x86-64 clang 3.7
x86-64 clang 3.7 (assertions)
x86-64 clang 3.7.1
x86-64 clang 3.8
x86-64 clang 3.8 (assertions)
x86-64 clang 3.8.1
x86-64 clang 3.9.0
x86-64 clang 3.9.0 (assertions)
x86-64 clang 3.9.1
x86-64 clang 4.0.0
x86-64 clang 4.0.0 (assertions)
x86-64 clang 4.0.1
x86-64 clang 5.0.0
x86-64 clang 5.0.0 (assertions)
x86-64 clang 5.0.1
x86-64 clang 5.0.2
x86-64 clang 6.0.0
x86-64 clang 6.0.0 (assertions)
x86-64 clang 6.0.1
x86-64 clang 7.0.0
x86-64 clang 7.0.0 (assertions)
x86-64 clang 7.0.1
x86-64 clang 7.1.0
x86-64 clang 8.0.0
x86-64 clang 8.0.0 (assertions)
x86-64 clang 8.0.1
x86-64 clang 9.0.0
x86-64 clang 9.0.0 (assertions)
x86-64 clang 9.0.1
x86-64 clang rocm-4.5.2
x86-64 clang rocm-5.0.2
x86-64 clang rocm-5.1.3
x86-64 clang rocm-5.2.3
x86-64 clang rocm-5.3.3
x86-64 clang rocm-5.7.0
x86-64 clang rocm-6.0.2
x86-64 clang rocm-6.1.2
x86-64 gcc (contract labels)
x86-64 gcc (contracts natural syntax)
x86-64 gcc (contracts)
x86-64 gcc (coroutines)
x86-64 gcc (modules)
x86-64 gcc (trunk)
x86-64 gcc 10.1
x86-64 gcc 10.2
x86-64 gcc 10.3
x86-64 gcc 10.4
x86-64 gcc 10.5
x86-64 gcc 11.1
x86-64 gcc 11.2
x86-64 gcc 11.3
x86-64 gcc 11.4
x86-64 gcc 12.1
x86-64 gcc 12.2
x86-64 gcc 12.3
x86-64 gcc 12.4
x86-64 gcc 13.1
x86-64 gcc 13.2
x86-64 gcc 13.3
x86-64 gcc 14.1
x86-64 gcc 3.4.6
x86-64 gcc 4.0.4
x86-64 gcc 4.1.2
x86-64 gcc 4.4.7
x86-64 gcc 4.5.3
x86-64 gcc 4.6.4
x86-64 gcc 4.7.1
x86-64 gcc 4.7.2
x86-64 gcc 4.7.3
x86-64 gcc 4.7.4
x86-64 gcc 4.8.1
x86-64 gcc 4.8.2
x86-64 gcc 4.8.3
x86-64 gcc 4.8.4
x86-64 gcc 4.8.5
x86-64 gcc 4.9.0
x86-64 gcc 4.9.1
x86-64 gcc 4.9.2
x86-64 gcc 4.9.3
x86-64 gcc 4.9.4
x86-64 gcc 5.1
x86-64 gcc 5.2
x86-64 gcc 5.3
x86-64 gcc 5.4
x86-64 gcc 5.5
x86-64 gcc 6.1
x86-64 gcc 6.2
x86-64 gcc 6.3
x86-64 gcc 6.4
x86-64 gcc 6.5
x86-64 gcc 7.1
x86-64 gcc 7.2
x86-64 gcc 7.3
x86-64 gcc 7.4
x86-64 gcc 7.5
x86-64 gcc 8.1
x86-64 gcc 8.2
x86-64 gcc 8.3
x86-64 gcc 8.4
x86-64 gcc 8.5
x86-64 gcc 9.1
x86-64 gcc 9.2
x86-64 gcc 9.3
x86-64 gcc 9.4
x86-64 gcc 9.5
x86-64 icc 13.0.1
x86-64 icc 16.0.3
x86-64 icc 17.0.0
x86-64 icc 18.0.0
x86-64 icc 19.0.0
x86-64 icc 19.0.1
x86-64 icc 2021.1.2
x86-64 icc 2021.10.0
x86-64 icc 2021.2.0
x86-64 icc 2021.3.0
x86-64 icc 2021.4.0
x86-64 icc 2021.5.0
x86-64 icc 2021.6.0
x86-64 icc 2021.7.0
x86-64 icc 2021.7.1
x86-64 icc 2021.8.0
x86-64 icc 2021.9.0
x86-64 icx (latest)
x86-64 icx 2021.1.2
x86-64 icx 2021.2.0
x86-64 icx 2021.3.0
x86-64 icx 2021.4.0
x86-64 icx 2022.0.0
x86-64 icx 2022.1.0
x86-64 icx 2022.2.0
x86-64 icx 2022.2.1
x86-64 icx 2023.0.0
x86-64 icx 2023.1.0
x86-64 icx 2023.2.1
x86-64 icx 2024.0.0
x86-64 icx 2024.1.0
x86-64 icx 2024.2.0
zig c++ 0.10.0
zig c++ 0.11.0
zig c++ 0.12.0
zig c++ 0.6.0
zig c++ 0.7.0
zig c++ 0.7.1
zig c++ 0.8.0
zig c++ 0.9.0
zig c++ trunk
Options
Source code
namespace std { typedef long unsigned int size_t; typedef long int ptrdiff_t; typedef decltype(nullptr) nullptr_t; } namespace std { inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { } } namespace __gnu_cxx { inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { } } typedef long int ptrdiff_t; typedef long unsigned int size_t; typedef struct { long long __max_align_ll __attribute__((__aligned__(__alignof__(long long)))); long double __max_align_ld __attribute__((__aligned__(__alignof__(long double)))); } max_align_t; typedef decltype(nullptr) nullptr_t; extern "C++" { namespace std { using ::max_align_t; } } namespace CryptoPP { typedef unsigned char byte; typedef unsigned short word16; typedef unsigned int word32; typedef signed char sbyte; typedef signed short sword16; typedef signed int sword32; typedef signed long sword64; typedef unsigned long word64; typedef word64 lword; const lword LWORD_MAX = 0xffffffffffffffffUL; typedef word32 hword; typedef word64 word; typedef __uint128_t dword; typedef __uint128_t word128; const unsigned int WORD_SIZE = sizeof(word); const unsigned int WORD_BITS = WORD_SIZE * 8; } namespace std __attribute__ ((__visibility__ ("default"))) { template<typename> class allocator; template<> class allocator<void>; template<typename, typename> struct uses_allocator; } namespace std __attribute__ ((__visibility__ ("default"))) { template<class _CharT> struct char_traits; template<> struct char_traits<char>; template<> struct char_traits<wchar_t>; template<> struct char_traits<char16_t>; template<> struct char_traits<char32_t>; namespace __cxx11 { template<typename _CharT, typename _Traits = char_traits<_CharT>, typename _Alloc = allocator<_CharT> > class basic_string; } typedef basic_string<char> string; typedef basic_string<wchar_t> wstring; typedef basic_string<char16_t> u16string; typedef basic_string<char32_t> u32string; } namespace std __attribute__ ((__visibility__ ("default"))) { void __throw_bad_exception(void) __attribute__((__noreturn__)); void __throw_bad_alloc(void) __attribute__((__noreturn__)); void __throw_bad_cast(void) __attribute__((__noreturn__)); void __throw_bad_typeid(void) __attribute__((__noreturn__)); 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__)); void __throw_ios_failure(const char*) __attribute__((__noreturn__)); void __throw_ios_failure(const char*, int) __attribute__((__noreturn__)); void __throw_system_error(int) __attribute__((__noreturn__)); void __throw_future_error(int) __attribute__((__noreturn__)); void __throw_bad_function_call() __attribute__((__noreturn__)); } extern "C++" { namespace std __attribute__ ((__visibility__ ("default"))) { struct __true_type { }; struct __false_type { }; template<bool> struct __truth_type { typedef __false_type __type; }; template<> struct __truth_type<true> { typedef __true_type __type; }; template<class _Sp, class _Tp> struct __traitor { enum { __value = bool(_Sp::__value) || bool(_Tp::__value) }; typedef typename __truth_type<__value>::__type __type; }; 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; }; 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; }; template<typename _Tp> struct __is_integer { enum { __value = 0 }; typedef __false_type __type; }; 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; }; template<> struct __is_integer<wchar_t> { enum { __value = 1 }; typedef __true_type __type; }; 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; }; 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; }; template<> struct __is_integer<__int128> { enum { __value = 1 }; typedef __true_type __type; }; template<> struct __is_integer<unsigned __int128> { enum { __value = 1 }; typedef __true_type __type; }; template<typename _Tp> struct __is_floating { enum { __value = 0 }; typedef __false_type __type; }; 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; }; 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; }; template<typename _Tp> struct __is_arithmetic : public __traitor<__is_integer<_Tp>, __is_floating<_Tp> > { }; template<typename _Tp> struct __is_scalar : public __traitor<__is_arithmetic<_Tp>, __is_pointer<_Tp> > { }; 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; }; template<> struct __is_char<wchar_t> { enum { __value = 1 }; typedef __true_type __type; }; 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; }; template<typename> struct iterator_traits; template<typename _Tp> struct __is_nonvolatile_trivially_copyable { enum { __value = __is_trivially_copyable(_Tp) }; }; template<typename _Tp> struct __is_nonvolatile_trivially_copyable<volatile _Tp> { enum { __value = 0 }; }; 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> { }; template<typename _Iter1, typename _Iter2> struct __memcmpable { enum { __value = 0 }; }; 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> { }; template<typename _Tp> struct __is_move_iterator { enum { __value = 0 }; typedef __false_type __type; }; template<typename _Iterator> inline _Iterator __miter_base(_Iterator __it) { return __it; } } } extern "C++" { namespace __gnu_cxx __attribute__ ((__visibility__ ("default"))) { template<bool, typename> struct __enable_if { }; template<typename _Tp> struct __enable_if<true, _Tp> { typedef _Tp __type; }; template<bool _Cond, typename _Iftrue, typename _Iffalse> struct __conditional_type { typedef _Iftrue __type; }; template<typename _Iftrue, typename _Iffalse> struct __conditional_type<false, _Iftrue, _Iffalse> { typedef _Iffalse __type; }; template<typename _Tp> struct __add_unsigned { private: typedef __enable_if<std::__is_integer<_Tp>::__value, _Tp> __if_type; public: typedef typename __if_type::__type __type; }; template<> struct __add_unsigned<char> { typedef unsigned char __type; }; template<> struct __add_unsigned<signed char> { typedef unsigned char __type; }; template<> struct __add_unsigned<short> { typedef unsigned short __type; }; template<> struct __add_unsigned<int> { typedef unsigned int __type; }; template<> struct __add_unsigned<long> { typedef unsigned long __type; }; template<> struct __add_unsigned<long long> { typedef unsigned long long __type; }; template<> struct __add_unsigned<bool>; template<> struct __add_unsigned<wchar_t>; template<typename _Tp> struct __remove_unsigned { private: typedef __enable_if<std::__is_integer<_Tp>::__value, _Tp> __if_type; public: typedef typename __if_type::__type __type; }; template<> struct __remove_unsigned<char> { typedef signed char __type; }; template<> struct __remove_unsigned<unsigned char> { typedef signed char __type; }; template<> struct __remove_unsigned<unsigned short> { typedef short __type; }; template<> struct __remove_unsigned<unsigned int> { typedef int __type; }; template<> struct __remove_unsigned<unsigned long> { typedef long __type; }; template<> struct __remove_unsigned<unsigned long long> { typedef long long __type; }; template<> struct __remove_unsigned<bool>; template<> struct __remove_unsigned<wchar_t>; template<typename _Type> inline bool __is_null_pointer(_Type* __ptr) { return __ptr == 0; } template<typename _Type> inline bool __is_null_pointer(_Type) { return false; } inline bool __is_null_pointer(std::nullptr_t) { return true; } template<typename _Tp, bool = std::__is_integer<_Tp>::__value> struct __promote { typedef double __type; }; template<typename _Tp> struct __promote<_Tp, false> { }; template<> struct __promote<long double> { typedef long double __type; }; template<> struct __promote<double> { typedef double __type; }; template<> struct __promote<float> { typedef float __type; }; template<typename _Tp, typename _Up, typename _Tp2 = typename __promote<_Tp>::__type, typename _Up2 = typename __promote<_Up>::__type> struct __promote_2 { typedef __typeof__(_Tp2() + _Up2()) __type; }; template<typename _Tp, typename _Up, typename _Vp, typename _Tp2 = typename __promote<_Tp>::__type, typename _Up2 = typename __promote<_Up>::__type, typename _Vp2 = typename __promote<_Vp>::__type> struct __promote_3 { typedef __typeof__(_Tp2() + _Up2() + _Vp2()) __type; }; template<typename _Tp, typename _Up, typename _Vp, typename _Wp, typename _Tp2 = typename __promote<_Tp>::__type, typename _Up2 = typename __promote<_Up>::__type, typename _Vp2 = typename __promote<_Vp>::__type, typename _Wp2 = typename __promote<_Wp>::__type> struct __promote_4 { typedef __typeof__(_Tp2() + _Up2() + _Vp2() + _Wp2()) __type; }; } } namespace __gnu_cxx __attribute__ ((__visibility__ ("default"))) { template<typename _Value> struct __numeric_traits_integer { static const _Value __min = (((_Value)(-1) < 0) ? -(((_Value)(-1) < 0) ? (((((_Value)1 << ((sizeof(_Value) * 8 - ((_Value)(-1) < 0)) - 1)) - 1) << 1) + 1) : ~(_Value)0) - 1 : (_Value)0); static const _Value __max = (((_Value)(-1) < 0) ? (((((_Value)1 << ((sizeof(_Value) * 8 - ((_Value)(-1) < 0)) - 1)) - 1) << 1) + 1) : ~(_Value)0); static const bool __is_signed = ((_Value)(-1) < 0); static const int __digits = (sizeof(_Value) * 8 - ((_Value)(-1) < 0)); }; template<typename _Value> const _Value __numeric_traits_integer<_Value>::__min; template<typename _Value> const _Value __numeric_traits_integer<_Value>::__max; template<typename _Value> const bool __numeric_traits_integer<_Value>::__is_signed; template<typename _Value> const int __numeric_traits_integer<_Value>::__digits; template<typename _Value> struct __numeric_traits_floating { static const int __max_digits10 = (2 + (std::__are_same<_Value, float>::__value ? 24 : std::__are_same<_Value, double>::__value ? 53 : 64) * 643L / 2136); static const bool __is_signed = true; static const int __digits10 = (std::__are_same<_Value, float>::__value ? 6 : std::__are_same<_Value, double>::__value ? 15 : 18); static const int __max_exponent10 = (std::__are_same<_Value, float>::__value ? 38 : std::__are_same<_Value, double>::__value ? 308 : 4932); }; template<typename _Value> const int __numeric_traits_floating<_Value>::__max_digits10; template<typename _Value> const bool __numeric_traits_floating<_Value>::__is_signed; template<typename _Value> const int __numeric_traits_floating<_Value>::__digits10; template<typename _Value> const int __numeric_traits_floating<_Value>::__max_exponent10; template<typename _Value> struct __numeric_traits : public __conditional_type<std::__is_integer<_Value>::__value, __numeric_traits_integer<_Value>, __numeric_traits_floating<_Value> >::__type { }; } namespace std __attribute__ ((__visibility__ ("default"))) { template<typename _Tp> inline constexpr _Tp* __addressof(_Tp& __r) noexcept { return __builtin_addressof(__r); } } namespace std __attribute__ ((__visibility__ ("default"))) { template<typename _Tp, _Tp __v> struct integral_constant { static constexpr _Tp value = __v; typedef _Tp value_type; typedef integral_constant<_Tp, __v> type; constexpr operator value_type() const noexcept { return value; } constexpr value_type operator()() const noexcept { return value; } }; template<typename _Tp, _Tp __v> constexpr _Tp integral_constant<_Tp, __v>::value; typedef integral_constant<bool, true> true_type; typedef integral_constant<bool, false> false_type; template<bool __v> using __bool_constant = integral_constant<bool, __v>; template<bool, typename, typename> struct conditional; template <typename _Type> struct __type_identity { using type = _Type; }; template<typename _Tp> using __type_identity_t = typename __type_identity<_Tp>::type; template<typename...> struct __or_; template<> struct __or_<> : public false_type { }; template<typename _B1> struct __or_<_B1> : public _B1 { }; template<typename _B1, typename _B2> struct __or_<_B1, _B2> : public conditional<_B1::value, _B1, _B2>::type { }; template<typename _B1, typename _B2, typename _B3, typename... _Bn> struct __or_<_B1, _B2, _B3, _Bn...> : public conditional<_B1::value, _B1, __or_<_B2, _B3, _Bn...>>::type { }; template<typename...> struct __and_; template<> struct __and_<> : public true_type { }; template<typename _B1> struct __and_<_B1> : public _B1 { }; template<typename _B1, typename _B2> struct __and_<_B1, _B2> : public conditional<_B1::value, _B2, _B1>::type { }; template<typename _B1, typename _B2, typename _B3, typename... _Bn> struct __and_<_B1, _B2, _B3, _Bn...> : public conditional<_B1::value, __and_<_B2, _B3, _Bn...>, _B1>::type { }; template<typename _Pp> struct __not_ : public __bool_constant<!bool(_Pp::value)> { }; template<typename> struct is_reference; template<typename> struct is_function; template<typename> struct is_void; template<typename> struct __is_array_unknown_bounds; template <typename _T, size_t = sizeof(_T)> constexpr true_type __is_complete_or_unbounded(__type_identity<_T>) { return {}; } template <typename _TypeIdentity, typename _NestedType = typename _TypeIdentity::type> constexpr typename __or_< is_reference<_NestedType>, is_function<_NestedType>, is_void<_NestedType>, __is_array_unknown_bounds<_NestedType> >::type __is_complete_or_unbounded(_TypeIdentity) { return {}; } template<typename _Tp> struct __success_type { typedef _Tp type; }; struct __failure_type { }; template<typename> struct remove_cv; template<typename _Tp> using __remove_cv_t = typename remove_cv<_Tp>::type; template<typename> struct is_const; template<typename> struct __is_void_helper : public false_type { }; template<> struct __is_void_helper<void> : public true_type { }; template<typename _Tp> struct is_void : public __is_void_helper<__remove_cv_t<_Tp>>::type { }; template<typename> struct __is_integral_helper : public false_type { }; template<> struct __is_integral_helper<bool> : public true_type { }; template<> struct __is_integral_helper<char> : public true_type { }; template<> struct __is_integral_helper<signed char> : public true_type { }; template<> struct __is_integral_helper<unsigned char> : public true_type { }; template<> struct __is_integral_helper<wchar_t> : public true_type { }; template<> struct __is_integral_helper<char16_t> : public true_type { }; template<> struct __is_integral_helper<char32_t> : public true_type { }; template<> struct __is_integral_helper<short> : public true_type { }; template<> struct __is_integral_helper<unsigned short> : public true_type { }; template<> struct __is_integral_helper<int> : public true_type { }; template<> struct __is_integral_helper<unsigned int> : public true_type { }; template<> struct __is_integral_helper<long> : public true_type { }; template<> struct __is_integral_helper<unsigned long> : public true_type { }; template<> struct __is_integral_helper<long long> : public true_type { }; template<> struct __is_integral_helper<unsigned long long> : public true_type { }; template<> struct __is_integral_helper<__int128> : public true_type { }; template<> struct __is_integral_helper<unsigned __int128> : public true_type { }; template<typename _Tp> struct is_integral : public __is_integral_helper<__remove_cv_t<_Tp>>::type { }; template<typename> struct __is_floating_point_helper : public false_type { }; template<> struct __is_floating_point_helper<float> : public true_type { }; template<> struct __is_floating_point_helper<double> : public true_type { }; template<> struct __is_floating_point_helper<long double> : public true_type { }; template<> struct __is_floating_point_helper<__float128> : public true_type { }; template<typename _Tp> struct is_floating_point : public __is_floating_point_helper<__remove_cv_t<_Tp>>::type { }; template<typename> struct is_array : public false_type { }; template<typename _Tp, std::size_t _Size> struct is_array<_Tp[_Size]> : public true_type { }; template<typename _Tp> struct is_array<_Tp[]> : public true_type { }; template<typename> struct __is_pointer_helper : public false_type { }; template<typename _Tp> struct __is_pointer_helper<_Tp*> : public true_type { }; template<typename _Tp> struct is_pointer : public __is_pointer_helper<__remove_cv_t<_Tp>>::type { }; template<typename> struct is_lvalue_reference : public false_type { }; template<typename _Tp> struct is_lvalue_reference<_Tp&> : public true_type { }; template<typename> struct is_rvalue_reference : public false_type { }; template<typename _Tp> struct is_rvalue_reference<_Tp&&> : public true_type { }; template<typename> struct __is_member_object_pointer_helper : public false_type { }; template<typename _Tp, typename _Cp> struct __is_member_object_pointer_helper<_Tp _Cp::*> : public __not_<is_function<_Tp>>::type { }; template<typename _Tp> struct is_member_object_pointer : public __is_member_object_pointer_helper<__remove_cv_t<_Tp>>::type { }; template<typename> struct __is_member_function_pointer_helper : public false_type { }; template<typename _Tp, typename _Cp> struct __is_member_function_pointer_helper<_Tp _Cp::*> : public is_function<_Tp>::type { }; template<typename _Tp> struct is_member_function_pointer : public __is_member_function_pointer_helper<__remove_cv_t<_Tp>>::type { }; template<typename _Tp> struct is_enum : public integral_constant<bool, __is_enum(_Tp)> { }; template<typename _Tp> struct is_union : public integral_constant<bool, __is_union(_Tp)> { }; template<typename _Tp> struct is_class : public integral_constant<bool, __is_class(_Tp)> { }; template<typename _Tp> struct is_function : public __bool_constant<!is_const<const _Tp>::value> { }; template<typename _Tp> struct is_function<_Tp&> : public false_type { }; template<typename _Tp> struct is_function<_Tp&&> : public false_type { }; template<typename> struct __is_null_pointer_helper : public false_type { }; template<> struct __is_null_pointer_helper<std::nullptr_t> : public true_type { }; template<typename _Tp> struct is_null_pointer : public __is_null_pointer_helper<__remove_cv_t<_Tp>>::type { }; template<typename _Tp> struct __is_nullptr_t : public is_null_pointer<_Tp> { } __attribute__ ((__deprecated__)); template<typename _Tp> struct is_reference : public __or_<is_lvalue_reference<_Tp>, is_rvalue_reference<_Tp>>::type { }; template<typename _Tp> struct is_arithmetic : public __or_<is_integral<_Tp>, is_floating_point<_Tp>>::type { }; template<typename _Tp> struct is_fundamental : public __or_<is_arithmetic<_Tp>, is_void<_Tp>, is_null_pointer<_Tp>>::type { }; template<typename _Tp> struct is_object : public __not_<__or_<is_function<_Tp>, is_reference<_Tp>, is_void<_Tp>>>::type { }; template<typename> struct is_member_pointer; template<typename _Tp> struct is_scalar : public __or_<is_arithmetic<_Tp>, is_enum<_Tp>, is_pointer<_Tp>, is_member_pointer<_Tp>, is_null_pointer<_Tp>>::type { }; template<typename _Tp> struct is_compound : public __not_<is_fundamental<_Tp>>::type { }; template<typename _Tp> struct __is_member_pointer_helper : public false_type { }; template<typename _Tp, typename _Cp> struct __is_member_pointer_helper<_Tp _Cp::*> : public true_type { }; template<typename _Tp> struct is_member_pointer : public __is_member_pointer_helper<__remove_cv_t<_Tp>>::type { }; template<typename, typename> struct is_same; template<typename _Tp, typename... _Types> using __is_one_of = __or_<is_same<_Tp, _Types>...>; template<typename _Tp> using __is_signed_integer = __is_one_of<__remove_cv_t<_Tp>, signed char, signed short, signed int, signed long, signed long long , signed __int128 >; template<typename _Tp> using __is_unsigned_integer = __is_one_of<__remove_cv_t<_Tp>, unsigned char, unsigned short, unsigned int, unsigned long, unsigned long long , unsigned __int128 >; template<typename _Tp> using __is_standard_integer = __or_<__is_signed_integer<_Tp>, __is_unsigned_integer<_Tp>>; template<typename...> using __void_t = void; template<typename _Tp, typename = void> struct __is_referenceable : public false_type { }; template<typename _Tp> struct __is_referenceable<_Tp, __void_t<_Tp&>> : public true_type { }; template<typename> struct is_const : public false_type { }; template<typename _Tp> struct is_const<_Tp const> : public true_type { }; template<typename> struct is_volatile : public false_type { }; template<typename _Tp> struct is_volatile<_Tp volatile> : public true_type { }; template<typename _Tp> struct is_trivial : public integral_constant<bool, __is_trivial(_Tp)> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; template<typename _Tp> struct is_trivially_copyable : public integral_constant<bool, __is_trivially_copyable(_Tp)> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; template<typename _Tp> struct is_standard_layout : public integral_constant<bool, __is_standard_layout(_Tp)> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; template<typename _Tp> struct is_pod : public integral_constant<bool, __is_pod(_Tp)> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; template<typename _Tp> struct is_literal_type : public integral_constant<bool, __is_literal_type(_Tp)> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; template<typename _Tp> struct is_empty : public integral_constant<bool, __is_empty(_Tp)> { }; template<typename _Tp> struct is_polymorphic : public integral_constant<bool, __is_polymorphic(_Tp)> { }; template<typename _Tp> struct is_final : public integral_constant<bool, __is_final(_Tp)> { }; template<typename _Tp> struct is_abstract : public integral_constant<bool, __is_abstract(_Tp)> { }; template<typename _Tp, bool = is_arithmetic<_Tp>::value> struct __is_signed_helper : public false_type { }; template<typename _Tp> struct __is_signed_helper<_Tp, true> : public integral_constant<bool, _Tp(-1) < _Tp(0)> { }; template<typename _Tp> struct is_signed : public __is_signed_helper<_Tp>::type { }; template<typename _Tp> struct is_unsigned : public __and_<is_arithmetic<_Tp>, __not_<is_signed<_Tp>>> { }; template<typename _Tp, typename _Up = _Tp&&> _Up __declval(int); template<typename _Tp> _Tp __declval(long); template<typename _Tp> auto declval() noexcept -> decltype(__declval<_Tp>(0)); template<typename, unsigned = 0> struct extent; template<typename> struct remove_all_extents; template<typename _Tp> struct __is_array_known_bounds : public integral_constant<bool, (extent<_Tp>::value > 0)> { }; template<typename _Tp> struct __is_array_unknown_bounds : public __and_<is_array<_Tp>, __not_<extent<_Tp>>> { }; struct __do_is_destructible_impl { template<typename _Tp, typename = decltype(declval<_Tp&>().~_Tp())> static true_type __test(int); template<typename> static false_type __test(...); }; template<typename _Tp> struct __is_destructible_impl : public __do_is_destructible_impl { typedef decltype(__test<_Tp>(0)) type; }; template<typename _Tp, bool = __or_<is_void<_Tp>, __is_array_unknown_bounds<_Tp>, is_function<_Tp>>::value, bool = __or_<is_reference<_Tp>, is_scalar<_Tp>>::value> struct __is_destructible_safe; template<typename _Tp> struct __is_destructible_safe<_Tp, false, false> : public __is_destructible_impl<typename remove_all_extents<_Tp>::type>::type { }; template<typename _Tp> struct __is_destructible_safe<_Tp, true, false> : public false_type { }; template<typename _Tp> struct __is_destructible_safe<_Tp, false, true> : public true_type { }; template<typename _Tp> struct is_destructible : public __is_destructible_safe<_Tp>::type { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; struct __do_is_nt_destructible_impl { template<typename _Tp> static __bool_constant<noexcept(declval<_Tp&>().~_Tp())> __test(int); template<typename> static false_type __test(...); }; template<typename _Tp> struct __is_nt_destructible_impl : public __do_is_nt_destructible_impl { typedef decltype(__test<_Tp>(0)) type; }; template<typename _Tp, bool = __or_<is_void<_Tp>, __is_array_unknown_bounds<_Tp>, is_function<_Tp>>::value, bool = __or_<is_reference<_Tp>, is_scalar<_Tp>>::value> struct __is_nt_destructible_safe; template<typename _Tp> struct __is_nt_destructible_safe<_Tp, false, false> : public __is_nt_destructible_impl<typename remove_all_extents<_Tp>::type>::type { }; template<typename _Tp> struct __is_nt_destructible_safe<_Tp, true, false> : public false_type { }; template<typename _Tp> struct __is_nt_destructible_safe<_Tp, false, true> : public true_type { }; template<typename _Tp> struct is_nothrow_destructible : public __is_nt_destructible_safe<_Tp>::type { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; template<typename _Tp, typename... _Args> struct __is_constructible_impl : public __bool_constant<__is_constructible(_Tp, _Args...)> { }; template<typename _Tp, typename... _Args> struct is_constructible : public __is_constructible_impl<_Tp, _Args...> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; template<typename _Tp> struct is_default_constructible : public __is_constructible_impl<_Tp>::type { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; template<typename _Tp, bool = __is_referenceable<_Tp>::value> struct __is_copy_constructible_impl; template<typename _Tp> struct __is_copy_constructible_impl<_Tp, false> : public false_type { }; template<typename _Tp> struct __is_copy_constructible_impl<_Tp, true> : public __is_constructible_impl<_Tp, const _Tp&> { }; template<typename _Tp> struct is_copy_constructible : public __is_copy_constructible_impl<_Tp> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; template<typename _Tp, bool = __is_referenceable<_Tp>::value> struct __is_move_constructible_impl; template<typename _Tp> struct __is_move_constructible_impl<_Tp, false> : public false_type { }; template<typename _Tp> struct __is_move_constructible_impl<_Tp, true> : public __is_constructible_impl<_Tp, _Tp&&> { }; template<typename _Tp> struct is_move_constructible : public __is_move_constructible_impl<_Tp> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; template<bool, typename _Tp, typename... _Args> struct __is_nt_constructible_impl : public false_type { }; template<typename _Tp, typename... _Args> struct __is_nt_constructible_impl<true, _Tp, _Args...> : public __bool_constant<noexcept(_Tp(std::declval<_Args>()...))> { }; template<typename _Tp, typename _Arg> struct __is_nt_constructible_impl<true, _Tp, _Arg> : public __bool_constant<noexcept(static_cast<_Tp>(std::declval<_Arg>()))> { }; template<typename _Tp> struct __is_nt_constructible_impl<true, _Tp> : public __bool_constant<noexcept(_Tp())> { }; template<typename _Tp, size_t _Num> struct __is_nt_constructible_impl<true, _Tp[_Num]> : public __bool_constant<noexcept(typename remove_all_extents<_Tp>::type())> { }; template<typename _Tp, typename... _Args> using __is_nothrow_constructible_impl = __is_nt_constructible_impl<__is_constructible(_Tp, _Args...), _Tp, _Args...>; template<typename _Tp, typename... _Args> struct is_nothrow_constructible : public __is_nothrow_constructible_impl<_Tp, _Args...>::type { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; template<typename _Tp> struct is_nothrow_default_constructible : public __is_nothrow_constructible_impl<_Tp>::type { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; template<typename _Tp, bool = __is_referenceable<_Tp>::value> struct __is_nothrow_copy_constructible_impl; template<typename _Tp> struct __is_nothrow_copy_constructible_impl<_Tp, false> : public false_type { }; template<typename _Tp> struct __is_nothrow_copy_constructible_impl<_Tp, true> : public __is_nothrow_constructible_impl<_Tp, const _Tp&> { }; template<typename _Tp> struct is_nothrow_copy_constructible : public __is_nothrow_copy_constructible_impl<_Tp>::type { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; template<typename _Tp, bool = __is_referenceable<_Tp>::value> struct __is_nothrow_move_constructible_impl; template<typename _Tp> struct __is_nothrow_move_constructible_impl<_Tp, false> : public false_type { }; template<typename _Tp> struct __is_nothrow_move_constructible_impl<_Tp, true> : public __is_nothrow_constructible_impl<_Tp, _Tp&&> { }; template<typename _Tp> struct is_nothrow_move_constructible : public __is_nothrow_move_constructible_impl<_Tp>::type { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; template<typename _Tp, typename _Up> struct is_assignable : public __bool_constant<__is_assignable(_Tp, _Up)> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; template<typename _Tp, bool = __is_referenceable<_Tp>::value> struct __is_copy_assignable_impl; template<typename _Tp> struct __is_copy_assignable_impl<_Tp, false> : public false_type { }; template<typename _Tp> struct __is_copy_assignable_impl<_Tp, true> : public __bool_constant<__is_assignable(_Tp&, const _Tp&)> { }; template<typename _Tp> struct is_copy_assignable : public __is_copy_assignable_impl<_Tp>::type { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; template<typename _Tp, bool = __is_referenceable<_Tp>::value> struct __is_move_assignable_impl; template<typename _Tp> struct __is_move_assignable_impl<_Tp, false> : public false_type { }; template<typename _Tp> struct __is_move_assignable_impl<_Tp, true> : public __bool_constant<__is_assignable(_Tp&, _Tp&&)> { }; template<typename _Tp> struct is_move_assignable : public __is_move_assignable_impl<_Tp>::type { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; template<typename _Tp, typename _Up> struct __is_nt_assignable_impl : public integral_constant<bool, noexcept(declval<_Tp>() = declval<_Up>())> { }; template<typename _Tp, typename _Up> struct __is_nothrow_assignable_impl : public __and_<__bool_constant<__is_assignable(_Tp, _Up)>, __is_nt_assignable_impl<_Tp, _Up>> { }; template<typename _Tp, typename _Up> struct is_nothrow_assignable : public __is_nothrow_assignable_impl<_Tp, _Up> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; template<typename _Tp, bool = __is_referenceable<_Tp>::value> struct __is_nt_copy_assignable_impl; template<typename _Tp> struct __is_nt_copy_assignable_impl<_Tp, false> : public false_type { }; template<typename _Tp> struct __is_nt_copy_assignable_impl<_Tp, true> : public __is_nothrow_assignable_impl<_Tp&, const _Tp&> { }; template<typename _Tp> struct is_nothrow_copy_assignable : public __is_nt_copy_assignable_impl<_Tp> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; template<typename _Tp, bool = __is_referenceable<_Tp>::value> struct __is_nt_move_assignable_impl; template<typename _Tp> struct __is_nt_move_assignable_impl<_Tp, false> : public false_type { }; template<typename _Tp> struct __is_nt_move_assignable_impl<_Tp, true> : public __is_nothrow_assignable_impl<_Tp&, _Tp&&> { }; template<typename _Tp> struct is_nothrow_move_assignable : public __is_nt_move_assignable_impl<_Tp> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; template<typename _Tp, typename... _Args> struct is_trivially_constructible : public __bool_constant<__is_trivially_constructible(_Tp, _Args...)> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; template<typename _Tp> struct is_trivially_default_constructible : public __bool_constant<__is_trivially_constructible(_Tp)> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; struct __do_is_implicitly_default_constructible_impl { template <typename _Tp> static void __helper(const _Tp&); template <typename _Tp> static true_type __test(const _Tp&, decltype(__helper<const _Tp&>({}))* = 0); static false_type __test(...); }; template<typename _Tp> struct __is_implicitly_default_constructible_impl : public __do_is_implicitly_default_constructible_impl { typedef decltype(__test(declval<_Tp>())) type; }; template<typename _Tp> struct __is_implicitly_default_constructible_safe : public __is_implicitly_default_constructible_impl<_Tp>::type { }; template <typename _Tp> struct __is_implicitly_default_constructible : public __and_<__is_constructible_impl<_Tp>, __is_implicitly_default_constructible_safe<_Tp>> { }; template<typename _Tp, bool = __is_referenceable<_Tp>::value> struct __is_trivially_copy_constructible_impl; template<typename _Tp> struct __is_trivially_copy_constructible_impl<_Tp, false> : public false_type { }; template<typename _Tp> struct __is_trivially_copy_constructible_impl<_Tp, true> : public __and_<__is_copy_constructible_impl<_Tp>, integral_constant<bool, __is_trivially_constructible(_Tp, const _Tp&)>> { }; template<typename _Tp> struct is_trivially_copy_constructible : public __is_trivially_copy_constructible_impl<_Tp> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; template<typename _Tp, bool = __is_referenceable<_Tp>::value> struct __is_trivially_move_constructible_impl; template<typename _Tp> struct __is_trivially_move_constructible_impl<_Tp, false> : public false_type { }; template<typename _Tp> struct __is_trivially_move_constructible_impl<_Tp, true> : public __and_<__is_move_constructible_impl<_Tp>, integral_constant<bool, __is_trivially_constructible(_Tp, _Tp&&)>> { }; template<typename _Tp> struct is_trivially_move_constructible : public __is_trivially_move_constructible_impl<_Tp> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; template<typename _Tp, typename _Up> struct is_trivially_assignable : public __bool_constant<__is_trivially_assignable(_Tp, _Up)> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; template<typename _Tp, bool = __is_referenceable<_Tp>::value> struct __is_trivially_copy_assignable_impl; template<typename _Tp> struct __is_trivially_copy_assignable_impl<_Tp, false> : public false_type { }; template<typename _Tp> struct __is_trivially_copy_assignable_impl<_Tp, true> : public __bool_constant<__is_trivially_assignable(_Tp&, const _Tp&)> { }; template<typename _Tp> struct is_trivially_copy_assignable : public __is_trivially_copy_assignable_impl<_Tp> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; template<typename _Tp, bool = __is_referenceable<_Tp>::value> struct __is_trivially_move_assignable_impl; template<typename _Tp> struct __is_trivially_move_assignable_impl<_Tp, false> : public false_type { }; template<typename _Tp> struct __is_trivially_move_assignable_impl<_Tp, true> : public __bool_constant<__is_trivially_assignable(_Tp&, _Tp&&)> { }; template<typename _Tp> struct is_trivially_move_assignable : public __is_trivially_move_assignable_impl<_Tp> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; template<typename _Tp> struct is_trivially_destructible : public __and_<__is_destructible_safe<_Tp>, __bool_constant<__has_trivial_destructor(_Tp)>> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; template<typename _Tp> struct has_virtual_destructor : public integral_constant<bool, __has_virtual_destructor(_Tp)> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; template<typename _Tp> struct alignment_of : public integral_constant<std::size_t, alignof(_Tp)> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; template<typename> struct rank : public integral_constant<std::size_t, 0> { }; template<typename _Tp, std::size_t _Size> struct rank<_Tp[_Size]> : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; template<typename _Tp> struct rank<_Tp[]> : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; template<typename, unsigned _Uint> struct extent : public integral_constant<std::size_t, 0> { }; template<typename _Tp, unsigned _Uint, std::size_t _Size> struct extent<_Tp[_Size], _Uint> : public integral_constant<std::size_t, _Uint == 0 ? _Size : extent<_Tp, _Uint - 1>::value> { }; template<typename _Tp, unsigned _Uint> struct extent<_Tp[], _Uint> : public integral_constant<std::size_t, _Uint == 0 ? 0 : extent<_Tp, _Uint - 1>::value> { }; template<typename _Tp, typename _Up> struct is_same : public integral_constant<bool, __is_same_as(_Tp, _Up)> { }; template<typename _Base, typename _Derived> struct is_base_of : public integral_constant<bool, __is_base_of(_Base, _Derived)> { }; template<typename _From, typename _To, bool = __or_<is_void<_From>, is_function<_To>, is_array<_To>>::value> struct __is_convertible_helper { typedef typename is_void<_To>::type type; }; template<typename _From, typename _To> class __is_convertible_helper<_From, _To, false> { template<typename _To1> static void __test_aux(_To1) noexcept; template<typename _From1, typename _To1, typename = decltype(__test_aux<_To1>(std::declval<_From1>()))> static true_type __test(int); template<typename, typename> static false_type __test(...); public: typedef decltype(__test<_From, _To>(0)) type; }; template<typename _From, typename _To> struct is_convertible : public __is_convertible_helper<_From, _To>::type { }; template<typename _ToElementType, typename _FromElementType> using __is_array_convertible = is_convertible<_FromElementType(*)[], _ToElementType(*)[]>; template<typename _From, typename _To, bool = __or_<is_void<_From>, is_function<_To>, is_array<_To>>::value> struct __is_nt_convertible_helper : is_void<_To> { }; template<typename _From, typename _To> class __is_nt_convertible_helper<_From, _To, false> { template<typename _To1> static void __test_aux(_To1) noexcept; template<typename _From1, typename _To1> static __bool_constant<noexcept(__test_aux<_To1>(std::declval<_From1>()))> __test(int); template<typename, typename> static false_type __test(...); public: using type = decltype(__test<_From, _To>(0)); }; template<typename _From, typename _To> struct __is_nothrow_convertible : public __is_nt_convertible_helper<_From, _To>::type { }; template<typename _Tp> struct remove_const { typedef _Tp type; }; template<typename _Tp> struct remove_const<_Tp const> { typedef _Tp type; }; template<typename _Tp> struct remove_volatile { typedef _Tp type; }; template<typename _Tp> struct remove_volatile<_Tp volatile> { typedef _Tp type; }; template<typename _Tp> struct remove_cv { using type = _Tp; }; template<typename _Tp> struct remove_cv<const _Tp> { using type = _Tp; }; template<typename _Tp> struct remove_cv<volatile _Tp> { using type = _Tp; }; template<typename _Tp> struct remove_cv<const volatile _Tp> { using type = _Tp; }; template<typename _Tp> struct add_const { typedef _Tp const type; }; template<typename _Tp> struct add_volatile { typedef _Tp volatile type; }; template<typename _Tp> struct add_cv { typedef typename add_const<typename add_volatile<_Tp>::type>::type type; }; template<typename _Tp> using remove_const_t = typename remove_const<_Tp>::type; template<typename _Tp> using remove_volatile_t = typename remove_volatile<_Tp>::type; template<typename _Tp> using remove_cv_t = typename remove_cv<_Tp>::type; template<typename _Tp> using add_const_t = typename add_const<_Tp>::type; template<typename _Tp> using add_volatile_t = typename add_volatile<_Tp>::type; template<typename _Tp> using add_cv_t = typename add_cv<_Tp>::type; template<typename _Tp> struct remove_reference { typedef _Tp type; }; template<typename _Tp> struct remove_reference<_Tp&> { typedef _Tp type; }; template<typename _Tp> struct remove_reference<_Tp&&> { typedef _Tp type; }; template<typename _Tp, bool = __is_referenceable<_Tp>::value> struct __add_lvalue_reference_helper { typedef _Tp type; }; template<typename _Tp> struct __add_lvalue_reference_helper<_Tp, true> { typedef _Tp& type; }; template<typename _Tp> struct add_lvalue_reference : public __add_lvalue_reference_helper<_Tp> { }; template<typename _Tp, bool = __is_referenceable<_Tp>::value> struct __add_rvalue_reference_helper { typedef _Tp type; }; template<typename _Tp> struct __add_rvalue_reference_helper<_Tp, true> { typedef _Tp&& type; }; template<typename _Tp> struct add_rvalue_reference : public __add_rvalue_reference_helper<_Tp> { }; template<typename _Tp> using remove_reference_t = typename remove_reference<_Tp>::type; template<typename _Tp> using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type; template<typename _Tp> using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type; template<typename _Unqualified, bool _IsConst, bool _IsVol> struct __cv_selector; template<typename _Unqualified> struct __cv_selector<_Unqualified, false, false> { typedef _Unqualified __type; }; template<typename _Unqualified> struct __cv_selector<_Unqualified, false, true> { typedef volatile _Unqualified __type; }; template<typename _Unqualified> struct __cv_selector<_Unqualified, true, false> { typedef const _Unqualified __type; }; template<typename _Unqualified> struct __cv_selector<_Unqualified, true, true> { typedef const volatile _Unqualified __type; }; template<typename _Qualified, typename _Unqualified, bool _IsConst = is_const<_Qualified>::value, bool _IsVol = is_volatile<_Qualified>::value> class __match_cv_qualifiers { typedef __cv_selector<_Unqualified, _IsConst, _IsVol> __match; public: typedef typename __match::__type __type; }; template<typename _Tp> struct __make_unsigned { typedef _Tp __type; }; template<> struct __make_unsigned<char> { typedef unsigned char __type; }; template<> struct __make_unsigned<signed char> { typedef unsigned char __type; }; template<> struct __make_unsigned<short> { typedef unsigned short __type; }; template<> struct __make_unsigned<int> { typedef unsigned int __type; }; template<> struct __make_unsigned<long> { typedef unsigned long __type; }; template<> struct __make_unsigned<long long> { typedef unsigned long long __type; }; template<> struct __make_unsigned<__int128> { typedef unsigned __int128 __type; }; template<typename _Tp, bool _IsInt = is_integral<_Tp>::value, bool _IsEnum = is_enum<_Tp>::value> class __make_unsigned_selector; template<typename _Tp> class __make_unsigned_selector<_Tp, true, false> { using __unsigned_type = typename __make_unsigned<__remove_cv_t<_Tp>>::__type; public: using __type = typename __match_cv_qualifiers<_Tp, __unsigned_type>::__type; }; class __make_unsigned_selector_base { protected: template<typename...> struct _List { }; template<typename _Tp, typename... _Up> struct _List<_Tp, _Up...> : _List<_Up...> { static constexpr size_t __size = sizeof(_Tp); }; template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)> struct __select; template<size_t _Sz, typename _Uint, typename... _UInts> struct __select<_Sz, _List<_Uint, _UInts...>, true> { using __type = _Uint; }; template<size_t _Sz, typename _Uint, typename... _UInts> struct __select<_Sz, _List<_Uint, _UInts...>, false> : __select<_Sz, _List<_UInts...>> { }; }; template<typename _Tp> class __make_unsigned_selector<_Tp, false, true> : __make_unsigned_selector_base { using _UInts = _List<unsigned char, unsigned short, unsigned int, unsigned long, unsigned long long>; using __unsigned_type = typename __select<sizeof(_Tp), _UInts>::__type; public: using __type = typename __match_cv_qualifiers<_Tp, __unsigned_type>::__type; }; template<> struct __make_unsigned<wchar_t> { using __type = typename __make_unsigned_selector<wchar_t, false, true>::__type; }; template<> struct __make_unsigned<char16_t> { using __type = typename __make_unsigned_selector<char16_t, false, true>::__type; }; template<> struct __make_unsigned<char32_t> { using __type = typename __make_unsigned_selector<char32_t, false, true>::__type; }; template<typename _Tp> struct make_unsigned { typedef typename __make_unsigned_selector<_Tp>::__type type; }; template<> struct make_unsigned<bool>; template<typename _Tp> struct __make_signed { typedef _Tp __type; }; template<> struct __make_signed<char> { typedef signed char __type; }; template<> struct __make_signed<unsigned char> { typedef signed char __type; }; template<> struct __make_signed<unsigned short> { typedef signed short __type; }; template<> struct __make_signed<unsigned int> { typedef signed int __type; }; template<> struct __make_signed<unsigned long> { typedef signed long __type; }; template<> struct __make_signed<unsigned long long> { typedef signed long long __type; }; template<> struct __make_signed<unsigned __int128> { typedef __int128 __type; }; template<typename _Tp, bool _IsInt = is_integral<_Tp>::value, bool _IsEnum = is_enum<_Tp>::value> class __make_signed_selector; template<typename _Tp> class __make_signed_selector<_Tp, true, false> { using __signed_type = typename __make_signed<__remove_cv_t<_Tp>>::__type; public: using __type = typename __match_cv_qualifiers<_Tp, __signed_type>::__type; }; template<typename _Tp> class __make_signed_selector<_Tp, false, true> { typedef typename __make_unsigned_selector<_Tp>::__type __unsigned_type; public: typedef typename __make_signed_selector<__unsigned_type>::__type __type; }; template<> struct __make_signed<wchar_t> { using __type = typename __make_signed_selector<wchar_t, false, true>::__type; }; template<> struct __make_signed<char16_t> { using __type = typename __make_signed_selector<char16_t, false, true>::__type; }; template<> struct __make_signed<char32_t> { using __type = typename __make_signed_selector<char32_t, false, true>::__type; }; template<typename _Tp> struct make_signed { typedef typename __make_signed_selector<_Tp>::__type type; }; template<> struct make_signed<bool>; template<typename _Tp> using make_signed_t = typename make_signed<_Tp>::type; template<typename _Tp> using make_unsigned_t = typename make_unsigned<_Tp>::type; template<typename _Tp> struct remove_extent { typedef _Tp type; }; template<typename _Tp, std::size_t _Size> struct remove_extent<_Tp[_Size]> { typedef _Tp type; }; template<typename _Tp> struct remove_extent<_Tp[]> { typedef _Tp type; }; template<typename _Tp> struct remove_all_extents { typedef _Tp type; }; template<typename _Tp, std::size_t _Size> struct remove_all_extents<_Tp[_Size]> { typedef typename remove_all_extents<_Tp>::type type; }; template<typename _Tp> struct remove_all_extents<_Tp[]> { typedef typename remove_all_extents<_Tp>::type type; }; template<typename _Tp> using remove_extent_t = typename remove_extent<_Tp>::type; template<typename _Tp> using remove_all_extents_t = typename remove_all_extents<_Tp>::type; template<typename _Tp, typename> struct __remove_pointer_helper { typedef _Tp type; }; template<typename _Tp, typename _Up> struct __remove_pointer_helper<_Tp, _Up*> { typedef _Up type; }; template<typename _Tp> struct remove_pointer : public __remove_pointer_helper<_Tp, __remove_cv_t<_Tp>> { }; template<typename _Tp, bool = __or_<__is_referenceable<_Tp>, is_void<_Tp>>::value> struct __add_pointer_helper { typedef _Tp type; }; template<typename _Tp> struct __add_pointer_helper<_Tp, true> { typedef typename remove_reference<_Tp>::type* type; }; template<typename _Tp> struct add_pointer : public __add_pointer_helper<_Tp> { }; template<typename _Tp> using remove_pointer_t = typename remove_pointer<_Tp>::type; template<typename _Tp> using add_pointer_t = typename add_pointer<_Tp>::type; template<std::size_t _Len> struct __aligned_storage_msa { union __type { unsigned char __data[_Len]; struct __attribute__((__aligned__)) { } __align; }; }; template<std::size_t _Len, std::size_t _Align = __alignof__(typename __aligned_storage_msa<_Len>::__type)> struct aligned_storage { union type { unsigned char __data[_Len]; struct __attribute__((__aligned__((_Align)))) { } __align; }; }; template <typename... _Types> struct __strictest_alignment { static const size_t _S_alignment = 0; static const size_t _S_size = 0; }; template <typename _Tp, typename... _Types> struct __strictest_alignment<_Tp, _Types...> { static const size_t _S_alignment = alignof(_Tp) > __strictest_alignment<_Types...>::_S_alignment ? alignof(_Tp) : __strictest_alignment<_Types...>::_S_alignment; static const size_t _S_size = sizeof(_Tp) > __strictest_alignment<_Types...>::_S_size ? sizeof(_Tp) : __strictest_alignment<_Types...>::_S_size; }; template <size_t _Len, typename... _Types> struct aligned_union { private: static_assert(sizeof...(_Types) != 0, "At least one type is required"); using __strictest = __strictest_alignment<_Types...>; static const size_t _S_len = _Len > __strictest::_S_size ? _Len : __strictest::_S_size; public: static const size_t alignment_value = __strictest::_S_alignment; typedef typename aligned_storage<_S_len, alignment_value>::type type; }; template <size_t _Len, typename... _Types> const size_t aligned_union<_Len, _Types...>::alignment_value; template<typename _Up, bool _IsArray = is_array<_Up>::value, bool _IsFunction = is_function<_Up>::value> struct __decay_selector; template<typename _Up> struct __decay_selector<_Up, false, false> { typedef __remove_cv_t<_Up> __type; }; template<typename _Up> struct __decay_selector<_Up, true, false> { typedef typename remove_extent<_Up>::type* __type; }; template<typename _Up> struct __decay_selector<_Up, false, true> { typedef typename add_pointer<_Up>::type __type; }; template<typename _Tp> class decay { typedef typename remove_reference<_Tp>::type __remove_type; public: typedef typename __decay_selector<__remove_type>::__type type; }; template<typename _Tp> using __decay_t = typename decay<_Tp>::type; template<typename _Tp> class reference_wrapper; template<typename _Tp> struct __strip_reference_wrapper { typedef _Tp __type; }; template<typename _Tp> struct __strip_reference_wrapper<reference_wrapper<_Tp> > { typedef _Tp& __type; }; template<typename _Tp> using __decay_and_strip = __strip_reference_wrapper<__decay_t<_Tp>>; template<bool, typename _Tp = void> struct enable_if { }; template<typename _Tp> struct enable_if<true, _Tp> { typedef _Tp type; }; template<bool _Cond, typename _Tp = void> using __enable_if_t = typename enable_if<_Cond, _Tp>::type; template<typename... _Cond> using _Require = __enable_if_t<__and_<_Cond...>::value>; template<bool _Cond, typename _Iftrue, typename _Iffalse> struct conditional { typedef _Iftrue type; }; template<typename _Iftrue, typename _Iffalse> struct conditional<false, _Iftrue, _Iffalse> { typedef _Iffalse type; }; template<typename _Tp> using __remove_cvref_t = typename remove_cv<typename remove_reference<_Tp>::type>::type; template<typename... _Tp> struct common_type; struct __do_common_type_impl { template<typename _Tp, typename _Up> using __cond_t = decltype(true ? std::declval<_Tp>() : std::declval<_Up>()); template<typename _Tp, typename _Up> static __success_type<__decay_t<__cond_t<_Tp, _Up>>> _S_test(int); template<typename, typename> static __failure_type _S_test_2(...); template<typename _Tp, typename _Up> static decltype(_S_test_2<_Tp, _Up>(0)) _S_test(...); }; template<> struct common_type<> { }; template<typename _Tp0> struct common_type<_Tp0> : public common_type<_Tp0, _Tp0> { }; template<typename _Tp1, typename _Tp2, typename _Dp1 = __decay_t<_Tp1>, typename _Dp2 = __decay_t<_Tp2>> struct __common_type_impl { using type = common_type<_Dp1, _Dp2>; }; template<typename _Tp1, typename _Tp2> struct __common_type_impl<_Tp1, _Tp2, _Tp1, _Tp2> : private __do_common_type_impl { using type = decltype(_S_test<_Tp1, _Tp2>(0)); }; template<typename _Tp1, typename _Tp2> struct common_type<_Tp1, _Tp2> : public __common_type_impl<_Tp1, _Tp2>::type { }; template<typename...> struct __common_type_pack { }; template<typename, typename, typename = void> struct __common_type_fold; template<typename _Tp1, typename _Tp2, typename... _Rp> struct common_type<_Tp1, _Tp2, _Rp...> : public __common_type_fold<common_type<_Tp1, _Tp2>, __common_type_pack<_Rp...>> { }; template<typename _CTp, typename... _Rp> struct __common_type_fold<_CTp, __common_type_pack<_Rp...>, __void_t<typename _CTp::type>> : public common_type<typename _CTp::type, _Rp...> { }; template<typename _CTp, typename _Rp> struct __common_type_fold<_CTp, _Rp, void> { }; template<typename _Tp, bool = is_enum<_Tp>::value> struct __underlying_type_impl { using type = __underlying_type(_Tp); }; template<typename _Tp> struct __underlying_type_impl<_Tp, false> { }; template<typename _Tp> struct underlying_type : public __underlying_type_impl<_Tp> { }; template<typename _Tp> struct __declval_protector { static const bool __stop = false; }; template<typename _Tp> auto declval() noexcept -> decltype(__declval<_Tp>(0)) { static_assert(__declval_protector<_Tp>::__stop, "declval() must not be used!"); return __declval<_Tp>(0); } template<typename _Signature> class result_of; struct __invoke_memfun_ref { }; struct __invoke_memfun_deref { }; struct __invoke_memobj_ref { }; struct __invoke_memobj_deref { }; struct __invoke_other { }; template<typename _Tp, typename _Tag> struct __result_of_success : __success_type<_Tp> { using __invoke_type = _Tag; }; struct __result_of_memfun_ref_impl { template<typename _Fp, typename _Tp1, typename... _Args> static __result_of_success<decltype( (std::declval<_Tp1>().*std::declval<_Fp>())(std::declval<_Args>()...) ), __invoke_memfun_ref> _S_test(int); template<typename...> static __failure_type _S_test(...); }; template<typename _MemPtr, typename _Arg, typename... _Args> struct __result_of_memfun_ref : private __result_of_memfun_ref_impl { typedef decltype(_S_test<_MemPtr, _Arg, _Args...>(0)) type; }; struct __result_of_memfun_deref_impl { template<typename _Fp, typename _Tp1, typename... _Args> static __result_of_success<decltype( ((*std::declval<_Tp1>()).*std::declval<_Fp>())(std::declval<_Args>()...) ), __invoke_memfun_deref> _S_test(int); template<typename...> static __failure_type _S_test(...); }; template<typename _MemPtr, typename _Arg, typename... _Args> struct __result_of_memfun_deref : private __result_of_memfun_deref_impl { typedef decltype(_S_test<_MemPtr, _Arg, _Args...>(0)) type; }; struct __result_of_memobj_ref_impl { template<typename _Fp, typename _Tp1> static __result_of_success<decltype( std::declval<_Tp1>().*std::declval<_Fp>() ), __invoke_memobj_ref> _S_test(int); template<typename, typename> static __failure_type _S_test(...); }; template<typename _MemPtr, typename _Arg> struct __result_of_memobj_ref : private __result_of_memobj_ref_impl { typedef decltype(_S_test<_MemPtr, _Arg>(0)) type; }; struct __result_of_memobj_deref_impl { template<typename _Fp, typename _Tp1> static __result_of_success<decltype( (*std::declval<_Tp1>()).*std::declval<_Fp>() ), __invoke_memobj_deref> _S_test(int); template<typename, typename> static __failure_type _S_test(...); }; template<typename _MemPtr, typename _Arg> struct __result_of_memobj_deref : private __result_of_memobj_deref_impl { typedef decltype(_S_test<_MemPtr, _Arg>(0)) type; }; template<typename _MemPtr, typename _Arg> struct __result_of_memobj; template<typename _Res, typename _Class, typename _Arg> struct __result_of_memobj<_Res _Class::*, _Arg> { typedef __remove_cvref_t<_Arg> _Argval; typedef _Res _Class::* _MemPtr; typedef typename conditional<__or_<is_same<_Argval, _Class>, is_base_of<_Class, _Argval>>::value, __result_of_memobj_ref<_MemPtr, _Arg>, __result_of_memobj_deref<_MemPtr, _Arg> >::type::type type; }; template<typename _MemPtr, typename _Arg, typename... _Args> struct __result_of_memfun; template<typename _Res, typename _Class, typename _Arg, typename... _Args> struct __result_of_memfun<_Res _Class::*, _Arg, _Args...> { typedef typename remove_reference<_Arg>::type _Argval; typedef _Res _Class::* _MemPtr; typedef typename conditional<is_base_of<_Class, _Argval>::value, __result_of_memfun_ref<_MemPtr, _Arg, _Args...>, __result_of_memfun_deref<_MemPtr, _Arg, _Args...> >::type::type type; }; template<typename _Tp, typename _Up = __remove_cvref_t<_Tp>> struct __inv_unwrap { using type = _Tp; }; template<typename _Tp, typename _Up> struct __inv_unwrap<_Tp, reference_wrapper<_Up>> { using type = _Up&; }; template<bool, bool, typename _Functor, typename... _ArgTypes> struct __result_of_impl { typedef __failure_type type; }; template<typename _MemPtr, typename _Arg> struct __result_of_impl<true, false, _MemPtr, _Arg> : public __result_of_memobj<__decay_t<_MemPtr>, typename __inv_unwrap<_Arg>::type> { }; template<typename _MemPtr, typename _Arg, typename... _Args> struct __result_of_impl<false, true, _MemPtr, _Arg, _Args...> : public __result_of_memfun<__decay_t<_MemPtr>, typename __inv_unwrap<_Arg>::type, _Args...> { }; struct __result_of_other_impl { template<typename _Fn, typename... _Args> static __result_of_success<decltype( std::declval<_Fn>()(std::declval<_Args>()...) ), __invoke_other> _S_test(int); template<typename...> static __failure_type _S_test(...); }; template<typename _Functor, typename... _ArgTypes> struct __result_of_impl<false, false, _Functor, _ArgTypes...> : private __result_of_other_impl { typedef decltype(_S_test<_Functor, _ArgTypes...>(0)) type; }; template<typename _Functor, typename... _ArgTypes> struct __invoke_result : public __result_of_impl< is_member_object_pointer< typename remove_reference<_Functor>::type >::value, is_member_function_pointer< typename remove_reference<_Functor>::type >::value, _Functor, _ArgTypes... >::type { }; template<typename _Functor, typename... _ArgTypes> struct result_of<_Functor(_ArgTypes...)> : public __invoke_result<_Functor, _ArgTypes...> { }; template<size_t _Len, size_t _Align = __alignof__(typename __aligned_storage_msa<_Len>::__type)> using aligned_storage_t = typename aligned_storage<_Len, _Align>::type; template <size_t _Len, typename... _Types> using aligned_union_t = typename aligned_union<_Len, _Types...>::type; template<typename _Tp> using decay_t = typename decay<_Tp>::type; template<bool _Cond, typename _Tp = void> using enable_if_t = typename enable_if<_Cond, _Tp>::type; template<bool _Cond, typename _Iftrue, typename _Iffalse> using conditional_t = typename conditional<_Cond, _Iftrue, _Iffalse>::type; template<typename... _Tp> using common_type_t = typename common_type<_Tp...>::type; template<typename _Tp> using underlying_type_t = typename underlying_type<_Tp>::type; template<typename _Tp> using result_of_t = typename result_of<_Tp>::type; template<typename...> using void_t = void; template<typename _Default, typename _AlwaysVoid, template<typename...> class _Op, typename... _Args> struct __detector { using value_t = false_type; using type = _Default; }; template<typename _Default, template<typename...> class _Op, typename... _Args> struct __detector<_Default, __void_t<_Op<_Args...>>, _Op, _Args...> { using value_t = true_type; using type = _Op<_Args...>; }; template<typename _Default, template<typename...> class _Op, typename... _Args> using __detected_or = __detector<_Default, void, _Op, _Args...>; template<typename _Default, template<typename...> class _Op, typename... _Args> using __detected_or_t = typename __detected_or<_Default, _Op, _Args...>::type; template <typename _Tp> struct __is_swappable; template <typename _Tp> struct __is_nothrow_swappable; template<typename... _Elements> class tuple; template<typename> struct __is_tuple_like_impl : false_type { }; template<typename... _Tps> struct __is_tuple_like_impl<tuple<_Tps...>> : true_type { }; template<typename _Tp> struct __is_tuple_like : public __is_tuple_like_impl<__remove_cvref_t<_Tp>>::type { }; template<typename _Tp> inline _Require<__not_<__is_tuple_like<_Tp>>, is_move_constructible<_Tp>, is_move_assignable<_Tp>> swap(_Tp&, _Tp&) noexcept(__and_<is_nothrow_move_constructible<_Tp>, is_nothrow_move_assignable<_Tp>>::value); template<typename _Tp, size_t _Nm> inline __enable_if_t<__is_swappable<_Tp>::value> swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm]) noexcept(__is_nothrow_swappable<_Tp>::value); namespace __swappable_details { using std::swap; struct __do_is_swappable_impl { template<typename _Tp, typename = decltype(swap(std::declval<_Tp&>(), std::declval<_Tp&>()))> static true_type __test(int); template<typename> static false_type __test(...); }; struct __do_is_nothrow_swappable_impl { template<typename _Tp> static __bool_constant< noexcept(swap(std::declval<_Tp&>(), std::declval<_Tp&>())) > __test(int); template<typename> static false_type __test(...); }; } template<typename _Tp> struct __is_swappable_impl : public __swappable_details::__do_is_swappable_impl { typedef decltype(__test<_Tp>(0)) type; }; template<typename _Tp> struct __is_nothrow_swappable_impl : public __swappable_details::__do_is_nothrow_swappable_impl { typedef decltype(__test<_Tp>(0)) type; }; template<typename _Tp> struct __is_swappable : public __is_swappable_impl<_Tp>::type { }; template<typename _Tp> struct __is_nothrow_swappable : public __is_nothrow_swappable_impl<_Tp>::type { }; template<typename _Tp> struct is_swappable : public __is_swappable_impl<_Tp>::type { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; template<typename _Tp> struct is_nothrow_swappable : public __is_nothrow_swappable_impl<_Tp>::type { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; template<typename _Tp> constexpr bool is_swappable_v = is_swappable<_Tp>::value; template<typename _Tp> constexpr bool is_nothrow_swappable_v = is_nothrow_swappable<_Tp>::value; namespace __swappable_with_details { using std::swap; struct __do_is_swappable_with_impl { template<typename _Tp, typename _Up, typename = decltype(swap(std::declval<_Tp>(), std::declval<_Up>())), typename = decltype(swap(std::declval<_Up>(), std::declval<_Tp>()))> static true_type __test(int); template<typename, typename> static false_type __test(...); }; struct __do_is_nothrow_swappable_with_impl { template<typename _Tp, typename _Up> static __bool_constant< noexcept(swap(std::declval<_Tp>(), std::declval<_Up>())) && noexcept(swap(std::declval<_Up>(), std::declval<_Tp>())) > __test(int); template<typename, typename> static false_type __test(...); }; } template<typename _Tp, typename _Up> struct __is_swappable_with_impl : public __swappable_with_details::__do_is_swappable_with_impl { typedef decltype(__test<_Tp, _Up>(0)) type; }; template<typename _Tp> struct __is_swappable_with_impl<_Tp&, _Tp&> : public __swappable_details::__do_is_swappable_impl { typedef decltype(__test<_Tp&>(0)) type; }; template<typename _Tp, typename _Up> struct __is_nothrow_swappable_with_impl : public __swappable_with_details::__do_is_nothrow_swappable_with_impl { typedef decltype(__test<_Tp, _Up>(0)) type; }; template<typename _Tp> struct __is_nothrow_swappable_with_impl<_Tp&, _Tp&> : public __swappable_details::__do_is_nothrow_swappable_impl { typedef decltype(__test<_Tp&>(0)) type; }; template<typename _Tp, typename _Up> struct is_swappable_with : public __is_swappable_with_impl<_Tp, _Up>::type { }; template<typename _Tp, typename _Up> struct is_nothrow_swappable_with : public __is_nothrow_swappable_with_impl<_Tp, _Up>::type { }; template<typename _Tp, typename _Up> constexpr bool is_swappable_with_v = is_swappable_with<_Tp, _Up>::value; template<typename _Tp, typename _Up> constexpr bool is_nothrow_swappable_with_v = is_nothrow_swappable_with<_Tp, _Up>::value; template<typename _Result, typename _Ret, bool = is_void<_Ret>::value, typename = void> struct __is_invocable_impl : false_type { }; template<typename _Result, typename _Ret> struct __is_invocable_impl<_Result, _Ret, true, __void_t<typename _Result::type>> : true_type { }; template<typename _Result, typename _Ret> struct __is_invocable_impl<_Result, _Ret, false, __void_t<typename _Result::type>> { private: static typename _Result::type _S_get(); template<typename _Tp> static void _S_conv(_Tp); template<typename _Tp, typename = decltype(_S_conv<_Tp>(_S_get()))> static true_type _S_test(int); template<typename _Tp> static false_type _S_test(...); public: using type = decltype(_S_test<_Ret>(1)); }; template<typename _Fn, typename... _ArgTypes> struct __is_invocable : __is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, void>::type { }; template<typename _Fn, typename _Tp, typename... _Args> constexpr bool __call_is_nt(__invoke_memfun_ref) { using _Up = typename __inv_unwrap<_Tp>::type; return noexcept((std::declval<_Up>().*std::declval<_Fn>())( std::declval<_Args>()...)); } template<typename _Fn, typename _Tp, typename... _Args> constexpr bool __call_is_nt(__invoke_memfun_deref) { return noexcept(((*std::declval<_Tp>()).*std::declval<_Fn>())( std::declval<_Args>()...)); } template<typename _Fn, typename _Tp> constexpr bool __call_is_nt(__invoke_memobj_ref) { using _Up = typename __inv_unwrap<_Tp>::type; return noexcept(std::declval<_Up>().*std::declval<_Fn>()); } template<typename _Fn, typename _Tp> constexpr bool __call_is_nt(__invoke_memobj_deref) { return noexcept((*std::declval<_Tp>()).*std::declval<_Fn>()); } template<typename _Fn, typename... _Args> constexpr bool __call_is_nt(__invoke_other) { return noexcept(std::declval<_Fn>()(std::declval<_Args>()...)); } template<typename _Result, typename _Fn, typename... _Args> struct __call_is_nothrow : __bool_constant< std::__call_is_nt<_Fn, _Args...>(typename _Result::__invoke_type{}) > { }; template<typename _Fn, typename... _Args> using __call_is_nothrow_ = __call_is_nothrow<__invoke_result<_Fn, _Args...>, _Fn, _Args...>; template<typename _Fn, typename... _Args> struct __is_nothrow_invocable : __and_<__is_invocable<_Fn, _Args...>, __call_is_nothrow_<_Fn, _Args...>>::type { }; struct __nonesuchbase {}; struct __nonesuch : private __nonesuchbase { ~__nonesuch() = delete; __nonesuch(__nonesuch const&) = delete; void operator=(__nonesuch const&) = delete; }; } namespace std __attribute__ ((__visibility__ ("default"))) { template<typename _Tp> constexpr _Tp&& forward(typename std::remove_reference<_Tp>::type& __t) noexcept { return static_cast<_Tp&&>(__t); } 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); } 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 { }; 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); } template<typename _Tp> inline _Tp* addressof(_Tp& __r) noexcept { return std::__addressof(__r); } template<typename _Tp> const _Tp* addressof(const _Tp&&) = delete; template <typename _Tp, typename _Up = _Tp> inline _Tp __exchange(_Tp& __obj, _Up&& __new_val) { _Tp __old_val = std::move(__obj); __obj = std::forward<_Up>(__new_val); return __old_val; } template<typename _Tp> inline typename enable_if<__and_<__not_<__is_tuple_like<_Tp>>, is_move_constructible<_Tp>, is_move_assignable<_Tp>>::value>::type swap(_Tp& __a, _Tp& __b) noexcept(__and_<is_nothrow_move_constructible<_Tp>, is_nothrow_move_assignable<_Tp>>::value) { _Tp __tmp = std::move(__a); __a = std::move(__b); __b = std::move(__tmp); } template<typename _Tp, size_t _Nm> inline typename enable_if<__is_swappable<_Tp>::value>::type swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm]) noexcept(__is_nothrow_swappable<_Tp>::value) { for (size_t __n = 0; __n < _Nm; ++__n) swap(__a[__n], __b[__n]); } } namespace std __attribute__ ((__visibility__ ("default"))) { struct piecewise_construct_t { explicit piecewise_construct_t() = default; }; constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t(); template<typename...> class tuple; template<std::size_t...> struct _Index_tuple; template <bool, typename _T1, typename _T2> struct _PCC { template <typename _U1, typename _U2> static constexpr bool _ConstructiblePair() { return __and_<is_constructible<_T1, const _U1&>, is_constructible<_T2, const _U2&>>::value; } template <typename _U1, typename _U2> static constexpr bool _ImplicitlyConvertiblePair() { return __and_<is_convertible<const _U1&, _T1>, is_convertible<const _U2&, _T2>>::value; } template <typename _U1, typename _U2> static constexpr bool _MoveConstructiblePair() { return __and_<is_constructible<_T1, _U1&&>, is_constructible<_T2, _U2&&>>::value; } template <typename _U1, typename _U2> static constexpr bool _ImplicitlyMoveConvertiblePair() { return __and_<is_convertible<_U1&&, _T1>, is_convertible<_U2&&, _T2>>::value; } template <bool __implicit, typename _U1, typename _U2> static constexpr bool _CopyMovePair() { using __do_converts = __and_<is_convertible<const _U1&, _T1>, is_convertible<_U2&&, _T2>>; using __converts = typename conditional<__implicit, __do_converts, __not_<__do_converts>>::type; return __and_<is_constructible<_T1, const _U1&>, is_constructible<_T2, _U2&&>, __converts >::value; } template <bool __implicit, typename _U1, typename _U2> static constexpr bool _MoveCopyPair() { using __do_converts = __and_<is_convertible<_U1&&, _T1>, is_convertible<const _U2&, _T2>>; using __converts = typename conditional<__implicit, __do_converts, __not_<__do_converts>>::type; return __and_<is_constructible<_T1, _U1&&>, is_constructible<_T2, const _U2&&>, __converts >::value; } }; template <typename _T1, typename _T2> struct _PCC<false, _T1, _T2> { template <typename _U1, typename _U2> static constexpr bool _ConstructiblePair() { return false; } template <typename _U1, typename _U2> static constexpr bool _ImplicitlyConvertiblePair() { return false; } template <typename _U1, typename _U2> static constexpr bool _MoveConstructiblePair() { return false; } template <typename _U1, typename _U2> static constexpr bool _ImplicitlyMoveConvertiblePair() { return false; } }; template<typename _U1, typename _U2> class __pair_base { template<typename _T1, typename _T2> friend struct pair; __pair_base() = default; ~__pair_base() = default; __pair_base(const __pair_base&) = default; __pair_base& operator=(const __pair_base&) = delete; }; template<typename _T1, typename _T2> struct pair : private __pair_base<_T1, _T2> { typedef _T1 first_type; typedef _T2 second_type; _T1 first; _T2 second; template <typename _U1 = _T1, typename _U2 = _T2, typename enable_if<__and_< __is_implicitly_default_constructible<_U1>, __is_implicitly_default_constructible<_U2>> ::value, bool>::type = true> constexpr pair() : first(), second() { } template <typename _U1 = _T1, typename _U2 = _T2, typename enable_if<__and_< is_default_constructible<_U1>, is_default_constructible<_U2>, __not_< __and_<__is_implicitly_default_constructible<_U1>, __is_implicitly_default_constructible<_U2>>>> ::value, bool>::type = false> explicit constexpr pair() : first(), second() { } using _PCCP = _PCC<true, _T1, _T2>; template<typename _U1 = _T1, typename _U2=_T2, typename enable_if<_PCCP::template _ConstructiblePair<_U1, _U2>() && _PCCP::template _ImplicitlyConvertiblePair<_U1, _U2>(), bool>::type=true> constexpr pair(const _T1& __a, const _T2& __b) : first(__a), second(__b) { } template<typename _U1 = _T1, typename _U2=_T2, typename enable_if<_PCCP::template _ConstructiblePair<_U1, _U2>() && !_PCCP::template _ImplicitlyConvertiblePair<_U1, _U2>(), bool>::type=false> explicit constexpr pair(const _T1& __a, const _T2& __b) : first(__a), second(__b) { } template <typename _U1, typename _U2> using _PCCFP = _PCC<!is_same<_T1, _U1>::value || !is_same<_T2, _U2>::value, _T1, _T2>; template<typename _U1, typename _U2, typename enable_if<_PCCFP<_U1, _U2>::template _ConstructiblePair<_U1, _U2>() && _PCCFP<_U1, _U2>::template _ImplicitlyConvertiblePair<_U1, _U2>(), bool>::type=true> constexpr pair(const pair<_U1, _U2>& __p) : first(__p.first), second(__p.second) { } template<typename _U1, typename _U2, typename enable_if<_PCCFP<_U1, _U2>::template _ConstructiblePair<_U1, _U2>() && !_PCCFP<_U1, _U2>::template _ImplicitlyConvertiblePair<_U1, _U2>(), bool>::type=false> explicit constexpr pair(const pair<_U1, _U2>& __p) : first(__p.first), second(__p.second) { } constexpr pair(const pair&) = default; constexpr pair(pair&&) = default; template<typename _U1, typename enable_if<_PCCP::template _MoveCopyPair<true, _U1, _T2>(), bool>::type=true> constexpr pair(_U1&& __x, const _T2& __y) : first(std::forward<_U1>(__x)), second(__y) { } template<typename _U1, typename enable_if<_PCCP::template _MoveCopyPair<false, _U1, _T2>(), bool>::type=false> explicit constexpr pair(_U1&& __x, const _T2& __y) : first(std::forward<_U1>(__x)), second(__y) { } template<typename _U2, typename enable_if<_PCCP::template _CopyMovePair<true, _T1, _U2>(), bool>::type=true> constexpr pair(const _T1& __x, _U2&& __y) : first(__x), second(std::forward<_U2>(__y)) { } template<typename _U2, typename enable_if<_PCCP::template _CopyMovePair<false, _T1, _U2>(), bool>::type=false> explicit pair(const _T1& __x, _U2&& __y) : first(__x), second(std::forward<_U2>(__y)) { } template<typename _U1, typename _U2, typename enable_if<_PCCP::template _MoveConstructiblePair<_U1, _U2>() && _PCCP::template _ImplicitlyMoveConvertiblePair<_U1, _U2>(), bool>::type=true> constexpr pair(_U1&& __x, _U2&& __y) : first(std::forward<_U1>(__x)), second(std::forward<_U2>(__y)) { } template<typename _U1, typename _U2, typename enable_if<_PCCP::template _MoveConstructiblePair<_U1, _U2>() && !_PCCP::template _ImplicitlyMoveConvertiblePair<_U1, _U2>(), bool>::type=false> explicit constexpr pair(_U1&& __x, _U2&& __y) : first(std::forward<_U1>(__x)), second(std::forward<_U2>(__y)) { } template<typename _U1, typename _U2, typename enable_if<_PCCFP<_U1, _U2>::template _MoveConstructiblePair<_U1, _U2>() && _PCCFP<_U1, _U2>::template _ImplicitlyMoveConvertiblePair<_U1, _U2>(), bool>::type=true> constexpr pair(pair<_U1, _U2>&& __p) : first(std::forward<_U1>(__p.first)), second(std::forward<_U2>(__p.second)) { } template<typename _U1, typename _U2, typename enable_if<_PCCFP<_U1, _U2>::template _MoveConstructiblePair<_U1, _U2>() && !_PCCFP<_U1, _U2>::template _ImplicitlyMoveConvertiblePair<_U1, _U2>(), bool>::type=false> explicit constexpr pair(pair<_U1, _U2>&& __p) : first(std::forward<_U1>(__p.first)), second(std::forward<_U2>(__p.second)) { } template<typename... _Args1, typename... _Args2> pair(piecewise_construct_t, tuple<_Args1...>, tuple<_Args2...>); pair& operator=(typename conditional< __and_<is_copy_assignable<_T1>, is_copy_assignable<_T2>>::value, const pair&, const __nonesuch&>::type __p) { first = __p.first; second = __p.second; return *this; } pair& operator=(typename conditional< __and_<is_move_assignable<_T1>, is_move_assignable<_T2>>::value, pair&&, __nonesuch&&>::type __p) noexcept(__and_<is_nothrow_move_assignable<_T1>, is_nothrow_move_assignable<_T2>>::value) { first = std::forward<first_type>(__p.first); second = std::forward<second_type>(__p.second); return *this; } template<typename _U1, typename _U2> typename enable_if<__and_<is_assignable<_T1&, const _U1&>, is_assignable<_T2&, const _U2&>>::value, pair&>::type operator=(const pair<_U1, _U2>& __p) { first = __p.first; second = __p.second; return *this; } template<typename _U1, typename _U2> typename enable_if<__and_<is_assignable<_T1&, _U1&&>, is_assignable<_T2&, _U2&&>>::value, pair&>::type operator=(pair<_U1, _U2>&& __p) { first = std::forward<_U1>(__p.first); second = std::forward<_U2>(__p.second); return *this; } void swap(pair& __p) noexcept(__and_<__is_nothrow_swappable<_T1>, __is_nothrow_swappable<_T2>>::value) { using std::swap; swap(first, __p.first); swap(second, __p.second); } private: template<typename... _Args1, std::size_t... _Indexes1, typename... _Args2, std::size_t... _Indexes2> pair(tuple<_Args1...>&, tuple<_Args2...>&, _Index_tuple<_Indexes1...>, _Index_tuple<_Indexes2...>); }; template<typename _T1, typename _T2> inline constexpr bool operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) { return __x.first == __y.first && __x.second == __y.second; } template<typename _T1, typename _T2> inline constexpr bool operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) { return __x.first < __y.first || (!(__y.first < __x.first) && __x.second < __y.second); } template<typename _T1, typename _T2> inline constexpr bool operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) { return !(__x == __y); } template<typename _T1, typename _T2> inline constexpr bool operator>(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) { return __y < __x; } template<typename _T1, typename _T2> inline constexpr bool operator<=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) { return !(__y < __x); } template<typename _T1, typename _T2> inline constexpr bool operator>=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) { return !(__x < __y); } template<typename _T1, typename _T2> inline typename enable_if<__and_<__is_swappable<_T1>, __is_swappable<_T2>>::value>::type swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y) noexcept(noexcept(__x.swap(__y))) { __x.swap(__y); } template<typename _T1, typename _T2> typename enable_if<!__and_<__is_swappable<_T1>, __is_swappable<_T2>>::value>::type swap(pair<_T1, _T2>&, pair<_T1, _T2>&) = delete; template<typename _T1, typename _T2> constexpr pair<typename __decay_and_strip<_T1>::__type, typename __decay_and_strip<_T2>::__type> make_pair(_T1&& __x, _T2&& __y) { typedef typename __decay_and_strip<_T1>::__type __ds_type1; typedef typename __decay_and_strip<_T2>::__type __ds_type2; typedef pair<__ds_type1, __ds_type2> __pair_type; return __pair_type(std::forward<_T1>(__x), std::forward<_T2>(__y)); } } namespace std __attribute__ ((__visibility__ ("default"))) { struct input_iterator_tag { }; struct output_iterator_tag { }; struct forward_iterator_tag : public input_iterator_tag { }; struct bidirectional_iterator_tag : public forward_iterator_tag { }; struct random_access_iterator_tag : public bidirectional_iterator_tag { }; template<typename _Category, typename _Tp, typename _Distance = ptrdiff_t, typename _Pointer = _Tp*, typename _Reference = _Tp&> struct iterator { typedef _Category iterator_category; typedef _Tp value_type; typedef _Distance difference_type; typedef _Pointer pointer; typedef _Reference reference; }; template<typename _Iterator> struct iterator_traits; template<typename _Iterator, typename = __void_t<>> struct __iterator_traits { }; template<typename _Iterator> struct __iterator_traits<_Iterator, __void_t<typename _Iterator::iterator_category, typename _Iterator::value_type, typename _Iterator::difference_type, typename _Iterator::pointer, typename _Iterator::reference>> { typedef typename _Iterator::iterator_category iterator_category; typedef typename _Iterator::value_type value_type; typedef typename _Iterator::difference_type difference_type; typedef typename _Iterator::pointer pointer; typedef typename _Iterator::reference reference; }; template<typename _Iterator> struct iterator_traits : public __iterator_traits<_Iterator> { }; template<typename _Tp> struct iterator_traits<_Tp*> { typedef random_access_iterator_tag iterator_category; typedef _Tp value_type; typedef ptrdiff_t difference_type; typedef _Tp* pointer; typedef _Tp& reference; }; template<typename _Tp> struct iterator_traits<const _Tp*> { typedef random_access_iterator_tag iterator_category; typedef _Tp value_type; typedef ptrdiff_t difference_type; typedef const _Tp* pointer; typedef const _Tp& reference; }; template<typename _Iter> inline constexpr typename iterator_traits<_Iter>::iterator_category __iterator_category(const _Iter&) { return typename iterator_traits<_Iter>::iterator_category(); } template<typename _Iter> using __iterator_category_t = typename iterator_traits<_Iter>::iterator_category; template<typename _InIter> using _RequireInputIter = __enable_if_t<is_convertible<__iterator_category_t<_InIter>, input_iterator_tag>::value>; template<typename _It, typename _Cat = __iterator_category_t<_It>> struct __is_random_access_iter : is_base_of<random_access_iterator_tag, _Cat> { typedef is_base_of<random_access_iterator_tag, _Cat> _Base; enum { __value = _Base::value }; }; } namespace std __attribute__ ((__visibility__ ("default"))) { template <typename> struct _List_iterator; template <typename> struct _List_const_iterator; template<typename _InputIterator> inline constexpr typename iterator_traits<_InputIterator>::difference_type __distance(_InputIterator __first, _InputIterator __last, input_iterator_tag) { typename iterator_traits<_InputIterator>::difference_type __n = 0; while (__first != __last) { ++__first; ++__n; } return __n; } template<typename _RandomAccessIterator> inline constexpr typename iterator_traits<_RandomAccessIterator>::difference_type __distance(_RandomAccessIterator __first, _RandomAccessIterator __last, random_access_iterator_tag) { return __last - __first; } template<typename _Tp> ptrdiff_t __distance(std::_List_iterator<_Tp>, std::_List_iterator<_Tp>, input_iterator_tag); template<typename _Tp> ptrdiff_t __distance(std::_List_const_iterator<_Tp>, std::_List_const_iterator<_Tp>, input_iterator_tag); template<typename _InputIterator> inline typename iterator_traits<_InputIterator>::difference_type distance(_InputIterator __first, _InputIterator __last) { return std::__distance(__first, __last, std::__iterator_category(__first)); } template<typename _InputIterator, typename _Distance> inline constexpr void __advance(_InputIterator& __i, _Distance __n, input_iterator_tag) { ; while (__n--) ++__i; } template<typename _BidirectionalIterator, typename _Distance> inline constexpr void __advance(_BidirectionalIterator& __i, _Distance __n, bidirectional_iterator_tag) { if (__n > 0) while (__n--) ++__i; else while (__n++) --__i; } template<typename _RandomAccessIterator, typename _Distance> inline constexpr void __advance(_RandomAccessIterator& __i, _Distance __n, random_access_iterator_tag) { if (__builtin_constant_p(__n) && __n == 1) ++__i; else if (__builtin_constant_p(__n) && __n == -1) --__i; else __i += __n; } template<typename _InputIterator, typename _Distance> inline void advance(_InputIterator& __i, _Distance __n) { typename iterator_traits<_InputIterator>::difference_type __d = __n; std::__advance(__i, __d, std::__iterator_category(__i)); } template<typename _InputIterator> inline _InputIterator next(_InputIterator __x, typename iterator_traits<_InputIterator>::difference_type __n = 1) { std::advance(__x, __n); return __x; } template<typename _BidirectionalIterator> inline _BidirectionalIterator prev(_BidirectionalIterator __x, typename iterator_traits<_BidirectionalIterator>::difference_type __n = 1) { std::advance(__x, -__n); return __x; } } namespace std __attribute__ ((__visibility__ ("default"))) { class __undefined; template<typename _Tp> struct __get_first_arg { using type = __undefined; }; template<template<typename, typename...> class _Template, typename _Tp, typename... _Types> struct __get_first_arg<_Template<_Tp, _Types...>> { using type = _Tp; }; template<typename _Tp> using __get_first_arg_t = typename __get_first_arg<_Tp>::type; template<typename _Tp, typename _Up> struct __replace_first_arg { }; template<template<typename, typename...> class _Template, typename _Up, typename _Tp, typename... _Types> struct __replace_first_arg<_Template<_Tp, _Types...>, _Up> { using type = _Template<_Up, _Types...>; }; template<typename _Tp, typename _Up> using __replace_first_arg_t = typename __replace_first_arg<_Tp, _Up>::type; template<typename _Tp> using __make_not_void = typename conditional<is_void<_Tp>::value, __undefined, _Tp>::type; template<typename _Ptr> struct pointer_traits { private: template<typename _Tp> using __element_type = typename _Tp::element_type; template<typename _Tp> using __difference_type = typename _Tp::difference_type; 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>>> { using type = typename _Tp::template rebind<_Up>; }; public: using pointer = _Ptr; using element_type = __detected_or_t<__get_first_arg_t<_Ptr>, __element_type, _Ptr>; using difference_type = __detected_or_t<ptrdiff_t, __difference_type, _Ptr>; template<typename _Up> using rebind = typename __rebind<_Ptr, _Up>::type; static _Ptr pointer_to(__make_not_void<element_type>& __e) { return _Ptr::pointer_to(__e); } static_assert(!is_same<element_type, __undefined>::value, "pointer type defines element_type or is like SomePointer<T, Args>"); }; template<typename _Tp> struct pointer_traits<_Tp*> { typedef _Tp* pointer; typedef _Tp element_type; typedef ptrdiff_t difference_type; template<typename _Up> using rebind = _Up*; static pointer pointer_to(__make_not_void<element_type>& __r) noexcept { return std::addressof(__r); } }; template<typename _Ptr, typename _Tp> using __ptr_rebind = typename pointer_traits<_Ptr>::template rebind<_Tp>; template<typename _Tp> constexpr _Tp* __to_address(_Tp* __ptr) noexcept { static_assert(!std::is_function<_Tp>::value, "not a function pointer"); return __ptr; } template<typename _Ptr> constexpr typename std::pointer_traits<_Ptr>::element_type* __to_address(const _Ptr& __ptr) { return std::__to_address(__ptr.operator->()); } } namespace std __attribute__ ((__visibility__ ("default"))) { template<typename _Iterator> class reverse_iterator : public iterator<typename iterator_traits<_Iterator>::iterator_category, typename iterator_traits<_Iterator>::value_type, typename iterator_traits<_Iterator>::difference_type, typename iterator_traits<_Iterator>::pointer, typename iterator_traits<_Iterator>::reference> { protected: _Iterator current; typedef iterator_traits<_Iterator> __traits_type; public: typedef _Iterator iterator_type; typedef typename __traits_type::difference_type difference_type; typedef typename __traits_type::pointer pointer; typedef typename __traits_type::reference reference; reverse_iterator() : current() { } explicit reverse_iterator(iterator_type __x) : current(__x) { } reverse_iterator(const reverse_iterator& __x) : current(__x.current) { } reverse_iterator& operator=(const reverse_iterator&) = default; template<typename _Iter> reverse_iterator(const reverse_iterator<_Iter>& __x) : current(__x.base()) { } iterator_type base() const { return current; } reference operator*() const { _Iterator __tmp = current; return *--__tmp; } pointer operator->() const { _Iterator __tmp = current; --__tmp; return _S_to_pointer(__tmp); } reverse_iterator& operator++() { --current; return *this; } reverse_iterator operator++(int) { reverse_iterator __tmp = *this; --current; return __tmp; } reverse_iterator& operator--() { ++current; return *this; } reverse_iterator operator--(int) { reverse_iterator __tmp = *this; ++current; return __tmp; } reverse_iterator operator+(difference_type __n) const { return reverse_iterator(current - __n); } reverse_iterator& operator+=(difference_type __n) { current -= __n; return *this; } reverse_iterator operator-(difference_type __n) const { return reverse_iterator(current + __n); } reverse_iterator& operator-=(difference_type __n) { current += __n; return *this; } reference operator[](difference_type __n) const { return *(*this + __n); } private: template<typename _Tp> static _Tp* _S_to_pointer(_Tp* __p) { return __p; } template<typename _Tp> static pointer _S_to_pointer(_Tp __t) { return __t.operator->(); } }; template<typename _Iterator> inline bool operator==(const reverse_iterator<_Iterator>& __x, const reverse_iterator<_Iterator>& __y) { return __x.base() == __y.base(); } template<typename _Iterator> inline bool operator<(const reverse_iterator<_Iterator>& __x, const reverse_iterator<_Iterator>& __y) { return __y.base() < __x.base(); } template<typename _Iterator> inline bool operator!=(const reverse_iterator<_Iterator>& __x, const reverse_iterator<_Iterator>& __y) { return !(__x == __y); } template<typename _Iterator> inline bool operator>(const reverse_iterator<_Iterator>& __x, const reverse_iterator<_Iterator>& __y) { return __y < __x; } template<typename _Iterator> inline bool operator<=(const reverse_iterator<_Iterator>& __x, const reverse_iterator<_Iterator>& __y) { return !(__y < __x); } template<typename _Iterator> inline bool operator>=(const reverse_iterator<_Iterator>& __x, const reverse_iterator<_Iterator>& __y) { return !(__x < __y); } template<typename _IteratorL, typename _IteratorR> inline bool operator==(const reverse_iterator<_IteratorL>& __x, const reverse_iterator<_IteratorR>& __y) { return __x.base() == __y.base(); } template<typename _IteratorL, typename _IteratorR> inline bool operator<(const reverse_iterator<_IteratorL>& __x, const reverse_iterator<_IteratorR>& __y) { return __y.base() < __x.base(); } template<typename _IteratorL, typename _IteratorR> inline bool operator!=(const reverse_iterator<_IteratorL>& __x, const reverse_iterator<_IteratorR>& __y) { return !(__x == __y); } template<typename _IteratorL, typename _IteratorR> inline bool operator>(const reverse_iterator<_IteratorL>& __x, const reverse_iterator<_IteratorR>& __y) { return __y < __x; } template<typename _IteratorL, typename _IteratorR> inline bool operator<=(const reverse_iterator<_IteratorL>& __x, const reverse_iterator<_IteratorR>& __y) { return !(__y < __x); } template<typename _IteratorL, typename _IteratorR> inline bool operator>=(const reverse_iterator<_IteratorL>& __x, const reverse_iterator<_IteratorR>& __y) { return !(__x < __y); } template<typename _IteratorL, typename _IteratorR> inline auto operator-(const reverse_iterator<_IteratorL>& __x, const reverse_iterator<_IteratorR>& __y) -> decltype(__y.base() - __x.base()) { return __y.base() - __x.base(); } template<typename _Iterator> inline reverse_iterator<_Iterator> operator+(typename reverse_iterator<_Iterator>::difference_type __n, const reverse_iterator<_Iterator>& __x) { return reverse_iterator<_Iterator>(__x.base() - __n); } template<typename _Iterator> inline reverse_iterator<_Iterator> __make_reverse_iterator(_Iterator __i) { return reverse_iterator<_Iterator>(__i); } template<typename _Iterator> inline reverse_iterator<_Iterator> make_reverse_iterator(_Iterator __i) { return reverse_iterator<_Iterator>(__i); } template<typename _Iterator> auto __niter_base(reverse_iterator<_Iterator> __it) -> decltype(__make_reverse_iterator(__niter_base(__it.base()))) { return __make_reverse_iterator(__niter_base(__it.base())); } template<typename _Iterator> struct __is_move_iterator<reverse_iterator<_Iterator> > : __is_move_iterator<_Iterator> { }; template<typename _Iterator> auto __miter_base(reverse_iterator<_Iterator> __it) -> decltype(__make_reverse_iterator(__miter_base(__it.base()))) { return __make_reverse_iterator(__miter_base(__it.base())); } template<typename _Container> class back_insert_iterator : public iterator<output_iterator_tag, void, void, void, void> { protected: _Container* container; public: typedef _Container container_type; explicit back_insert_iterator(_Container& __x) : container(std::__addressof(__x)) { } back_insert_iterator& operator=(const typename _Container::value_type& __value) { container->push_back(__value); return *this; } back_insert_iterator& operator=(typename _Container::value_type&& __value) { container->push_back(std::move(__value)); return *this; } back_insert_iterator& operator*() { return *this; } back_insert_iterator& operator++() { return *this; } back_insert_iterator operator++(int) { return *this; } }; template<typename _Container> inline back_insert_iterator<_Container> back_inserter(_Container& __x) { return back_insert_iterator<_Container>(__x); } template<typename _Container> class front_insert_iterator : public iterator<output_iterator_tag, void, void, void, void> { protected: _Container* container; public: typedef _Container container_type; explicit front_insert_iterator(_Container& __x) : container(std::__addressof(__x)) { } front_insert_iterator& operator=(const typename _Container::value_type& __value) { container->push_front(__value); return *this; } front_insert_iterator& operator=(typename _Container::value_type&& __value) { container->push_front(std::move(__value)); return *this; } front_insert_iterator& operator*() { return *this; } front_insert_iterator& operator++() { return *this; } front_insert_iterator operator++(int) { return *this; } }; template<typename _Container> inline front_insert_iterator<_Container> front_inserter(_Container& __x) { return front_insert_iterator<_Container>(__x); } template<typename _Container> class insert_iterator : public iterator<output_iterator_tag, void, void, void, void> { typedef typename _Container::iterator _Iter; protected: _Container* container; _Iter iter; public: typedef _Container container_type; insert_iterator(_Container& __x, _Iter __i) : container(std::__addressof(__x)), iter(__i) {} insert_iterator& operator=(const typename _Container::value_type& __value) { iter = container->insert(iter, __value); ++iter; return *this; } insert_iterator& operator=(typename _Container::value_type&& __value) { iter = container->insert(iter, std::move(__value)); ++iter; return *this; } insert_iterator& operator*() { return *this; } insert_iterator& operator++() { return *this; } insert_iterator& operator++(int) { return *this; } }; template<typename _Container, typename _Iterator> inline insert_iterator<_Container> inserter(_Container& __x, _Iterator __i) { return insert_iterator<_Container>(__x, typename _Container::iterator(__i)); } } namespace __gnu_cxx __attribute__ ((__visibility__ ("default"))) { template<typename _Iterator, typename _Container> class __normal_iterator { protected: _Iterator _M_current; typedef std::iterator_traits<_Iterator> __traits_type; public: typedef _Iterator iterator_type; typedef typename __traits_type::iterator_category iterator_category; typedef typename __traits_type::value_type value_type; typedef typename __traits_type::difference_type difference_type; typedef typename __traits_type::reference reference; typedef typename __traits_type::pointer pointer; constexpr __normal_iterator() noexcept : _M_current(_Iterator()) { } explicit __normal_iterator(const _Iterator& __i) noexcept : _M_current(__i) { } template<typename _Iter> __normal_iterator(const __normal_iterator<_Iter, typename __enable_if< (std::__are_same<_Iter, typename _Container::pointer>::__value), _Container>::__type>& __i) noexcept : _M_current(__i.base()) { } reference operator*() const noexcept { return *_M_current; } pointer operator->() const noexcept { return _M_current; } __normal_iterator& operator++() noexcept { ++_M_current; return *this; } __normal_iterator operator++(int) noexcept { return __normal_iterator(_M_current++); } __normal_iterator& operator--() noexcept { --_M_current; return *this; } __normal_iterator operator--(int) noexcept { return __normal_iterator(_M_current--); } reference operator[](difference_type __n) const noexcept { return _M_current[__n]; } __normal_iterator& operator+=(difference_type __n) noexcept { _M_current += __n; return *this; } __normal_iterator operator+(difference_type __n) const noexcept { return __normal_iterator(_M_current + __n); } __normal_iterator& operator-=(difference_type __n) noexcept { _M_current -= __n; return *this; } __normal_iterator operator-(difference_type __n) const noexcept { return __normal_iterator(_M_current - __n); } const _Iterator& base() const noexcept { return _M_current; } }; template<typename _IteratorL, typename _IteratorR, typename _Container> inline bool operator==(const __normal_iterator<_IteratorL, _Container>& __lhs, const __normal_iterator<_IteratorR, _Container>& __rhs) noexcept { return __lhs.base() == __rhs.base(); } template<typename _Iterator, typename _Container> inline bool operator==(const __normal_iterator<_Iterator, _Container>& __lhs, const __normal_iterator<_Iterator, _Container>& __rhs) noexcept { return __lhs.base() == __rhs.base(); } template<typename _IteratorL, typename _IteratorR, typename _Container> inline bool operator!=(const __normal_iterator<_IteratorL, _Container>& __lhs, const __normal_iterator<_IteratorR, _Container>& __rhs) noexcept { return __lhs.base() != __rhs.base(); } template<typename _Iterator, typename _Container> inline bool operator!=(const __normal_iterator<_Iterator, _Container>& __lhs, const __normal_iterator<_Iterator, _Container>& __rhs) noexcept { return __lhs.base() != __rhs.base(); } template<typename _IteratorL, typename _IteratorR, typename _Container> inline bool operator<(const __normal_iterator<_IteratorL, _Container>& __lhs, const __normal_iterator<_IteratorR, _Container>& __rhs) noexcept { return __lhs.base() < __rhs.base(); } template<typename _Iterator, typename _Container> inline bool operator<(const __normal_iterator<_Iterator, _Container>& __lhs, const __normal_iterator<_Iterator, _Container>& __rhs) noexcept { return __lhs.base() < __rhs.base(); } template<typename _IteratorL, typename _IteratorR, typename _Container> inline bool operator>(const __normal_iterator<_IteratorL, _Container>& __lhs, const __normal_iterator<_IteratorR, _Container>& __rhs) noexcept { return __lhs.base() > __rhs.base(); } template<typename _Iterator, typename _Container> inline bool operator>(const __normal_iterator<_Iterator, _Container>& __lhs, const __normal_iterator<_Iterator, _Container>& __rhs) noexcept { return __lhs.base() > __rhs.base(); } template<typename _IteratorL, typename _IteratorR, typename _Container> inline bool operator<=(const __normal_iterator<_IteratorL, _Container>& __lhs, const __normal_iterator<_IteratorR, _Container>& __rhs) noexcept { return __lhs.base() <= __rhs.base(); } template<typename _Iterator, typename _Container> inline bool operator<=(const __normal_iterator<_Iterator, _Container>& __lhs, const __normal_iterator<_Iterator, _Container>& __rhs) noexcept { return __lhs.base() <= __rhs.base(); } template<typename _IteratorL, typename _IteratorR, typename _Container> inline bool operator>=(const __normal_iterator<_IteratorL, _Container>& __lhs, const __normal_iterator<_IteratorR, _Container>& __rhs) noexcept { return __lhs.base() >= __rhs.base(); } template<typename _Iterator, typename _Container> inline bool operator>=(const __normal_iterator<_Iterator, _Container>& __lhs, const __normal_iterator<_Iterator, _Container>& __rhs) noexcept { return __lhs.base() >= __rhs.base(); } template<typename _IteratorL, typename _IteratorR, typename _Container> inline auto operator-(const __normal_iterator<_IteratorL, _Container>& __lhs, const __normal_iterator<_IteratorR, _Container>& __rhs) noexcept -> decltype(__lhs.base() - __rhs.base()) { return __lhs.base() - __rhs.base(); } template<typename _Iterator, typename _Container> inline typename __normal_iterator<_Iterator, _Container>::difference_type operator-(const __normal_iterator<_Iterator, _Container>& __lhs, const __normal_iterator<_Iterator, _Container>& __rhs) noexcept { return __lhs.base() - __rhs.base(); } template<typename _Iterator, typename _Container> inline __normal_iterator<_Iterator, _Container> operator+(typename __normal_iterator<_Iterator, _Container>::difference_type __n, const __normal_iterator<_Iterator, _Container>& __i) noexcept { return __normal_iterator<_Iterator, _Container>(__i.base() + __n); } } namespace std __attribute__ ((__visibility__ ("default"))) { template<typename _Iterator, typename _Container> _Iterator __niter_base(__gnu_cxx::__normal_iterator<_Iterator, _Container> __it) noexcept(std::is_nothrow_copy_constructible<_Iterator>::value) { return __it.base(); } template<typename _Iterator> class move_iterator { _Iterator _M_current; using __traits_type = iterator_traits<_Iterator>; using __base_ref = typename __traits_type::reference; public: using iterator_type = _Iterator; typedef typename __traits_type::iterator_category iterator_category; typedef typename __traits_type::value_type value_type; typedef typename __traits_type::difference_type difference_type; typedef _Iterator pointer; typedef typename conditional<is_reference<__base_ref>::value, typename remove_reference<__base_ref>::type&&, __base_ref>::type reference; move_iterator() : _M_current() { } explicit move_iterator(iterator_type __i) : _M_current(std::move(__i)) { } template<typename _Iter> move_iterator(const move_iterator<_Iter>& __i) : _M_current(__i.base()) { } iterator_type base() const { return _M_current; } reference operator*() const { return static_cast<reference>(*_M_current); } pointer operator->() const { return _M_current; } move_iterator& operator++() { ++_M_current; return *this; } move_iterator operator++(int) { move_iterator __tmp = *this; ++_M_current; return __tmp; } move_iterator& operator--() { --_M_current; return *this; } move_iterator operator--(int) { move_iterator __tmp = *this; --_M_current; return __tmp; } move_iterator operator+(difference_type __n) const { return move_iterator(_M_current + __n); } move_iterator& operator+=(difference_type __n) { _M_current += __n; return *this; } move_iterator operator-(difference_type __n) const { return move_iterator(_M_current - __n); } move_iterator& operator-=(difference_type __n) { _M_current -= __n; return *this; } reference operator[](difference_type __n) const { return std::move(_M_current[__n]); } }; template<typename _IteratorL, typename _IteratorR> inline bool operator==(const move_iterator<_IteratorL>& __x, const move_iterator<_IteratorR>& __y) { return __x.base() == __y.base(); } template<typename _IteratorL, typename _IteratorR> inline bool operator!=(const move_iterator<_IteratorL>& __x, const move_iterator<_IteratorR>& __y) { return !(__x == __y); } template<typename _IteratorL, typename _IteratorR> inline bool operator<(const move_iterator<_IteratorL>& __x, const move_iterator<_IteratorR>& __y) { return __x.base() < __y.base(); } template<typename _IteratorL, typename _IteratorR> inline bool operator<=(const move_iterator<_IteratorL>& __x, const move_iterator<_IteratorR>& __y) { return !(__y < __x); } template<typename _IteratorL, typename _IteratorR> inline bool operator>(const move_iterator<_IteratorL>& __x, const move_iterator<_IteratorR>& __y) { return __y < __x; } template<typename _IteratorL, typename _IteratorR> inline bool operator>=(const move_iterator<_IteratorL>& __x, const move_iterator<_IteratorR>& __y) { return !(__x < __y); } template<typename _Iterator> inline bool operator==(const move_iterator<_Iterator>& __x, const move_iterator<_Iterator>& __y) { return __x.base() == __y.base(); } template<typename _Iterator> inline bool operator!=(const move_iterator<_Iterator>& __x, const move_iterator<_Iterator>& __y) { return !(__x == __y); } template<typename _Iterator> inline bool operator<(const move_iterator<_Iterator>& __x, const move_iterator<_Iterator>& __y) { return __x.base() < __y.base(); } template<typename _Iterator> inline bool operator<=(const move_iterator<_Iterator>& __x, const move_iterator<_Iterator>& __y) { return !(__y < __x); } template<typename _Iterator> inline bool operator>(const move_iterator<_Iterator>& __x, const move_iterator<_Iterator>& __y) { return __y < __x; } template<typename _Iterator> inline bool operator>=(const move_iterator<_Iterator>& __x, const move_iterator<_Iterator>& __y) { return !(__x < __y); } template<typename _IteratorL, typename _IteratorR> inline auto operator-(const move_iterator<_IteratorL>& __x, const move_iterator<_IteratorR>& __y) -> decltype(__x.base() - __y.base()) { return __x.base() - __y.base(); } template<typename _Iterator> inline move_iterator<_Iterator> operator+(typename move_iterator<_Iterator>::difference_type __n, const move_iterator<_Iterator>& __x) { return __x + __n; } template<typename _Iterator> inline move_iterator<_Iterator> make_move_iterator(_Iterator __i) { return move_iterator<_Iterator>(std::move(__i)); } template<typename _Iterator, typename _ReturnType = typename conditional<__move_if_noexcept_cond <typename iterator_traits<_Iterator>::value_type>::value, _Iterator, move_iterator<_Iterator>>::type> inline _ReturnType __make_move_if_noexcept_iterator(_Iterator __i) { return _ReturnType(__i); } template<typename _Tp, typename _ReturnType = typename conditional<__move_if_noexcept_cond<_Tp>::value, const _Tp*, move_iterator<_Tp*>>::type> inline _ReturnType __make_move_if_noexcept_iterator(_Tp* __i) { return _ReturnType(__i); } template<typename _Iterator> auto __niter_base(move_iterator<_Iterator> __it) -> decltype(make_move_iterator(__niter_base(__it.base()))) { return make_move_iterator(__niter_base(__it.base())); } template<typename _Iterator> struct __is_move_iterator<move_iterator<_Iterator> > { enum { __value = 1 }; typedef __true_type __type; }; template<typename _Iterator> auto __miter_base(move_iterator<_Iterator> __it) -> decltype(__miter_base(__it.base())) { return __miter_base(__it.base()); } } namespace std { namespace __debug { } } namespace __gnu_debug { using namespace std::__debug; template<typename _Ite, typename _Seq, typename _Cat> struct _Safe_iterator; } namespace __gnu_cxx { namespace __ops { struct _Iter_less_iter { template<typename _Iterator1, typename _Iterator2> constexpr bool operator()(_Iterator1 __it1, _Iterator2 __it2) const { return *__it1 < *__it2; } }; constexpr inline _Iter_less_iter __iter_less_iter() { return _Iter_less_iter(); } struct _Iter_less_val { constexpr _Iter_less_val() = default; explicit _Iter_less_val(_Iter_less_iter) { } template<typename _Iterator, typename _Value> bool operator()(_Iterator __it, _Value& __val) const { return *__it < __val; } }; inline _Iter_less_val __iter_less_val() { return _Iter_less_val(); } inline _Iter_less_val __iter_comp_val(_Iter_less_iter) { return _Iter_less_val(); } struct _Val_less_iter { constexpr _Val_less_iter() = default; explicit _Val_less_iter(_Iter_less_iter) { } template<typename _Value, typename _Iterator> bool operator()(_Value& __val, _Iterator __it) const { return __val < *__it; } }; inline _Val_less_iter __val_less_iter() { return _Val_less_iter(); } inline _Val_less_iter __val_comp_iter(_Iter_less_iter) { return _Val_less_iter(); } struct _Iter_equal_to_iter { template<typename _Iterator1, typename _Iterator2> bool operator()(_Iterator1 __it1, _Iterator2 __it2) const { return *__it1 == *__it2; } }; inline _Iter_equal_to_iter __iter_equal_to_iter() { return _Iter_equal_to_iter(); } struct _Iter_equal_to_val { template<typename _Iterator, typename _Value> bool operator()(_Iterator __it, _Value& __val) const { return *__it == __val; } }; inline _Iter_equal_to_val __iter_equal_to_val() { return _Iter_equal_to_val(); } inline _Iter_equal_to_val __iter_comp_val(_Iter_equal_to_iter) { return _Iter_equal_to_val(); } template<typename _Compare> struct _Iter_comp_iter { _Compare _M_comp; explicit constexpr _Iter_comp_iter(_Compare __comp) : _M_comp(std::move(__comp)) { } template<typename _Iterator1, typename _Iterator2> constexpr bool operator()(_Iterator1 __it1, _Iterator2 __it2) { return bool(_M_comp(*__it1, *__it2)); } }; template<typename _Compare> constexpr inline _Iter_comp_iter<_Compare> __iter_comp_iter(_Compare __comp) { return _Iter_comp_iter<_Compare>(std::move(__comp)); } template<typename _Compare> struct _Iter_comp_val { _Compare _M_comp; explicit _Iter_comp_val(_Compare __comp) : _M_comp(std::move(__comp)) { } explicit _Iter_comp_val(const _Iter_comp_iter<_Compare>& __comp) : _M_comp(__comp._M_comp) { } explicit _Iter_comp_val(_Iter_comp_iter<_Compare>&& __comp) : _M_comp(std::move(__comp._M_comp)) { } template<typename _Iterator, typename _Value> bool operator()(_Iterator __it, _Value& __val) { return bool(_M_comp(*__it, __val)); } }; template<typename _Compare> inline _Iter_comp_val<_Compare> __iter_comp_val(_Compare __comp) { return _Iter_comp_val<_Compare>(std::move(__comp)); } template<typename _Compare> inline _Iter_comp_val<_Compare> __iter_comp_val(_Iter_comp_iter<_Compare> __comp) { return _Iter_comp_val<_Compare>(std::move(__comp)); } template<typename _Compare> struct _Val_comp_iter { _Compare _M_comp; explicit _Val_comp_iter(_Compare __comp) : _M_comp(std::move(__comp)) { } explicit _Val_comp_iter(const _Iter_comp_iter<_Compare>& __comp) : _M_comp(__comp._M_comp) { } explicit _Val_comp_iter(_Iter_comp_iter<_Compare>&& __comp) : _M_comp(std::move(__comp._M_comp)) { } template<typename _Value, typename _Iterator> bool operator()(_Value& __val, _Iterator __it) { return bool(_M_comp(__val, *__it)); } }; template<typename _Compare> inline _Val_comp_iter<_Compare> __val_comp_iter(_Compare __comp) { return _Val_comp_iter<_Compare>(std::move(__comp)); } template<typename _Compare> inline _Val_comp_iter<_Compare> __val_comp_iter(_Iter_comp_iter<_Compare> __comp) { return _Val_comp_iter<_Compare>(std::move(__comp)); } template<typename _Value> struct _Iter_equals_val { _Value& _M_value; explicit _Iter_equals_val(_Value& __value) : _M_value(__value) { } template<typename _Iterator> bool operator()(_Iterator __it) { return *__it == _M_value; } }; template<typename _Value> inline _Iter_equals_val<_Value> __iter_equals_val(_Value& __val) { return _Iter_equals_val<_Value>(__val); } template<typename _Iterator1> struct _Iter_equals_iter { _Iterator1 _M_it1; explicit _Iter_equals_iter(_Iterator1 __it1) : _M_it1(__it1) { } template<typename _Iterator2> bool operator()(_Iterator2 __it2) { return *__it2 == *_M_it1; } }; template<typename _Iterator> inline _Iter_equals_iter<_Iterator> __iter_comp_iter(_Iter_equal_to_iter, _Iterator __it) { return _Iter_equals_iter<_Iterator>(__it); } template<typename _Predicate> struct _Iter_pred { _Predicate _M_pred; explicit _Iter_pred(_Predicate __pred) : _M_pred(std::move(__pred)) { } template<typename _Iterator> bool operator()(_Iterator __it) { return bool(_M_pred(*__it)); } }; template<typename _Predicate> inline _Iter_pred<_Predicate> __pred_iter(_Predicate __pred) { return _Iter_pred<_Predicate>(std::move(__pred)); } template<typename _Compare, typename _Value> struct _Iter_comp_to_val { _Compare _M_comp; _Value& _M_value; _Iter_comp_to_val(_Compare __comp, _Value& __value) : _M_comp(std::move(__comp)), _M_value(__value) { } template<typename _Iterator> bool operator()(_Iterator __it) { return bool(_M_comp(*__it, _M_value)); } }; template<typename _Compare, typename _Value> _Iter_comp_to_val<_Compare, _Value> __iter_comp_val(_Compare __comp, _Value &__val) { return _Iter_comp_to_val<_Compare, _Value>(std::move(__comp), __val); } template<typename _Compare, typename _Iterator1> struct _Iter_comp_to_iter { _Compare _M_comp; _Iterator1 _M_it1; _Iter_comp_to_iter(_Compare __comp, _Iterator1 __it1) : _M_comp(std::move(__comp)), _M_it1(__it1) { } template<typename _Iterator2> bool operator()(_Iterator2 __it2) { return bool(_M_comp(*__it2, *_M_it1)); } }; template<typename _Compare, typename _Iterator> inline _Iter_comp_to_iter<_Compare, _Iterator> __iter_comp_iter(_Iter_comp_iter<_Compare> __comp, _Iterator __it) { return _Iter_comp_to_iter<_Compare, _Iterator>( std::move(__comp._M_comp), __it); } template<typename _Predicate> struct _Iter_negate { _Predicate _M_pred; explicit _Iter_negate(_Predicate __pred) : _M_pred(std::move(__pred)) { } template<typename _Iterator> bool operator()(_Iterator __it) { return !bool(_M_pred(*__it)); } }; template<typename _Predicate> inline _Iter_negate<_Predicate> __negate(_Iter_pred<_Predicate> __pred) { return _Iter_negate<_Predicate>(std::move(__pred._M_pred)); } } } namespace std __attribute__ ((__visibility__ ("default"))) { template<typename _Tp, typename _Up> constexpr inline int __memcmp(const _Tp* __first1, const _Up* __first2, size_t __num) { static_assert(sizeof(_Tp) == sizeof(_Up), "can be compared with memcmp"); return __builtin_memcmp(__first1, __first2, sizeof(_Tp) * __num); } template<typename _ForwardIterator1, typename _ForwardIterator2> inline void iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b) { swap(*__a, *__b); } template<typename _ForwardIterator1, typename _ForwardIterator2> _ForwardIterator2 swap_ranges(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2) { ; for (; __first1 != __last1; ++__first1, (void)++__first2) std::iter_swap(__first1, __first2); return __first2; } template<typename _Tp> constexpr inline const _Tp& min(const _Tp& __a, const _Tp& __b) { if (__b < __a) return __b; return __a; } template<typename _Tp> constexpr inline const _Tp& max(const _Tp& __a, const _Tp& __b) { if (__a < __b) return __b; return __a; } template<typename _Tp, typename _Compare> constexpr inline const _Tp& min(const _Tp& __a, const _Tp& __b, _Compare __comp) { if (__comp(__b, __a)) return __b; return __a; } template<typename _Tp, typename _Compare> constexpr inline const _Tp& max(const _Tp& __a, const _Tp& __b, _Compare __comp) { if (__comp(__a, __b)) return __b; return __a; } template<typename _Iterator> inline _Iterator __niter_base(_Iterator __it) noexcept(std::is_nothrow_copy_constructible<_Iterator>::value) { return __it; } template<typename _From, typename _To> inline _From __niter_wrap(_From __from, _To __res) { return __from + (__res - std::__niter_base(__from)); } template<typename _Iterator> inline _Iterator __niter_wrap(const _Iterator&, _Iterator __res) { return __res; } template<bool _IsMove, bool _IsSimple, typename _Category> struct __copy_move { template<typename _II, typename _OI> static _OI __copy_m(_II __first, _II __last, _OI __result) { for (; __first != __last; ++__result, (void)++__first) *__result = *__first; return __result; } }; template<typename _Category> struct __copy_move<true, false, _Category> { template<typename _II, typename _OI> static _OI __copy_m(_II __first, _II __last, _OI __result) { for (; __first != __last; ++__result, (void)++__first) *__result = std::move(*__first); return __result; } }; template<> struct __copy_move<false, false, random_access_iterator_tag> { template<typename _II, typename _OI> static _OI __copy_m(_II __first, _II __last, _OI __result) { typedef typename iterator_traits<_II>::difference_type _Distance; for(_Distance __n = __last - __first; __n > 0; --__n) { *__result = *__first; ++__first; ++__result; } return __result; } }; template<> struct __copy_move<true, false, random_access_iterator_tag> { template<typename _II, typename _OI> static _OI __copy_m(_II __first, _II __last, _OI __result) { typedef typename iterator_traits<_II>::difference_type _Distance; for(_Distance __n = __last - __first; __n > 0; --__n) { *__result = std::move(*__first); ++__first; ++__result; } return __result; } }; template<bool _IsMove> struct __copy_move<_IsMove, true, random_access_iterator_tag> { template<typename _Tp> static _Tp* __copy_m(const _Tp* __first, const _Tp* __last, _Tp* __result) { using __assignable = conditional<_IsMove, is_move_assignable<_Tp>, is_copy_assignable<_Tp>>; static_assert( __assignable::type::value, "type is not assignable" ); const ptrdiff_t _Num = __last - __first; if (_Num) __builtin_memmove(__result, __first, sizeof(_Tp) * _Num); return __result + _Num; } }; template<typename _CharT> struct char_traits; template<typename _CharT, typename _Traits> class istreambuf_iterator; template<typename _CharT, typename _Traits> class ostreambuf_iterator; template<bool _IsMove, typename _CharT> typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value, ostreambuf_iterator<_CharT, char_traits<_CharT> > >::__type __copy_move_a2(_CharT*, _CharT*, ostreambuf_iterator<_CharT, char_traits<_CharT> >); template<bool _IsMove, typename _CharT> typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value, ostreambuf_iterator<_CharT, char_traits<_CharT> > >::__type __copy_move_a2(const _CharT*, const _CharT*, ostreambuf_iterator<_CharT, char_traits<_CharT> >); template<bool _IsMove, typename _CharT> typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value, _CharT*>::__type __copy_move_a2(istreambuf_iterator<_CharT, char_traits<_CharT> >, istreambuf_iterator<_CharT, char_traits<_CharT> >, _CharT*); template<bool _IsMove, typename _II, typename _OI> inline _OI __copy_move_a2(_II __first, _II __last, _OI __result) { typedef typename iterator_traits<_II>::iterator_category _Category; return std::__copy_move<_IsMove, __memcpyable<_OI, _II>::__value, _Category>::__copy_m(__first, __last, __result); } template<typename _Tp, typename _Ref, typename _Ptr> struct _Deque_iterator; template<bool _IsMove, typename _Tp, typename _Ref, typename _Ptr, typename _OI> _OI __copy_move_a1(std::_Deque_iterator<_Tp, _Ref, _Ptr>, std::_Deque_iterator<_Tp, _Ref, _Ptr>, _OI); template<bool _IsMove, typename _ITp, typename _IRef, typename _IPtr, typename _OTp> std::_Deque_iterator<_OTp, _OTp&, _OTp*> __copy_move_a1(std::_Deque_iterator<_ITp, _IRef, _IPtr>, std::_Deque_iterator<_ITp, _IRef, _IPtr>, std::_Deque_iterator<_OTp, _OTp&, _OTp*>); template<bool _IsMove, typename _II, typename _Tp> typename __gnu_cxx::__enable_if< __is_random_access_iter<_II>::__value, std::_Deque_iterator<_Tp, _Tp&, _Tp*> >::__type __copy_move_a1(_II, _II, std::_Deque_iterator<_Tp, _Tp&, _Tp*>); template<bool _IsMove, typename _II, typename _OI> inline _OI __copy_move_a1(_II __first, _II __last, _OI __result) { return std::__copy_move_a2<_IsMove>(__first, __last, __result); } template<bool _IsMove, typename _II, typename _OI> inline _OI __copy_move_a(_II __first, _II __last, _OI __result) { return std::__niter_wrap(__result, std::__copy_move_a1<_IsMove>(std::__niter_base(__first), std::__niter_base(__last), std::__niter_base(__result))); } template<bool _IsMove, typename _Ite, typename _Seq, typename _Cat, typename _OI> _OI __copy_move_a(const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>&, const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>&, _OI); template<bool _IsMove, typename _II, typename _Ite, typename _Seq, typename _Cat> __gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat> __copy_move_a(_II, _II, const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>&); template<bool _IsMove, typename _IIte, typename _ISeq, typename _ICat, typename _OIte, typename _OSeq, typename _OCat> ::__gnu_debug::_Safe_iterator<_OIte, _OSeq, _OCat> __copy_move_a(const ::__gnu_debug::_Safe_iterator<_IIte, _ISeq, _ICat>&, const ::__gnu_debug::_Safe_iterator<_IIte, _ISeq, _ICat>&, const ::__gnu_debug::_Safe_iterator<_OIte, _OSeq, _OCat>&); template<typename _II, typename _OI> inline _OI copy(_II __first, _II __last, _OI __result) { ; return std::__copy_move_a<__is_move_iterator<_II>::__value> (std::__miter_base(__first), std::__miter_base(__last), __result); } template<typename _II, typename _OI> inline _OI move(_II __first, _II __last, _OI __result) { ; return std::__copy_move_a<true>(std::__miter_base(__first), std::__miter_base(__last), __result); } template<bool _IsMove, bool _IsSimple, typename _Category> struct __copy_move_backward { template<typename _BI1, typename _BI2> static _BI2 __copy_move_b(_BI1 __first, _BI1 __last, _BI2 __result) { while (__first != __last) *--__result = *--__last; return __result; } }; template<typename _Category> struct __copy_move_backward<true, false, _Category> { template<typename _BI1, typename _BI2> static _BI2 __copy_move_b(_BI1 __first, _BI1 __last, _BI2 __result) { while (__first != __last) *--__result = std::move(*--__last); return __result; } }; template<> struct __copy_move_backward<false, false, random_access_iterator_tag> { template<typename _BI1, typename _BI2> static _BI2 __copy_move_b(_BI1 __first, _BI1 __last, _BI2 __result) { typename iterator_traits<_BI1>::difference_type __n = __last - __first; for (; __n > 0; --__n) *--__result = *--__last; return __result; } }; template<> struct __copy_move_backward<true, false, random_access_iterator_tag> { template<typename _BI1, typename _BI2> static _BI2 __copy_move_b(_BI1 __first, _BI1 __last, _BI2 __result) { typename iterator_traits<_BI1>::difference_type __n = __last - __first; for (; __n > 0; --__n) *--__result = std::move(*--__last); return __result; } }; template<bool _IsMove> struct __copy_move_backward<_IsMove, true, random_access_iterator_tag> { template<typename _Tp> static _Tp* __copy_move_b(const _Tp* __first, const _Tp* __last, _Tp* __result) { using __assignable = conditional<_IsMove, is_move_assignable<_Tp>, is_copy_assignable<_Tp>>; static_assert( __assignable::type::value, "type is not assignable" ); const ptrdiff_t _Num = __last - __first; if (_Num) __builtin_memmove(__result - _Num, __first, sizeof(_Tp) * _Num); return __result - _Num; } }; template<bool _IsMove, typename _BI1, typename _BI2> inline _BI2 __copy_move_backward_a2(_BI1 __first, _BI1 __last, _BI2 __result) { typedef typename iterator_traits<_BI1>::iterator_category _Category; return std::__copy_move_backward<_IsMove, __memcpyable<_BI2, _BI1>::__value, _Category>::__copy_move_b(__first, __last, __result); } template<bool _IsMove, typename _BI1, typename _BI2> inline _BI2 __copy_move_backward_a1(_BI1 __first, _BI1 __last, _BI2 __result) { return std::__copy_move_backward_a2<_IsMove>(__first, __last, __result); } template<bool _IsMove, typename _Tp, typename _Ref, typename _Ptr, typename _OI> _OI __copy_move_backward_a1(std::_Deque_iterator<_Tp, _Ref, _Ptr>, std::_Deque_iterator<_Tp, _Ref, _Ptr>, _OI); template<bool _IsMove, typename _ITp, typename _IRef, typename _IPtr, typename _OTp> std::_Deque_iterator<_OTp, _OTp&, _OTp*> __copy_move_backward_a1( std::_Deque_iterator<_ITp, _IRef, _IPtr>, std::_Deque_iterator<_ITp, _IRef, _IPtr>, std::_Deque_iterator<_OTp, _OTp&, _OTp*>); template<bool _IsMove, typename _II, typename _Tp> typename __gnu_cxx::__enable_if< __is_random_access_iter<_II>::__value, std::_Deque_iterator<_Tp, _Tp&, _Tp*> >::__type __copy_move_backward_a1(_II, _II, std::_Deque_iterator<_Tp, _Tp&, _Tp*>); template<bool _IsMove, typename _II, typename _OI> inline _OI __copy_move_backward_a(_II __first, _II __last, _OI __result) { return std::__niter_wrap(__result, std::__copy_move_backward_a1<_IsMove> (std::__niter_base(__first), std::__niter_base(__last), std::__niter_base(__result))); } template<bool _IsMove, typename _Ite, typename _Seq, typename _Cat, typename _OI> _OI __copy_move_backward_a( const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>&, const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>&, _OI); template<bool _IsMove, typename _II, typename _Ite, typename _Seq, typename _Cat> __gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat> __copy_move_backward_a(_II, _II, const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>&); template<bool _IsMove, typename _IIte, typename _ISeq, typename _ICat, typename _OIte, typename _OSeq, typename _OCat> ::__gnu_debug::_Safe_iterator<_OIte, _OSeq, _OCat> __copy_move_backward_a( const ::__gnu_debug::_Safe_iterator<_IIte, _ISeq, _ICat>&, const ::__gnu_debug::_Safe_iterator<_IIte, _ISeq, _ICat>&, const ::__gnu_debug::_Safe_iterator<_OIte, _OSeq, _OCat>&); template<typename _BI1, typename _BI2> inline _BI2 copy_backward(_BI1 __first, _BI1 __last, _BI2 __result) { ; return std::__copy_move_backward_a<__is_move_iterator<_BI1>::__value> (std::__miter_base(__first), std::__miter_base(__last), __result); } template<typename _BI1, typename _BI2> inline _BI2 move_backward(_BI1 __first, _BI1 __last, _BI2 __result) { ; return std::__copy_move_backward_a<true>(std::__miter_base(__first), std::__miter_base(__last), __result); } template<typename _ForwardIterator, typename _Tp> inline typename __gnu_cxx::__enable_if<!__is_scalar<_Tp>::__value, void>::__type __fill_a1(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) { for (; __first != __last; ++__first) *__first = __value; } template<typename _ForwardIterator, typename _Tp> inline typename __gnu_cxx::__enable_if<__is_scalar<_Tp>::__value, void>::__type __fill_a1(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) { const _Tp __tmp = __value; for (; __first != __last; ++__first) *__first = __tmp; } template<typename _Tp> inline typename __gnu_cxx::__enable_if<__is_byte<_Tp>::__value, void>::__type __fill_a1(_Tp* __first, _Tp* __last, const _Tp& __c) { const _Tp __tmp = __c; if (const size_t __len = __last - __first) __builtin_memset(__first, static_cast<unsigned char>(__tmp), __len); } template<typename _Ite, typename _Cont, typename _Tp> inline void __fill_a1(::__gnu_cxx::__normal_iterator<_Ite, _Cont> __first, ::__gnu_cxx::__normal_iterator<_Ite, _Cont> __last, const _Tp& __value) { std::__fill_a1(__first.base(), __last.base(), __value); } template<typename _Tp, typename _VTp> void __fill_a1(const std::_Deque_iterator<_Tp, _Tp&, _Tp*>&, const std::_Deque_iterator<_Tp, _Tp&, _Tp*>&, const _VTp&); template<typename _FIte, typename _Tp> inline void __fill_a(_FIte __first, _FIte __last, const _Tp& __value) { std::__fill_a1(__first, __last, __value); } template<typename _Ite, typename _Seq, typename _Cat, typename _Tp> void __fill_a(const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>&, const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>&, const _Tp&); template<typename _ForwardIterator, typename _Tp> inline void fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) { ; std::__fill_a(__first, __last, __value); } inline constexpr int __size_to_integer(int __n) { return __n; } inline constexpr unsigned __size_to_integer(unsigned __n) { return __n; } inline constexpr long __size_to_integer(long __n) { return __n; } inline constexpr unsigned long __size_to_integer(unsigned long __n) { return __n; } inline constexpr long long __size_to_integer(long long __n) { return __n; } inline constexpr unsigned long long __size_to_integer(unsigned long long __n) { return __n; } inline constexpr __int128 __size_to_integer(__int128 __n) { return __n; } inline constexpr unsigned __int128 __size_to_integer(unsigned __int128 __n) { return __n; } inline constexpr long long __size_to_integer(float __n) { return __n; } inline constexpr long long __size_to_integer(double __n) { return __n; } inline constexpr long long __size_to_integer(long double __n) { return __n; } inline constexpr long long __size_to_integer(__float128 __n) { return __n; } template<typename _OutputIterator, typename _Size, typename _Tp> inline typename __gnu_cxx::__enable_if<!__is_scalar<_Tp>::__value, _OutputIterator>::__type __fill_n_a1(_OutputIterator __first, _Size __n, const _Tp& __value) { for (; __n > 0; --__n, (void) ++__first) *__first = __value; return __first; } template<typename _OutputIterator, typename _Size, typename _Tp> inline typename __gnu_cxx::__enable_if<__is_scalar<_Tp>::__value, _OutputIterator>::__type __fill_n_a1(_OutputIterator __first, _Size __n, const _Tp& __value) { const _Tp __tmp = __value; for (; __n > 0; --__n, (void) ++__first) *__first = __tmp; return __first; } template<typename _Ite, typename _Seq, typename _Cat, typename _Size, typename _Tp> ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat> __fill_n_a(const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>& __first, _Size __n, const _Tp& __value, std::input_iterator_tag); template<typename _OutputIterator, typename _Size, typename _Tp> inline _OutputIterator __fill_n_a(_OutputIterator __first, _Size __n, const _Tp& __value, std::output_iterator_tag) { static_assert(is_integral<_Size>{}, "fill_n must pass integral size"); return __fill_n_a1(__first, __n, __value); } template<typename _OutputIterator, typename _Size, typename _Tp> inline _OutputIterator __fill_n_a(_OutputIterator __first, _Size __n, const _Tp& __value, std::input_iterator_tag) { static_assert(is_integral<_Size>{}, "fill_n must pass integral size"); return __fill_n_a1(__first, __n, __value); } template<typename _OutputIterator, typename _Size, typename _Tp> inline _OutputIterator __fill_n_a(_OutputIterator __first, _Size __n, const _Tp& __value, std::random_access_iterator_tag) { static_assert(is_integral<_Size>{}, "fill_n must pass integral size"); if (__n <= 0) return __first; ; std::__fill_a(__first, __first + __n, __value); return __first + __n; } template<typename _OI, typename _Size, typename _Tp> inline _OI fill_n(_OI __first, _Size __n, const _Tp& __value) { return std::__fill_n_a(__first, std::__size_to_integer(__n), __value, std::__iterator_category(__first)); } template<bool _BoolType> struct __equal { template<typename _II1, typename _II2> static bool equal(_II1 __first1, _II1 __last1, _II2 __first2) { for (; __first1 != __last1; ++__first1, (void) ++__first2) if (!(*__first1 == *__first2)) return false; return true; } }; template<> struct __equal<true> { template<typename _Tp> static bool equal(const _Tp* __first1, const _Tp* __last1, const _Tp* __first2) { if (const size_t __len = (__last1 - __first1)) return !std::__memcmp(__first1, __first2, __len); return true; } }; template<typename _Tp, typename _Ref, typename _Ptr, typename _II> typename __gnu_cxx::__enable_if< __is_random_access_iter<_II>::__value, bool>::__type __equal_aux1(std::_Deque_iterator<_Tp, _Ref, _Ptr>, std::_Deque_iterator<_Tp, _Ref, _Ptr>, _II); template<typename _Tp1, typename _Ref1, typename _Ptr1, typename _Tp2, typename _Ref2, typename _Ptr2> bool __equal_aux1(std::_Deque_iterator<_Tp1, _Ref1, _Ptr1>, std::_Deque_iterator<_Tp1, _Ref1, _Ptr1>, std::_Deque_iterator<_Tp2, _Ref2, _Ptr2>); template<typename _II, typename _Tp, typename _Ref, typename _Ptr> typename __gnu_cxx::__enable_if< __is_random_access_iter<_II>::__value, bool>::__type __equal_aux1(_II, _II, std::_Deque_iterator<_Tp, _Ref, _Ptr>); template<typename _II1, typename _II2> inline bool __equal_aux1(_II1 __first1, _II1 __last1, _II2 __first2) { typedef typename iterator_traits<_II1>::value_type _ValueType1; const bool __simple = ((__is_integer<_ValueType1>::__value || __is_pointer<_ValueType1>::__value) && __memcmpable<_II1, _II2>::__value); return std::__equal<__simple>::equal(__first1, __last1, __first2); } template<typename _II1, typename _II2> inline bool __equal_aux(_II1 __first1, _II1 __last1, _II2 __first2) { return std::__equal_aux1(std::__niter_base(__first1), std::__niter_base(__last1), std::__niter_base(__first2)); } template<typename _II1, typename _Seq1, typename _Cat1, typename _II2> bool __equal_aux(const ::__gnu_debug::_Safe_iterator<_II1, _Seq1, _Cat1>&, const ::__gnu_debug::_Safe_iterator<_II1, _Seq1, _Cat1>&, _II2); template<typename _II1, typename _II2, typename _Seq2, typename _Cat2> bool __equal_aux(_II1, _II1, const ::__gnu_debug::_Safe_iterator<_II2, _Seq2, _Cat2>&); template<typename _II1, typename _Seq1, typename _Cat1, typename _II2, typename _Seq2, typename _Cat2> bool __equal_aux(const ::__gnu_debug::_Safe_iterator<_II1, _Seq1, _Cat1>&, const ::__gnu_debug::_Safe_iterator<_II1, _Seq1, _Cat1>&, const ::__gnu_debug::_Safe_iterator<_II2, _Seq2, _Cat2>&); template<typename, typename> struct __lc_rai { template<typename _II1, typename _II2> static _II1 __newlast1(_II1, _II1 __last1, _II2, _II2) { return __last1; } template<typename _II> static bool __cnd2(_II __first, _II __last) { return __first != __last; } }; template<> struct __lc_rai<random_access_iterator_tag, random_access_iterator_tag> { template<typename _RAI1, typename _RAI2> static _RAI1 __newlast1(_RAI1 __first1, _RAI1 __last1, _RAI2 __first2, _RAI2 __last2) { const typename iterator_traits<_RAI1>::difference_type __diff1 = __last1 - __first1; const typename iterator_traits<_RAI2>::difference_type __diff2 = __last2 - __first2; return __diff2 < __diff1 ? __first1 + __diff2 : __last1; } template<typename _RAI> static bool __cnd2(_RAI, _RAI) { return true; } }; template<typename _II1, typename _II2, typename _Compare> bool __lexicographical_compare_impl(_II1 __first1, _II1 __last1, _II2 __first2, _II2 __last2, _Compare __comp) { typedef typename iterator_traits<_II1>::iterator_category _Category1; typedef typename iterator_traits<_II2>::iterator_category _Category2; typedef std::__lc_rai<_Category1, _Category2> __rai_type; __last1 = __rai_type::__newlast1(__first1, __last1, __first2, __last2); for (; __first1 != __last1 && __rai_type::__cnd2(__first2, __last2); ++__first1, (void)++__first2) { if (__comp(__first1, __first2)) return true; if (__comp(__first2, __first1)) return false; } return __first1 == __last1 && __first2 != __last2; } template<bool _BoolType> struct __lexicographical_compare { template<typename _II1, typename _II2> static bool __lc(_II1 __first1, _II1 __last1, _II2 __first2, _II2 __last2) { using __gnu_cxx::__ops::__iter_less_iter; return std::__lexicographical_compare_impl(__first1, __last1, __first2, __last2, __iter_less_iter()); } }; template<> struct __lexicographical_compare<true> { template<typename _Tp, typename _Up> static bool __lc(const _Tp* __first1, const _Tp* __last1, const _Up* __first2, const _Up* __last2) { const size_t __len1 = __last1 - __first1; const size_t __len2 = __last2 - __first2; if (const size_t __len = std::min(__len1, __len2)) if (int __result = std::__memcmp(__first1, __first2, __len)) return __result < 0; return __len1 < __len2; } }; template<typename _II1, typename _II2> inline bool __lexicographical_compare_aux(_II1 __first1, _II1 __last1, _II2 __first2, _II2 __last2) { typedef typename iterator_traits<_II1>::value_type _ValueType1; typedef typename iterator_traits<_II2>::value_type _ValueType2; const bool __simple = (__is_byte<_ValueType1>::__value && __is_byte<_ValueType2>::__value && !__gnu_cxx::__numeric_traits<_ValueType1>::__is_signed && !__gnu_cxx::__numeric_traits<_ValueType2>::__is_signed && __is_pointer<_II1>::__value && __is_pointer<_II2>::__value ); return std::__lexicographical_compare<__simple>::__lc(__first1, __last1, __first2, __last2); } template<typename _ForwardIterator, typename _Tp, typename _Compare> _ForwardIterator __lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __val, _Compare __comp) { typedef typename iterator_traits<_ForwardIterator>::difference_type _DistanceType; _DistanceType __len = std::distance(__first, __last); while (__len > 0) { _DistanceType __half = __len >> 1; _ForwardIterator __middle = __first; std::advance(__middle, __half); if (__comp(__middle, __val)) { __first = __middle; ++__first; __len = __len - __half - 1; } else __len = __half; } return __first; } template<typename _ForwardIterator, typename _Tp> inline _ForwardIterator lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __val) { ; return std::__lower_bound(__first, __last, __val, __gnu_cxx::__ops::__iter_less_val()); } inline constexpr int __lg(int __n) { return (int)sizeof(int) * 8 - 1 - __builtin_clz(__n); } inline constexpr unsigned __lg(unsigned __n) { return (int)sizeof(int) * 8 - 1 - __builtin_clz(__n); } inline constexpr long __lg(long __n) { return (int)sizeof(long) * 8 - 1 - __builtin_clzl(__n); } inline constexpr unsigned long __lg(unsigned long __n) { return (int)sizeof(long) * 8 - 1 - __builtin_clzl(__n); } inline constexpr long long __lg(long long __n) { return (int)sizeof(long long) * 8 - 1 - __builtin_clzll(__n); } inline constexpr unsigned long long __lg(unsigned long long __n) { return (int)sizeof(long long) * 8 - 1 - __builtin_clzll(__n); } template<typename _II1, typename _II2> inline bool equal(_II1 __first1, _II1 __last1, _II2 __first2) { ; return std::__equal_aux(__first1, __last1, __first2); } template<typename _IIter1, typename _IIter2, typename _BinaryPredicate> inline bool equal(_IIter1 __first1, _IIter1 __last1, _IIter2 __first2, _BinaryPredicate __binary_pred) { ; for (; __first1 != __last1; ++__first1, (void)++__first2) if (!bool(__binary_pred(*__first1, *__first2))) return false; return true; } template<typename _II1, typename _II2> inline bool __equal4(_II1 __first1, _II1 __last1, _II2 __first2, _II2 __last2) { using _RATag = random_access_iterator_tag; using _Cat1 = typename iterator_traits<_II1>::iterator_category; using _Cat2 = typename iterator_traits<_II2>::iterator_category; using _RAIters = __and_<is_same<_Cat1, _RATag>, is_same<_Cat2, _RATag>>; if (_RAIters()) { auto __d1 = std::distance(__first1, __last1); auto __d2 = std::distance(__first2, __last2); if (__d1 != __d2) return false; return std::equal(__first1, __last1, __first2); } for (; __first1 != __last1 && __first2 != __last2; ++__first1, (void)++__first2) if (!(*__first1 == *__first2)) return false; return __first1 == __last1 && __first2 == __last2; } template<typename _II1, typename _II2, typename _BinaryPredicate> inline bool __equal4(_II1 __first1, _II1 __last1, _II2 __first2, _II2 __last2, _BinaryPredicate __binary_pred) { using _RATag = random_access_iterator_tag; using _Cat1 = typename iterator_traits<_II1>::iterator_category; using _Cat2 = typename iterator_traits<_II2>::iterator_category; using _RAIters = __and_<is_same<_Cat1, _RATag>, is_same<_Cat2, _RATag>>; if (_RAIters()) { auto __d1 = std::distance(__first1, __last1); auto __d2 = std::distance(__first2, __last2); if (__d1 != __d2) return false; return std::equal(__first1, __last1, __first2, __binary_pred); } for (; __first1 != __last1 && __first2 != __last2; ++__first1, (void)++__first2) if (!bool(__binary_pred(*__first1, *__first2))) return false; return __first1 == __last1 && __first2 == __last2; } template<typename _II1, typename _II2> inline bool equal(_II1 __first1, _II1 __last1, _II2 __first2, _II2 __last2) { ; ; return std::__equal4(__first1, __last1, __first2, __last2); } template<typename _IIter1, typename _IIter2, typename _BinaryPredicate> inline bool equal(_IIter1 __first1, _IIter1 __last1, _IIter2 __first2, _IIter2 __last2, _BinaryPredicate __binary_pred) { ; ; return std::__equal4(__first1, __last1, __first2, __last2, __binary_pred); } template<typename _II1, typename _II2> inline bool lexicographical_compare(_II1 __first1, _II1 __last1, _II2 __first2, _II2 __last2) { ; ; return std::__lexicographical_compare_aux(std::__niter_base(__first1), std::__niter_base(__last1), std::__niter_base(__first2), std::__niter_base(__last2)); } template<typename _II1, typename _II2, typename _Compare> inline bool lexicographical_compare(_II1 __first1, _II1 __last1, _II2 __first2, _II2 __last2, _Compare __comp) { ; ; return std::__lexicographical_compare_impl (__first1, __last1, __first2, __last2, __gnu_cxx::__ops::__iter_comp_iter(__comp)); } template<typename _InputIterator1, typename _InputIterator2, typename _BinaryPredicate> pair<_InputIterator1, _InputIterator2> __mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate __binary_pred) { while (__first1 != __last1 && __binary_pred(__first1, __first2)) { ++__first1; ++__first2; } return pair<_InputIterator1, _InputIterator2>(__first1, __first2); } template<typename _InputIterator1, typename _InputIterator2> inline pair<_InputIterator1, _InputIterator2> mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2) { ; return std::__mismatch(__first1, __last1, __first2, __gnu_cxx::__ops::__iter_equal_to_iter()); } template<typename _InputIterator1, typename _InputIterator2, typename _BinaryPredicate> inline pair<_InputIterator1, _InputIterator2> mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate __binary_pred) { ; return std::__mismatch(__first1, __last1, __first2, __gnu_cxx::__ops::__iter_comp_iter(__binary_pred)); } template<typename _InputIterator1, typename _InputIterator2, typename _BinaryPredicate> pair<_InputIterator1, _InputIterator2> __mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _BinaryPredicate __binary_pred) { while (__first1 != __last1 && __first2 != __last2 && __binary_pred(__first1, __first2)) { ++__first1; ++__first2; } return pair<_InputIterator1, _InputIterator2>(__first1, __first2); } template<typename _InputIterator1, typename _InputIterator2> inline pair<_InputIterator1, _InputIterator2> mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) { ; ; return std::__mismatch(__first1, __last1, __first2, __last2, __gnu_cxx::__ops::__iter_equal_to_iter()); } template<typename _InputIterator1, typename _InputIterator2, typename _BinaryPredicate> inline pair<_InputIterator1, _InputIterator2> mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _BinaryPredicate __binary_pred) { ; ; return std::__mismatch(__first1, __last1, __first2, __last2, __gnu_cxx::__ops::__iter_comp_iter(__binary_pred)); } template<typename _InputIterator, typename _Predicate> inline _InputIterator __find_if(_InputIterator __first, _InputIterator __last, _Predicate __pred, input_iterator_tag) { while (__first != __last && !__pred(__first)) ++__first; return __first; } template<typename _RandomAccessIterator, typename _Predicate> _RandomAccessIterator __find_if(_RandomAccessIterator __first, _RandomAccessIterator __last, _Predicate __pred, random_access_iterator_tag) { typename iterator_traits<_RandomAccessIterator>::difference_type __trip_count = (__last - __first) >> 2; for (; __trip_count > 0; --__trip_count) { if (__pred(__first)) return __first; ++__first; if (__pred(__first)) return __first; ++__first; if (__pred(__first)) return __first; ++__first; if (__pred(__first)) return __first; ++__first; } switch (__last - __first) { case 3: if (__pred(__first)) return __first; ++__first; case 2: if (__pred(__first)) return __first; ++__first; case 1: if (__pred(__first)) return __first; ++__first; case 0: default: return __last; } } template<typename _Iterator, typename _Predicate> inline _Iterator __find_if(_Iterator __first, _Iterator __last, _Predicate __pred) { return __find_if(__first, __last, __pred, std::__iterator_category(__first)); } template<typename _InputIterator, typename _Predicate> typename iterator_traits<_InputIterator>::difference_type __count_if(_InputIterator __first, _InputIterator __last, _Predicate __pred) { typename iterator_traits<_InputIterator>::difference_type __n = 0; for (; __first != __last; ++__first) if (__pred(__first)) ++__n; return __n; } template<typename _ForwardIterator1, typename _ForwardIterator2, typename _BinaryPredicate> bool __is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _BinaryPredicate __pred) { for (; __first1 != __last1; ++__first1, (void)++__first2) if (!__pred(__first1, __first2)) break; if (__first1 == __last1) return true; _ForwardIterator2 __last2 = __first2; std::advance(__last2, std::distance(__first1, __last1)); for (_ForwardIterator1 __scan = __first1; __scan != __last1; ++__scan) { if (__scan != std::__find_if(__first1, __scan, __gnu_cxx::__ops::__iter_comp_iter(__pred, __scan))) continue; auto __matches = std::__count_if(__first2, __last2, __gnu_cxx::__ops::__iter_comp_iter(__pred, __scan)); if (0 == __matches || std::__count_if(__scan, __last1, __gnu_cxx::__ops::__iter_comp_iter(__pred, __scan)) != __matches) return false; } return true; } template<typename _ForwardIterator1, typename _ForwardIterator2> inline bool is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2) { ; return std::__is_permutation(__first1, __last1, __first2, __gnu_cxx::__ops::__iter_equal_to_iter()); } } typedef _Complex float __cfloat128 __attribute__ ((__mode__ (__TC__))); typedef __float128 _Float128; typedef float _Float32; typedef double _Float64; typedef double _Float32x; typedef long double _Float64x; typedef __builtin_va_list __gnuc_va_list; typedef unsigned int wint_t; typedef struct { int __count; union { unsigned int __wch; char __wchb[4]; } __value; } __mbstate_t; typedef __mbstate_t mbstate_t; struct _IO_FILE; typedef struct _IO_FILE __FILE; struct _IO_FILE; typedef struct _IO_FILE FILE; struct __locale_struct { struct __locale_data *__locales[13]; const unsigned short int *__ctype_b; const int *__ctype_tolower; const int *__ctype_toupper; const char *__names[13]; }; typedef struct __locale_struct *__locale_t; typedef __locale_t locale_t; extern "C" { struct tm; extern wchar_t *wcscpy (wchar_t *__restrict __dest, const wchar_t *__restrict __src) throw () __attribute__ ((__nonnull__ (1, 2))); extern wchar_t *wcsncpy (wchar_t *__restrict __dest, const wchar_t *__restrict __src, size_t __n) throw () __attribute__ ((__nonnull__ (1, 2))); extern wchar_t *wcscat (wchar_t *__restrict __dest, const wchar_t *__restrict __src) throw () __attribute__ ((__nonnull__ (1, 2))); extern wchar_t *wcsncat (wchar_t *__restrict __dest, const wchar_t *__restrict __src, size_t __n) throw () __attribute__ ((__nonnull__ (1, 2))); extern int wcscmp (const wchar_t *__s1, const wchar_t *__s2) throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); extern int wcsncmp (const wchar_t *__s1, const wchar_t *__s2, size_t __n) throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); extern int wcscasecmp (const wchar_t *__s1, const wchar_t *__s2) throw (); extern int wcsncasecmp (const wchar_t *__s1, const wchar_t *__s2, size_t __n) throw (); extern int wcscasecmp_l (const wchar_t *__s1, const wchar_t *__s2, locale_t __loc) throw (); extern int wcsncasecmp_l (const wchar_t *__s1, const wchar_t *__s2, size_t __n, locale_t __loc) throw (); extern int wcscoll (const wchar_t *__s1, const wchar_t *__s2) throw (); extern size_t wcsxfrm (wchar_t *__restrict __s1, const wchar_t *__restrict __s2, size_t __n) throw (); extern int wcscoll_l (const wchar_t *__s1, const wchar_t *__s2, locale_t __loc) throw (); extern size_t wcsxfrm_l (wchar_t *__s1, const wchar_t *__s2, size_t __n, locale_t __loc) throw (); extern wchar_t *wcsdup (const wchar_t *__s) throw () __attribute__ ((__malloc__)); extern "C++" wchar_t *wcschr (wchar_t *__wcs, wchar_t __wc) throw () __asm ("wcschr") __attribute__ ((__pure__)); extern "C++" const wchar_t *wcschr (const wchar_t *__wcs, wchar_t __wc) throw () __asm ("wcschr") __attribute__ ((__pure__)); extern "C++" wchar_t *wcsrchr (wchar_t *__wcs, wchar_t __wc) throw () __asm ("wcsrchr") __attribute__ ((__pure__)); extern "C++" const wchar_t *wcsrchr (const wchar_t *__wcs, wchar_t __wc) throw () __asm ("wcsrchr") __attribute__ ((__pure__)); extern wchar_t *wcschrnul (const wchar_t *__s, wchar_t __wc) throw () __attribute__ ((__pure__)); extern size_t wcscspn (const wchar_t *__wcs, const wchar_t *__reject) throw () __attribute__ ((__pure__)); extern size_t wcsspn (const wchar_t *__wcs, const wchar_t *__accept) throw () __attribute__ ((__pure__)); extern "C++" wchar_t *wcspbrk (wchar_t *__wcs, const wchar_t *__accept) throw () __asm ("wcspbrk") __attribute__ ((__pure__)); extern "C++" const wchar_t *wcspbrk (const wchar_t *__wcs, const wchar_t *__accept) throw () __asm ("wcspbrk") __attribute__ ((__pure__)); extern "C++" wchar_t *wcsstr (wchar_t *__haystack, const wchar_t *__needle) throw () __asm ("wcsstr") __attribute__ ((__pure__)); extern "C++" const wchar_t *wcsstr (const wchar_t *__haystack, const wchar_t *__needle) throw () __asm ("wcsstr") __attribute__ ((__pure__)); extern wchar_t *wcstok (wchar_t *__restrict __s, const wchar_t *__restrict __delim, wchar_t **__restrict __ptr) throw (); extern size_t wcslen (const wchar_t *__s) throw () __attribute__ ((__pure__)); extern "C++" wchar_t *wcswcs (wchar_t *__haystack, const wchar_t *__needle) throw () __asm ("wcswcs") __attribute__ ((__pure__)); extern "C++" const wchar_t *wcswcs (const wchar_t *__haystack, const wchar_t *__needle) throw () __asm ("wcswcs") __attribute__ ((__pure__)); extern size_t wcsnlen (const wchar_t *__s, size_t __maxlen) throw () __attribute__ ((__pure__)); extern "C++" wchar_t *wmemchr (wchar_t *__s, wchar_t __c, size_t __n) throw () __asm ("wmemchr") __attribute__ ((__pure__)); extern "C++" const wchar_t *wmemchr (const wchar_t *__s, wchar_t __c, size_t __n) throw () __asm ("wmemchr") __attribute__ ((__pure__)); extern int wmemcmp (const wchar_t *__s1, const wchar_t *__s2, size_t __n) throw () __attribute__ ((__pure__)); extern wchar_t *wmemcpy (wchar_t *__restrict __s1, const wchar_t *__restrict __s2, size_t __n) throw (); extern wchar_t *wmemmove (wchar_t *__s1, const wchar_t *__s2, size_t __n) throw (); extern wchar_t *wmemset (wchar_t *__s, wchar_t __c, size_t __n) throw (); extern wchar_t *wmempcpy (wchar_t *__restrict __s1, const wchar_t *__restrict __s2, size_t __n) throw (); extern wint_t btowc (int __c) throw (); extern int wctob (wint_t __c) throw (); extern int mbsinit (const mbstate_t *__ps) throw () __attribute__ ((__pure__)); extern size_t mbrtowc (wchar_t *__restrict __pwc, const char *__restrict __s, size_t __n, mbstate_t *__restrict __p) throw (); extern size_t wcrtomb (char *__restrict __s, wchar_t __wc, mbstate_t *__restrict __ps) throw (); extern size_t __mbrlen (const char *__restrict __s, size_t __n, mbstate_t *__restrict __ps) throw (); extern size_t mbrlen (const char *__restrict __s, size_t __n, mbstate_t *__restrict __ps) throw (); extern wint_t __btowc_alias (int __c) __asm ("btowc"); extern __inline __attribute__ ((__gnu_inline__)) wint_t __attribute__ ((__leaf__)) btowc (int __c) throw () { return (__builtin_constant_p (__c) && __c >= '\0' && __c <= '\x7f' ? (wint_t) __c : __btowc_alias (__c)); } extern int __wctob_alias (wint_t __c) __asm ("wctob"); extern __inline __attribute__ ((__gnu_inline__)) int __attribute__ ((__leaf__)) wctob (wint_t __wc) throw () { return (__builtin_constant_p (__wc) && __wc >= L'\0' && __wc <= L'\x7f' ? (int) __wc : __wctob_alias (__wc)); } extern __inline __attribute__ ((__gnu_inline__)) size_t __attribute__ ((__leaf__)) mbrlen (const char *__restrict __s, size_t __n, mbstate_t *__restrict __ps) throw () { return (__ps != __null ? mbrtowc (__null, __s, __n, __ps) : __mbrlen (__s, __n, __null)); } extern size_t mbsrtowcs (wchar_t *__restrict __dst, const char **__restrict __src, size_t __len, mbstate_t *__restrict __ps) throw (); extern size_t wcsrtombs (char *__restrict __dst, const wchar_t **__restrict __src, size_t __len, mbstate_t *__restrict __ps) throw (); extern size_t mbsnrtowcs (wchar_t *__restrict __dst, const char **__restrict __src, size_t __nmc, size_t __len, mbstate_t *__restrict __ps) throw (); extern size_t wcsnrtombs (char *__restrict __dst, const wchar_t **__restrict __src, size_t __nwc, size_t __len, mbstate_t *__restrict __ps) throw (); extern int wcwidth (wchar_t __c) throw (); extern int wcswidth (const wchar_t *__s, size_t __n) throw (); extern double wcstod (const wchar_t *__restrict __nptr, wchar_t **__restrict __endptr) throw (); extern float wcstof (const wchar_t *__restrict __nptr, wchar_t **__restrict __endptr) throw (); extern long double wcstold (const wchar_t *__restrict __nptr, wchar_t **__restrict __endptr) throw (); extern _Float32 wcstof32 (const wchar_t *__restrict __nptr, wchar_t **__restrict __endptr) throw (); extern _Float64 wcstof64 (const wchar_t *__restrict __nptr, wchar_t **__restrict __endptr) throw (); extern _Float128 wcstof128 (const wchar_t *__restrict __nptr, wchar_t **__restrict __endptr) throw (); extern _Float32x wcstof32x (const wchar_t *__restrict __nptr, wchar_t **__restrict __endptr) throw (); extern _Float64x wcstof64x (const wchar_t *__restrict __nptr, wchar_t **__restrict __endptr) throw (); extern long int wcstol (const wchar_t *__restrict __nptr, wchar_t **__restrict __endptr, int __base) throw (); extern unsigned long int wcstoul (const wchar_t *__restrict __nptr, wchar_t **__restrict __endptr, int __base) throw (); __extension__ extern long long int wcstoll (const wchar_t *__restrict __nptr, wchar_t **__restrict __endptr, int __base) throw (); __extension__ extern unsigned long long int wcstoull (const wchar_t *__restrict __nptr, wchar_t **__restrict __endptr, int __base) throw (); __extension__ extern long long int wcstoq (const wchar_t *__restrict __nptr, wchar_t **__restrict __endptr, int __base) throw (); __extension__ extern unsigned long long int wcstouq (const wchar_t *__restrict __nptr, wchar_t **__restrict __endptr, int __base) throw (); extern long int wcstol_l (const wchar_t *__restrict __nptr, wchar_t **__restrict __endptr, int __base, locale_t __loc) throw (); extern unsigned long int wcstoul_l (const wchar_t *__restrict __nptr, wchar_t **__restrict __endptr, int __base, locale_t __loc) throw (); __extension__ extern long long int wcstoll_l (const wchar_t *__restrict __nptr, wchar_t **__restrict __endptr, int __base, locale_t __loc) throw (); __extension__ extern unsigned long long int wcstoull_l (const wchar_t *__restrict __nptr, wchar_t **__restrict __endptr, int __base, locale_t __loc) throw (); extern double wcstod_l (const wchar_t *__restrict __nptr, wchar_t **__restrict __endptr, locale_t __loc) throw (); extern float wcstof_l (const wchar_t *__restrict __nptr, wchar_t **__restrict __endptr, locale_t __loc) throw (); extern long double wcstold_l (const wchar_t *__restrict __nptr, wchar_t **__restrict __endptr, locale_t __loc) throw (); extern _Float32 wcstof32_l (const wchar_t *__restrict __nptr, wchar_t **__restrict __endptr, locale_t __loc) throw (); extern _Float64 wcstof64_l (const wchar_t *__restrict __nptr, wchar_t **__restrict __endptr, locale_t __loc) throw (); extern _Float128 wcstof128_l (const wchar_t *__restrict __nptr, wchar_t **__restrict __endptr, locale_t __loc) throw (); extern _Float32x wcstof32x_l (const wchar_t *__restrict __nptr, wchar_t **__restrict __endptr, locale_t __loc) throw (); extern _Float64x wcstof64x_l (const wchar_t *__restrict __nptr, wchar_t **__restrict __endptr, locale_t __loc) throw (); extern wchar_t *wcpcpy (wchar_t *__restrict __dest, const wchar_t *__restrict __src) throw (); extern wchar_t *wcpncpy (wchar_t *__restrict __dest, const wchar_t *__restrict __src, size_t __n) throw (); extern __FILE *open_wmemstream (wchar_t **__bufloc, size_t *__sizeloc) throw (); extern int fwide (__FILE *__fp, int __mode) throw (); extern int fwprintf (__FILE *__restrict __stream, const wchar_t *__restrict __format, ...) ; extern int wprintf (const wchar_t *__restrict __format, ...) ; extern int swprintf (wchar_t *__restrict __s, size_t __n, const wchar_t *__restrict __format, ...) throw () ; extern int vfwprintf (__FILE *__restrict __s, const wchar_t *__restrict __format, __gnuc_va_list __arg) ; extern int vwprintf (const wchar_t *__restrict __format, __gnuc_va_list __arg) ; extern int vswprintf (wchar_t *__restrict __s, size_t __n, const wchar_t *__restrict __format, __gnuc_va_list __arg) throw () ; extern int fwscanf (__FILE *__restrict __stream, const wchar_t *__restrict __format, ...) ; extern int wscanf (const wchar_t *__restrict __format, ...) ; extern int swscanf (const wchar_t *__restrict __s, const wchar_t *__restrict __format, ...) throw () ; extern int fwscanf (__FILE *__restrict __stream, const wchar_t *__restrict __format, ...) __asm__ ("" "__isoc99_fwscanf") ; extern int wscanf (const wchar_t *__restrict __format, ...) __asm__ ("" "__isoc99_wscanf") ; extern int swscanf (const wchar_t *__restrict __s, const wchar_t *__restrict __format, ...) throw () __asm__ ("" "__isoc99_swscanf") ; extern int vfwscanf (__FILE *__restrict __s, const wchar_t *__restrict __format, __gnuc_va_list __arg) ; extern int vwscanf (const wchar_t *__restrict __format, __gnuc_va_list __arg) ; extern int vswscanf (const wchar_t *__restrict __s, const wchar_t *__restrict __format, __gnuc_va_list __arg) throw () ; extern int vfwscanf (__FILE *__restrict __s, const wchar_t *__restrict __format, __gnuc_va_list __arg) __asm__ ("" "__isoc99_vfwscanf") ; extern int vwscanf (const wchar_t *__restrict __format, __gnuc_va_list __arg) __asm__ ("" "__isoc99_vwscanf") ; extern int vswscanf (const wchar_t *__restrict __s, const wchar_t *__restrict __format, __gnuc_va_list __arg) throw () __asm__ ("" "__isoc99_vswscanf") ; extern wint_t fgetwc (__FILE *__stream); extern wint_t getwc (__FILE *__stream); extern wint_t getwchar (void); extern wint_t fputwc (wchar_t __wc, __FILE *__stream); extern wint_t putwc (wchar_t __wc, __FILE *__stream); extern wint_t putwchar (wchar_t __wc); extern wchar_t *fgetws (wchar_t *__restrict __ws, int __n, __FILE *__restrict __stream); extern int fputws (const wchar_t *__restrict __ws, __FILE *__restrict __stream); extern wint_t ungetwc (wint_t __wc, __FILE *__stream); extern wint_t getwc_unlocked (__FILE *__stream); extern wint_t getwchar_unlocked (void); extern wint_t fgetwc_unlocked (__FILE *__stream); extern wint_t fputwc_unlocked (wchar_t __wc, __FILE *__stream); extern wint_t putwc_unlocked (wchar_t __wc, __FILE *__stream); extern wint_t putwchar_unlocked (wchar_t __wc); extern wchar_t *fgetws_unlocked (wchar_t *__restrict __ws, int __n, __FILE *__restrict __stream); extern int fputws_unlocked (const wchar_t *__restrict __ws, __FILE *__restrict __stream); extern size_t wcsftime (wchar_t *__restrict __s, size_t __maxsize, const wchar_t *__restrict __format, const struct tm *__restrict __tp) throw (); extern size_t wcsftime_l (wchar_t *__restrict __s, size_t __maxsize, const wchar_t *__restrict __format, const struct tm *__restrict __tp, locale_t __loc) throw (); } namespace std { using ::mbstate_t; } extern "C++" { namespace std __attribute__ ((__visibility__ ("default"))) { using ::wint_t; using ::btowc; using ::fgetwc; using ::fgetws; using ::fputwc; using ::fputws; using ::fwide; using ::fwprintf; using ::fwscanf; using ::getwc; using ::getwchar; using ::mbrlen; using ::mbrtowc; using ::mbsinit; using ::mbsrtowcs; using ::putwc; using ::putwchar; using ::swprintf; using ::swscanf; using ::ungetwc; using ::vfwprintf; using ::vfwscanf; using ::vswprintf; using ::vswscanf; using ::vwprintf; using ::vwscanf; using ::wcrtomb; using ::wcscat; using ::wcscmp; using ::wcscoll; using ::wcscpy; using ::wcscspn; using ::wcsftime; using ::wcslen; using ::wcsncat; using ::wcsncmp; using ::wcsncpy; using ::wcsrtombs; using ::wcsspn; using ::wcstod; using ::wcstof; using ::wcstok; using ::wcstol; using ::wcstoul; using ::wcsxfrm; using ::wctob; using ::wmemcmp; using ::wmemcpy; using ::wmemmove; using ::wmemset; using ::wprintf; using ::wscanf; using ::wcschr; using ::wcspbrk; using ::wcsrchr; using ::wcsstr; using ::wmemchr; } } namespace __gnu_cxx { using ::wcstold; using ::wcstoll; using ::wcstoull; } namespace std { using ::__gnu_cxx::wcstold; using ::__gnu_cxx::wcstoll; using ::__gnu_cxx::wcstoull; } namespace std { using std::wcstof; using std::vfwscanf; using std::vswscanf; using std::vwscanf; using std::wcstold; using std::wcstoll; using std::wcstoull; } namespace std __attribute__ ((__visibility__ ("default"))) { typedef long streamoff; typedef ptrdiff_t streamsize; template<typename _StateT> class fpos { private: streamoff _M_off; _StateT _M_state; public: fpos() : _M_off(0), _M_state() { } fpos(streamoff __off) : _M_off(__off), _M_state() { } fpos(const fpos&) = default; fpos& operator=(const fpos&) = default; ~fpos() = default; operator streamoff() const { return _M_off; } void state(_StateT __st) { _M_state = __st; } _StateT state() const { return _M_state; } fpos& operator+=(streamoff __off) { _M_off += __off; return *this; } fpos& operator-=(streamoff __off) { _M_off -= __off; return *this; } fpos operator+(streamoff __off) const { fpos __pos(*this); __pos += __off; return __pos; } fpos operator-(streamoff __off) const { fpos __pos(*this); __pos -= __off; return __pos; } streamoff operator-(const fpos& __other) const { return _M_off - __other._M_off; } }; 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); } typedef fpos<mbstate_t> streampos; typedef fpos<mbstate_t> wstreampos; typedef fpos<mbstate_t> u16streampos; typedef fpos<mbstate_t> u32streampos; } namespace __gnu_cxx __attribute__ ((__visibility__ ("default"))) { 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; }; 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; static constexpr void assign(char_type& __c1, const char_type& __c2) { __c1 = __c2; } static constexpr bool eq(const char_type& __c1, const char_type& __c2) { return __c1 == __c2; } static constexpr bool lt(const char_type& __c1, const char_type& __c2) { return __c1 < __c2; } static constexpr int compare(const char_type* __s1, const char_type* __s2, std::size_t __n); static constexpr std::size_t length(const char_type* __s); static constexpr const char_type* find(const char_type* __s, std::size_t __n, const char_type& __a); static char_type* move(char_type* __s1, const char_type* __s2, std::size_t __n); static char_type* copy(char_type* __s1, const char_type* __s2, std::size_t __n); static char_type* assign(char_type* __s, std::size_t __n, char_type __a); static constexpr char_type to_char_type(const int_type& __c) { return static_cast<char_type>(__c); } static constexpr int_type to_int_type(const char_type& __c) { return static_cast<int_type>(__c); } static constexpr bool eq_int_type(const int_type& __c1, const int_type& __c2) { return __c1 == __c2; } static constexpr int_type eof() { return static_cast<int_type>(-1); } static constexpr int_type not_eof(const int_type& __c) { return !eq_int_type(__c, eof()) ? __c : to_int_type(char_type()); } }; template<typename _CharT> 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> 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> 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> 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; return static_cast<_CharT*>(__builtin_memmove(__s1, __s2, __n * sizeof(char_type))); } template<typename _CharT> typename char_traits<_CharT>::char_type* char_traits<_CharT>:: copy(char_type* __s1, const char_type* __s2, std::size_t __n) { std::copy(__s2, __s2 + __n, __s1); return __s1; } template<typename _CharT> typename char_traits<_CharT>::char_type* char_traits<_CharT>:: assign(char_type* __s, std::size_t __n, char_type __a) { std::fill_n(__s, __n, __a); return __s; } } namespace std __attribute__ ((__visibility__ ("default"))) { template<class _CharT> struct char_traits : public __gnu_cxx::char_traits<_CharT> { }; 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; static 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 (static_cast<unsigned char>(__c1) < static_cast<unsigned char>(__c2)); } static int compare(const char_type* __s1, const char_type* __s2, size_t __n) { if (__n == 0) return 0; return __builtin_memcmp(__s1, __s2, __n); } static size_t length(const char_type* __s) { return __builtin_strlen(__s); } static const char_type* find(const char_type* __s, size_t __n, const char_type& __a) { if (__n == 0) return 0; return static_cast<const char_type*>(__builtin_memchr(__s, __a, __n)); } static char_type* move(char_type* __s1, const char_type* __s2, size_t __n) { if (__n == 0) return __s1; return static_cast<char_type*>(__builtin_memmove(__s1, __s2, __n)); } static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) { if (__n == 0) return __s1; return static_cast<char_type*>(__builtin_memcpy(__s1, __s2, __n)); } static char_type* assign(char_type* __s, size_t __n, char_type __a) { if (__n == 0) return __s; return static_cast<char_type*>(__builtin_memset(__s, __a, __n)); } static constexpr char_type to_char_type(const int_type& __c) noexcept { return static_cast<char_type>(__c); } static constexpr int_type to_int_type(const char_type& __c) noexcept { return static_cast<int_type>(static_cast<unsigned char>(__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 (__c == eof()) ? 0 : __c; } }; 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; static 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 int compare(const char_type* __s1, const char_type* __s2, size_t __n) { if (__n == 0) return 0; return wmemcmp(__s1, __s2, __n); } static size_t length(const char_type* __s) { return wcslen(__s); } static const char_type* find(const char_type* __s, size_t __n, const char_type& __a) { if (__n == 0) return 0; return wmemchr(__s, __a, __n); } static char_type* move(char_type* __s1, const char_type* __s2, size_t __n) { if (__n == 0) return __s1; return wmemmove(__s1, __s2, __n); } static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) { if (__n == 0) return __s1; return wmemcpy(__s1, __s2, __n); } static char_type* assign(char_type* __s, size_t __n, char_type __a) { if (__n == 0) return __s; return wmemset(__s, __a, __n); } 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>((0xffffffffu)); } static constexpr int_type not_eof(const int_type& __c) noexcept { return eq_int_type(__c, eof()) ? 0 : __c; } }; } typedef unsigned char __u_char; typedef unsigned short int __u_short; typedef unsigned int __u_int; typedef unsigned long int __u_long; typedef signed char __int8_t; typedef unsigned char __uint8_t; typedef signed short int __int16_t; typedef unsigned short int __uint16_t; typedef signed int __int32_t; typedef unsigned int __uint32_t; typedef signed long int __int64_t; typedef unsigned long int __uint64_t; typedef __int8_t __int_least8_t; typedef __uint8_t __uint_least8_t; typedef __int16_t __int_least16_t; typedef __uint16_t __uint_least16_t; typedef __int32_t __int_least32_t; typedef __uint32_t __uint_least32_t; typedef __int64_t __int_least64_t; typedef __uint64_t __uint_least64_t; typedef long int __quad_t; typedef unsigned long int __u_quad_t; typedef long int __intmax_t; typedef unsigned long int __uintmax_t; typedef unsigned long int __dev_t; typedef unsigned int __uid_t; typedef unsigned int __gid_t; typedef unsigned long int __ino_t; typedef unsigned long int __ino64_t; typedef unsigned int __mode_t; typedef unsigned long int __nlink_t; typedef long int __off_t; typedef long int __off64_t; typedef int __pid_t; typedef struct { int __val[2]; } __fsid_t; typedef long int __clock_t; typedef unsigned long int __rlim_t; typedef unsigned long int __rlim64_t; typedef unsigned int __id_t; typedef long int __time_t; typedef unsigned int __useconds_t; typedef long int __suseconds_t; typedef int __daddr_t; typedef int __key_t; typedef int __clockid_t; typedef void * __timer_t; typedef long int __blksize_t; typedef long int __blkcnt_t; typedef long int __blkcnt64_t; typedef unsigned long int __fsblkcnt_t; typedef unsigned long int __fsblkcnt64_t; typedef unsigned long int __fsfilcnt_t; typedef unsigned long int __fsfilcnt64_t; typedef long int __fsword_t; typedef long int __ssize_t; typedef long int __syscall_slong_t; typedef unsigned long int __syscall_ulong_t; typedef __off64_t __loff_t; typedef char *__caddr_t; typedef long int __intptr_t; typedef unsigned int __socklen_t; typedef int __sig_atomic_t; typedef __int8_t int8_t; typedef __int16_t int16_t; typedef __int32_t int32_t; typedef __int64_t int64_t; typedef __uint8_t uint8_t; typedef __uint16_t uint16_t; typedef __uint32_t uint32_t; typedef __uint64_t uint64_t; typedef __int_least8_t int_least8_t; typedef __int_least16_t int_least16_t; typedef __int_least32_t int_least32_t; typedef __int_least64_t int_least64_t; typedef __uint_least8_t uint_least8_t; typedef __uint_least16_t uint_least16_t; typedef __uint_least32_t uint_least32_t; typedef __uint_least64_t uint_least64_t; typedef signed char int_fast8_t; typedef long int int_fast16_t; typedef long int int_fast32_t; typedef long int int_fast64_t; typedef unsigned char uint_fast8_t; typedef unsigned long int uint_fast16_t; typedef unsigned long int uint_fast32_t; typedef unsigned long int uint_fast64_t; typedef long int intptr_t; typedef unsigned long int uintptr_t; typedef __intmax_t intmax_t; typedef __uintmax_t uintmax_t; namespace std { using ::int8_t; using ::int16_t; using ::int32_t; using ::int64_t; using ::int_fast8_t; using ::int_fast16_t; using ::int_fast32_t; using ::int_fast64_t; using ::int_least8_t; using ::int_least16_t; using ::int_least32_t; using ::int_least64_t; using ::intmax_t; using ::intptr_t; using ::uint8_t; using ::uint16_t; using ::uint32_t; using ::uint64_t; using ::uint_fast8_t; using ::uint_fast16_t; using ::uint_fast32_t; using ::uint_fast64_t; using ::uint_least8_t; using ::uint_least16_t; using ::uint_least32_t; using ::uint_least64_t; using ::uintmax_t; using ::uintptr_t; } namespace std __attribute__ ((__visibility__ ("default"))) { template<> struct char_traits<char16_t> { typedef char16_t char_type; typedef uint_least16_t int_type; typedef streamoff off_type; typedef u16streampos pos_type; typedef mbstate_t state_type; static 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 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 size_t length(const char_type* __s) { size_t __i = 0; while (!eq(__s[__i], char_type())) ++__i; return __i; } static 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 char_type* move(char_type* __s1, const char_type* __s2, size_t __n) { if (__n == 0) return __s1; return (static_cast<char_type*> (__builtin_memmove(__s1, __s2, __n * sizeof(char_type)))); } static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) { if (__n == 0) return __s1; return (static_cast<char_type*> (__builtin_memcpy(__s1, __s2, __n * sizeof(char_type)))); } static 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; typedef uint_least32_t int_type; typedef streamoff off_type; typedef u32streampos pos_type; typedef mbstate_t state_type; static 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 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 size_t length(const char_type* __s) { size_t __i = 0; while (!eq(__s[__i], char_type())) ++__i; return __i; } static 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 char_type* move(char_type* __s1, const char_type* __s2, size_t __n) { if (__n == 0) return __s1; return (static_cast<char_type*> (__builtin_memmove(__s1, __s2, __n * sizeof(char_type)))); } static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) { if (__n == 0) return __s1; return (static_cast<char_type*> (__builtin_memcpy(__s1, __s2, __n * sizeof(char_type)))); } static 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; } }; } extern "C++" { namespace std { class exception { public: exception() noexcept { } virtual ~exception() noexcept; exception(const exception&) = default; exception& operator=(const exception&) = default; exception(exception&&) = default; exception& operator=(exception&&) = default; virtual const char* what() const noexcept; }; } } extern "C++" { namespace std { class bad_exception : public exception { public: bad_exception() noexcept { } virtual ~bad_exception() noexcept; virtual const char* what() const noexcept; }; typedef void (*terminate_handler) (); typedef void (*unexpected_handler) (); terminate_handler set_terminate(terminate_handler) noexcept; terminate_handler get_terminate() noexcept; void terminate() noexcept __attribute__ ((__noreturn__)); unexpected_handler set_unexpected(unexpected_handler) noexcept; unexpected_handler get_unexpected() noexcept; void unexpected() __attribute__ ((__noreturn__)); bool uncaught_exception() noexcept __attribute__ ((__pure__)); int uncaught_exceptions() noexcept __attribute__ ((__pure__)); } namespace __gnu_cxx { void __verbose_terminate_handler(); } } namespace std { class type_info; } namespace __cxxabiv1 { struct __cxa_refcounted_exception; extern "C" { void* __cxa_allocate_exception(size_t) noexcept; void __cxa_free_exception(void*) noexcept; __cxa_refcounted_exception* __cxa_init_primary_exception(void *object, std::type_info *tinfo, void ( *dest) (void *)) noexcept; } } namespace std { size_t _Hash_bytes(const void* __ptr, size_t __len, size_t __seed); size_t _Fnv_hash_bytes(const void* __ptr, size_t __len, size_t __seed); } extern "C++" { namespace __cxxabiv1 { class __class_type_info; } namespace std { class type_info { public: virtual ~type_info(); const char* name() const noexcept { return __name[0] == '*' ? __name + 1 : __name; } bool before(const type_info& __arg) const noexcept { return (__name[0] == '*' && __arg.__name[0] == '*') ? __name < __arg.__name : __builtin_strcmp (__name, __arg.__name) < 0; } bool operator==(const type_info& __arg) const noexcept { return ((__name == __arg.__name) || (__name[0] != '*' && __builtin_strcmp (__name, __arg.__name) == 0)); } bool operator!=(const type_info& __arg) const noexcept { return !operator==(__arg); } size_t hash_code() const noexcept { return _Hash_bytes(name(), __builtin_strlen(name()), static_cast<size_t>(0xc70f6907UL)); } virtual bool __is_pointer_p() const; virtual bool __is_function_p() const; virtual bool __do_catch(const type_info *__thr_type, void **__thr_obj, unsigned __outer) const; virtual bool __do_upcast(const __cxxabiv1::__class_type_info *__target, void **__obj_ptr) const; protected: const char *__name; explicit type_info(const char *__n): __name(__n) { } private: type_info& operator=(const type_info&); type_info(const type_info&); }; class bad_cast : public exception { public: bad_cast() noexcept { } virtual ~bad_cast() noexcept; virtual const char* what() const noexcept; }; class bad_typeid : public exception { public: bad_typeid () noexcept { } virtual ~bad_typeid() noexcept; virtual const char* what() const noexcept; }; } } extern "C++" { namespace std { class type_info; namespace __exception_ptr { class exception_ptr; } using __exception_ptr::exception_ptr; exception_ptr current_exception() noexcept; template<typename _Ex> exception_ptr make_exception_ptr(_Ex) noexcept; void rethrow_exception(exception_ptr) __attribute__ ((__noreturn__)); namespace __exception_ptr { using std::rethrow_exception; class exception_ptr { void* _M_exception_object; explicit exception_ptr(void* __e) noexcept; void _M_addref() noexcept; void _M_release() noexcept; void *_M_get() const noexcept __attribute__ ((__pure__)); friend exception_ptr std::current_exception() noexcept; friend void std::rethrow_exception(exception_ptr); template<typename _Ex> friend exception_ptr std::make_exception_ptr(_Ex) noexcept; public: exception_ptr() noexcept; exception_ptr(const exception_ptr&) noexcept; 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; } exception_ptr& operator=(const exception_ptr&) noexcept; exception_ptr& operator=(exception_ptr&& __o) noexcept { exception_ptr(static_cast<exception_ptr&&>(__o)).swap(*this); return *this; } ~exception_ptr() noexcept; void swap(exception_ptr&) noexcept; explicit operator bool() const { return _M_exception_object; } friend bool operator==(const exception_ptr&, const exception_ptr&) noexcept __attribute__ ((__pure__)); const class std::type_info* __cxa_exception_type() const noexcept __attribute__ ((__pure__)); }; bool operator==(const exception_ptr&, const exception_ptr&) noexcept __attribute__ ((__pure__)); bool operator!=(const exception_ptr&, const exception_ptr&) noexcept __attribute__ ((__pure__)); inline void swap(exception_ptr& __lhs, exception_ptr& __rhs) { __lhs.swap(__rhs); } template<typename _Ex> inline void __dest_thunk(void* __x) { static_cast<_Ex*>(__x)->~_Ex(); } } template<typename _Ex> exception_ptr make_exception_ptr(_Ex __ex) noexcept { 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(); } } } } extern "C++" { namespace std { 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; } }; 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)) { } }; 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); } 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{}); } 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; 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(); } inline void __rethrow_if_nested_impl(const void*) { } template<typename _Ex> inline void rethrow_if_nested(const _Ex& __ex) { std::__rethrow_if_nested_impl(std::__addressof(__ex)); } } } extern "C++" { namespace std { class bad_alloc : public exception { public: bad_alloc() throw() { } bad_alloc(const bad_alloc&) = default; bad_alloc& operator=(const bad_alloc&) = default; virtual ~bad_alloc() throw(); virtual const char* what() const throw(); }; class bad_array_new_length : public bad_alloc { public: bad_array_new_length() throw() { } virtual ~bad_array_new_length() throw(); virtual const char* what() const throw(); }; struct nothrow_t { explicit nothrow_t() = default; }; extern const nothrow_t nothrow; typedef void (*new_handler)(); new_handler set_new_handler(new_handler) throw(); new_handler get_new_handler() noexcept; } void* operator new(std::size_t) __attribute__((__externally_visible__)); void* operator new[](std::size_t) __attribute__((__externally_visible__)); void operator delete(void*) noexcept __attribute__((__externally_visible__)); void operator delete[](void*) noexcept __attribute__((__externally_visible__)); void operator delete(void*, std::size_t) noexcept __attribute__((__externally_visible__)); void operator delete[](void*, std::size_t) noexcept __attribute__((__externally_visible__)); void* operator new(std::size_t, const std::nothrow_t&) noexcept __attribute__((__externally_visible__, __malloc__)); void* operator new[](std::size_t, const std::nothrow_t&) noexcept __attribute__((__externally_visible__, __malloc__)); void operator delete(void*, const std::nothrow_t&) noexcept __attribute__((__externally_visible__)); void operator delete[](void*, const std::nothrow_t&) noexcept __attribute__((__externally_visible__)); inline void* operator new(std::size_t, void* __p) noexcept { return __p; } inline void* operator new[](std::size_t, void* __p) noexcept { return __p; } inline void operator delete (void*, void*) noexcept { } inline void operator delete[](void*, void*) noexcept { } } namespace __gnu_cxx __attribute__ ((__visibility__ ("default"))) { template<typename _Tp> class new_allocator { public: typedef _Tp value_type; typedef std::size_t size_type; typedef std::ptrdiff_t difference_type; typedef _Tp* pointer; typedef const _Tp* const_pointer; typedef _Tp& reference; typedef const _Tp& const_reference; template<typename _Tp1> struct rebind { typedef new_allocator<_Tp1> other; }; typedef std::true_type propagate_on_container_move_assignment; new_allocator() noexcept { } new_allocator(const new_allocator&) noexcept { } template<typename _Tp1> new_allocator(const new_allocator<_Tp1>&) noexcept { } ~new_allocator() noexcept { } pointer address(reference __x) const noexcept { return std::__addressof(__x); } const_pointer address(const_reference __x) const noexcept { return std::__addressof(__x); } _Tp* allocate(size_type __n, const void* = static_cast<const void*>(0)) { if (__n > this->_M_max_size()) std::__throw_bad_alloc(); return static_cast<_Tp*>(::operator new(__n * sizeof(_Tp))); } void deallocate(_Tp* __p, size_type __t) { ::operator delete(__p , __t * sizeof(_Tp) ); } size_type max_size() const noexcept { return _M_max_size(); } 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(); } template<typename _Up> friend bool operator==(const new_allocator&, const new_allocator<_Up>&) noexcept { return true; } template<typename _Up> friend bool operator!=(const new_allocator&, const new_allocator<_Up>&) noexcept { return false; } private: constexpr size_type _M_max_size() const noexcept { return std::size_t(0x7fffffffffffffffL) / sizeof(_Tp); } }; } namespace std { template<typename _Tp> using __allocator_base = __gnu_cxx::new_allocator<_Tp>; } namespace std __attribute__ ((__visibility__ ("default"))) { template<> class allocator<void> { public: typedef void value_type; typedef size_t size_type; typedef ptrdiff_t difference_type; typedef void* pointer; typedef const void* const_pointer; template<typename _Tp1> struct rebind { typedef allocator<_Tp1> other; }; 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(); } }; template<typename _Tp> class allocator : public __allocator_base<_Tp> { public: typedef _Tp value_type; typedef size_t size_type; typedef ptrdiff_t difference_type; 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; }; typedef true_type propagate_on_container_move_assignment; typedef true_type is_always_equal; allocator() noexcept { } allocator(const allocator& __a) noexcept : __allocator_base<_Tp>(__a) { } allocator& operator=(const allocator&) = default; template<typename _Tp1> allocator(const allocator<_Tp1>&) noexcept { } ~allocator() noexcept { } friend bool operator==(const allocator&, const allocator&) noexcept { return true; } friend bool operator!=(const allocator&, const allocator&) noexcept { return false; } }; template<typename _T1, typename _T2> inline bool operator==(const allocator<_T1>&, const allocator<_T2>&) noexcept { return true; } template<typename _T1, typename _T2> inline bool operator!=(const allocator<_T1>&, const allocator<_T2>&) noexcept { return false; } 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>&) { } }; extern template class allocator<char>; extern template class allocator<wchar_t>; template<typename _Alloc, bool = __is_empty(_Alloc)> struct __alloc_swap { static void _S_do_it(_Alloc&, _Alloc&) noexcept { } }; template<typename _Alloc> struct __alloc_swap<_Alloc, false> { static void _S_do_it(_Alloc& __one, _Alloc& __two) noexcept { if (__one != __two) swap(__one, __two); } }; 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; } }; 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 { 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; } } }; } extern "C" { struct lconv { char *decimal_point; char *thousands_sep; char *grouping; char *int_curr_symbol; char *currency_symbol; char *mon_decimal_point; char *mon_thousands_sep; char *mon_grouping; char *positive_sign; char *negative_sign; char int_frac_digits; char frac_digits; char p_cs_precedes; char p_sep_by_space; char n_cs_precedes; char n_sep_by_space; char p_sign_posn; char n_sign_posn; char int_p_cs_precedes; char int_p_sep_by_space; char int_n_cs_precedes; char int_n_sep_by_space; char int_p_sign_posn; char int_n_sign_posn; }; extern char *setlocale (int __category, const char *__locale) throw (); extern struct lconv *localeconv (void) throw (); extern locale_t newlocale (int __category_mask, const char *__locale, locale_t __base) throw (); extern locale_t duplocale (locale_t __dataset) throw (); extern void freelocale (locale_t __dataset) throw (); extern locale_t uselocale (locale_t __dataset) throw (); } namespace std { using ::lconv; using ::setlocale; using ::localeconv; } namespace __gnu_cxx __attribute__ ((__visibility__ ("default"))) { extern "C" __typeof(uselocale) __uselocale; } namespace std __attribute__ ((__visibility__ ("default"))) { typedef __locale_t __c_locale; inline int __convert_from_v(const __c_locale& __cloc __attribute__ ((__unused__)), char* __out, const int __size __attribute__ ((__unused__)), const char* __fmt, ...) { __c_locale __old = __gnu_cxx::__uselocale(__cloc); __builtin_va_list __args; __builtin_va_start(__args, __fmt); const int __ret = __builtin_vsnprintf(__out, __size, __fmt, __args); __builtin_va_end(__args); __gnu_cxx::__uselocale(__old); return __ret; } } namespace std __attribute__ ((__visibility__ ("default"))) { class ios_base; template<typename _CharT, typename _Traits = char_traits<_CharT> > class basic_ios; template<typename _CharT, typename _Traits = char_traits<_CharT> > class basic_streambuf; template<typename _CharT, typename _Traits = char_traits<_CharT> > class basic_istream; template<typename _CharT, typename _Traits = char_traits<_CharT> > class basic_ostream; template<typename _CharT, typename _Traits = char_traits<_CharT> > class basic_iostream; namespace __cxx11 { template<typename _CharT, typename _Traits = char_traits<_CharT>, typename _Alloc = allocator<_CharT> > class basic_stringbuf; template<typename _CharT, typename _Traits = char_traits<_CharT>, typename _Alloc = allocator<_CharT> > class basic_istringstream; template<typename _CharT, typename _Traits = char_traits<_CharT>, typename _Alloc = allocator<_CharT> > class basic_ostringstream; template<typename _CharT, typename _Traits = char_traits<_CharT>, typename _Alloc = allocator<_CharT> > class basic_stringstream; } template<typename _CharT, typename _Traits = char_traits<_CharT> > class basic_filebuf; template<typename _CharT, typename _Traits = char_traits<_CharT> > class basic_ifstream; template<typename _CharT, typename _Traits = char_traits<_CharT> > class basic_ofstream; template<typename _CharT, typename _Traits = char_traits<_CharT> > class basic_fstream; template<typename _CharT, typename _Traits = char_traits<_CharT> > class istreambuf_iterator; template<typename _CharT, typename _Traits = char_traits<_CharT> > class ostreambuf_iterator; typedef basic_ios<char> ios; typedef basic_streambuf<char> streambuf; typedef basic_istream<char> istream; typedef basic_ostream<char> ostream; typedef basic_iostream<char> iostream; typedef basic_stringbuf<char> stringbuf; typedef basic_istringstream<char> istringstream; typedef basic_ostringstream<char> ostringstream; typedef basic_stringstream<char> stringstream; typedef basic_filebuf<char> filebuf; typedef basic_ifstream<char> ifstream; typedef basic_ofstream<char> ofstream; typedef basic_fstream<char> fstream; typedef basic_ios<wchar_t> wios; typedef basic_streambuf<wchar_t> wstreambuf; typedef basic_istream<wchar_t> wistream; typedef basic_ostream<wchar_t> wostream; typedef basic_iostream<wchar_t> wiostream; typedef basic_stringbuf<wchar_t> wstringbuf; typedef basic_istringstream<wchar_t> wistringstream; typedef basic_ostringstream<wchar_t> wostringstream; typedef basic_stringstream<wchar_t> wstringstream; typedef basic_filebuf<wchar_t> wfilebuf; typedef basic_ifstream<wchar_t> wifstream; typedef basic_ofstream<wchar_t> wofstream; typedef basic_fstream<wchar_t> wfstream; } extern "C" { enum { _ISupper = ((0) < 8 ? ((1 << (0)) << 8) : ((1 << (0)) >> 8)), _ISlower = ((1) < 8 ? ((1 << (1)) << 8) : ((1 << (1)) >> 8)), _ISalpha = ((2) < 8 ? ((1 << (2)) << 8) : ((1 << (2)) >> 8)), _ISdigit = ((3) < 8 ? ((1 << (3)) << 8) : ((1 << (3)) >> 8)), _ISxdigit = ((4) < 8 ? ((1 << (4)) << 8) : ((1 << (4)) >> 8)), _ISspace = ((5) < 8 ? ((1 << (5)) << 8) : ((1 << (5)) >> 8)), _ISprint = ((6) < 8 ? ((1 << (6)) << 8) : ((1 << (6)) >> 8)), _ISgraph = ((7) < 8 ? ((1 << (7)) << 8) : ((1 << (7)) >> 8)), _ISblank = ((8) < 8 ? ((1 << (8)) << 8) : ((1 << (8)) >> 8)), _IScntrl = ((9) < 8 ? ((1 << (9)) << 8) : ((1 << (9)) >> 8)), _ISpunct = ((10) < 8 ? ((1 << (10)) << 8) : ((1 << (10)) >> 8)), _ISalnum = ((11) < 8 ? ((1 << (11)) << 8) : ((1 << (11)) >> 8)) }; extern const unsigned short int **__ctype_b_loc (void) throw () __attribute__ ((__const__)); extern const __int32_t **__ctype_tolower_loc (void) throw () __attribute__ ((__const__)); extern const __int32_t **__ctype_toupper_loc (void) throw () __attribute__ ((__const__)); extern int isalnum (int) throw (); extern int isalpha (int) throw (); extern int iscntrl (int) throw (); extern int isdigit (int) throw (); extern int islower (int) throw (); extern int isgraph (int) throw (); extern int isprint (int) throw (); extern int ispunct (int) throw (); extern int isspace (int) throw (); extern int isupper (int) throw (); extern int isxdigit (int) throw (); extern int tolower (int __c) throw (); extern int toupper (int __c) throw (); extern int isblank (int) throw (); extern int isctype (int __c, int __mask) throw (); extern int isascii (int __c) throw (); extern int toascii (int __c) throw (); extern int _toupper (int) throw (); extern int _tolower (int) throw (); extern int isalnum_l (int, locale_t) throw (); extern int isalpha_l (int, locale_t) throw (); extern int iscntrl_l (int, locale_t) throw (); extern int isdigit_l (int, locale_t) throw (); extern int islower_l (int, locale_t) throw (); extern int isgraph_l (int, locale_t) throw (); extern int isprint_l (int, locale_t) throw (); extern int ispunct_l (int, locale_t) throw (); extern int isspace_l (int, locale_t) throw (); extern int isupper_l (int, locale_t) throw (); extern int isxdigit_l (int, locale_t) throw (); extern int isblank_l (int, locale_t) throw (); extern int __tolower_l (int __c, locale_t __l) throw (); extern int tolower_l (int __c, locale_t __l) throw (); extern int __toupper_l (int __c, locale_t __l) throw (); extern int toupper_l (int __c, locale_t __l) throw (); } namespace std { using ::isalnum; using ::isalpha; using ::iscntrl; using ::isdigit; using ::isgraph; using ::islower; using ::isprint; using ::ispunct; using ::isspace; using ::isupper; using ::isxdigit; using ::tolower; using ::toupper; } namespace std { using ::isblank; } namespace std __attribute__ ((__visibility__ ("default"))) { class locale; template<typename _Facet> bool has_facet(const locale&) throw(); template<typename _Facet> const _Facet& use_facet(const locale&); 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&); template<typename _CharT> bool isblank(_CharT, const locale&); template<typename _CharT> _CharT toupper(_CharT, const locale&); template<typename _CharT> _CharT tolower(_CharT, const locale&); class ctype_base; template<typename _CharT> class ctype; template<> class ctype<char>; template<> class ctype<wchar_t>; template<typename _CharT> class ctype_byname; class codecvt_base; template<typename _InternT, typename _ExternT, typename _StateT> class codecvt; template<> class codecvt<char, char, mbstate_t>; template<> class codecvt<wchar_t, char, mbstate_t>; template<> class codecvt<char16_t, char, mbstate_t>; template<> class codecvt<char32_t, char, mbstate_t>; template<typename _InternT, typename _ExternT, typename _StateT> class codecvt_byname; template<typename _CharT, typename _InIter = istreambuf_iterator<_CharT> > class num_get; template<typename _CharT, typename _OutIter = ostreambuf_iterator<_CharT> > class num_put; namespace __cxx11 { template<typename _CharT> class numpunct; template<typename _CharT> class numpunct_byname; } namespace __cxx11 { template<typename _CharT> class collate; template<typename _CharT> class collate_byname; } class time_base; 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; } template<typename _CharT, typename _OutIter = ostreambuf_iterator<_CharT> > class time_put; template<typename _CharT, typename _OutIter = ostreambuf_iterator<_CharT> > class time_put_byname; class money_base; namespace __cxx11 { template<typename _CharT, typename _InIter = istreambuf_iterator<_CharT> > class money_get; template<typename _CharT, typename _OutIter = ostreambuf_iterator<_CharT> > class money_put; } namespace __cxx11 { template<typename _CharT, bool _Intl = false> class moneypunct; template<typename _CharT, bool _Intl = false> class moneypunct_byname; } class messages_base; namespace __cxx11 { template<typename _CharT> class messages; template<typename _CharT> class messages_byname; } } namespace __cxxabiv1 { class __forced_unwind { virtual ~__forced_unwind() throw(); virtual void __pure_dummy() = 0; }; } namespace std __attribute__ ((__visibility__ ("default"))) { 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; } catch(...) { __out._M_setstate(__ios_base::badbit); } } return __out; } extern template ostream& __ostream_insert(ostream&, const char*, streamsize); extern template wostream& __ostream_insert(wostream&, const wchar_t*, streamsize); } namespace std __attribute__ ((__visibility__ ("default"))) { template<typename _Arg, typename _Result> struct unary_function { typedef _Arg argument_type; typedef _Result result_type; }; template<typename _Arg1, typename _Arg2, typename _Result> struct binary_function { typedef _Arg1 first_argument_type; typedef _Arg2 second_argument_type; typedef _Result result_type; }; struct __is_transparent; template<typename _Tp = void> struct plus; template<typename _Tp = void> struct minus; template<typename _Tp = void> struct multiplies; template<typename _Tp = void> struct divides; template<typename _Tp = void> struct modulus; template<typename _Tp = void> struct negate; template<typename _Tp> struct plus : public binary_function<_Tp, _Tp, _Tp> { constexpr _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x + __y; } }; template<typename _Tp> struct minus : public binary_function<_Tp, _Tp, _Tp> { constexpr _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x - __y; } }; template<typename _Tp> struct multiplies : public binary_function<_Tp, _Tp, _Tp> { constexpr _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x * __y; } }; template<typename _Tp> struct divides : public binary_function<_Tp, _Tp, _Tp> { constexpr _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x / __y; } }; template<typename _Tp> struct modulus : public binary_function<_Tp, _Tp, _Tp> { constexpr _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x % __y; } }; template<typename _Tp> struct negate : public unary_function<_Tp, _Tp> { constexpr _Tp operator()(const _Tp& __x) const { return -__x; } }; template<> struct plus<void> { template <typename _Tp, typename _Up> constexpr auto operator()(_Tp&& __t, _Up&& __u) const noexcept(noexcept(std::forward<_Tp>(__t) + std::forward<_Up>(__u))) -> decltype(std::forward<_Tp>(__t) + std::forward<_Up>(__u)) { return std::forward<_Tp>(__t) + std::forward<_Up>(__u); } typedef __is_transparent is_transparent; }; template<> struct minus<void> { template <typename _Tp, typename _Up> constexpr auto operator()(_Tp&& __t, _Up&& __u) const noexcept(noexcept(std::forward<_Tp>(__t) - std::forward<_Up>(__u))) -> decltype(std::forward<_Tp>(__t) - std::forward<_Up>(__u)) { return std::forward<_Tp>(__t) - std::forward<_Up>(__u); } typedef __is_transparent is_transparent; }; template<> struct multiplies<void> { template <typename _Tp, typename _Up> constexpr auto operator()(_Tp&& __t, _Up&& __u) const noexcept(noexcept(std::forward<_Tp>(__t) * std::forward<_Up>(__u))) -> decltype(std::forward<_Tp>(__t) * std::forward<_Up>(__u)) { return std::forward<_Tp>(__t) * std::forward<_Up>(__u); } typedef __is_transparent is_transparent; }; template<> struct divides<void> { template <typename _Tp, typename _Up> constexpr auto operator()(_Tp&& __t, _Up&& __u) const noexcept(noexcept(std::forward<_Tp>(__t) / std::forward<_Up>(__u))) -> decltype(std::forward<_Tp>(__t) / std::forward<_Up>(__u)) { return std::forward<_Tp>(__t) / std::forward<_Up>(__u); } typedef __is_transparent is_transparent; }; template<> struct modulus<void> { template <typename _Tp, typename _Up> constexpr auto operator()(_Tp&& __t, _Up&& __u) const noexcept(noexcept(std::forward<_Tp>(__t) % std::forward<_Up>(__u))) -> decltype(std::forward<_Tp>(__t) % std::forward<_Up>(__u)) { return std::forward<_Tp>(__t) % std::forward<_Up>(__u); } typedef __is_transparent is_transparent; }; template<> struct negate<void> { template <typename _Tp> constexpr auto operator()(_Tp&& __t) const noexcept(noexcept(-std::forward<_Tp>(__t))) -> decltype(-std::forward<_Tp>(__t)) { return -std::forward<_Tp>(__t); } typedef __is_transparent is_transparent; }; template<typename _Tp = void> struct equal_to; template<typename _Tp = void> struct not_equal_to; template<typename _Tp = void> struct greater; template<typename _Tp = void> struct less; template<typename _Tp = void> struct greater_equal; template<typename _Tp = void> struct less_equal; template<typename _Tp> struct equal_to : public binary_function<_Tp, _Tp, bool> { constexpr bool operator()(const _Tp& __x, const _Tp& __y) const { return __x == __y; } }; template<typename _Tp> struct not_equal_to : public binary_function<_Tp, _Tp, bool> { constexpr bool operator()(const _Tp& __x, const _Tp& __y) const { return __x != __y; } }; template<typename _Tp> struct greater : public binary_function<_Tp, _Tp, bool> { constexpr bool operator()(const _Tp& __x, const _Tp& __y) const { return __x > __y; } }; template<typename _Tp> struct less : public binary_function<_Tp, _Tp, bool> { constexpr bool operator()(const _Tp& __x, const _Tp& __y) const { return __x < __y; } }; template<typename _Tp> struct greater_equal : public binary_function<_Tp, _Tp, bool> { constexpr bool operator()(const _Tp& __x, const _Tp& __y) const { return __x >= __y; } }; template<typename _Tp> struct less_equal : public binary_function<_Tp, _Tp, bool> { constexpr bool operator()(const _Tp& __x, const _Tp& __y) const { return __x <= __y; } }; template<typename _Tp> struct greater<_Tp*> : public binary_function<_Tp*, _Tp*, bool> { constexpr bool operator()(_Tp* __x, _Tp* __y) const noexcept { if (__builtin_is_constant_evaluated()) return __x > __y; return (long unsigned int)__x > (long unsigned int)__y; } }; template<typename _Tp> struct less<_Tp*> : public binary_function<_Tp*, _Tp*, bool> { constexpr bool operator()(_Tp* __x, _Tp* __y) const noexcept { if (__builtin_is_constant_evaluated()) return __x < __y; return (long unsigned int)__x < (long unsigned int)__y; } }; template<typename _Tp> struct greater_equal<_Tp*> : public binary_function<_Tp*, _Tp*, bool> { constexpr bool operator()(_Tp* __x, _Tp* __y) const noexcept { if (__builtin_is_constant_evaluated()) return __x >= __y; return (long unsigned int)__x >= (long unsigned int)__y; } }; template<typename _Tp> struct less_equal<_Tp*> : public binary_function<_Tp*, _Tp*, bool> { constexpr bool operator()(_Tp* __x, _Tp* __y) const noexcept { if (__builtin_is_constant_evaluated()) return __x <= __y; return (long unsigned int)__x <= (long unsigned int)__y; } }; template<> struct equal_to<void> { template <typename _Tp, typename _Up> constexpr auto operator()(_Tp&& __t, _Up&& __u) const noexcept(noexcept(std::forward<_Tp>(__t) == std::forward<_Up>(__u))) -> decltype(std::forward<_Tp>(__t) == std::forward<_Up>(__u)) { return std::forward<_Tp>(__t) == std::forward<_Up>(__u); } typedef __is_transparent is_transparent; }; template<> struct not_equal_to<void> { template <typename _Tp, typename _Up> constexpr auto operator()(_Tp&& __t, _Up&& __u) const noexcept(noexcept(std::forward<_Tp>(__t) != std::forward<_Up>(__u))) -> decltype(std::forward<_Tp>(__t) != std::forward<_Up>(__u)) { return std::forward<_Tp>(__t) != std::forward<_Up>(__u); } typedef __is_transparent is_transparent; }; template<> struct greater<void> { template <typename _Tp, typename _Up> constexpr auto operator()(_Tp&& __t, _Up&& __u) const noexcept(noexcept(std::forward<_Tp>(__t) > std::forward<_Up>(__u))) -> decltype(std::forward<_Tp>(__t) > std::forward<_Up>(__u)) { return _S_cmp(std::forward<_Tp>(__t), std::forward<_Up>(__u), __ptr_cmp<_Tp, _Up>{}); } template<typename _Tp, typename _Up> constexpr bool operator()(_Tp* __t, _Up* __u) const noexcept { return greater<common_type_t<_Tp*, _Up*>>{}(__t, __u); } typedef __is_transparent is_transparent; private: template <typename _Tp, typename _Up> static constexpr decltype(auto) _S_cmp(_Tp&& __t, _Up&& __u, false_type) { return std::forward<_Tp>(__t) > std::forward<_Up>(__u); } template <typename _Tp, typename _Up> static constexpr bool _S_cmp(_Tp&& __t, _Up&& __u, true_type) noexcept { return greater<const volatile void*>{}( static_cast<const volatile void*>(std::forward<_Tp>(__t)), static_cast<const volatile void*>(std::forward<_Up>(__u))); } template<typename _Tp, typename _Up, typename = void> struct __not_overloaded2 : true_type { }; template<typename _Tp, typename _Up> struct __not_overloaded2<_Tp, _Up, __void_t< decltype(std::declval<_Tp>().operator>(std::declval<_Up>()))>> : false_type { }; template<typename _Tp, typename _Up, typename = void> struct __not_overloaded : __not_overloaded2<_Tp, _Up> { }; template<typename _Tp, typename _Up> struct __not_overloaded<_Tp, _Up, __void_t< decltype(operator>(std::declval<_Tp>(), std::declval<_Up>()))>> : false_type { }; template<typename _Tp, typename _Up> using __ptr_cmp = __and_<__not_overloaded<_Tp, _Up>, is_convertible<_Tp, const volatile void*>, is_convertible<_Up, const volatile void*>>; }; template<> struct less<void> { template <typename _Tp, typename _Up> constexpr auto operator()(_Tp&& __t, _Up&& __u) const noexcept(noexcept(std::forward<_Tp>(__t) < std::forward<_Up>(__u))) -> decltype(std::forward<_Tp>(__t) < std::forward<_Up>(__u)) { return _S_cmp(std::forward<_Tp>(__t), std::forward<_Up>(__u), __ptr_cmp<_Tp, _Up>{}); } template<typename _Tp, typename _Up> constexpr bool operator()(_Tp* __t, _Up* __u) const noexcept { return less<common_type_t<_Tp*, _Up*>>{}(__t, __u); } typedef __is_transparent is_transparent; private: template <typename _Tp, typename _Up> static constexpr decltype(auto) _S_cmp(_Tp&& __t, _Up&& __u, false_type) { return std::forward<_Tp>(__t) < std::forward<_Up>(__u); } template <typename _Tp, typename _Up> static constexpr bool _S_cmp(_Tp&& __t, _Up&& __u, true_type) noexcept { return less<const volatile void*>{}( static_cast<const volatile void*>(std::forward<_Tp>(__t)), static_cast<const volatile void*>(std::forward<_Up>(__u))); } template<typename _Tp, typename _Up, typename = void> struct __not_overloaded2 : true_type { }; template<typename _Tp, typename _Up> struct __not_overloaded2<_Tp, _Up, __void_t< decltype(std::declval<_Tp>().operator<(std::declval<_Up>()))>> : false_type { }; template<typename _Tp, typename _Up, typename = void> struct __not_overloaded : __not_overloaded2<_Tp, _Up> { }; template<typename _Tp, typename _Up> struct __not_overloaded<_Tp, _Up, __void_t< decltype(operator<(std::declval<_Tp>(), std::declval<_Up>()))>> : false_type { }; template<typename _Tp, typename _Up> using __ptr_cmp = __and_<__not_overloaded<_Tp, _Up>, is_convertible<_Tp, const volatile void*>, is_convertible<_Up, const volatile void*>>; }; template<> struct greater_equal<void> { template <typename _Tp, typename _Up> constexpr auto operator()(_Tp&& __t, _Up&& __u) const noexcept(noexcept(std::forward<_Tp>(__t) >= std::forward<_Up>(__u))) -> decltype(std::forward<_Tp>(__t) >= std::forward<_Up>(__u)) { return _S_cmp(std::forward<_Tp>(__t), std::forward<_Up>(__u), __ptr_cmp<_Tp, _Up>{}); } template<typename _Tp, typename _Up> constexpr bool operator()(_Tp* __t, _Up* __u) const noexcept { return greater_equal<common_type_t<_Tp*, _Up*>>{}(__t, __u); } typedef __is_transparent is_transparent; private: template <typename _Tp, typename _Up> static constexpr decltype(auto) _S_cmp(_Tp&& __t, _Up&& __u, false_type) { return std::forward<_Tp>(__t) >= std::forward<_Up>(__u); } template <typename _Tp, typename _Up> static constexpr bool _S_cmp(_Tp&& __t, _Up&& __u, true_type) noexcept { return greater_equal<const volatile void*>{}( static_cast<const volatile void*>(std::forward<_Tp>(__t)), static_cast<const volatile void*>(std::forward<_Up>(__u))); } template<typename _Tp, typename _Up, typename = void> struct __not_overloaded2 : true_type { }; template<typename _Tp, typename _Up> struct __not_overloaded2<_Tp, _Up, __void_t< decltype(std::declval<_Tp>().operator>=(std::declval<_Up>()))>> : false_type { }; template<typename _Tp, typename _Up, typename = void> struct __not_overloaded : __not_overloaded2<_Tp, _Up> { }; template<typename _Tp, typename _Up> struct __not_overloaded<_Tp, _Up, __void_t< decltype(operator>=(std::declval<_Tp>(), std::declval<_Up>()))>> : false_type { }; template<typename _Tp, typename _Up> using __ptr_cmp = __and_<__not_overloaded<_Tp, _Up>, is_convertible<_Tp, const volatile void*>, is_convertible<_Up, const volatile void*>>; }; template<> struct less_equal<void> { template <typename _Tp, typename _Up> constexpr auto operator()(_Tp&& __t, _Up&& __u) const noexcept(noexcept(std::forward<_Tp>(__t) <= std::forward<_Up>(__u))) -> decltype(std::forward<_Tp>(__t) <= std::forward<_Up>(__u)) { return _S_cmp(std::forward<_Tp>(__t), std::forward<_Up>(__u), __ptr_cmp<_Tp, _Up>{}); } template<typename _Tp, typename _Up> constexpr bool operator()(_Tp* __t, _Up* __u) const noexcept { return less_equal<common_type_t<_Tp*, _Up*>>{}(__t, __u); } typedef __is_transparent is_transparent; private: template <typename _Tp, typename _Up> static constexpr decltype(auto) _S_cmp(_Tp&& __t, _Up&& __u, false_type) { return std::forward<_Tp>(__t) <= std::forward<_Up>(__u); } template <typename _Tp, typename _Up> static constexpr bool _S_cmp(_Tp&& __t, _Up&& __u, true_type) noexcept { return less_equal<const volatile void*>{}( static_cast<const volatile void*>(std::forward<_Tp>(__t)), static_cast<const volatile void*>(std::forward<_Up>(__u))); } template<typename _Tp, typename _Up, typename = void> struct __not_overloaded2 : true_type { }; template<typename _Tp, typename _Up> struct __not_overloaded2<_Tp, _Up, __void_t< decltype(std::declval<_Tp>().operator<=(std::declval<_Up>()))>> : false_type { }; template<typename _Tp, typename _Up, typename = void> struct __not_overloaded : __not_overloaded2<_Tp, _Up> { }; template<typename _Tp, typename _Up> struct __not_overloaded<_Tp, _Up, __void_t< decltype(operator<=(std::declval<_Tp>(), std::declval<_Up>()))>> : false_type { }; template<typename _Tp, typename _Up> using __ptr_cmp = __and_<__not_overloaded<_Tp, _Up>, is_convertible<_Tp, const volatile void*>, is_convertible<_Up, const volatile void*>>; }; template<typename _Tp = void> struct logical_and; template<typename _Tp = void> struct logical_or; template<typename _Tp = void> struct logical_not; template<typename _Tp> struct logical_and : public binary_function<_Tp, _Tp, bool> { constexpr bool operator()(const _Tp& __x, const _Tp& __y) const { return __x && __y; } }; template<typename _Tp> struct logical_or : public binary_function<_Tp, _Tp, bool> { constexpr bool operator()(const _Tp& __x, const _Tp& __y) const { return __x || __y; } }; template<typename _Tp> struct logical_not : public unary_function<_Tp, bool> { constexpr bool operator()(const _Tp& __x) const { return !__x; } }; template<> struct logical_and<void> { template <typename _Tp, typename _Up> constexpr auto operator()(_Tp&& __t, _Up&& __u) const noexcept(noexcept(std::forward<_Tp>(__t) && std::forward<_Up>(__u))) -> decltype(std::forward<_Tp>(__t) && std::forward<_Up>(__u)) { return std::forward<_Tp>(__t) && std::forward<_Up>(__u); } typedef __is_transparent is_transparent; }; template<> struct logical_or<void> { template <typename _Tp, typename _Up> constexpr auto operator()(_Tp&& __t, _Up&& __u) const noexcept(noexcept(std::forward<_Tp>(__t) || std::forward<_Up>(__u))) -> decltype(std::forward<_Tp>(__t) || std::forward<_Up>(__u)) { return std::forward<_Tp>(__t) || std::forward<_Up>(__u); } typedef __is_transparent is_transparent; }; template<> struct logical_not<void> { template <typename _Tp> constexpr auto operator()(_Tp&& __t) const noexcept(noexcept(!std::forward<_Tp>(__t))) -> decltype(!std::forward<_Tp>(__t)) { return !std::forward<_Tp>(__t); } typedef __is_transparent is_transparent; }; template<typename _Tp = void> struct bit_and; template<typename _Tp = void> struct bit_or; template<typename _Tp = void> struct bit_xor; template<typename _Tp = void> struct bit_not; template<typename _Tp> struct bit_and : public binary_function<_Tp, _Tp, _Tp> { constexpr _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x & __y; } }; template<typename _Tp> struct bit_or : public binary_function<_Tp, _Tp, _Tp> { constexpr _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x | __y; } }; template<typename _Tp> struct bit_xor : public binary_function<_Tp, _Tp, _Tp> { constexpr _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x ^ __y; } }; template<typename _Tp> struct bit_not : public unary_function<_Tp, _Tp> { constexpr _Tp operator()(const _Tp& __x) const { return ~__x; } }; template <> struct bit_and<void> { template <typename _Tp, typename _Up> constexpr auto operator()(_Tp&& __t, _Up&& __u) const noexcept(noexcept(std::forward<_Tp>(__t) & std::forward<_Up>(__u))) -> decltype(std::forward<_Tp>(__t) & std::forward<_Up>(__u)) { return std::forward<_Tp>(__t) & std::forward<_Up>(__u); } typedef __is_transparent is_transparent; }; template <> struct bit_or<void> { template <typename _Tp, typename _Up> constexpr auto operator()(_Tp&& __t, _Up&& __u) const noexcept(noexcept(std::forward<_Tp>(__t) | std::forward<_Up>(__u))) -> decltype(std::forward<_Tp>(__t) | std::forward<_Up>(__u)) { return std::forward<_Tp>(__t) | std::forward<_Up>(__u); } typedef __is_transparent is_transparent; }; template <> struct bit_xor<void> { template <typename _Tp, typename _Up> constexpr auto operator()(_Tp&& __t, _Up&& __u) const noexcept(noexcept(std::forward<_Tp>(__t) ^ std::forward<_Up>(__u))) -> decltype(std::forward<_Tp>(__t) ^ std::forward<_Up>(__u)) { return std::forward<_Tp>(__t) ^ std::forward<_Up>(__u); } typedef __is_transparent is_transparent; }; template <> struct bit_not<void> { template <typename _Tp> constexpr auto operator()(_Tp&& __t) const noexcept(noexcept(~std::forward<_Tp>(__t))) -> decltype(~std::forward<_Tp>(__t)) { return ~std::forward<_Tp>(__t); } typedef __is_transparent is_transparent; }; template<typename _Predicate> class unary_negate : public unary_function<typename _Predicate::argument_type, bool> { protected: _Predicate _M_pred; public: constexpr explicit unary_negate(const _Predicate& __x) : _M_pred(__x) { } constexpr bool operator()(const typename _Predicate::argument_type& __x) const { return !_M_pred(__x); } }; template<typename _Predicate> constexpr inline unary_negate<_Predicate> not1(const _Predicate& __pred) { return unary_negate<_Predicate>(__pred); } template<typename _Predicate> class binary_negate : public binary_function<typename _Predicate::first_argument_type, typename _Predicate::second_argument_type, bool> { protected: _Predicate _M_pred; public: constexpr explicit binary_negate(const _Predicate& __x) : _M_pred(__x) { } constexpr bool operator()(const typename _Predicate::first_argument_type& __x, const typename _Predicate::second_argument_type& __y) const { return !_M_pred(__x, __y); } }; template<typename _Predicate> constexpr inline binary_negate<_Predicate> not2(const _Predicate& __pred) { return binary_negate<_Predicate>(__pred); } template<typename _Arg, typename _Result> class pointer_to_unary_function : public unary_function<_Arg, _Result> { protected: _Result (*_M_ptr)(_Arg); public: pointer_to_unary_function() { } explicit pointer_to_unary_function(_Result (*__x)(_Arg)) : _M_ptr(__x) { } _Result operator()(_Arg __x) const { return _M_ptr(__x); } }; template<typename _Arg, typename _Result> inline pointer_to_unary_function<_Arg, _Result> ptr_fun(_Result (*__x)(_Arg)) { return pointer_to_unary_function<_Arg, _Result>(__x); } template<typename _Arg1, typename _Arg2, typename _Result> class pointer_to_binary_function : public binary_function<_Arg1, _Arg2, _Result> { protected: _Result (*_M_ptr)(_Arg1, _Arg2); public: pointer_to_binary_function() { } explicit pointer_to_binary_function(_Result (*__x)(_Arg1, _Arg2)) : _M_ptr(__x) { } _Result operator()(_Arg1 __x, _Arg2 __y) const { return _M_ptr(__x, __y); } }; template<typename _Arg1, typename _Arg2, typename _Result> inline pointer_to_binary_function<_Arg1, _Arg2, _Result> ptr_fun(_Result (*__x)(_Arg1, _Arg2)) { return pointer_to_binary_function<_Arg1, _Arg2, _Result>(__x); } template<typename _Tp> struct _Identity : public unary_function<_Tp, _Tp> { _Tp& operator()(_Tp& __x) const { return __x; } const _Tp& operator()(const _Tp& __x) const { return __x; } }; template<typename _Tp> struct _Identity<const _Tp> : _Identity<_Tp> { }; template<typename _Pair> struct _Select1st : public unary_function<_Pair, typename _Pair::first_type> { typename _Pair::first_type& operator()(_Pair& __x) const { return __x.first; } const typename _Pair::first_type& operator()(const _Pair& __x) const { return __x.first; } template<typename _Pair2> typename _Pair2::first_type& operator()(_Pair2& __x) const { return __x.first; } template<typename _Pair2> const typename _Pair2::first_type& operator()(const _Pair2& __x) const { return __x.first; } }; template<typename _Pair> struct _Select2nd : public unary_function<_Pair, typename _Pair::second_type> { typename _Pair::second_type& operator()(_Pair& __x) const { return __x.second; } const typename _Pair::second_type& operator()(const _Pair& __x) const { return __x.second; } }; template<typename _Ret, typename _Tp> class mem_fun_t : public unary_function<_Tp*, _Ret> { public: explicit mem_fun_t(_Ret (_Tp::*__pf)()) : _M_f(__pf) { } _Ret operator()(_Tp* __p) const { return (__p->*_M_f)(); } private: _Ret (_Tp::*_M_f)(); }; template<typename _Ret, typename _Tp> class const_mem_fun_t : public unary_function<const _Tp*, _Ret> { public: explicit const_mem_fun_t(_Ret (_Tp::*__pf)() const) : _M_f(__pf) { } _Ret operator()(const _Tp* __p) const { return (__p->*_M_f)(); } private: _Ret (_Tp::*_M_f)() const; }; template<typename _Ret, typename _Tp> class mem_fun_ref_t : public unary_function<_Tp, _Ret> { public: explicit mem_fun_ref_t(_Ret (_Tp::*__pf)()) : _M_f(__pf) { } _Ret operator()(_Tp& __r) const { return (__r.*_M_f)(); } private: _Ret (_Tp::*_M_f)(); }; template<typename _Ret, typename _Tp> class const_mem_fun_ref_t : public unary_function<_Tp, _Ret> { public: explicit const_mem_fun_ref_t(_Ret (_Tp::*__pf)() const) : _M_f(__pf) { } _Ret operator()(const _Tp& __r) const { return (__r.*_M_f)(); } private: _Ret (_Tp::*_M_f)() const; }; template<typename _Ret, typename _Tp, typename _Arg> class mem_fun1_t : public binary_function<_Tp*, _Arg, _Ret> { public: explicit mem_fun1_t(_Ret (_Tp::*__pf)(_Arg)) : _M_f(__pf) { } _Ret operator()(_Tp* __p, _Arg __x) const { return (__p->*_M_f)(__x); } private: _Ret (_Tp::*_M_f)(_Arg); }; template<typename _Ret, typename _Tp, typename _Arg> class const_mem_fun1_t : public binary_function<const _Tp*, _Arg, _Ret> { public: explicit const_mem_fun1_t(_Ret (_Tp::*__pf)(_Arg) const) : _M_f(__pf) { } _Ret operator()(const _Tp* __p, _Arg __x) const { return (__p->*_M_f)(__x); } private: _Ret (_Tp::*_M_f)(_Arg) const; }; template<typename _Ret, typename _Tp, typename _Arg> class mem_fun1_ref_t : public binary_function<_Tp, _Arg, _Ret> { public: explicit mem_fun1_ref_t(_Ret (_Tp::*__pf)(_Arg)) : _M_f(__pf) { } _Ret operator()(_Tp& __r, _Arg __x) const { return (__r.*_M_f)(__x); } private: _Ret (_Tp::*_M_f)(_Arg); }; template<typename _Ret, typename _Tp, typename _Arg> class const_mem_fun1_ref_t : public binary_function<_Tp, _Arg, _Ret> { public: explicit const_mem_fun1_ref_t(_Ret (_Tp::*__pf)(_Arg) const) : _M_f(__pf) { } _Ret operator()(const _Tp& __r, _Arg __x) const { return (__r.*_M_f)(__x); } private: _Ret (_Tp::*_M_f)(_Arg) const; }; template<typename _Ret, typename _Tp> inline mem_fun_t<_Ret, _Tp> mem_fun(_Ret (_Tp::*__f)()) { return mem_fun_t<_Ret, _Tp>(__f); } template<typename _Ret, typename _Tp> inline const_mem_fun_t<_Ret, _Tp> mem_fun(_Ret (_Tp::*__f)() const) { return const_mem_fun_t<_Ret, _Tp>(__f); } template<typename _Ret, typename _Tp> inline mem_fun_ref_t<_Ret, _Tp> mem_fun_ref(_Ret (_Tp::*__f)()) { return mem_fun_ref_t<_Ret, _Tp>(__f); } template<typename _Ret, typename _Tp> inline const_mem_fun_ref_t<_Ret, _Tp> mem_fun_ref(_Ret (_Tp::*__f)() const) { return const_mem_fun_ref_t<_Ret, _Tp>(__f); } template<typename _Ret, typename _Tp, typename _Arg> inline mem_fun1_t<_Ret, _Tp, _Arg> mem_fun(_Ret (_Tp::*__f)(_Arg)) { return mem_fun1_t<_Ret, _Tp, _Arg>(__f); } template<typename _Ret, typename _Tp, typename _Arg> inline const_mem_fun1_t<_Ret, _Tp, _Arg> mem_fun(_Ret (_Tp::*__f)(_Arg) const) { return const_mem_fun1_t<_Ret, _Tp, _Arg>(__f); } template<typename _Ret, typename _Tp, typename _Arg> inline mem_fun1_ref_t<_Ret, _Tp, _Arg> mem_fun_ref(_Ret (_Tp::*__f)(_Arg)) { return mem_fun1_ref_t<_Ret, _Tp, _Arg>(__f); } template<typename _Ret, typename _Tp, typename _Arg> inline const_mem_fun1_ref_t<_Ret, _Tp, _Arg> mem_fun_ref(_Ret (_Tp::*__f)(_Arg) const) { return const_mem_fun1_ref_t<_Ret, _Tp, _Arg>(__f); } } namespace std __attribute__ ((__visibility__ ("default"))) { 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); } typename _Operation::result_type operator()(typename _Operation::second_argument_type& __x) const { return op(value, __x); } } __attribute__ ((__deprecated__)); 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)); } 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); } typename _Operation::result_type operator()(typename _Operation::first_argument_type& __x) const { return op(__x, value); } } __attribute__ ((__deprecated__)); 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)); } } namespace std { template<class _E> class initializer_list { public: typedef _E value_type; typedef const _E& reference; typedef const _E& const_reference; typedef size_t size_type; typedef const _E* iterator; typedef const _E* const_iterator; private: iterator _M_array; size_type _M_len; constexpr initializer_list(const_iterator __a, size_type __l) : _M_array(__a), _M_len(__l) { } public: constexpr initializer_list() noexcept : _M_array(0), _M_len(0) { } constexpr size_type size() const noexcept { return _M_len; } constexpr const_iterator begin() const noexcept { return _M_array; } constexpr const_iterator end() const noexcept { return begin() + size(); } }; template<class _Tp> constexpr const _Tp* begin(initializer_list<_Tp> __ils) noexcept { return __ils.begin(); } template<class _Tp> constexpr const _Tp* end(initializer_list<_Tp> __ils) noexcept { return __ils.end(); } } namespace std __attribute__ ((__visibility__ ("default"))) { namespace __detail { template<typename _Tp, bool = is_signed<_Tp>::value> struct __int_limits { static_assert(is_integral<_Tp>::value, "unsupported specialization"); using _Up = typename make_unsigned<_Tp>::type; static constexpr int digits = sizeof(_Tp) * 8 - 1; static constexpr _Tp min() noexcept { return _Tp(_Up(1) << digits); } static constexpr _Tp max() noexcept { return _Tp(_Up(~_Up(0)) >> 1); } }; template<typename _Tp> struct __int_limits<_Tp, false> { static_assert(is_integral<_Tp>::value, "unsupported specialization"); static constexpr int digits = sizeof(_Tp) * 8; static constexpr _Tp min() noexcept { return 0; } static constexpr _Tp max() noexcept { return _Tp(-1); } }; template<> struct __int_limits<bool>; } } namespace std __attribute__ ((__visibility__ ("default"))) { template<typename _Container> inline auto begin(_Container& __cont) -> decltype(__cont.begin()) { return __cont.begin(); } template<typename _Container> inline auto begin(const _Container& __cont) -> decltype(__cont.begin()) { return __cont.begin(); } template<typename _Container> inline auto end(_Container& __cont) -> decltype(__cont.end()) { return __cont.end(); } template<typename _Container> inline auto end(const _Container& __cont) -> decltype(__cont.end()) { return __cont.end(); } template<typename _Tp, size_t _Nm> inline constexpr _Tp* begin(_Tp (&__arr)[_Nm]) { return __arr; } template<typename _Tp, size_t _Nm> inline constexpr _Tp* end(_Tp (&__arr)[_Nm]) { return __arr + _Nm; } template<typename _Tp> class valarray; template<typename _Tp> _Tp* begin(valarray<_Tp>&); template<typename _Tp> const _Tp* begin(const valarray<_Tp>&); template<typename _Tp> _Tp* end(valarray<_Tp>&); template<typename _Tp> const _Tp* end(const valarray<_Tp>&); template<typename _Container> inline constexpr auto cbegin(const _Container& __cont) noexcept(noexcept(std::begin(__cont))) -> decltype(std::begin(__cont)) { return std::begin(__cont); } template<typename _Container> inline constexpr auto cend(const _Container& __cont) noexcept(noexcept(std::end(__cont))) -> decltype(std::end(__cont)) { return std::end(__cont); } template<typename _Container> inline auto rbegin(_Container& __cont) -> decltype(__cont.rbegin()) { return __cont.rbegin(); } template<typename _Container> inline auto rbegin(const _Container& __cont) -> decltype(__cont.rbegin()) { return __cont.rbegin(); } template<typename _Container> inline auto rend(_Container& __cont) -> decltype(__cont.rend()) { return __cont.rend(); } template<typename _Container> inline auto rend(const _Container& __cont) -> decltype(__cont.rend()) { return __cont.rend(); } template<typename _Tp, size_t _Nm> inline reverse_iterator<_Tp*> rbegin(_Tp (&__arr)[_Nm]) { return reverse_iterator<_Tp*>(__arr + _Nm); } template<typename _Tp, size_t _Nm> inline reverse_iterator<_Tp*> rend(_Tp (&__arr)[_Nm]) { return reverse_iterator<_Tp*>(__arr); } template<typename _Tp> inline reverse_iterator<const _Tp*> rbegin(initializer_list<_Tp> __il) { return reverse_iterator<const _Tp*>(__il.end()); } template<typename _Tp> inline reverse_iterator<const _Tp*> rend(initializer_list<_Tp> __il) { return reverse_iterator<const _Tp*>(__il.begin()); } template<typename _Container> inline auto crbegin(const _Container& __cont) -> decltype(std::rbegin(__cont)) { return std::rbegin(__cont); } template<typename _Container> inline auto crend(const _Container& __cont) -> decltype(std::rend(__cont)) { return std::rend(__cont); } } typedef __time_t time_t; struct timespec { __time_t tv_sec; __syscall_slong_t tv_nsec; }; typedef __pid_t pid_t; struct sched_param { int sched_priority; }; extern "C" { extern int clone (int (*__fn) (void *__arg), void *__child_stack, int __flags, void *__arg, ...) throw (); extern int unshare (int __flags) throw (); extern int sched_getcpu (void) throw (); extern int getcpu (unsigned int *, unsigned int *) throw (); extern int setns (int __fd, int __nstype) throw (); } typedef unsigned long int __cpu_mask; typedef struct { __cpu_mask __bits[1024 / (8 * sizeof (__cpu_mask))]; } cpu_set_t; extern "C" { extern int __sched_cpucount (size_t __setsize, const cpu_set_t *__setp) throw (); extern cpu_set_t *__sched_cpualloc (size_t __count) throw () ; extern void __sched_cpufree (cpu_set_t *__set) throw (); } extern "C" { extern int sched_setparam (__pid_t __pid, const struct sched_param *__param) throw (); extern int sched_getparam (__pid_t __pid, struct sched_param *__param) throw (); extern int sched_setscheduler (__pid_t __pid, int __policy, const struct sched_param *__param) throw (); extern int sched_getscheduler (__pid_t __pid) throw (); extern int sched_yield (void) throw (); extern int sched_get_priority_max (int __algorithm) throw (); extern int sched_get_priority_min (int __algorithm) throw (); extern int sched_rr_get_interval (__pid_t __pid, struct timespec *__t) throw (); extern int sched_setaffinity (__pid_t __pid, size_t __cpusetsize, const cpu_set_t *__cpuset) throw (); extern int sched_getaffinity (__pid_t __pid, size_t __cpusetsize, cpu_set_t *__cpuset) throw (); } struct timeval { __time_t tv_sec; __suseconds_t tv_usec; }; struct timex { unsigned int modes; __syscall_slong_t offset; __syscall_slong_t freq; __syscall_slong_t maxerror; __syscall_slong_t esterror; int status; __syscall_slong_t constant; __syscall_slong_t precision; __syscall_slong_t tolerance; struct timeval time; __syscall_slong_t tick; __syscall_slong_t ppsfreq; __syscall_slong_t jitter; int shift; __syscall_slong_t stabil; __syscall_slong_t jitcnt; __syscall_slong_t calcnt; __syscall_slong_t errcnt; __syscall_slong_t stbcnt; int tai; int :32; int :32; int :32; int :32; int :32; int :32; int :32; int :32; int :32; int :32; int :32; }; extern "C" { extern int clock_adjtime (__clockid_t __clock_id, struct timex *__utx) throw (); } typedef __clock_t clock_t; struct tm { int tm_sec; int tm_min; int tm_hour; int tm_mday; int tm_mon; int tm_year; int tm_wday; int tm_yday; int tm_isdst; long int tm_gmtoff; const char *tm_zone; }; typedef __clockid_t clockid_t; typedef __timer_t timer_t; struct itimerspec { struct timespec it_interval; struct timespec it_value; }; struct sigevent; extern "C" { extern clock_t clock (void) throw (); extern time_t time (time_t *__timer) throw (); extern double difftime (time_t __time1, time_t __time0) throw () __attribute__ ((__const__)); extern time_t mktime (struct tm *__tp) throw (); extern size_t strftime (char *__restrict __s, size_t __maxsize, const char *__restrict __format, const struct tm *__restrict __tp) throw (); extern char *strptime (const char *__restrict __s, const char *__restrict __fmt, struct tm *__tp) throw (); extern size_t strftime_l (char *__restrict __s, size_t __maxsize, const char *__restrict __format, const struct tm *__restrict __tp, locale_t __loc) throw (); extern char *strptime_l (const char *__restrict __s, const char *__restrict __fmt, struct tm *__tp, locale_t __loc) throw (); extern struct tm *gmtime (const time_t *__timer) throw (); extern struct tm *localtime (const time_t *__timer) throw (); extern struct tm *gmtime_r (const time_t *__restrict __timer, struct tm *__restrict __tp) throw (); extern struct tm *localtime_r (const time_t *__restrict __timer, struct tm *__restrict __tp) throw (); extern char *asctime (const struct tm *__tp) throw (); extern char *ctime (const time_t *__timer) throw (); extern char *asctime_r (const struct tm *__restrict __tp, char *__restrict __buf) throw (); extern char *ctime_r (const time_t *__restrict __timer, char *__restrict __buf) throw (); extern char *__tzname[2]; extern int __daylight; extern long int __timezone; extern char *tzname[2]; extern void tzset (void) throw (); extern int daylight; extern long int timezone; extern time_t timegm (struct tm *__tp) throw (); extern time_t timelocal (struct tm *__tp) throw (); extern int dysize (int __year) throw () __attribute__ ((__const__)); extern int nanosleep (const struct timespec *__requested_time, struct timespec *__remaining); extern int clock_getres (clockid_t __clock_id, struct timespec *__res) throw (); extern int clock_gettime (clockid_t __clock_id, struct timespec *__tp) throw (); extern int clock_settime (clockid_t __clock_id, const struct timespec *__tp) throw (); extern int clock_nanosleep (clockid_t __clock_id, int __flags, const struct timespec *__req, struct timespec *__rem); extern int clock_getcpuclockid (pid_t __pid, clockid_t *__clock_id) throw (); extern int timer_create (clockid_t __clock_id, struct sigevent *__restrict __evp, timer_t *__restrict __timerid) throw (); extern int timer_delete (timer_t __timerid) throw (); extern int timer_settime (timer_t __timerid, int __flags, const struct itimerspec *__restrict __value, struct itimerspec *__restrict __ovalue) throw (); extern int timer_gettime (timer_t __timerid, struct itimerspec *__value) throw (); extern int timer_getoverrun (timer_t __timerid) throw (); extern int timespec_get (struct timespec *__ts, int __base) throw () __attribute__ ((__nonnull__ (1))); extern int getdate_err; extern struct tm *getdate (const char *__string); extern int getdate_r (const char *__restrict __string, struct tm *__restrict __resbufp); } typedef struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __pthread_list_t; typedef struct __pthread_internal_slist { struct __pthread_internal_slist *__next; } __pthread_slist_t; struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; __pthread_list_t __list; }; struct __pthread_rwlock_arch_t { unsigned int __readers; unsigned int __writers; unsigned int __wrphase_futex; unsigned int __writers_futex; unsigned int __pad3; unsigned int __pad4; int __cur_writer; int __shared; signed char __rwelision; unsigned char __pad1[7]; unsigned long int __pad2; unsigned int __flags; }; struct __pthread_cond_s { __extension__ union { __extension__ unsigned long long int __wseq; struct { unsigned int __low; unsigned int __high; } __wseq32; }; __extension__ union { __extension__ unsigned long long int __g1_start; struct { unsigned int __low; unsigned int __high; } __g1_start32; }; unsigned int __g_refs[2] ; unsigned int __g_size[2]; unsigned int __g1_orig_size; unsigned int __wrefs; unsigned int __g_signals[2]; }; typedef unsigned long int pthread_t; typedef union { char __size[4]; int __align; } pthread_mutexattr_t; typedef union { char __size[4]; int __align; } pthread_condattr_t; typedef unsigned int pthread_key_t; typedef int pthread_once_t; union pthread_attr_t { char __size[56]; long int __align; }; typedef union pthread_attr_t pthread_attr_t; typedef union { struct __pthread_mutex_s __data; char __size[40]; long int __align; } pthread_mutex_t; typedef union { struct __pthread_cond_s __data; char __size[48]; __extension__ long long int __align; } pthread_cond_t; typedef union { struct __pthread_rwlock_arch_t __data; char __size[56]; long int __align; } pthread_rwlock_t; typedef union { char __size[8]; long int __align; } pthread_rwlockattr_t; typedef volatile int pthread_spinlock_t; typedef union { char __size[32]; long int __align; } pthread_barrier_t; typedef union { char __size[4]; int __align; } pthread_barrierattr_t; typedef long int __jmp_buf[8]; enum { PTHREAD_CREATE_JOINABLE, PTHREAD_CREATE_DETACHED }; enum { PTHREAD_MUTEX_TIMED_NP, PTHREAD_MUTEX_RECURSIVE_NP, PTHREAD_MUTEX_ERRORCHECK_NP, PTHREAD_MUTEX_ADAPTIVE_NP , PTHREAD_MUTEX_NORMAL = PTHREAD_MUTEX_TIMED_NP, PTHREAD_MUTEX_RECURSIVE = PTHREAD_MUTEX_RECURSIVE_NP, PTHREAD_MUTEX_ERRORCHECK = PTHREAD_MUTEX_ERRORCHECK_NP, PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_NORMAL , PTHREAD_MUTEX_FAST_NP = PTHREAD_MUTEX_TIMED_NP }; enum { PTHREAD_MUTEX_STALLED, PTHREAD_MUTEX_STALLED_NP = PTHREAD_MUTEX_STALLED, PTHREAD_MUTEX_ROBUST, PTHREAD_MUTEX_ROBUST_NP = PTHREAD_MUTEX_ROBUST }; enum { PTHREAD_PRIO_NONE, PTHREAD_PRIO_INHERIT, PTHREAD_PRIO_PROTECT }; enum { PTHREAD_RWLOCK_PREFER_READER_NP, PTHREAD_RWLOCK_PREFER_WRITER_NP, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP, PTHREAD_RWLOCK_DEFAULT_NP = PTHREAD_RWLOCK_PREFER_READER_NP }; enum { PTHREAD_INHERIT_SCHED, PTHREAD_EXPLICIT_SCHED }; enum { PTHREAD_SCOPE_SYSTEM, PTHREAD_SCOPE_PROCESS }; enum { PTHREAD_PROCESS_PRIVATE, PTHREAD_PROCESS_SHARED }; struct _pthread_cleanup_buffer { void (*__routine) (void *); void *__arg; int __canceltype; struct _pthread_cleanup_buffer *__prev; }; enum { PTHREAD_CANCEL_ENABLE, PTHREAD_CANCEL_DISABLE }; enum { PTHREAD_CANCEL_DEFERRED, PTHREAD_CANCEL_ASYNCHRONOUS }; extern "C" { extern int pthread_create (pthread_t *__restrict __newthread, const pthread_attr_t *__restrict __attr, void *(*__start_routine) (void *), void *__restrict __arg) throw () __attribute__ ((__nonnull__ (1, 3))); extern void pthread_exit (void *__retval) __attribute__ ((__noreturn__)); extern int pthread_join (pthread_t __th, void **__thread_return); extern int pthread_tryjoin_np (pthread_t __th, void **__thread_return) throw (); extern int pthread_timedjoin_np (pthread_t __th, void **__thread_return, const struct timespec *__abstime); extern int pthread_clockjoin_np (pthread_t __th, void **__thread_return, clockid_t __clockid, const struct timespec *__abstime); extern int pthread_detach (pthread_t __th) throw (); extern pthread_t pthread_self (void) throw () __attribute__ ((__const__)); extern int pthread_equal (pthread_t __thread1, pthread_t __thread2) throw () __attribute__ ((__const__)); extern int pthread_attr_init (pthread_attr_t *__attr) throw () __attribute__ ((__nonnull__ (1))); extern int pthread_attr_destroy (pthread_attr_t *__attr) throw () __attribute__ ((__nonnull__ (1))); extern int pthread_attr_getdetachstate (const pthread_attr_t *__attr, int *__detachstate) throw () __attribute__ ((__nonnull__ (1, 2))); extern int pthread_attr_setdetachstate (pthread_attr_t *__attr, int __detachstate) throw () __attribute__ ((__nonnull__ (1))); extern int pthread_attr_getguardsize (const pthread_attr_t *__attr, size_t *__guardsize) throw () __attribute__ ((__nonnull__ (1, 2))); extern int pthread_attr_setguardsize (pthread_attr_t *__attr, size_t __guardsize) throw () __attribute__ ((__nonnull__ (1))); extern int pthread_attr_getschedparam (const pthread_attr_t *__restrict __attr, struct sched_param *__restrict __param) throw () __attribute__ ((__nonnull__ (1, 2))); extern int pthread_attr_setschedparam (pthread_attr_t *__restrict __attr, const struct sched_param *__restrict __param) throw () __attribute__ ((__nonnull__ (1, 2))); extern int pthread_attr_getschedpolicy (const pthread_attr_t *__restrict __attr, int *__restrict __policy) throw () __attribute__ ((__nonnull__ (1, 2))); extern int pthread_attr_setschedpolicy (pthread_attr_t *__attr, int __policy) throw () __attribute__ ((__nonnull__ (1))); extern int pthread_attr_getinheritsched (const pthread_attr_t *__restrict __attr, int *__restrict __inherit) throw () __attribute__ ((__nonnull__ (1, 2))); extern int pthread_attr_setinheritsched (pthread_attr_t *__attr, int __inherit) throw () __attribute__ ((__nonnull__ (1))); extern int pthread_attr_getscope (const pthread_attr_t *__restrict __attr, int *__restrict __scope) throw () __attribute__ ((__nonnull__ (1, 2))); extern int pthread_attr_setscope (pthread_attr_t *__attr, int __scope) throw () __attribute__ ((__nonnull__ (1))); extern int pthread_attr_getstackaddr (const pthread_attr_t *__restrict __attr, void **__restrict __stackaddr) throw () __attribute__ ((__nonnull__ (1, 2))) __attribute__ ((__deprecated__)); extern int pthread_attr_setstackaddr (pthread_attr_t *__attr, void *__stackaddr) throw () __attribute__ ((__nonnull__ (1))) __attribute__ ((__deprecated__)); extern int pthread_attr_getstacksize (const pthread_attr_t *__restrict __attr, size_t *__restrict __stacksize) throw () __attribute__ ((__nonnull__ (1, 2))); extern int pthread_attr_setstacksize (pthread_attr_t *__attr, size_t __stacksize) throw () __attribute__ ((__nonnull__ (1))); extern int pthread_attr_getstack (const pthread_attr_t *__restrict __attr, void **__restrict __stackaddr, size_t *__restrict __stacksize) throw () __attribute__ ((__nonnull__ (1, 2, 3))); extern int pthread_attr_setstack (pthread_attr_t *__attr, void *__stackaddr, size_t __stacksize) throw () __attribute__ ((__nonnull__ (1))); extern int pthread_attr_setaffinity_np (pthread_attr_t *__attr, size_t __cpusetsize, const cpu_set_t *__cpuset) throw () __attribute__ ((__nonnull__ (1, 3))); extern int pthread_attr_getaffinity_np (const pthread_attr_t *__attr, size_t __cpusetsize, cpu_set_t *__cpuset) throw () __attribute__ ((__nonnull__ (1, 3))); extern int pthread_getattr_default_np (pthread_attr_t *__attr) throw () __attribute__ ((__nonnull__ (1))); extern int pthread_setattr_default_np (const pthread_attr_t *__attr) throw () __attribute__ ((__nonnull__ (1))); extern int pthread_getattr_np (pthread_t __th, pthread_attr_t *__attr) throw () __attribute__ ((__nonnull__ (2))); extern int pthread_setschedparam (pthread_t __target_thread, int __policy, const struct sched_param *__param) throw () __attribute__ ((__nonnull__ (3))); extern int pthread_getschedparam (pthread_t __target_thread, int *__restrict __policy, struct sched_param *__restrict __param) throw () __attribute__ ((__nonnull__ (2, 3))); extern int pthread_setschedprio (pthread_t __target_thread, int __prio) throw (); extern int pthread_getname_np (pthread_t __target_thread, char *__buf, size_t __buflen) throw () __attribute__ ((__nonnull__ (2))); extern int pthread_setname_np (pthread_t __target_thread, const char *__name) throw () __attribute__ ((__nonnull__ (2))); extern int pthread_getconcurrency (void) throw (); extern int pthread_setconcurrency (int __level) throw (); extern int pthread_yield (void) throw (); extern int pthread_setaffinity_np (pthread_t __th, size_t __cpusetsize, const cpu_set_t *__cpuset) throw () __attribute__ ((__nonnull__ (3))); extern int pthread_getaffinity_np (pthread_t __th, size_t __cpusetsize, cpu_set_t *__cpuset) throw () __attribute__ ((__nonnull__ (3))); extern int pthread_once (pthread_once_t *__once_control, void (*__init_routine) (void)) __attribute__ ((__nonnull__ (1, 2))); extern int pthread_setcancelstate (int __state, int *__oldstate); extern int pthread_setcanceltype (int __type, int *__oldtype); extern int pthread_cancel (pthread_t __th); extern void pthread_testcancel (void); typedef struct { struct { __jmp_buf __cancel_jmp_buf; int __mask_was_saved; } __cancel_jmp_buf[1]; void *__pad[4]; } __pthread_unwind_buf_t __attribute__ ((__aligned__)); struct __pthread_cleanup_frame { void (*__cancel_routine) (void *); void *__cancel_arg; int __do_it; int __cancel_type; }; class __pthread_cleanup_class { void (*__cancel_routine) (void *); void *__cancel_arg; int __do_it; int __cancel_type; public: __pthread_cleanup_class (void (*__fct) (void *), void *__arg) : __cancel_routine (__fct), __cancel_arg (__arg), __do_it (1) { } ~__pthread_cleanup_class () { if (__do_it) __cancel_routine (__cancel_arg); } void __setdoit (int __newval) { __do_it = __newval; } void __defer () { pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, &__cancel_type); } void __restore () const { pthread_setcanceltype (__cancel_type, 0); } }; struct __jmp_buf_tag; extern int __sigsetjmp (struct __jmp_buf_tag *__env, int __savemask) throw (); extern int pthread_mutex_init (pthread_mutex_t *__mutex, const pthread_mutexattr_t *__mutexattr) throw () __attribute__ ((__nonnull__ (1))); extern int pthread_mutex_destroy (pthread_mutex_t *__mutex) throw () __attribute__ ((__nonnull__ (1))); extern int pthread_mutex_trylock (pthread_mutex_t *__mutex) throw () __attribute__ ((__nonnull__ (1))); extern int pthread_mutex_lock (pthread_mutex_t *__mutex) throw () __attribute__ ((__nonnull__ (1))); extern int pthread_mutex_timedlock (pthread_mutex_t *__restrict __mutex, const struct timespec *__restrict __abstime) throw () __attribute__ ((__nonnull__ (1, 2))); extern int pthread_mutex_clocklock (pthread_mutex_t *__restrict __mutex, clockid_t __clockid, const struct timespec *__restrict __abstime) throw () __attribute__ ((__nonnull__ (1, 3))); extern int pthread_mutex_unlock (pthread_mutex_t *__mutex) throw () __attribute__ ((__nonnull__ (1))); extern int pthread_mutex_getprioceiling (const pthread_mutex_t * __restrict __mutex, int *__restrict __prioceiling) throw () __attribute__ ((__nonnull__ (1, 2))); extern int pthread_mutex_setprioceiling (pthread_mutex_t *__restrict __mutex, int __prioceiling, int *__restrict __old_ceiling) throw () __attribute__ ((__nonnull__ (1, 3))); extern int pthread_mutex_consistent (pthread_mutex_t *__mutex) throw () __attribute__ ((__nonnull__ (1))); extern int pthread_mutex_consistent_np (pthread_mutex_t *__mutex) throw () __attribute__ ((__nonnull__ (1))); extern int pthread_mutexattr_init (pthread_mutexattr_t *__attr) throw () __attribute__ ((__nonnull__ (1))); extern int pthread_mutexattr_destroy (pthread_mutexattr_t *__attr) throw () __attribute__ ((__nonnull__ (1))); extern int pthread_mutexattr_getpshared (const pthread_mutexattr_t * __restrict __attr, int *__restrict __pshared) throw () __attribute__ ((__nonnull__ (1, 2))); extern int pthread_mutexattr_setpshared (pthread_mutexattr_t *__attr, int __pshared) throw () __attribute__ ((__nonnull__ (1))); extern int pthread_mutexattr_gettype (const pthread_mutexattr_t *__restrict __attr, int *__restrict __kind) throw () __attribute__ ((__nonnull__ (1, 2))); extern int pthread_mutexattr_settype (pthread_mutexattr_t *__attr, int __kind) throw () __attribute__ ((__nonnull__ (1))); extern int pthread_mutexattr_getprotocol (const pthread_mutexattr_t * __restrict __attr, int *__restrict __protocol) throw () __attribute__ ((__nonnull__ (1, 2))); extern int pthread_mutexattr_setprotocol (pthread_mutexattr_t *__attr, int __protocol) throw () __attribute__ ((__nonnull__ (1))); extern int pthread_mutexattr_getprioceiling (const pthread_mutexattr_t * __restrict __attr, int *__restrict __prioceiling) throw () __attribute__ ((__nonnull__ (1, 2))); extern int pthread_mutexattr_setprioceiling (pthread_mutexattr_t *__attr, int __prioceiling) throw () __attribute__ ((__nonnull__ (1))); extern int pthread_mutexattr_getrobust (const pthread_mutexattr_t *__attr, int *__robustness) throw () __attribute__ ((__nonnull__ (1, 2))); extern int pthread_mutexattr_getrobust_np (const pthread_mutexattr_t *__attr, int *__robustness) throw () __attribute__ ((__nonnull__ (1, 2))); extern int pthread_mutexattr_setrobust (pthread_mutexattr_t *__attr, int __robustness) throw () __attribute__ ((__nonnull__ (1))); extern int pthread_mutexattr_setrobust_np (pthread_mutexattr_t *__attr, int __robustness) throw () __attribute__ ((__nonnull__ (1))); extern int pthread_rwlock_init (pthread_rwlock_t *__restrict __rwlock, const pthread_rwlockattr_t *__restrict __attr) throw () __attribute__ ((__nonnull__ (1))); extern int pthread_rwlock_destroy (pthread_rwlock_t *__rwlock) throw () __attribute__ ((__nonnull__ (1))); extern int pthread_rwlock_rdlock (pthread_rwlock_t *__rwlock) throw () __attribute__ ((__nonnull__ (1))); extern int pthread_rwlock_tryrdlock (pthread_rwlock_t *__rwlock) throw () __attribute__ ((__nonnull__ (1))); extern int pthread_rwlock_timedrdlock (pthread_rwlock_t *__restrict __rwlock, const struct timespec *__restrict __abstime) throw () __attribute__ ((__nonnull__ (1, 2))); extern int pthread_rwlock_clockrdlock (pthread_rwlock_t *__restrict __rwlock, clockid_t __clockid, const struct timespec *__restrict __abstime) throw () __attribute__ ((__nonnull__ (1, 3))); extern int pthread_rwlock_wrlock (pthread_rwlock_t *__rwlock) throw () __attribute__ ((__nonnull__ (1))); extern int pthread_rwlock_trywrlock (pthread_rwlock_t *__rwlock) throw () __attribute__ ((__nonnull__ (1))); extern int pthread_rwlock_timedwrlock (pthread_rwlock_t *__restrict __rwlock, const struct timespec *__restrict __abstime) throw () __attribute__ ((__nonnull__ (1, 2))); extern int pthread_rwlock_clockwrlock (pthread_rwlock_t *__restrict __rwlock, clockid_t __clockid, const struct timespec *__restrict __abstime) throw () __attribute__ ((__nonnull__ (1, 3))); extern int pthread_rwlock_unlock (pthread_rwlock_t *__rwlock) throw () __attribute__ ((__nonnull__ (1))); extern int pthread_rwlockattr_init (pthread_rwlockattr_t *__attr) throw () __attribute__ ((__nonnull__ (1))); extern int pthread_rwlockattr_destroy (pthread_rwlockattr_t *__attr) throw () __attribute__ ((__nonnull__ (1))); extern int pthread_rwlockattr_getpshared (const pthread_rwlockattr_t * __restrict __attr, int *__restrict __pshared) throw () __attribute__ ((__nonnull__ (1, 2))); extern int pthread_rwlockattr_setpshared (pthread_rwlockattr_t *__attr, int __pshared) throw () __attribute__ ((__nonnull__ (1))); extern int pthread_rwlockattr_getkind_np (const pthread_rwlockattr_t * __restrict __attr, int *__restrict __pref) throw () __attribute__ ((__nonnull__ (1, 2))); extern int pthread_rwlockattr_setkind_np (pthread_rwlockattr_t *__attr, int __pref) throw () __attribute__ ((__nonnull__ (1))); extern int pthread_cond_init (pthread_cond_t *__restrict __cond, const pthread_condattr_t *__restrict __cond_attr) throw () __attribute__ ((__nonnull__ (1))); extern int pthread_cond_destroy (pthread_cond_t *__cond) throw () __attribute__ ((__nonnull__ (1))); extern int pthread_cond_signal (pthread_cond_t *__cond) throw () __attribute__ ((__nonnull__ (1))); extern int pthread_cond_broadcast (pthread_cond_t *__cond) throw () __attribute__ ((__nonnull__ (1))); extern int pthread_cond_wait (pthread_cond_t *__restrict __cond, pthread_mutex_t *__restrict __mutex) __attribute__ ((__nonnull__ (1, 2))); extern int pthread_cond_timedwait (pthread_cond_t *__restrict __cond, pthread_mutex_t *__restrict __mutex, const struct timespec *__restrict __abstime) __attribute__ ((__nonnull__ (1, 2, 3))); extern int pthread_cond_clockwait (pthread_cond_t *__restrict __cond, pthread_mutex_t *__restrict __mutex, __clockid_t __clock_id, const struct timespec *__restrict __abstime) __attribute__ ((__nonnull__ (1, 2, 4))); extern int pthread_condattr_init (pthread_condattr_t *__attr) throw () __attribute__ ((__nonnull__ (1))); extern int pthread_condattr_destroy (pthread_condattr_t *__attr) throw () __attribute__ ((__nonnull__ (1))); extern int pthread_condattr_getpshared (const pthread_condattr_t * __restrict __attr, int *__restrict __pshared) throw () __attribute__ ((__nonnull__ (1, 2))); extern int pthread_condattr_setpshared (pthread_condattr_t *__attr, int __pshared) throw () __attribute__ ((__nonnull__ (1))); extern int pthread_condattr_getclock (const pthread_condattr_t * __restrict __attr, __clockid_t *__restrict __clock_id) throw () __attribute__ ((__nonnull__ (1, 2))); extern int pthread_condattr_setclock (pthread_condattr_t *__attr, __clockid_t __clock_id) throw () __attribute__ ((__nonnull__ (1))); extern int pthread_spin_init (pthread_spinlock_t *__lock, int __pshared) throw () __attribute__ ((__nonnull__ (1))); extern int pthread_spin_destroy (pthread_spinlock_t *__lock) throw () __attribute__ ((__nonnull__ (1))); extern int pthread_spin_lock (pthread_spinlock_t *__lock) throw () __attribute__ ((__nonnull__ (1))); extern int pthread_spin_trylock (pthread_spinlock_t *__lock) throw () __attribute__ ((__nonnull__ (1))); extern int pthread_spin_unlock (pthread_spinlock_t *__lock) throw () __attribute__ ((__nonnull__ (1))); extern int pthread_barrier_init (pthread_barrier_t *__restrict __barrier, const pthread_barrierattr_t *__restrict __attr, unsigned int __count) throw () __attribute__ ((__nonnull__ (1))); extern int pthread_barrier_destroy (pthread_barrier_t *__barrier) throw () __attribute__ ((__nonnull__ (1))); extern int pthread_barrier_wait (pthread_barrier_t *__barrier) throw () __attribute__ ((__nonnull__ (1))); extern int pthread_barrierattr_init (pthread_barrierattr_t *__attr) throw () __attribute__ ((__nonnull__ (1))); extern int pthread_barrierattr_destroy (pthread_barrierattr_t *__attr) throw () __attribute__ ((__nonnull__ (1))); extern int pthread_barrierattr_getpshared (const pthread_barrierattr_t * __restrict __attr, int *__restrict __pshared) throw () __attribute__ ((__nonnull__ (1, 2))); extern int pthread_barrierattr_setpshared (pthread_barrierattr_t *__attr, int __pshared) throw () __attribute__ ((__nonnull__ (1))); extern int pthread_key_create (pthread_key_t *__key, void (*__destr_function) (void *)) throw () __attribute__ ((__nonnull__ (1))); extern int pthread_key_delete (pthread_key_t __key) throw (); extern void *pthread_getspecific (pthread_key_t __key) throw (); extern int pthread_setspecific (pthread_key_t __key, const void *__pointer) throw () ; extern int pthread_getcpuclockid (pthread_t __thread_id, __clockid_t *__clock_id) throw () __attribute__ ((__nonnull__ (2))); extern int pthread_atfork (void (*__prepare) (void), void (*__parent) (void), void (*__child) (void)) throw (); extern __inline __attribute__ ((__gnu_inline__)) int __attribute__ ((__leaf__)) pthread_equal (pthread_t __thread1, pthread_t __thread2) throw () { return __thread1 == __thread2; } } typedef pthread_t __gthread_t; typedef pthread_key_t __gthread_key_t; typedef pthread_once_t __gthread_once_t; typedef pthread_mutex_t __gthread_mutex_t; typedef pthread_mutex_t __gthread_recursive_mutex_t; typedef pthread_cond_t __gthread_cond_t; typedef struct timespec __gthread_time_t; static __typeof(pthread_once) __gthrw_pthread_once __attribute__ ((__weakref__("pthread_once"), __copy__ (pthread_once))); static __typeof(pthread_getspecific) __gthrw_pthread_getspecific __attribute__ ((__weakref__("pthread_getspecific"), __copy__ (pthread_getspecific))); static __typeof(pthread_setspecific) __gthrw_pthread_setspecific __attribute__ ((__weakref__("pthread_setspecific"), __copy__ (pthread_setspecific))); static __typeof(pthread_create) __gthrw_pthread_create __attribute__ ((__weakref__("pthread_create"), __copy__ (pthread_create))); static __typeof(pthread_join) __gthrw_pthread_join __attribute__ ((__weakref__("pthread_join"), __copy__ (pthread_join))); static __typeof(pthread_equal) __gthrw_pthread_equal __attribute__ ((__weakref__("pthread_equal"), __copy__ (pthread_equal))); static __typeof(pthread_self) __gthrw_pthread_self __attribute__ ((__weakref__("pthread_self"), __copy__ (pthread_self))); static __typeof(pthread_detach) __gthrw_pthread_detach __attribute__ ((__weakref__("pthread_detach"), __copy__ (pthread_detach))); static __typeof(pthread_cancel) __gthrw_pthread_cancel __attribute__ ((__weakref__("pthread_cancel"), __copy__ (pthread_cancel))); static __typeof(sched_yield) __gthrw_sched_yield __attribute__ ((__weakref__("sched_yield"), __copy__ (sched_yield))); static __typeof(pthread_mutex_lock) __gthrw_pthread_mutex_lock __attribute__ ((__weakref__("pthread_mutex_lock"), __copy__ (pthread_mutex_lock))); static __typeof(pthread_mutex_trylock) __gthrw_pthread_mutex_trylock __attribute__ ((__weakref__("pthread_mutex_trylock"), __copy__ (pthread_mutex_trylock))); static __typeof(pthread_mutex_timedlock) __gthrw_pthread_mutex_timedlock __attribute__ ((__weakref__("pthread_mutex_timedlock"), __copy__ (pthread_mutex_timedlock))); static __typeof(pthread_mutex_unlock) __gthrw_pthread_mutex_unlock __attribute__ ((__weakref__("pthread_mutex_unlock"), __copy__ (pthread_mutex_unlock))); static __typeof(pthread_mutex_init) __gthrw_pthread_mutex_init __attribute__ ((__weakref__("pthread_mutex_init"), __copy__ (pthread_mutex_init))); static __typeof(pthread_mutex_destroy) __gthrw_pthread_mutex_destroy __attribute__ ((__weakref__("pthread_mutex_destroy"), __copy__ (pthread_mutex_destroy))); static __typeof(pthread_cond_init) __gthrw_pthread_cond_init __attribute__ ((__weakref__("pthread_cond_init"), __copy__ (pthread_cond_init))); static __typeof(pthread_cond_broadcast) __gthrw_pthread_cond_broadcast __attribute__ ((__weakref__("pthread_cond_broadcast"), __copy__ (pthread_cond_broadcast))); static __typeof(pthread_cond_signal) __gthrw_pthread_cond_signal __attribute__ ((__weakref__("pthread_cond_signal"), __copy__ (pthread_cond_signal))); static __typeof(pthread_cond_wait) __gthrw_pthread_cond_wait __attribute__ ((__weakref__("pthread_cond_wait"), __copy__ (pthread_cond_wait))); static __typeof(pthread_cond_timedwait) __gthrw_pthread_cond_timedwait __attribute__ ((__weakref__("pthread_cond_timedwait"), __copy__ (pthread_cond_timedwait))); static __typeof(pthread_cond_destroy) __gthrw_pthread_cond_destroy __attribute__ ((__weakref__("pthread_cond_destroy"), __copy__ (pthread_cond_destroy))); static __typeof(pthread_key_create) __gthrw_pthread_key_create __attribute__ ((__weakref__("pthread_key_create"), __copy__ (pthread_key_create))); static __typeof(pthread_key_delete) __gthrw_pthread_key_delete __attribute__ ((__weakref__("pthread_key_delete"), __copy__ (pthread_key_delete))); static __typeof(pthread_mutexattr_init) __gthrw_pthread_mutexattr_init __attribute__ ((__weakref__("pthread_mutexattr_init"), __copy__ (pthread_mutexattr_init))); static __typeof(pthread_mutexattr_settype) __gthrw_pthread_mutexattr_settype __attribute__ ((__weakref__("pthread_mutexattr_settype"), __copy__ (pthread_mutexattr_settype))); static __typeof(pthread_mutexattr_destroy) __gthrw_pthread_mutexattr_destroy __attribute__ ((__weakref__("pthread_mutexattr_destroy"), __copy__ (pthread_mutexattr_destroy))); static __typeof(pthread_key_create) __gthrw___pthread_key_create __attribute__ ((__weakref__("__pthread_key_create"), __copy__ (pthread_key_create))); static inline int __gthread_active_p (void) { static void *const __gthread_active_ptr = __extension__ (void *) &__gthrw___pthread_key_create; return __gthread_active_ptr != 0; } static inline int __gthread_create (__gthread_t *__threadid, void *(*__func) (void*), void *__args) { return __gthrw_pthread_create (__threadid, __null, __func, __args); } static inline int __gthread_join (__gthread_t __threadid, void **__value_ptr) { return __gthrw_pthread_join (__threadid, __value_ptr); } static inline int __gthread_detach (__gthread_t __threadid) { return __gthrw_pthread_detach (__threadid); } static inline int __gthread_equal (__gthread_t __t1, __gthread_t __t2) { return __gthrw_pthread_equal (__t1, __t2); } static inline __gthread_t __gthread_self (void) { return __gthrw_pthread_self (); } static inline int __gthread_yield (void) { return __gthrw_sched_yield (); } static inline int __gthread_once (__gthread_once_t *__once, void (*__func) (void)) { if (__gthread_active_p ()) return __gthrw_pthread_once (__once, __func); else return -1; } static inline int __gthread_key_create (__gthread_key_t *__key, void (*__dtor) (void *)) { return __gthrw_pthread_key_create (__key, __dtor); } static inline int __gthread_key_delete (__gthread_key_t __key) { return __gthrw_pthread_key_delete (__key); } static inline void * __gthread_getspecific (__gthread_key_t __key) { return __gthrw_pthread_getspecific (__key); } static inline int __gthread_setspecific (__gthread_key_t __key, const void *__ptr) { return __gthrw_pthread_setspecific (__key, __ptr); } static inline void __gthread_mutex_init_function (__gthread_mutex_t *__mutex) { if (__gthread_active_p ()) __gthrw_pthread_mutex_init (__mutex, __null); } static inline int __gthread_mutex_destroy (__gthread_mutex_t *__mutex) { if (__gthread_active_p ()) return __gthrw_pthread_mutex_destroy (__mutex); else return 0; } static inline int __gthread_mutex_lock (__gthread_mutex_t *__mutex) { if (__gthread_active_p ()) return __gthrw_pthread_mutex_lock (__mutex); else return 0; } static inline int __gthread_mutex_trylock (__gthread_mutex_t *__mutex) { if (__gthread_active_p ()) return __gthrw_pthread_mutex_trylock (__mutex); else return 0; } static inline int __gthread_mutex_timedlock (__gthread_mutex_t *__mutex, const __gthread_time_t *__abs_timeout) { if (__gthread_active_p ()) return __gthrw_pthread_mutex_timedlock (__mutex, __abs_timeout); else return 0; } static inline int __gthread_mutex_unlock (__gthread_mutex_t *__mutex) { if (__gthread_active_p ()) return __gthrw_pthread_mutex_unlock (__mutex); else return 0; } static inline int __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex) { return __gthread_mutex_lock (__mutex); } static inline int __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex) { return __gthread_mutex_trylock (__mutex); } static inline int __gthread_recursive_mutex_timedlock (__gthread_recursive_mutex_t *__mutex, const __gthread_time_t *__abs_timeout) { return __gthread_mutex_timedlock (__mutex, __abs_timeout); } static inline int __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex) { return __gthread_mutex_unlock (__mutex); } static inline int __gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *__mutex) { return __gthread_mutex_destroy (__mutex); } static inline int __gthread_cond_broadcast (__gthread_cond_t *__cond) { return __gthrw_pthread_cond_broadcast (__cond); } static inline int __gthread_cond_signal (__gthread_cond_t *__cond) { return __gthrw_pthread_cond_signal (__cond); } static inline int __gthread_cond_wait (__gthread_cond_t *__cond, __gthread_mutex_t *__mutex) { return __gthrw_pthread_cond_wait (__cond, __mutex); } static inline int __gthread_cond_timedwait (__gthread_cond_t *__cond, __gthread_mutex_t *__mutex, const __gthread_time_t *__abs_timeout) { return __gthrw_pthread_cond_timedwait (__cond, __mutex, __abs_timeout); } static inline int __gthread_cond_wait_recursive (__gthread_cond_t *__cond, __gthread_recursive_mutex_t *__mutex) { return __gthread_cond_wait (__cond, __mutex); } static inline int __gthread_cond_destroy (__gthread_cond_t* __cond) { return __gthrw_pthread_cond_destroy (__cond); } typedef int _Atomic_word; namespace __gnu_cxx __attribute__ ((__visibility__ ("default"))) { inline _Atomic_word __attribute__((__always_inline__)) __exchange_and_add(volatile _Atomic_word* __mem, int __val) { return __atomic_fetch_add(__mem, __val, 4); } inline void __attribute__((__always_inline__)) __atomic_add(volatile _Atomic_word* __mem, int __val) { __atomic_fetch_add(__mem, __val, 4); } inline _Atomic_word __attribute__((__always_inline__)) __exchange_and_add_single(_Atomic_word* __mem, int __val) { _Atomic_word __result = *__mem; *__mem += __val; return __result; } inline void __attribute__((__always_inline__)) __atomic_add_single(_Atomic_word* __mem, int __val) { *__mem += __val; } inline _Atomic_word __attribute__ ((__always_inline__)) __exchange_and_add_dispatch(_Atomic_word* __mem, int __val) { if (__gthread_active_p()) return __exchange_and_add(__mem, __val); return __exchange_and_add_single(__mem, __val); } inline void __attribute__ ((__always_inline__)) __atomic_add_dispatch(_Atomic_word* __mem, int __val) { if (__gthread_active_p()) { __atomic_add(__mem, __val); return; } __atomic_add_single(__mem, __val); } } namespace std __attribute__ ((__visibility__ ("default"))) { template<typename _Tp, typename... _Args> inline void _Construct(_Tp* __p, _Args&&... __args) { ::new(static_cast<void*>(__p)) _Tp(std::forward<_Args>(__args)...); } template<typename _T1> inline void _Construct_novalue(_T1* __p) { ::new(static_cast<void*>(__p)) _T1; } template<typename _ForwardIterator> void _Destroy(_ForwardIterator __first, _ForwardIterator __last); template<typename _Tp> constexpr inline void _Destroy(_Tp* __pointer) { __pointer->~_Tp(); } template<bool> struct _Destroy_aux { template<typename _ForwardIterator> static void __destroy(_ForwardIterator __first, _ForwardIterator __last) { for (; __first != __last; ++__first) std::_Destroy(std::__addressof(*__first)); } }; template<> struct _Destroy_aux<true> { template<typename _ForwardIterator> static void __destroy(_ForwardIterator, _ForwardIterator) { } }; template<typename _ForwardIterator> inline void _Destroy(_ForwardIterator __first, _ForwardIterator __last) { typedef typename iterator_traits<_ForwardIterator>::value_type _Value_type; static_assert(is_destructible<_Value_type>::value, "value type is destructible"); std::_Destroy_aux<__has_trivial_destructor(_Value_type)>:: __destroy(__first, __last); } template<bool> struct _Destroy_n_aux { template<typename _ForwardIterator, typename _Size> static _ForwardIterator __destroy_n(_ForwardIterator __first, _Size __count) { for (; __count > 0; (void)++__first, --__count) std::_Destroy(std::__addressof(*__first)); return __first; } }; template<> struct _Destroy_n_aux<true> { template<typename _ForwardIterator, typename _Size> static _ForwardIterator __destroy_n(_ForwardIterator __first, _Size __count) { std::advance(__first, __count); return __first; } }; template<typename _ForwardIterator, typename _Size> inline _ForwardIterator _Destroy_n(_ForwardIterator __first, _Size __count) { typedef typename iterator_traits<_ForwardIterator>::value_type _Value_type; static_assert(is_destructible<_Value_type>::value, "value type is destructible"); return std::_Destroy_n_aux<__has_trivial_destructor(_Value_type)>:: __destroy_n(__first, __count); } } namespace std __attribute__ ((__visibility__ ("default"))) { 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; template<typename _Alloc> struct allocator_traits : __allocator_traits_base { typedef _Alloc allocator_type; typedef typename _Alloc::value_type value_type; using pointer = __detected_or_t<value_type*, __pointer, _Alloc>; private: 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>; }; 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; }; 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: using const_pointer = typename _Ptr<__c_pointer, const value_type>::type; using void_pointer = typename _Ptr<__v_pointer, void>::type; using const_void_pointer = typename _Ptr<__cv_pointer, const void>::type; using difference_type = typename _Diff<_Alloc, pointer>::type; using size_type = typename _Size<_Alloc, difference_type>::type; using propagate_on_container_copy_assignment = __detected_or_t<false_type, __pocca, _Alloc>; using propagate_on_container_move_assignment = __detected_or_t<false_type, __pocma, _Alloc>; using propagate_on_container_swap = __detected_or_t<false_type, __pocs, _Alloc>; 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 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 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) { ::new((void*)__p) _Tp(std::forward<_Args>(__args)...); } template<typename _Alloc2, typename _Tp> static 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 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&, ...) { 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: static pointer allocate(_Alloc& __a, size_type __n) { return __a.allocate(__n); } static pointer allocate(_Alloc& __a, size_type __n, const_void_pointer __hint) { return _S_allocate(__a, __n, __hint, 0); } static void deallocate(_Alloc& __a, pointer __p, size_type __n) { __a.deallocate(__p, __n); } template<typename _Tp, typename... _Args> static 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)...); } template<typename _Tp> static void destroy(_Alloc& __a, _Tp* __p) noexcept(noexcept(_S_destroy(__a, __p, 0))) { _S_destroy(__a, __p, 0); } static size_type max_size(const _Alloc& __a) noexcept { return _S_max_size(__a, 0); } static _Alloc select_on_container_copy_construction(const _Alloc& __rhs) { return _S_select(__rhs, 0); } }; template<typename _Tp> struct allocator_traits<allocator<_Tp>> { using allocator_type = allocator<_Tp>; using value_type = _Tp; using pointer = _Tp*; using const_pointer = const _Tp*; using void_pointer = void*; using const_void_pointer = const void*; using difference_type = std::ptrdiff_t; using size_type = std::size_t; using propagate_on_container_copy_assignment = false_type; using propagate_on_container_move_assignment = true_type; using propagate_on_container_swap = false_type; using is_always_equal = true_type; template<typename _Up> using rebind_alloc = allocator<_Up>; template<typename _Up> using rebind_traits = allocator_traits<allocator<_Up>>; static pointer allocate(allocator_type& __a, size_type __n) { return __a.allocate(__n); } static pointer allocate(allocator_type& __a, size_type __n, const_void_pointer __hint) { return __a.allocate(__n, __hint); } static void deallocate(allocator_type& __a, pointer __p, size_type __n) { __a.deallocate(__p, __n); } template<typename _Up, typename... _Args> static void construct(allocator_type& __a __attribute__((__unused__)), _Up* __p, _Args&&... __args) noexcept(std::is_nothrow_constructible<_Up, _Args...>::value) { __a.construct(__p, std::forward<_Args>(__args)...); } template<typename _Up> static void destroy(allocator_type& __a __attribute__((__unused__)), _Up* __p) noexcept(is_nothrow_destructible<_Up>::value) { __a.destroy(__p); } static size_type max_size(const allocator_type& __a __attribute__((__unused__))) noexcept { return __a.max_size(); } static allocator_type select_on_container_copy_construction(const allocator_type& __rhs) { return __rhs; } }; 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) { } template<typename _Alloc> 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; __do_alloc_on_copy(__one, __two, __pocca()); } template<typename _Alloc> constexpr _Alloc __alloc_on_copy(const _Alloc& __a) { typedef allocator_traits<_Alloc> __traits; return __traits::select_on_container_copy_construction(__a); } 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) { } template<typename _Alloc> constexpr inline void __alloc_on_move(_Alloc& __one, _Alloc& __two) { typedef allocator_traits<_Alloc> __traits; typedef typename __traits::propagate_on_container_move_assignment __pocma; __do_alloc_on_move(__one, __two, __pocma()); } 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) { } template<typename _Alloc> constexpr inline void __alloc_on_swap(_Alloc& __one, _Alloc& __two) { typedef allocator_traits<_Alloc> __traits; typedef typename __traits::propagate_on_container_swap __pocs; __do_alloc_on_swap(__one, __two, __pocs()); } 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 { }; template<typename _Alloc> struct __is_copy_insertable : __is_alloc_insertable_impl<_Alloc, typename _Alloc::value_type const&>::type { }; template<typename _Tp> struct __is_copy_insertable<allocator<_Tp>> : is_copy_constructible<_Tp> { }; template<typename _Alloc> struct __is_move_insertable : __is_alloc_insertable_impl<_Alloc, typename _Alloc::value_type>::type { }; template<typename _Tp> struct __is_move_insertable<allocator<_Tp>> : is_move_constructible<_Tp> { }; 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; template<typename _ForwardIterator, typename _Allocator> void _Destroy(_ForwardIterator __first, _ForwardIterator __last, _Allocator& __alloc) { for (; __first != __last; ++__first) allocator_traits<_Allocator>::destroy(__alloc, std::__addressof(*__first)); } template<typename _ForwardIterator, typename _Tp> inline void _Destroy(_ForwardIterator __first, _ForwardIterator __last, allocator<_Tp>&) { _Destroy(__first, __last); } } namespace __gnu_cxx __attribute__ ((__visibility__ ("default"))) { template<typename _Alloc, typename = typename _Alloc::value_type> struct __alloc_traits : std::allocator_traits<_Alloc> { typedef _Alloc allocator_type; typedef std::allocator_traits<_Alloc> _Base_type; typedef typename _Base_type::value_type value_type; typedef typename _Base_type::pointer pointer; typedef typename _Base_type::const_pointer const_pointer; typedef typename _Base_type::size_type size_type; typedef typename _Base_type::difference_type difference_type; typedef value_type& reference; typedef const value_type& const_reference; using _Base_type::allocate; using _Base_type::deallocate; using _Base_type::construct; using _Base_type::destroy; using _Base_type::max_size; private: template<typename _Ptr> using __is_custom_pointer = std::__and_<std::is_same<pointer, _Ptr>, std::__not_<std::is_pointer<_Ptr>>>; public: template<typename _Ptr, typename... _Args> static constexpr std::__enable_if_t<__is_custom_pointer<_Ptr>::value> construct(_Alloc& __a, _Ptr __p, _Args&&... __args) noexcept(noexcept(_Base_type::construct(__a, std::__to_address(__p), std::forward<_Args>(__args)...))) { _Base_type::construct(__a, std::__to_address(__p), std::forward<_Args>(__args)...); } template<typename _Ptr> static constexpr std::__enable_if_t<__is_custom_pointer<_Ptr>::value> destroy(_Alloc& __a, _Ptr __p) noexcept(noexcept(_Base_type::destroy(__a, std::__to_address(__p)))) { _Base_type::destroy(__a, std::__to_address(__p)); } static constexpr _Alloc _S_select_on_copy(const _Alloc& __a) { return _Base_type::select_on_container_copy_construction(__a); } static constexpr void _S_on_swap(_Alloc& __a, _Alloc& __b) { std::__alloc_on_swap(__a, __b); } static constexpr bool _S_propagate_on_copy_assign() { return _Base_type::propagate_on_container_copy_assignment::value; } static constexpr bool _S_propagate_on_move_assign() { return _Base_type::propagate_on_container_move_assignment::value; } static constexpr bool _S_propagate_on_swap() { return _Base_type::propagate_on_container_swap::value; } static constexpr bool _S_always_equal() { return _Base_type::is_always_equal::value; } static constexpr bool _S_nothrow_move() { return _S_propagate_on_move_assign() || _S_always_equal(); } template<typename _Tp> struct rebind { typedef typename _Base_type::template rebind_alloc<_Tp> other; }; }; } namespace std __attribute__ ((__visibility__ ("default"))) { namespace __cxx11 { template<typename _CharT, typename _Traits, typename _Alloc> class basic_string { typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template rebind<_CharT>::other _Char_alloc_type; typedef __gnu_cxx::__alloc_traits<_Char_alloc_type> _Alloc_traits; public: typedef _Traits traits_type; typedef typename _Traits::char_type value_type; typedef _Char_alloc_type allocator_type; typedef typename _Alloc_traits::size_type size_type; typedef typename _Alloc_traits::difference_type difference_type; typedef typename _Alloc_traits::reference reference; typedef typename _Alloc_traits::const_reference const_reference; typedef typename _Alloc_traits::pointer pointer; typedef typename _Alloc_traits::const_pointer const_pointer; typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator; typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string> const_iterator; typedef std::reverse_iterator<const_iterator> const_reverse_iterator; typedef std::reverse_iterator<iterator> reverse_iterator; static const size_type npos = static_cast<size_type>(-1); protected: typedef const_iterator __const_iterator; private: struct _Alloc_hider : allocator_type { _Alloc_hider(pointer __dat, const _Alloc& __a) : allocator_type(__a), _M_p(__dat) { } _Alloc_hider(pointer __dat, _Alloc&& __a = _Alloc()) : allocator_type(std::move(__a)), _M_p(__dat) { } pointer _M_p; }; _Alloc_hider _M_dataplus; size_type _M_string_length; enum { _S_local_capacity = 15 / sizeof(_CharT) }; union { _CharT _M_local_buf[_S_local_capacity + 1]; size_type _M_allocated_capacity; }; void _M_data(pointer __p) { _M_dataplus._M_p = __p; } void _M_length(size_type __length) { _M_string_length = __length; } pointer _M_data() const { return _M_dataplus._M_p; } pointer _M_local_data() { return std::pointer_traits<pointer>::pointer_to(*_M_local_buf); } const_pointer _M_local_data() const { return std::pointer_traits<const_pointer>::pointer_to(*_M_local_buf); } void _M_capacity(size_type __capacity) { _M_allocated_capacity = __capacity; } void _M_set_length(size_type __n) { _M_length(__n); traits_type::assign(_M_data()[__n], _CharT()); } bool _M_is_local() const { return _M_data() == _M_local_data(); } pointer _M_create(size_type&, size_type); void _M_dispose() { if (!_M_is_local()) _M_destroy(_M_allocated_capacity); } void _M_destroy(size_type __size) throw() { _Alloc_traits::deallocate(_M_get_allocator(), _M_data(), __size + 1); } template<typename _InIterator> void _M_construct_aux(_InIterator __beg, _InIterator __end, std::__false_type) { typedef typename iterator_traits<_InIterator>::iterator_category _Tag; _M_construct(__beg, __end, _Tag()); } template<typename _Integer> void _M_construct_aux(_Integer __beg, _Integer __end, std::__true_type) { _M_construct_aux_2(static_cast<size_type>(__beg), __end); } void _M_construct_aux_2(size_type __req, _CharT __c) { _M_construct(__req, __c); } template<typename _InIterator> void _M_construct(_InIterator __beg, _InIterator __end) { typedef typename std::__is_integer<_InIterator>::__type _Integral; _M_construct_aux(__beg, __end, _Integral()); } template<typename _InIterator> void _M_construct(_InIterator __beg, _InIterator __end, std::input_iterator_tag); template<typename _FwdIterator> void _M_construct(_FwdIterator __beg, _FwdIterator __end, std::forward_iterator_tag); void _M_construct(size_type __req, _CharT __c); allocator_type& _M_get_allocator() { return _M_dataplus; } const allocator_type& _M_get_allocator() const { return _M_dataplus; } private: size_type _M_check(size_type __pos, const char* __s) const { if (__pos > this->size()) __throw_out_of_range_fmt(("%s: __pos (which is %zu) > " "this->size() (which is %zu)") , __s, __pos, this->size()); return __pos; } void _M_check_length(size_type __n1, size_type __n2, const char* __s) const { if (this->max_size() - (this->size() - __n1) < __n2) __throw_length_error((__s)); } size_type _M_limit(size_type __pos, size_type __off) const noexcept { const bool __testoff = __off < this->size() - __pos; return __testoff ? __off : this->size() - __pos; } bool _M_disjunct(const _CharT* __s) const noexcept { return (less<const _CharT*>()(__s, _M_data()) || less<const _CharT*>()(_M_data() + this->size(), __s)); } static void _S_copy(_CharT* __d, const _CharT* __s, size_type __n) { if (__n == 1) traits_type::assign(*__d, *__s); else traits_type::copy(__d, __s, __n); } static void _S_move(_CharT* __d, const _CharT* __s, size_type __n) { if (__n == 1) traits_type::assign(*__d, *__s); else traits_type::move(__d, __s, __n); } static void _S_assign(_CharT* __d, size_type __n, _CharT __c) { if (__n == 1) traits_type::assign(*__d, __c); else traits_type::assign(__d, __n, __c); } template<class _Iterator> static void _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2) { for (; __k1 != __k2; ++__k1, (void)++__p) traits_type::assign(*__p, *__k1); } static void _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) noexcept { _S_copy_chars(__p, __k1.base(), __k2.base()); } static void _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2) noexcept { _S_copy_chars(__p, __k1.base(), __k2.base()); } static void _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) noexcept { _S_copy(__p, __k1, __k2 - __k1); } static void _S_copy_chars(_CharT* __p, const _CharT* __k1, const _CharT* __k2) noexcept { _S_copy(__p, __k1, __k2 - __k1); } static int _S_compare(size_type __n1, size_type __n2) noexcept { const difference_type __d = difference_type(__n1 - __n2); if (__d > __gnu_cxx::__numeric_traits<int>::__max) return __gnu_cxx::__numeric_traits<int>::__max; else if (__d < __gnu_cxx::__numeric_traits<int>::__min) return __gnu_cxx::__numeric_traits<int>::__min; else return int(__d); } void _M_assign(const basic_string&); void _M_mutate(size_type __pos, size_type __len1, const _CharT* __s, size_type __len2); void _M_erase(size_type __pos, size_type __n); public: basic_string() noexcept(is_nothrow_default_constructible<_Alloc>::value) : _M_dataplus(_M_local_data()) { _M_set_length(0); } explicit basic_string(const _Alloc& __a) noexcept : _M_dataplus(_M_local_data(), __a) { _M_set_length(0); } basic_string(const basic_string& __str) : _M_dataplus(_M_local_data(), _Alloc_traits::_S_select_on_copy(__str._M_get_allocator())) { _M_construct(__str._M_data(), __str._M_data() + __str.length()); } basic_string(const basic_string& __str, size_type __pos, const _Alloc& __a = _Alloc()) : _M_dataplus(_M_local_data(), __a) { const _CharT* __start = __str._M_data() + __str._M_check(__pos, "basic_string::basic_string"); _M_construct(__start, __start + __str._M_limit(__pos, npos)); } basic_string(const basic_string& __str, size_type __pos, size_type __n) : _M_dataplus(_M_local_data()) { const _CharT* __start = __str._M_data() + __str._M_check(__pos, "basic_string::basic_string"); _M_construct(__start, __start + __str._M_limit(__pos, __n)); } basic_string(const basic_string& __str, size_type __pos, size_type __n, const _Alloc& __a) : _M_dataplus(_M_local_data(), __a) { const _CharT* __start = __str._M_data() + __str._M_check(__pos, "string::string"); _M_construct(__start, __start + __str._M_limit(__pos, __n)); } basic_string(const _CharT* __s, size_type __n, const _Alloc& __a = _Alloc()) : _M_dataplus(_M_local_data(), __a) { _M_construct(__s, __s + __n); } basic_string(const _CharT* __s, const _Alloc& __a = _Alloc()) : _M_dataplus(_M_local_data(), __a) { _M_construct(__s, __s ? __s + traits_type::length(__s) : __s+npos); } basic_string(size_type __n, _CharT __c, const _Alloc& __a = _Alloc()) : _M_dataplus(_M_local_data(), __a) { _M_construct(__n, __c); } basic_string(basic_string&& __str) noexcept : _M_dataplus(_M_local_data(), std::move(__str._M_get_allocator())) { if (__str._M_is_local()) { traits_type::copy(_M_local_buf, __str._M_local_buf, _S_local_capacity + 1); } else { _M_data(__str._M_data()); _M_capacity(__str._M_allocated_capacity); } _M_length(__str.length()); __str._M_data(__str._M_local_data()); __str._M_set_length(0); } basic_string(initializer_list<_CharT> __l, const _Alloc& __a = _Alloc()) : _M_dataplus(_M_local_data(), __a) { _M_construct(__l.begin(), __l.end()); } basic_string(const basic_string& __str, const _Alloc& __a) : _M_dataplus(_M_local_data(), __a) { _M_construct(__str.begin(), __str.end()); } basic_string(basic_string&& __str, const _Alloc& __a) noexcept(_Alloc_traits::_S_always_equal()) : _M_dataplus(_M_local_data(), __a) { if (__str._M_is_local()) { traits_type::copy(_M_local_buf, __str._M_local_buf, _S_local_capacity + 1); _M_length(__str.length()); __str._M_set_length(0); } else if (_Alloc_traits::_S_always_equal() || __str.get_allocator() == __a) { _M_data(__str._M_data()); _M_length(__str.length()); _M_capacity(__str._M_allocated_capacity); __str._M_data(__str._M_local_buf); __str._M_set_length(0); } else _M_construct(__str.begin(), __str.end()); } template<typename _InputIterator, typename = std::_RequireInputIter<_InputIterator>> basic_string(_InputIterator __beg, _InputIterator __end, const _Alloc& __a = _Alloc()) : _M_dataplus(_M_local_data(), __a) { _M_construct(__beg, __end); } ~basic_string() { _M_dispose(); } basic_string& operator=(const basic_string& __str) { return this->assign(__str); } basic_string& operator=(const _CharT* __s) { return this->assign(__s); } basic_string& operator=(_CharT __c) { this->assign(1, __c); return *this; } basic_string& operator=(basic_string&& __str) noexcept(_Alloc_traits::_S_nothrow_move()) { if (!_M_is_local() && _Alloc_traits::_S_propagate_on_move_assign() && !_Alloc_traits::_S_always_equal() && _M_get_allocator() != __str._M_get_allocator()) { _M_destroy(_M_allocated_capacity); _M_data(_M_local_data()); _M_set_length(0); } std::__alloc_on_move(_M_get_allocator(), __str._M_get_allocator()); if (__str._M_is_local()) { if (__str.size()) this->_S_copy(_M_data(), __str._M_data(), __str.size()); _M_set_length(__str.size()); } else if (_Alloc_traits::_S_propagate_on_move_assign() || _Alloc_traits::_S_always_equal() || _M_get_allocator() == __str._M_get_allocator()) { pointer __data = nullptr; size_type __capacity; if (!_M_is_local()) { if (_Alloc_traits::_S_always_equal()) { __data = _M_data(); __capacity = _M_allocated_capacity; } else _M_destroy(_M_allocated_capacity); } _M_data(__str._M_data()); _M_length(__str.length()); _M_capacity(__str._M_allocated_capacity); if (__data) { __str._M_data(__data); __str._M_capacity(__capacity); } else __str._M_data(__str._M_local_buf); } else assign(__str); __str.clear(); return *this; } basic_string& operator=(initializer_list<_CharT> __l) { this->assign(__l.begin(), __l.size()); return *this; } iterator begin() noexcept { return iterator(_M_data()); } const_iterator begin() const noexcept { return const_iterator(_M_data()); } iterator end() noexcept { return iterator(_M_data() + this->size()); } const_iterator end() const noexcept { return const_iterator(_M_data() + this->size()); } reverse_iterator rbegin() noexcept { return reverse_iterator(this->end()); } const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(this->end()); } reverse_iterator rend() noexcept { return reverse_iterator(this->begin()); } const_reverse_iterator rend() const noexcept { return const_reverse_iterator(this->begin()); } const_iterator cbegin() const noexcept { return const_iterator(this->_M_data()); } const_iterator cend() const noexcept { return const_iterator(this->_M_data() + this->size()); } const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(this->end()); } const_reverse_iterator crend() const noexcept { return const_reverse_iterator(this->begin()); } public: size_type size() const noexcept { return _M_string_length; } size_type length() const noexcept { return _M_string_length; } size_type max_size() const noexcept { return (_Alloc_traits::max_size(_M_get_allocator()) - 1) / 2; } void resize(size_type __n, _CharT __c); void resize(size_type __n) { this->resize(__n, _CharT()); } void shrink_to_fit() noexcept { if (capacity() > size()) { try { reserve(0); } catch(...) { } } } size_type capacity() const noexcept { return _M_is_local() ? size_type(_S_local_capacity) : _M_allocated_capacity; } void reserve(size_type __res_arg = 0); void clear() noexcept { _M_set_length(0); } bool empty() const noexcept { return this->size() == 0; } const_reference operator[] (size_type __pos) const noexcept { ; return _M_data()[__pos]; } reference operator[](size_type __pos) { ; ; return _M_data()[__pos]; } const_reference at(size_type __n) const { if (__n >= this->size()) __throw_out_of_range_fmt(("basic_string::at: __n " "(which is %zu) >= this->size() " "(which is %zu)") , __n, this->size()); return _M_data()[__n]; } reference at(size_type __n) { if (__n >= size()) __throw_out_of_range_fmt(("basic_string::at: __n " "(which is %zu) >= this->size() " "(which is %zu)") , __n, this->size()); return _M_data()[__n]; } reference front() noexcept { ; return operator[](0); } const_reference front() const noexcept { ; return operator[](0); } reference back() noexcept { ; return operator[](this->size() - 1); } const_reference back() const noexcept { ; return operator[](this->size() - 1); } basic_string& operator+=(const basic_string& __str) { return this->append(__str); } basic_string& operator+=(const _CharT* __s) { return this->append(__s); } basic_string& operator+=(_CharT __c) { this->push_back(__c); return *this; } basic_string& operator+=(initializer_list<_CharT> __l) { return this->append(__l.begin(), __l.size()); } basic_string& append(const basic_string& __str) { return _M_append(__str._M_data(), __str.size()); } basic_string& append(const basic_string& __str, size_type __pos, size_type __n = npos) { return _M_append(__str._M_data() + __str._M_check(__pos, "basic_string::append"), __str._M_limit(__pos, __n)); } basic_string& append(const _CharT* __s, size_type __n) { ; _M_check_length(size_type(0), __n, "basic_string::append"); return _M_append(__s, __n); } basic_string& append(const _CharT* __s) { ; const size_type __n = traits_type::length(__s); _M_check_length(size_type(0), __n, "basic_string::append"); return _M_append(__s, __n); } basic_string& append(size_type __n, _CharT __c) { return _M_replace_aux(this->size(), size_type(0), __n, __c); } basic_string& append(initializer_list<_CharT> __l) { return this->append(__l.begin(), __l.size()); } template<class _InputIterator, typename = std::_RequireInputIter<_InputIterator>> basic_string& append(_InputIterator __first, _InputIterator __last) { return this->replace(end(), end(), __first, __last); } void push_back(_CharT __c) { const size_type __size = this->size(); if (__size + 1 > this->capacity()) this->_M_mutate(__size, size_type(0), 0, size_type(1)); traits_type::assign(this->_M_data()[__size], __c); this->_M_set_length(__size + 1); } basic_string& assign(const basic_string& __str) { if (_Alloc_traits::_S_propagate_on_copy_assign()) { if (!_Alloc_traits::_S_always_equal() && !_M_is_local() && _M_get_allocator() != __str._M_get_allocator()) { if (__str.size() <= _S_local_capacity) { _M_destroy(_M_allocated_capacity); _M_data(_M_local_data()); _M_set_length(0); } else { const auto __len = __str.size(); auto __alloc = __str._M_get_allocator(); auto __ptr = _Alloc_traits::allocate(__alloc, __len + 1); _M_destroy(_M_allocated_capacity); _M_data(__ptr); _M_capacity(__len); _M_set_length(__len); } } std::__alloc_on_copy(_M_get_allocator(), __str._M_get_allocator()); } this->_M_assign(__str); return *this; } basic_string& assign(basic_string&& __str) noexcept(_Alloc_traits::_S_nothrow_move()) { return *this = std::move(__str); } basic_string& assign(const basic_string& __str, size_type __pos, size_type __n = npos) { return _M_replace(size_type(0), this->size(), __str._M_data() + __str._M_check(__pos, "basic_string::assign"), __str._M_limit(__pos, __n)); } basic_string& assign(const _CharT* __s, size_type __n) { ; return _M_replace(size_type(0), this->size(), __s, __n); } basic_string& assign(const _CharT* __s) { ; return _M_replace(size_type(0), this->size(), __s, traits_type::length(__s)); } basic_string& assign(size_type __n, _CharT __c) { return _M_replace_aux(size_type(0), this->size(), __n, __c); } template<class _InputIterator, typename = std::_RequireInputIter<_InputIterator>> basic_string& assign(_InputIterator __first, _InputIterator __last) { return this->replace(begin(), end(), __first, __last); } basic_string& assign(initializer_list<_CharT> __l) { return this->assign(__l.begin(), __l.size()); } iterator insert(const_iterator __p, size_type __n, _CharT __c) { ; const size_type __pos = __p - begin(); this->replace(__p, __p, __n, __c); return iterator(this->_M_data() + __pos); } template<class _InputIterator, typename = std::_RequireInputIter<_InputIterator>> iterator insert(const_iterator __p, _InputIterator __beg, _InputIterator __end) { ; const size_type __pos = __p - begin(); this->replace(__p, __p, __beg, __end); return iterator(this->_M_data() + __pos); } iterator insert(const_iterator __p, initializer_list<_CharT> __l) { return this->insert(__p, __l.begin(), __l.end()); } basic_string& insert(size_type __pos1, const basic_string& __str) { return this->replace(__pos1, size_type(0), __str._M_data(), __str.size()); } basic_string& insert(size_type __pos1, const basic_string& __str, size_type __pos2, size_type __n = npos) { return this->replace(__pos1, size_type(0), __str._M_data() + __str._M_check(__pos2, "basic_string::insert"), __str._M_limit(__pos2, __n)); } basic_string& insert(size_type __pos, const _CharT* __s, size_type __n) { return this->replace(__pos, size_type(0), __s, __n); } basic_string& insert(size_type __pos, const _CharT* __s) { ; return this->replace(__pos, size_type(0), __s, traits_type::length(__s)); } basic_string& insert(size_type __pos, size_type __n, _CharT __c) { return _M_replace_aux(_M_check(__pos, "basic_string::insert"), size_type(0), __n, __c); } iterator insert(__const_iterator __p, _CharT __c) { ; const size_type __pos = __p - begin(); _M_replace_aux(__pos, size_type(0), size_type(1), __c); return iterator(_M_data() + __pos); } basic_string& erase(size_type __pos = 0, size_type __n = npos) { _M_check(__pos, "basic_string::erase"); if (__n == npos) this->_M_set_length(__pos); else if (__n != 0) this->_M_erase(__pos, _M_limit(__pos, __n)); return *this; } iterator erase(__const_iterator __position) { ; const size_type __pos = __position - begin(); this->_M_erase(__pos, size_type(1)); return iterator(_M_data() + __pos); } iterator erase(__const_iterator __first, __const_iterator __last) { ; const size_type __pos = __first - begin(); if (__last == end()) this->_M_set_length(__pos); else this->_M_erase(__pos, __last - __first); return iterator(this->_M_data() + __pos); } void pop_back() noexcept { ; _M_erase(size() - 1, 1); } basic_string& replace(size_type __pos, size_type __n, const basic_string& __str) { return this->replace(__pos, __n, __str._M_data(), __str.size()); } basic_string& replace(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2 = npos) { return this->replace(__pos1, __n1, __str._M_data() + __str._M_check(__pos2, "basic_string::replace"), __str._M_limit(__pos2, __n2)); } basic_string& replace(size_type __pos, size_type __n1, const _CharT* __s, size_type __n2) { ; return _M_replace(_M_check(__pos, "basic_string::replace"), _M_limit(__pos, __n1), __s, __n2); } basic_string& replace(size_type __pos, size_type __n1, const _CharT* __s) { ; return this->replace(__pos, __n1, __s, traits_type::length(__s)); } basic_string& replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c) { return _M_replace_aux(_M_check(__pos, "basic_string::replace"), _M_limit(__pos, __n1), __n2, __c); } basic_string& replace(__const_iterator __i1, __const_iterator __i2, const basic_string& __str) { return this->replace(__i1, __i2, __str._M_data(), __str.size()); } basic_string& replace(__const_iterator __i1, __const_iterator __i2, const _CharT* __s, size_type __n) { ; return this->replace(__i1 - begin(), __i2 - __i1, __s, __n); } basic_string& replace(__const_iterator __i1, __const_iterator __i2, const _CharT* __s) { ; return this->replace(__i1, __i2, __s, traits_type::length(__s)); } basic_string& replace(__const_iterator __i1, __const_iterator __i2, size_type __n, _CharT __c) { ; return _M_replace_aux(__i1 - begin(), __i2 - __i1, __n, __c); } template<class _InputIterator, typename = std::_RequireInputIter<_InputIterator>> basic_string& replace(const_iterator __i1, const_iterator __i2, _InputIterator __k1, _InputIterator __k2) { ; ; return this->_M_replace_dispatch(__i1, __i2, __k1, __k2, std::__false_type()); } basic_string& replace(__const_iterator __i1, __const_iterator __i2, _CharT* __k1, _CharT* __k2) { ; ; return this->replace(__i1 - begin(), __i2 - __i1, __k1, __k2 - __k1); } basic_string& replace(__const_iterator __i1, __const_iterator __i2, const _CharT* __k1, const _CharT* __k2) { ; ; return this->replace(__i1 - begin(), __i2 - __i1, __k1, __k2 - __k1); } basic_string& replace(__const_iterator __i1, __const_iterator __i2, iterator __k1, iterator __k2) { ; ; return this->replace(__i1 - begin(), __i2 - __i1, __k1.base(), __k2 - __k1); } basic_string& replace(__const_iterator __i1, __const_iterator __i2, const_iterator __k1, const_iterator __k2) { ; ; return this->replace(__i1 - begin(), __i2 - __i1, __k1.base(), __k2 - __k1); } basic_string& replace(const_iterator __i1, const_iterator __i2, initializer_list<_CharT> __l) { return this->replace(__i1, __i2, __l.begin(), __l.size()); } private: template<class _Integer> basic_string& _M_replace_dispatch(const_iterator __i1, const_iterator __i2, _Integer __n, _Integer __val, __true_type) { return _M_replace_aux(__i1 - begin(), __i2 - __i1, __n, __val); } template<class _InputIterator> basic_string& _M_replace_dispatch(const_iterator __i1, const_iterator __i2, _InputIterator __k1, _InputIterator __k2, __false_type); basic_string& _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2, _CharT __c); basic_string& _M_replace(size_type __pos, size_type __len1, const _CharT* __s, const size_type __len2); basic_string& _M_append(const _CharT* __s, size_type __n); public: size_type copy(_CharT* __s, size_type __n, size_type __pos = 0) const; void swap(basic_string& __s) noexcept; const _CharT* c_str() const noexcept { return _M_data(); } const _CharT* data() const noexcept { return _M_data(); } allocator_type get_allocator() const noexcept { return _M_get_allocator(); } size_type find(const _CharT* __s, size_type __pos, size_type __n) const noexcept; size_type find(const basic_string& __str, size_type __pos = 0) const noexcept { return this->find(__str.data(), __pos, __str.size()); } size_type find(const _CharT* __s, size_type __pos = 0) const noexcept { ; return this->find(__s, __pos, traits_type::length(__s)); } size_type find(_CharT __c, size_type __pos = 0) const noexcept; size_type rfind(const basic_string& __str, size_type __pos = npos) const noexcept { return this->rfind(__str.data(), __pos, __str.size()); } size_type rfind(const _CharT* __s, size_type __pos, size_type __n) const noexcept; size_type rfind(const _CharT* __s, size_type __pos = npos) const { ; return this->rfind(__s, __pos, traits_type::length(__s)); } size_type rfind(_CharT __c, size_type __pos = npos) const noexcept; size_type find_first_of(const basic_string& __str, size_type __pos = 0) const noexcept { return this->find_first_of(__str.data(), __pos, __str.size()); } size_type find_first_of(const _CharT* __s, size_type __pos, size_type __n) const noexcept; size_type find_first_of(const _CharT* __s, size_type __pos = 0) const noexcept { ; return this->find_first_of(__s, __pos, traits_type::length(__s)); } size_type find_first_of(_CharT __c, size_type __pos = 0) const noexcept { return this->find(__c, __pos); } size_type find_last_of(const basic_string& __str, size_type __pos = npos) const noexcept { return this->find_last_of(__str.data(), __pos, __str.size()); } size_type find_last_of(const _CharT* __s, size_type __pos, size_type __n) const noexcept; size_type find_last_of(const _CharT* __s, size_type __pos = npos) const noexcept { ; return this->find_last_of(__s, __pos, traits_type::length(__s)); } size_type find_last_of(_CharT __c, size_type __pos = npos) const noexcept { return this->rfind(__c, __pos); } size_type find_first_not_of(const basic_string& __str, size_type __pos = 0) const noexcept { return this->find_first_not_of(__str.data(), __pos, __str.size()); } size_type find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const noexcept; size_type find_first_not_of(const _CharT* __s, size_type __pos = 0) const noexcept { ; return this->find_first_not_of(__s, __pos, traits_type::length(__s)); } size_type find_first_not_of(_CharT __c, size_type __pos = 0) const noexcept; size_type find_last_not_of(const basic_string& __str, size_type __pos = npos) const noexcept { return this->find_last_not_of(__str.data(), __pos, __str.size()); } size_type find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const noexcept; size_type find_last_not_of(const _CharT* __s, size_type __pos = npos) const noexcept { ; return this->find_last_not_of(__s, __pos, traits_type::length(__s)); } size_type find_last_not_of(_CharT __c, size_type __pos = npos) const noexcept; basic_string substr(size_type __pos = 0, size_type __n = npos) const { return basic_string(*this, _M_check(__pos, "basic_string::substr"), __n); } int compare(const basic_string& __str) const { const size_type __size = this->size(); const size_type __osize = __str.size(); const size_type __len = std::min(__size, __osize); int __r = traits_type::compare(_M_data(), __str.data(), __len); if (!__r) __r = _S_compare(__size, __osize); return __r; } int compare(size_type __pos, size_type __n, const basic_string& __str) const; int compare(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2 = npos) const; int compare(const _CharT* __s) const noexcept; int compare(size_type __pos, size_type __n1, const _CharT* __s) const; int compare(size_type __pos, size_type __n1, const _CharT* __s, size_type __n2) const; template<typename, typename, typename> friend class basic_stringbuf; }; } template<typename _CharT, typename _Traits, typename _Alloc> basic_string<_CharT, _Traits, _Alloc> operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, const basic_string<_CharT, _Traits, _Alloc>& __rhs) { basic_string<_CharT, _Traits, _Alloc> __str(__lhs); __str.append(__rhs); return __str; } template<typename _CharT, typename _Traits, typename _Alloc> basic_string<_CharT,_Traits,_Alloc> operator+(const _CharT* __lhs, const basic_string<_CharT,_Traits,_Alloc>& __rhs); template<typename _CharT, typename _Traits, typename _Alloc> basic_string<_CharT,_Traits,_Alloc> operator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Alloc>& __rhs); template<typename _CharT, typename _Traits, typename _Alloc> inline basic_string<_CharT, _Traits, _Alloc> operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, const _CharT* __rhs) { basic_string<_CharT, _Traits, _Alloc> __str(__lhs); __str.append(__rhs); return __str; } template<typename _CharT, typename _Traits, typename _Alloc> inline basic_string<_CharT, _Traits, _Alloc> operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, _CharT __rhs) { typedef basic_string<_CharT, _Traits, _Alloc> __string_type; typedef typename __string_type::size_type __size_type; __string_type __str(__lhs); __str.append(__size_type(1), __rhs); return __str; } template<typename _CharT, typename _Traits, typename _Alloc> inline basic_string<_CharT, _Traits, _Alloc> operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, const basic_string<_CharT, _Traits, _Alloc>& __rhs) { return std::move(__lhs.append(__rhs)); } template<typename _CharT, typename _Traits, typename _Alloc> inline basic_string<_CharT, _Traits, _Alloc> operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, basic_string<_CharT, _Traits, _Alloc>&& __rhs) { return std::move(__rhs.insert(0, __lhs)); } template<typename _CharT, typename _Traits, typename _Alloc> inline basic_string<_CharT, _Traits, _Alloc> operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, basic_string<_CharT, _Traits, _Alloc>&& __rhs) { using _Alloc_traits = allocator_traits<_Alloc>; bool __use_rhs = false; if (typename _Alloc_traits::is_always_equal{}) __use_rhs = true; else if (__lhs.get_allocator() == __rhs.get_allocator()) __use_rhs = true; if (__use_rhs) { const auto __size = __lhs.size() + __rhs.size(); if (__size > __lhs.capacity() && __size <= __rhs.capacity()) return std::move(__rhs.insert(0, __lhs)); } return std::move(__lhs.append(__rhs)); } template<typename _CharT, typename _Traits, typename _Alloc> inline basic_string<_CharT, _Traits, _Alloc> operator+(const _CharT* __lhs, basic_string<_CharT, _Traits, _Alloc>&& __rhs) { return std::move(__rhs.insert(0, __lhs)); } template<typename _CharT, typename _Traits, typename _Alloc> inline basic_string<_CharT, _Traits, _Alloc> operator+(_CharT __lhs, basic_string<_CharT, _Traits, _Alloc>&& __rhs) { return std::move(__rhs.insert(0, 1, __lhs)); } template<typename _CharT, typename _Traits, typename _Alloc> inline basic_string<_CharT, _Traits, _Alloc> operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, const _CharT* __rhs) { return std::move(__lhs.append(__rhs)); } template<typename _CharT, typename _Traits, typename _Alloc> inline basic_string<_CharT, _Traits, _Alloc> operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, _CharT __rhs) { return std::move(__lhs.append(1, __rhs)); } template<typename _CharT, typename _Traits, typename _Alloc> inline bool operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs, const basic_string<_CharT, _Traits, _Alloc>& __rhs) noexcept { return __lhs.compare(__rhs) == 0; } template<typename _CharT> inline typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value, bool>::__type operator==(const basic_string<_CharT>& __lhs, const basic_string<_CharT>& __rhs) noexcept { return (__lhs.size() == __rhs.size() && !std::char_traits<_CharT>::compare(__lhs.data(), __rhs.data(), __lhs.size())); } template<typename _CharT, typename _Traits, typename _Alloc> inline bool operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs, const _CharT* __rhs) { return __lhs.compare(__rhs) == 0; } template<typename _CharT, typename _Traits, typename _Alloc> inline bool operator==(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Alloc>& __rhs) { return __rhs.compare(__lhs) == 0; } template<typename _CharT, typename _Traits, typename _Alloc> inline bool operator!=(const basic_string<_CharT, _Traits, _Alloc>& __lhs, const basic_string<_CharT, _Traits, _Alloc>& __rhs) noexcept { return !(__lhs == __rhs); } template<typename _CharT, typename _Traits, typename _Alloc> inline bool operator!=(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Alloc>& __rhs) { return !(__lhs == __rhs); } template<typename _CharT, typename _Traits, typename _Alloc> inline bool operator!=(const basic_string<_CharT, _Traits, _Alloc>& __lhs, const _CharT* __rhs) { return !(__lhs == __rhs); } template<typename _CharT, typename _Traits, typename _Alloc> inline bool operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs, const basic_string<_CharT, _Traits, _Alloc>& __rhs) noexcept { return __lhs.compare(__rhs) < 0; } template<typename _CharT, typename _Traits, typename _Alloc> inline bool operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs, const _CharT* __rhs) { return __lhs.compare(__rhs) < 0; } template<typename _CharT, typename _Traits, typename _Alloc> inline bool operator<(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Alloc>& __rhs) { return __rhs.compare(__lhs) > 0; } template<typename _CharT, typename _Traits, typename _Alloc> inline bool operator>(const basic_string<_CharT, _Traits, _Alloc>& __lhs, const basic_string<_CharT, _Traits, _Alloc>& __rhs) noexcept { return __lhs.compare(__rhs) > 0; } template<typename _CharT, typename _Traits, typename _Alloc> inline bool operator>(const basic_string<_CharT, _Traits, _Alloc>& __lhs, const _CharT* __rhs) { return __lhs.compare(__rhs) > 0; } template<typename _CharT, typename _Traits, typename _Alloc> inline bool operator>(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Alloc>& __rhs) { return __rhs.compare(__lhs) < 0; } template<typename _CharT, typename _Traits, typename _Alloc> inline bool operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs, const basic_string<_CharT, _Traits, _Alloc>& __rhs) noexcept { return __lhs.compare(__rhs) <= 0; } template<typename _CharT, typename _Traits, typename _Alloc> inline bool operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs, const _CharT* __rhs) { return __lhs.compare(__rhs) <= 0; } template<typename _CharT, typename _Traits, typename _Alloc> inline bool operator<=(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Alloc>& __rhs) { return __rhs.compare(__lhs) >= 0; } template<typename _CharT, typename _Traits, typename _Alloc> inline bool operator>=(const basic_string<_CharT, _Traits, _Alloc>& __lhs, const basic_string<_CharT, _Traits, _Alloc>& __rhs) noexcept { return __lhs.compare(__rhs) >= 0; } template<typename _CharT, typename _Traits, typename _Alloc> inline bool operator>=(const basic_string<_CharT, _Traits, _Alloc>& __lhs, const _CharT* __rhs) { return __lhs.compare(__rhs) >= 0; } template<typename _CharT, typename _Traits, typename _Alloc> inline bool operator>=(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Alloc>& __rhs) { return __rhs.compare(__lhs) <= 0; } template<typename _CharT, typename _Traits, typename _Alloc> inline void swap(basic_string<_CharT, _Traits, _Alloc>& __lhs, basic_string<_CharT, _Traits, _Alloc>& __rhs) noexcept(noexcept(__lhs.swap(__rhs))) { __lhs.swap(__rhs); } template<typename _CharT, typename _Traits, typename _Alloc> basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _Alloc>& __str); template<> basic_istream<char>& operator>>(basic_istream<char>& __is, basic_string<char>& __str); template<typename _CharT, typename _Traits, typename _Alloc> inline basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const basic_string<_CharT, _Traits, _Alloc>& __str) { return __ostream_insert(__os, __str.data(), __str.size()); } template<typename _CharT, typename _Traits, typename _Alloc> basic_istream<_CharT, _Traits>& getline(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _Alloc>& __str, _CharT __delim); template<typename _CharT, typename _Traits, typename _Alloc> inline basic_istream<_CharT, _Traits>& getline(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _Alloc>& __str) { return std::getline(__is, __str, __is.widen('\n')); } template<typename _CharT, typename _Traits, typename _Alloc> inline basic_istream<_CharT, _Traits>& getline(basic_istream<_CharT, _Traits>&& __is, basic_string<_CharT, _Traits, _Alloc>& __str, _CharT __delim) { return std::getline(__is, __str, __delim); } template<typename _CharT, typename _Traits, typename _Alloc> inline basic_istream<_CharT, _Traits>& getline(basic_istream<_CharT, _Traits>&& __is, basic_string<_CharT, _Traits, _Alloc>& __str) { return std::getline(__is, __str); } template<> basic_istream<char>& getline(basic_istream<char>& __in, basic_string<char>& __str, char __delim); template<> basic_istream<wchar_t>& getline(basic_istream<wchar_t>& __in, basic_string<wchar_t>& __str, wchar_t __delim); } extern "C" { typedef struct { int quot; int rem; } div_t; typedef struct { long int quot; long int rem; } ldiv_t; __extension__ typedef struct { long long int quot; long long int rem; } lldiv_t; extern size_t __ctype_get_mb_cur_max (void) throw () ; extern double atof (const char *__nptr) throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) ; extern int atoi (const char *__nptr) throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) ; extern long int atol (const char *__nptr) throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) ; __extension__ extern long long int atoll (const char *__nptr) throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) ; extern double strtod (const char *__restrict __nptr, char **__restrict __endptr) throw () __attribute__ ((__nonnull__ (1))); extern float strtof (const char *__restrict __nptr, char **__restrict __endptr) throw () __attribute__ ((__nonnull__ (1))); extern long double strtold (const char *__restrict __nptr, char **__restrict __endptr) throw () __attribute__ ((__nonnull__ (1))); extern _Float32 strtof32 (const char *__restrict __nptr, char **__restrict __endptr) throw () __attribute__ ((__nonnull__ (1))); extern _Float64 strtof64 (const char *__restrict __nptr, char **__restrict __endptr) throw () __attribute__ ((__nonnull__ (1))); extern _Float128 strtof128 (const char *__restrict __nptr, char **__restrict __endptr) throw () __attribute__ ((__nonnull__ (1))); extern _Float32x strtof32x (const char *__restrict __nptr, char **__restrict __endptr) throw () __attribute__ ((__nonnull__ (1))); extern _Float64x strtof64x (const char *__restrict __nptr, char **__restrict __endptr) throw () __attribute__ ((__nonnull__ (1))); extern long int strtol (const char *__restrict __nptr, char **__restrict __endptr, int __base) throw () __attribute__ ((__nonnull__ (1))); extern unsigned long int strtoul (const char *__restrict __nptr, char **__restrict __endptr, int __base) throw () __attribute__ ((__nonnull__ (1))); __extension__ extern long long int strtoq (const char *__restrict __nptr, char **__restrict __endptr, int __base) throw () __attribute__ ((__nonnull__ (1))); __extension__ extern unsigned long long int strtouq (const char *__restrict __nptr, char **__restrict __endptr, int __base) throw () __attribute__ ((__nonnull__ (1))); __extension__ extern long long int strtoll (const char *__restrict __nptr, char **__restrict __endptr, int __base) throw () __attribute__ ((__nonnull__ (1))); __extension__ extern unsigned long long int strtoull (const char *__restrict __nptr, char **__restrict __endptr, int __base) throw () __attribute__ ((__nonnull__ (1))); extern int strfromd (char *__dest, size_t __size, const char *__format, double __f) throw () __attribute__ ((__nonnull__ (3))); extern int strfromf (char *__dest, size_t __size, const char *__format, float __f) throw () __attribute__ ((__nonnull__ (3))); extern int strfroml (char *__dest, size_t __size, const char *__format, long double __f) throw () __attribute__ ((__nonnull__ (3))); extern int strfromf32 (char *__dest, size_t __size, const char * __format, _Float32 __f) throw () __attribute__ ((__nonnull__ (3))); extern int strfromf64 (char *__dest, size_t __size, const char * __format, _Float64 __f) throw () __attribute__ ((__nonnull__ (3))); extern int strfromf128 (char *__dest, size_t __size, const char * __format, _Float128 __f) throw () __attribute__ ((__nonnull__ (3))); extern int strfromf32x (char *__dest, size_t __size, const char * __format, _Float32x __f) throw () __attribute__ ((__nonnull__ (3))); extern int strfromf64x (char *__dest, size_t __size, const char * __format, _Float64x __f) throw () __attribute__ ((__nonnull__ (3))); extern long int strtol_l (const char *__restrict __nptr, char **__restrict __endptr, int __base, locale_t __loc) throw () __attribute__ ((__nonnull__ (1, 4))); extern unsigned long int strtoul_l (const char *__restrict __nptr, char **__restrict __endptr, int __base, locale_t __loc) throw () __attribute__ ((__nonnull__ (1, 4))); __extension__ extern long long int strtoll_l (const char *__restrict __nptr, char **__restrict __endptr, int __base, locale_t __loc) throw () __attribute__ ((__nonnull__ (1, 4))); __extension__ extern unsigned long long int strtoull_l (const char *__restrict __nptr, char **__restrict __endptr, int __base, locale_t __loc) throw () __attribute__ ((__nonnull__ (1, 4))); extern double strtod_l (const char *__restrict __nptr, char **__restrict __endptr, locale_t __loc) throw () __attribute__ ((__nonnull__ (1, 3))); extern float strtof_l (const char *__restrict __nptr, char **__restrict __endptr, locale_t __loc) throw () __attribute__ ((__nonnull__ (1, 3))); extern long double strtold_l (const char *__restrict __nptr, char **__restrict __endptr, locale_t __loc) throw () __attribute__ ((__nonnull__ (1, 3))); extern _Float32 strtof32_l (const char *__restrict __nptr, char **__restrict __endptr, locale_t __loc) throw () __attribute__ ((__nonnull__ (1, 3))); extern _Float64 strtof64_l (const char *__restrict __nptr, char **__restrict __endptr, locale_t __loc) throw () __attribute__ ((__nonnull__ (1, 3))); extern _Float128 strtof128_l (const char *__restrict __nptr, char **__restrict __endptr, locale_t __loc) throw () __attribute__ ((__nonnull__ (1, 3))); extern _Float32x strtof32x_l (const char *__restrict __nptr, char **__restrict __endptr, locale_t __loc) throw () __attribute__ ((__nonnull__ (1, 3))); extern _Float64x strtof64x_l (const char *__restrict __nptr, char **__restrict __endptr, locale_t __loc) throw () __attribute__ ((__nonnull__ (1, 3))); extern __inline __attribute__ ((__gnu_inline__)) int __attribute__ ((__leaf__)) atoi (const char *__nptr) throw () { return (int) strtol (__nptr, (char **) __null, 10); } extern __inline __attribute__ ((__gnu_inline__)) long int __attribute__ ((__leaf__)) atol (const char *__nptr) throw () { return strtol (__nptr, (char **) __null, 10); } __extension__ extern __inline __attribute__ ((__gnu_inline__)) long long int __attribute__ ((__leaf__)) atoll (const char *__nptr) throw () { return strtoll (__nptr, (char **) __null, 10); } extern char *l64a (long int __n) throw () ; extern long int a64l (const char *__s) throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) ; extern "C" { typedef __u_char u_char; typedef __u_short u_short; typedef __u_int u_int; typedef __u_long u_long; typedef __quad_t quad_t; typedef __u_quad_t u_quad_t; typedef __fsid_t fsid_t; typedef __loff_t loff_t; typedef __ino_t ino_t; typedef __ino64_t ino64_t; typedef __dev_t dev_t; typedef __gid_t gid_t; typedef __mode_t mode_t; typedef __nlink_t nlink_t; typedef __uid_t uid_t; typedef __off_t off_t; typedef __off64_t off64_t; typedef __id_t id_t; typedef __ssize_t ssize_t; typedef __daddr_t daddr_t; typedef __caddr_t caddr_t; typedef __key_t key_t; typedef __useconds_t useconds_t; typedef __suseconds_t suseconds_t; typedef unsigned long int ulong; typedef unsigned short int ushort; typedef unsigned int uint; typedef __uint8_t u_int8_t; typedef __uint16_t u_int16_t; typedef __uint32_t u_int32_t; typedef __uint64_t u_int64_t; typedef int register_t __attribute__ ((__mode__ (__word__))); static __inline __uint16_t __bswap_16 (__uint16_t __bsx) { return __builtin_bswap16 (__bsx); } static __inline __uint32_t __bswap_32 (__uint32_t __bsx) { return __builtin_bswap32 (__bsx); } __extension__ static __inline __uint64_t __bswap_64 (__uint64_t __bsx) { return __builtin_bswap64 (__bsx); } static __inline __uint16_t __uint16_identity (__uint16_t __x) { return __x; } static __inline __uint32_t __uint32_identity (__uint32_t __x) { return __x; } static __inline __uint64_t __uint64_identity (__uint64_t __x) { return __x; } typedef struct { unsigned long int __val[(1024 / (8 * sizeof (unsigned long int)))]; } __sigset_t; typedef __sigset_t sigset_t; typedef long int __fd_mask; typedef struct { __fd_mask fds_bits[1024 / (8 * (int) sizeof (__fd_mask))]; } fd_set; typedef __fd_mask fd_mask; extern "C" { extern int select (int __nfds, fd_set *__restrict __readfds, fd_set *__restrict __writefds, fd_set *__restrict __exceptfds, struct timeval *__restrict __timeout); extern int pselect (int __nfds, fd_set *__restrict __readfds, fd_set *__restrict __writefds, fd_set *__restrict __exceptfds, const struct timespec *__restrict __timeout, const __sigset_t *__restrict __sigmask); } typedef __blksize_t blksize_t; typedef __blkcnt_t blkcnt_t; typedef __fsblkcnt_t fsblkcnt_t; typedef __fsfilcnt_t fsfilcnt_t; typedef __blkcnt64_t blkcnt64_t; typedef __fsblkcnt64_t fsblkcnt64_t; typedef __fsfilcnt64_t fsfilcnt64_t; } extern long int random (void) throw (); extern void srandom (unsigned int __seed) throw (); extern char *initstate (unsigned int __seed, char *__statebuf, size_t __statelen) throw () __attribute__ ((__nonnull__ (2))); extern char *setstate (char *__statebuf) throw () __attribute__ ((__nonnull__ (1))); struct random_data { int32_t *fptr; int32_t *rptr; int32_t *state; int rand_type; int rand_deg; int rand_sep; int32_t *end_ptr; }; extern int random_r (struct random_data *__restrict __buf, int32_t *__restrict __result) throw () __attribute__ ((__nonnull__ (1, 2))); extern int srandom_r (unsigned int __seed, struct random_data *__buf) throw () __attribute__ ((__nonnull__ (2))); extern int initstate_r (unsigned int __seed, char *__restrict __statebuf, size_t __statelen, struct random_data *__restrict __buf) throw () __attribute__ ((__nonnull__ (2, 4))); extern int setstate_r (char *__restrict __statebuf, struct random_data *__restrict __buf) throw () __attribute__ ((__nonnull__ (1, 2))); extern int rand (void) throw (); extern void srand (unsigned int __seed) throw (); extern int rand_r (unsigned int *__seed) throw (); extern double drand48 (void) throw (); extern double erand48 (unsigned short int __xsubi[3]) throw () __attribute__ ((__nonnull__ (1))); extern long int lrand48 (void) throw (); extern long int nrand48 (unsigned short int __xsubi[3]) throw () __attribute__ ((__nonnull__ (1))); extern long int mrand48 (void) throw (); extern long int jrand48 (unsigned short int __xsubi[3]) throw () __attribute__ ((__nonnull__ (1))); extern void srand48 (long int __seedval) throw (); extern unsigned short int *seed48 (unsigned short int __seed16v[3]) throw () __attribute__ ((__nonnull__ (1))); extern void lcong48 (unsigned short int __param[7]) throw () __attribute__ ((__nonnull__ (1))); struct drand48_data { unsigned short int __x[3]; unsigned short int __old_x[3]; unsigned short int __c; unsigned short int __init; __extension__ unsigned long long int __a; }; extern int drand48_r (struct drand48_data *__restrict __buffer, double *__restrict __result) throw () __attribute__ ((__nonnull__ (1, 2))); extern int erand48_r (unsigned short int __xsubi[3], struct drand48_data *__restrict __buffer, double *__restrict __result) throw () __attribute__ ((__nonnull__ (1, 2))); extern int lrand48_r (struct drand48_data *__restrict __buffer, long int *__restrict __result) throw () __attribute__ ((__nonnull__ (1, 2))); extern int nrand48_r (unsigned short int __xsubi[3], struct drand48_data *__restrict __buffer, long int *__restrict __result) throw () __attribute__ ((__nonnull__ (1, 2))); extern int mrand48_r (struct drand48_data *__restrict __buffer, long int *__restrict __result) throw () __attribute__ ((__nonnull__ (1, 2))); extern int jrand48_r (unsigned short int __xsubi[3], struct drand48_data *__restrict __buffer, long int *__restrict __result) throw () __attribute__ ((__nonnull__ (1, 2))); extern int srand48_r (long int __seedval, struct drand48_data *__buffer) throw () __attribute__ ((__nonnull__ (2))); extern int seed48_r (unsigned short int __seed16v[3], struct drand48_data *__buffer) throw () __attribute__ ((__nonnull__ (1, 2))); extern int lcong48_r (unsigned short int __param[7], struct drand48_data *__buffer) throw () __attribute__ ((__nonnull__ (1, 2))); extern void *malloc (size_t __size) throw () __attribute__ ((__malloc__)) __attribute__ ((__alloc_size__ (1))) ; extern void *calloc (size_t __nmemb, size_t __size) throw () __attribute__ ((__malloc__)) __attribute__ ((__alloc_size__ (1, 2))) ; extern void *realloc (void *__ptr, size_t __size) throw () __attribute__ ((__warn_unused_result__)) __attribute__ ((__alloc_size__ (2))); extern void *reallocarray (void *__ptr, size_t __nmemb, size_t __size) throw () __attribute__ ((__warn_unused_result__)) __attribute__ ((__alloc_size__ (2, 3))); extern void free (void *__ptr) throw (); extern "C" { extern void *alloca (size_t __size) throw (); } extern void *valloc (size_t __size) throw () __attribute__ ((__malloc__)) __attribute__ ((__alloc_size__ (1))) ; extern int posix_memalign (void **__memptr, size_t __alignment, size_t __size) throw () __attribute__ ((__nonnull__ (1))) ; extern void *aligned_alloc (size_t __alignment, size_t __size) throw () __attribute__ ((__malloc__)) __attribute__ ((__alloc_size__ (2))) ; extern void abort (void) throw () __attribute__ ((__noreturn__)); extern int atexit (void (*__func) (void)) throw () __attribute__ ((__nonnull__ (1))); extern "C++" int at_quick_exit (void (*__func) (void)) throw () __asm ("at_quick_exit") __attribute__ ((__nonnull__ (1))); extern int on_exit (void (*__func) (int __status, void *__arg), void *__arg) throw () __attribute__ ((__nonnull__ (1))); extern void exit (int __status) throw () __attribute__ ((__noreturn__)); extern void quick_exit (int __status) throw () __attribute__ ((__noreturn__)); extern void _Exit (int __status) throw () __attribute__ ((__noreturn__)); extern char *getenv (const char *__name) throw () __attribute__ ((__nonnull__ (1))) ; extern char *secure_getenv (const char *__name) throw () __attribute__ ((__nonnull__ (1))) ; extern int putenv (char *__string) throw () __attribute__ ((__nonnull__ (1))); extern int setenv (const char *__name, const char *__value, int __replace) throw () __attribute__ ((__nonnull__ (2))); extern int unsetenv (const char *__name) throw () __attribute__ ((__nonnull__ (1))); extern int clearenv (void) throw (); extern char *mktemp (char *__template) throw () __attribute__ ((__nonnull__ (1))); extern int mkstemp (char *__template) __attribute__ ((__nonnull__ (1))) ; extern int mkstemp64 (char *__template) __attribute__ ((__nonnull__ (1))) ; extern int mkstemps (char *__template, int __suffixlen) __attribute__ ((__nonnull__ (1))) ; extern int mkstemps64 (char *__template, int __suffixlen) __attribute__ ((__nonnull__ (1))) ; extern char *mkdtemp (char *__template) throw () __attribute__ ((__nonnull__ (1))) ; extern int mkostemp (char *__template, int __flags) __attribute__ ((__nonnull__ (1))) ; extern int mkostemp64 (char *__template, int __flags) __attribute__ ((__nonnull__ (1))) ; extern int mkostemps (char *__template, int __suffixlen, int __flags) __attribute__ ((__nonnull__ (1))) ; extern int mkostemps64 (char *__template, int __suffixlen, int __flags) __attribute__ ((__nonnull__ (1))) ; extern int system (const char *__command) ; extern char *canonicalize_file_name (const char *__name) throw () __attribute__ ((__nonnull__ (1))) ; extern char *realpath (const char *__restrict __name, char *__restrict __resolved) throw () ; typedef int (*__compar_fn_t) (const void *, const void *); typedef __compar_fn_t comparison_fn_t; typedef int (*__compar_d_fn_t) (const void *, const void *, void *); extern void *bsearch (const void *__key, const void *__base, size_t __nmemb, size_t __size, __compar_fn_t __compar) __attribute__ ((__nonnull__ (1, 2, 5))) ; extern __inline __attribute__ ((__gnu_inline__)) void * bsearch (const void *__key, const void *__base, size_t __nmemb, size_t __size, __compar_fn_t __compar) { size_t __l, __u, __idx; const void *__p; int __comparison; __l = 0; __u = __nmemb; while (__l < __u) { __idx = (__l + __u) / 2; __p = (void *) (((const char *) __base) + (__idx * __size)); __comparison = (*__compar) (__key, __p); if (__comparison < 0) __u = __idx; else if (__comparison > 0) __l = __idx + 1; else return (void *) __p; } return __null; } extern void qsort (void *__base, size_t __nmemb, size_t __size, __compar_fn_t __compar) __attribute__ ((__nonnull__ (1, 4))); extern void qsort_r (void *__base, size_t __nmemb, size_t __size, __compar_d_fn_t __compar, void *__arg) __attribute__ ((__nonnull__ (1, 4))); extern int abs (int __x) throw () __attribute__ ((__const__)) ; extern long int labs (long int __x) throw () __attribute__ ((__const__)) ; __extension__ extern long long int llabs (long long int __x) throw () __attribute__ ((__const__)) ; extern div_t div (int __numer, int __denom) throw () __attribute__ ((__const__)) ; extern ldiv_t ldiv (long int __numer, long int __denom) throw () __attribute__ ((__const__)) ; __extension__ extern lldiv_t lldiv (long long int __numer, long long int __denom) throw () __attribute__ ((__const__)) ; extern char *ecvt (double __value, int __ndigit, int *__restrict __decpt, int *__restrict __sign) throw () __attribute__ ((__nonnull__ (3, 4))) ; extern char *fcvt (double __value, int __ndigit, int *__restrict __decpt, int *__restrict __sign) throw () __attribute__ ((__nonnull__ (3, 4))) ; extern char *gcvt (double __value, int __ndigit, char *__buf) throw () __attribute__ ((__nonnull__ (3))) ; extern char *qecvt (long double __value, int __ndigit, int *__restrict __decpt, int *__restrict __sign) throw () __attribute__ ((__nonnull__ (3, 4))) ; extern char *qfcvt (long double __value, int __ndigit, int *__restrict __decpt, int *__restrict __sign) throw () __attribute__ ((__nonnull__ (3, 4))) ; extern char *qgcvt (long double __value, int __ndigit, char *__buf) throw () __attribute__ ((__nonnull__ (3))) ; extern int ecvt_r (double __value, int __ndigit, int *__restrict __decpt, int *__restrict __sign, char *__restrict __buf, size_t __len) throw () __attribute__ ((__nonnull__ (3, 4, 5))); extern int fcvt_r (double __value, int __ndigit, int *__restrict __decpt, int *__restrict __sign, char *__restrict __buf, size_t __len) throw () __attribute__ ((__nonnull__ (3, 4, 5))); extern int qecvt_r (long double __value, int __ndigit, int *__restrict __decpt, int *__restrict __sign, char *__restrict __buf, size_t __len) throw () __attribute__ ((__nonnull__ (3, 4, 5))); extern int qfcvt_r (long double __value, int __ndigit, int *__restrict __decpt, int *__restrict __sign, char *__restrict __buf, size_t __len) throw () __attribute__ ((__nonnull__ (3, 4, 5))); extern int mblen (const char *__s, size_t __n) throw (); extern int mbtowc (wchar_t *__restrict __pwc, const char *__restrict __s, size_t __n) throw (); extern int wctomb (char *__s, wchar_t __wchar) throw (); extern size_t mbstowcs (wchar_t *__restrict __pwcs, const char *__restrict __s, size_t __n) throw (); extern size_t wcstombs (char *__restrict __s, const wchar_t *__restrict __pwcs, size_t __n) throw (); extern int rpmatch (const char *__response) throw () __attribute__ ((__nonnull__ (1))) ; extern int getsubopt (char **__restrict __optionp, char *const *__restrict __tokens, char **__restrict __valuep) throw () __attribute__ ((__nonnull__ (1, 2, 3))) ; extern int posix_openpt (int __oflag) ; extern int grantpt (int __fd) throw (); extern int unlockpt (int __fd) throw (); extern char *ptsname (int __fd) throw () ; extern int ptsname_r (int __fd, char *__buf, size_t __buflen) throw () __attribute__ ((__nonnull__ (2))); extern int getpt (void); extern int getloadavg (double __loadavg[], int __nelem) throw () __attribute__ ((__nonnull__ (1))); extern __inline __attribute__ ((__gnu_inline__)) double __attribute__ ((__leaf__)) atof (const char *__nptr) throw () { return strtod (__nptr, (char **) __null); } } extern "C++" { namespace std __attribute__ ((__visibility__ ("default"))) { using ::abs; inline long abs(long __i) { return __builtin_labs(__i); } inline long long abs(long long __x) { return __builtin_llabs (__x); } inline constexpr double abs(double __x) { return __builtin_fabs(__x); } inline constexpr float abs(float __x) { return __builtin_fabsf(__x); } inline constexpr long double abs(long double __x) { return __builtin_fabsl(__x); } inline constexpr __int128 abs(__int128 __x) { return __x >= 0 ? __x : -__x; } inline constexpr __float128 abs(__float128 __x) { return __x < 0 ? -__x : __x; } } } extern "C++" { namespace std __attribute__ ((__visibility__ ("default"))) { using ::div_t; using ::ldiv_t; using ::abort; using ::atexit; using ::at_quick_exit; using ::atof; using ::atoi; using ::atol; using ::bsearch; using ::calloc; using ::div; using ::exit; using ::free; using ::getenv; using ::labs; using ::ldiv; using ::malloc; using ::mblen; using ::mbstowcs; using ::mbtowc; using ::qsort; using ::quick_exit; using ::rand; using ::realloc; using ::srand; using ::strtod; using ::strtol; using ::strtoul; using ::system; using ::wcstombs; using ::wctomb; inline ldiv_t div(long __i, long __j) { return ldiv(__i, __j); } } namespace __gnu_cxx __attribute__ ((__visibility__ ("default"))) { using ::lldiv_t; using ::_Exit; using ::llabs; inline lldiv_t div(long long __n, long long __d) { lldiv_t __q; __q.quot = __n / __d; __q.rem = __n % __d; return __q; } using ::lldiv; using ::atoll; using ::strtoll; using ::strtoull; using ::strtof; using ::strtold; } namespace std { using ::__gnu_cxx::lldiv_t; using ::__gnu_cxx::_Exit; using ::__gnu_cxx::llabs; using ::__gnu_cxx::div; using ::__gnu_cxx::lldiv; using ::__gnu_cxx::atoll; using ::__gnu_cxx::strtof; using ::__gnu_cxx::strtoll; using ::__gnu_cxx::strtoull; using ::__gnu_cxx::strtold; } } extern "C" { typedef struct _G_fpos_t { __off_t __pos; __mbstate_t __state; } __fpos_t; typedef struct _G_fpos64_t { __off64_t __pos; __mbstate_t __state; } __fpos64_t; struct _IO_FILE; struct _IO_marker; struct _IO_codecvt; struct _IO_wide_data; typedef void _IO_lock_t; struct _IO_FILE { int _flags; char *_IO_read_ptr; char *_IO_read_end; char *_IO_read_base; char *_IO_write_base; char *_IO_write_ptr; char *_IO_write_end; char *_IO_buf_base; char *_IO_buf_end; char *_IO_save_base; char *_IO_backup_base; char *_IO_save_end; struct _IO_marker *_markers; struct _IO_FILE *_chain; int _fileno; int _flags2; __off_t _old_offset; unsigned short _cur_column; signed char _vtable_offset; char _shortbuf[1]; _IO_lock_t *_lock; __off64_t _offset; struct _IO_codecvt *_codecvt; struct _IO_wide_data *_wide_data; struct _IO_FILE *_freeres_list; void *_freeres_buf; size_t __pad5; int _mode; char _unused2[15 * sizeof (int) - 4 * sizeof (void *) - sizeof (size_t)]; }; typedef __ssize_t cookie_read_function_t (void *__cookie, char *__buf, size_t __nbytes); typedef __ssize_t cookie_write_function_t (void *__cookie, const char *__buf, size_t __nbytes); typedef int cookie_seek_function_t (void *__cookie, __off64_t *__pos, int __w); typedef int cookie_close_function_t (void *__cookie); typedef struct _IO_cookie_io_functions_t { cookie_read_function_t *read; cookie_write_function_t *write; cookie_seek_function_t *seek; cookie_close_function_t *close; } cookie_io_functions_t; typedef __gnuc_va_list va_list; typedef __fpos_t fpos_t; typedef __fpos64_t fpos64_t; extern FILE *stdin; extern FILE *stdout; extern FILE *stderr; extern int remove (const char *__filename) throw (); extern int rename (const char *__old, const char *__new) throw (); extern int renameat (int __oldfd, const char *__old, int __newfd, const char *__new) throw (); extern int renameat2 (int __oldfd, const char *__old, int __newfd, const char *__new, unsigned int __flags) throw (); extern FILE *tmpfile (void) ; extern FILE *tmpfile64 (void) ; extern char *tmpnam (char *__s) throw () ; extern char *tmpnam_r (char *__s) throw () ; extern char *tempnam (const char *__dir, const char *__pfx) throw () __attribute__ ((__malloc__)) ; extern int fclose (FILE *__stream); extern int fflush (FILE *__stream); extern int fflush_unlocked (FILE *__stream); extern int fcloseall (void); extern FILE *fopen (const char *__restrict __filename, const char *__restrict __modes) ; extern FILE *freopen (const char *__restrict __filename, const char *__restrict __modes, FILE *__restrict __stream) ; extern FILE *fopen64 (const char *__restrict __filename, const char *__restrict __modes) ; extern FILE *freopen64 (const char *__restrict __filename, const char *__restrict __modes, FILE *__restrict __stream) ; extern FILE *fdopen (int __fd, const char *__modes) throw () ; extern FILE *fopencookie (void *__restrict __magic_cookie, const char *__restrict __modes, cookie_io_functions_t __io_funcs) throw () ; extern FILE *fmemopen (void *__s, size_t __len, const char *__modes) throw () ; extern FILE *open_memstream (char **__bufloc, size_t *__sizeloc) throw () ; extern void setbuf (FILE *__restrict __stream, char *__restrict __buf) throw (); extern int setvbuf (FILE *__restrict __stream, char *__restrict __buf, int __modes, size_t __n) throw (); extern void setbuffer (FILE *__restrict __stream, char *__restrict __buf, size_t __size) throw (); extern void setlinebuf (FILE *__stream) throw (); extern int fprintf (FILE *__restrict __stream, const char *__restrict __format, ...); extern int printf (const char *__restrict __format, ...); extern int sprintf (char *__restrict __s, const char *__restrict __format, ...) throw (); extern int vfprintf (FILE *__restrict __s, const char *__restrict __format, __gnuc_va_list __arg); extern int vprintf (const char *__restrict __format, __gnuc_va_list __arg); extern int vsprintf (char *__restrict __s, const char *__restrict __format, __gnuc_va_list __arg) throw (); extern int snprintf (char *__restrict __s, size_t __maxlen, const char *__restrict __format, ...) throw () __attribute__ ((__format__ (__printf__, 3, 4))); extern int vsnprintf (char *__restrict __s, size_t __maxlen, const char *__restrict __format, __gnuc_va_list __arg) throw () __attribute__ ((__format__ (__printf__, 3, 0))); extern int vasprintf (char **__restrict __ptr, const char *__restrict __f, __gnuc_va_list __arg) throw () __attribute__ ((__format__ (__printf__, 2, 0))) ; extern int __asprintf (char **__restrict __ptr, const char *__restrict __fmt, ...) throw () __attribute__ ((__format__ (__printf__, 2, 3))) ; extern int asprintf (char **__restrict __ptr, const char *__restrict __fmt, ...) throw () __attribute__ ((__format__ (__printf__, 2, 3))) ; extern int vdprintf (int __fd, const char *__restrict __fmt, __gnuc_va_list __arg) __attribute__ ((__format__ (__printf__, 2, 0))); extern int dprintf (int __fd, const char *__restrict __fmt, ...) __attribute__ ((__format__ (__printf__, 2, 3))); extern int fscanf (FILE *__restrict __stream, const char *__restrict __format, ...) ; extern int scanf (const char *__restrict __format, ...) ; extern int sscanf (const char *__restrict __s, const char *__restrict __format, ...) throw (); extern int fscanf (FILE *__restrict __stream, const char *__restrict __format, ...) __asm__ ("" "__isoc99_fscanf") ; extern int scanf (const char *__restrict __format, ...) __asm__ ("" "__isoc99_scanf") ; extern int sscanf (const char *__restrict __s, const char *__restrict __format, ...) throw () __asm__ ("" "__isoc99_sscanf") ; extern int vfscanf (FILE *__restrict __s, const char *__restrict __format, __gnuc_va_list __arg) __attribute__ ((__format__ (__scanf__, 2, 0))) ; extern int vscanf (const char *__restrict __format, __gnuc_va_list __arg) __attribute__ ((__format__ (__scanf__, 1, 0))) ; extern int vsscanf (const char *__restrict __s, const char *__restrict __format, __gnuc_va_list __arg) throw () __attribute__ ((__format__ (__scanf__, 2, 0))); extern int vfscanf (FILE *__restrict __s, const char *__restrict __format, __gnuc_va_list __arg) __asm__ ("" "__isoc99_vfscanf") __attribute__ ((__format__ (__scanf__, 2, 0))) ; extern int vscanf (const char *__restrict __format, __gnuc_va_list __arg) __asm__ ("" "__isoc99_vscanf") __attribute__ ((__format__ (__scanf__, 1, 0))) ; extern int vsscanf (const char *__restrict __s, const char *__restrict __format, __gnuc_va_list __arg) throw () __asm__ ("" "__isoc99_vsscanf") __attribute__ ((__format__ (__scanf__, 2, 0))); extern int fgetc (FILE *__stream); extern int getc (FILE *__stream); extern int getchar (void); extern int getc_unlocked (FILE *__stream); extern int getchar_unlocked (void); extern int fgetc_unlocked (FILE *__stream); extern int fputc (int __c, FILE *__stream); extern int putc (int __c, FILE *__stream); extern int putchar (int __c); extern int fputc_unlocked (int __c, FILE *__stream); extern int putc_unlocked (int __c, FILE *__stream); extern int putchar_unlocked (int __c); extern int getw (FILE *__stream); extern int putw (int __w, FILE *__stream); extern char *fgets (char *__restrict __s, int __n, FILE *__restrict __stream) ; extern char *fgets_unlocked (char *__restrict __s, int __n, FILE *__restrict __stream) ; extern __ssize_t __getdelim (char **__restrict __lineptr, size_t *__restrict __n, int __delimiter, FILE *__restrict __stream) ; extern __ssize_t getdelim (char **__restrict __lineptr, size_t *__restrict __n, int __delimiter, FILE *__restrict __stream) ; extern __ssize_t getline (char **__restrict __lineptr, size_t *__restrict __n, FILE *__restrict __stream) ; extern int fputs (const char *__restrict __s, FILE *__restrict __stream); extern int puts (const char *__s); extern int ungetc (int __c, FILE *__stream); extern size_t fread (void *__restrict __ptr, size_t __size, size_t __n, FILE *__restrict __stream) ; extern size_t fwrite (const void *__restrict __ptr, size_t __size, size_t __n, FILE *__restrict __s); extern int fputs_unlocked (const char *__restrict __s, FILE *__restrict __stream); extern size_t fread_unlocked (void *__restrict __ptr, size_t __size, size_t __n, FILE *__restrict __stream) ; extern size_t fwrite_unlocked (const void *__restrict __ptr, size_t __size, size_t __n, FILE *__restrict __stream); extern int fseek (FILE *__stream, long int __off, int __whence); extern long int ftell (FILE *__stream) ; extern void rewind (FILE *__stream); extern int fseeko (FILE *__stream, __off_t __off, int __whence); extern __off_t ftello (FILE *__stream) ; extern int fgetpos (FILE *__restrict __stream, fpos_t *__restrict __pos); extern int fsetpos (FILE *__stream, const fpos_t *__pos); extern int fseeko64 (FILE *__stream, __off64_t __off, int __whence); extern __off64_t ftello64 (FILE *__stream) ; extern int fgetpos64 (FILE *__restrict __stream, fpos64_t *__restrict __pos); extern int fsetpos64 (FILE *__stream, const fpos64_t *__pos); extern void clearerr (FILE *__stream) throw (); extern int feof (FILE *__stream) throw () ; extern int ferror (FILE *__stream) throw () ; extern void clearerr_unlocked (FILE *__stream) throw (); extern int feof_unlocked (FILE *__stream) throw () ; extern int ferror_unlocked (FILE *__stream) throw () ; extern void perror (const char *__s); extern int sys_nerr; extern const char *const sys_errlist[]; extern int _sys_nerr; extern const char *const _sys_errlist[]; extern int fileno (FILE *__stream) throw () ; extern int fileno_unlocked (FILE *__stream) throw () ; extern FILE *popen (const char *__command, const char *__modes) ; extern int pclose (FILE *__stream); extern char *ctermid (char *__s) throw (); extern char *cuserid (char *__s); struct obstack; extern int obstack_printf (struct obstack *__restrict __obstack, const char *__restrict __format, ...) throw () __attribute__ ((__format__ (__printf__, 2, 3))); extern int obstack_vprintf (struct obstack *__restrict __obstack, const char *__restrict __format, __gnuc_va_list __args) throw () __attribute__ ((__format__ (__printf__, 2, 0))); extern void flockfile (FILE *__stream) throw (); extern int ftrylockfile (FILE *__stream) throw () ; extern void funlockfile (FILE *__stream) throw (); extern int __uflow (FILE *); extern int __overflow (FILE *, int); extern __inline __attribute__ ((__gnu_inline__)) int vprintf (const char *__restrict __fmt, __gnuc_va_list __arg) { return vfprintf (stdout, __fmt, __arg); } extern __inline __attribute__ ((__gnu_inline__)) int getchar (void) { return getc (stdin); } extern __inline __attribute__ ((__gnu_inline__)) int fgetc_unlocked (FILE *__fp) { return (__builtin_expect (((__fp)->_IO_read_ptr >= (__fp)->_IO_read_end), 0) ? __uflow (__fp) : *(unsigned char *) (__fp)->_IO_read_ptr++); } extern __inline __attribute__ ((__gnu_inline__)) int getc_unlocked (FILE *__fp) { return (__builtin_expect (((__fp)->_IO_read_ptr >= (__fp)->_IO_read_end), 0) ? __uflow (__fp) : *(unsigned char *) (__fp)->_IO_read_ptr++); } extern __inline __attribute__ ((__gnu_inline__)) int getchar_unlocked (void) { return (__builtin_expect (((stdin)->_IO_read_ptr >= (stdin)->_IO_read_end), 0) ? __uflow (stdin) : *(unsigned char *) (stdin)->_IO_read_ptr++); } extern __inline __attribute__ ((__gnu_inline__)) int putchar (int __c) { return putc (__c, stdout); } extern __inline __attribute__ ((__gnu_inline__)) int fputc_unlocked (int __c, FILE *__stream) { return (__builtin_expect (((__stream)->_IO_write_ptr >= (__stream)->_IO_write_end), 0) ? __overflow (__stream, (unsigned char) (__c)) : (unsigned char) (*(__stream)->_IO_write_ptr++ = (__c))); } extern __inline __attribute__ ((__gnu_inline__)) int putc_unlocked (int __c, FILE *__stream) { return (__builtin_expect (((__stream)->_IO_write_ptr >= (__stream)->_IO_write_end), 0) ? __overflow (__stream, (unsigned char) (__c)) : (unsigned char) (*(__stream)->_IO_write_ptr++ = (__c))); } extern __inline __attribute__ ((__gnu_inline__)) int putchar_unlocked (int __c) { return (__builtin_expect (((stdout)->_IO_write_ptr >= (stdout)->_IO_write_end), 0) ? __overflow (stdout, (unsigned char) (__c)) : (unsigned char) (*(stdout)->_IO_write_ptr++ = (__c))); } extern __inline __attribute__ ((__gnu_inline__)) __ssize_t getline (char **__lineptr, size_t *__n, FILE *__stream) { return __getdelim (__lineptr, __n, '\n', __stream); } extern __inline __attribute__ ((__gnu_inline__)) int __attribute__ ((__leaf__)) feof_unlocked (FILE *__stream) throw () { return (((__stream)->_flags & 0x0010) != 0); } extern __inline __attribute__ ((__gnu_inline__)) int __attribute__ ((__leaf__)) ferror_unlocked (FILE *__stream) throw () { return (((__stream)->_flags & 0x0020) != 0); } } namespace std { using ::FILE; using ::fpos_t; using ::clearerr; using ::fclose; using ::feof; using ::ferror; using ::fflush; using ::fgetc; using ::fgetpos; using ::fgets; using ::fopen; using ::fprintf; using ::fputc; using ::fputs; using ::fread; using ::freopen; using ::fscanf; using ::fseek; using ::fsetpos; using ::ftell; using ::fwrite; using ::getc; using ::getchar; using ::perror; using ::printf; using ::putc; using ::putchar; using ::puts; using ::remove; using ::rename; using ::rewind; using ::scanf; using ::setbuf; using ::setvbuf; using ::sprintf; using ::sscanf; using ::tmpfile; using ::tmpnam; using ::ungetc; using ::vfprintf; using ::vprintf; using ::vsprintf; } namespace __gnu_cxx { using ::snprintf; using ::vfscanf; using ::vscanf; using ::vsnprintf; using ::vsscanf; } namespace std { using ::__gnu_cxx::snprintf; using ::__gnu_cxx::vfscanf; using ::__gnu_cxx::vscanf; using ::__gnu_cxx::vsnprintf; using ::__gnu_cxx::vsscanf; } extern "C" { extern int *__errno_location (void) throw () __attribute__ ((__const__)); extern char *program_invocation_name; extern char *program_invocation_short_name; typedef int error_t; } namespace __gnu_cxx __attribute__ ((__visibility__ ("default"))) { template<typename _TRet, typename _Ret = _TRet, typename _CharT, typename... _Base> _Ret __stoa(_TRet (*__convf) (const _CharT*, _CharT**, _Base...), const char* __name, const _CharT* __str, std::size_t* __idx, _Base... __base) { _Ret __ret; _CharT* __endptr; struct _Save_errno { _Save_errno() : _M_errno((*__errno_location ())) { (*__errno_location ()) = 0; } ~_Save_errno() { if ((*__errno_location ()) == 0) (*__errno_location ()) = _M_errno; } int _M_errno; } const __save_errno; struct _Range_chk { static bool _S_chk(_TRet, std::false_type) { return false; } static bool _S_chk(_TRet __val, std::true_type) { return __val < _TRet(__numeric_traits<int>::__min) || __val > _TRet(__numeric_traits<int>::__max); } }; const _TRet __tmp = __convf(__str, &__endptr, __base...); if (__endptr == __str) std::__throw_invalid_argument(__name); else if ((*__errno_location ()) == 34 || _Range_chk::_S_chk(__tmp, std::is_same<_Ret, int>{})) std::__throw_out_of_range(__name); else __ret = __tmp; if (__idx) *__idx = __endptr - __str; return __ret; } template<typename _String, typename _CharT = typename _String::value_type> _String __to_xstring(int (*__convf) (_CharT*, std::size_t, const _CharT*, __builtin_va_list), std::size_t __n, const _CharT* __fmt, ...) { _CharT* __s = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __n)); __builtin_va_list __args; __builtin_va_start(__args, __fmt); const int __len = __convf(__s, __n, __fmt, __args); __builtin_va_end(__args); return _String(__s, __s + __len); } } namespace std __attribute__ ((__visibility__ ("default"))) { namespace __detail { template<typename _Tp> 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; } } 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 std __attribute__ ((__visibility__ ("default"))) { namespace __cxx11 { inline int stoi(const string& __str, size_t* __idx = 0, int __base = 10) { return __gnu_cxx::__stoa<long, int>(&std::strtol, "stoi", __str.c_str(), __idx, __base); } inline long stol(const string& __str, size_t* __idx = 0, int __base = 10) { return __gnu_cxx::__stoa(&std::strtol, "stol", __str.c_str(), __idx, __base); } inline unsigned long stoul(const string& __str, size_t* __idx = 0, int __base = 10) { return __gnu_cxx::__stoa(&std::strtoul, "stoul", __str.c_str(), __idx, __base); } inline long long stoll(const string& __str, size_t* __idx = 0, int __base = 10) { return __gnu_cxx::__stoa(&std::strtoll, "stoll", __str.c_str(), __idx, __base); } inline unsigned long long stoull(const string& __str, size_t* __idx = 0, int __base = 10) { return __gnu_cxx::__stoa(&std::strtoull, "stoull", __str.c_str(), __idx, __base); } inline float stof(const string& __str, size_t* __idx = 0) { return __gnu_cxx::__stoa(&std::strtof, "stof", __str.c_str(), __idx); } inline double stod(const string& __str, size_t* __idx = 0) { return __gnu_cxx::__stoa(&std::strtod, "stod", __str.c_str(), __idx); } inline long double stold(const string& __str, size_t* __idx = 0) { return __gnu_cxx::__stoa(&std::strtold, "stold", __str.c_str(), __idx); } inline string to_string(int __val) { const bool __neg = __val < 0; const unsigned __uval = __neg ? (unsigned)~__val + 1u : __val; const auto __len = __detail::__to_chars_len(__uval); string __str(__neg + __len, '-'); __detail::__to_chars_10_impl(&__str[__neg], __len, __uval); return __str; } inline string to_string(unsigned __val) { string __str(__detail::__to_chars_len(__val), '\0'); __detail::__to_chars_10_impl(&__str[0], __str.size(), __val); return __str; } inline string to_string(long __val) { const bool __neg = __val < 0; const unsigned long __uval = __neg ? (unsigned long)~__val + 1ul : __val; const auto __len = __detail::__to_chars_len(__uval); string __str(__neg + __len, '-'); __detail::__to_chars_10_impl(&__str[__neg], __len, __uval); return __str; } inline string to_string(unsigned long __val) { string __str(__detail::__to_chars_len(__val), '\0'); __detail::__to_chars_10_impl(&__str[0], __str.size(), __val); return __str; } inline string to_string(long long __val) { const bool __neg = __val < 0; const unsigned long long __uval = __neg ? (unsigned long long)~__val + 1ull : __val; const auto __len = __detail::__to_chars_len(__uval); string __str(__neg + __len, '-'); __detail::__to_chars_10_impl(&__str[__neg], __len, __uval); return __str; } inline string to_string(unsigned long long __val) { string __str(__detail::__to_chars_len(__val), '\0'); __detail::__to_chars_10_impl(&__str[0], __str.size(), __val); return __str; } inline string to_string(float __val) { const int __n = __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20; return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n, "%f", __val); } inline string to_string(double __val) { const int __n = __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20; return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n, "%f", __val); } inline string to_string(long double __val) { const int __n = __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20; return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n, "%Lf", __val); } inline int stoi(const wstring& __str, size_t* __idx = 0, int __base = 10) { return __gnu_cxx::__stoa<long, int>(&std::wcstol, "stoi", __str.c_str(), __idx, __base); } inline long stol(const wstring& __str, size_t* __idx = 0, int __base = 10) { return __gnu_cxx::__stoa(&std::wcstol, "stol", __str.c_str(), __idx, __base); } inline unsigned long stoul(const wstring& __str, size_t* __idx = 0, int __base = 10) { return __gnu_cxx::__stoa(&std::wcstoul, "stoul", __str.c_str(), __idx, __base); } inline long long stoll(const wstring& __str, size_t* __idx = 0, int __base = 10) { return __gnu_cxx::__stoa(&std::wcstoll, "stoll", __str.c_str(), __idx, __base); } inline unsigned long long stoull(const wstring& __str, size_t* __idx = 0, int __base = 10) { return __gnu_cxx::__stoa(&std::wcstoull, "stoull", __str.c_str(), __idx, __base); } inline float stof(const wstring& __str, size_t* __idx = 0) { return __gnu_cxx::__stoa(&std::wcstof, "stof", __str.c_str(), __idx); } inline double stod(const wstring& __str, size_t* __idx = 0) { return __gnu_cxx::__stoa(&std::wcstod, "stod", __str.c_str(), __idx); } inline long double stold(const wstring& __str, size_t* __idx = 0) { return __gnu_cxx::__stoa(&std::wcstold, "stold", __str.c_str(), __idx); } inline wstring to_wstring(int __val) { return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 * sizeof(int), L"%d", __val); } inline wstring to_wstring(unsigned __val) { return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 * sizeof(unsigned), L"%u", __val); } inline wstring to_wstring(long __val) { return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 * sizeof(long), L"%ld", __val); } inline wstring to_wstring(unsigned long __val) { return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 * sizeof(unsigned long), L"%lu", __val); } inline wstring to_wstring(long long __val) { return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 * sizeof(long long), L"%lld", __val); } inline wstring to_wstring(unsigned long long __val) { return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 * sizeof(unsigned long long), L"%llu", __val); } inline wstring to_wstring(float __val) { const int __n = __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20; return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n, L"%f", __val); } inline wstring to_wstring(double __val) { const int __n = __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20; return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n, L"%f", __val); } inline wstring to_wstring(long double __val) { const int __n = __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20; return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n, L"%Lf", __val); } } } namespace std __attribute__ ((__visibility__ ("default"))) { template<typename _Result, typename _Arg> struct __hash_base { typedef _Result result_type ; typedef _Arg argument_type ; }; template<typename _Tp> struct hash; template<typename _Tp, typename = void> struct __poison_hash { static constexpr bool __enable_hash_call = false; private: __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; }; template<typename _Tp, bool = is_enum<_Tp>::value> struct __hash_enum { private: __hash_enum(__hash_enum&&); ~__hash_enum(); }; 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)); } }; template<typename _Tp> struct hash : __hash_enum<_Tp> { }; 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); } }; template<> struct hash<bool> : public __hash_base<size_t, bool> { size_t operator()(bool __val) const noexcept { return static_cast<size_t>(__val); } }; template<> struct hash<char> : public __hash_base<size_t, char> { size_t operator()(char __val) const noexcept { return static_cast<size_t>(__val); } }; template<> struct hash<signed char> : public __hash_base<size_t, signed char> { size_t operator()(signed char __val) const noexcept { return static_cast<size_t>(__val); } }; template<> struct hash<unsigned char> : public __hash_base<size_t, unsigned char> { size_t operator()(unsigned char __val) const noexcept { return static_cast<size_t>(__val); } }; template<> struct hash<wchar_t> : public __hash_base<size_t, wchar_t> { size_t operator()(wchar_t __val) const noexcept { return static_cast<size_t>(__val); } }; template<> struct hash<char16_t> : public __hash_base<size_t, char16_t> { size_t operator()(char16_t __val) const noexcept { return static_cast<size_t>(__val); } }; template<> struct hash<char32_t> : public __hash_base<size_t, char32_t> { size_t operator()(char32_t __val) const noexcept { return static_cast<size_t>(__val); } }; template<> struct hash<short> : public __hash_base<size_t, short> { size_t operator()(short __val) const noexcept { return static_cast<size_t>(__val); } }; template<> struct hash<int> : public __hash_base<size_t, int> { size_t operator()(int __val) const noexcept { return static_cast<size_t>(__val); } }; template<> struct hash<long> : public __hash_base<size_t, long> { size_t operator()(long __val) const noexcept { return static_cast<size_t>(__val); } }; template<> struct hash<long long> : public __hash_base<size_t, long long> { size_t operator()(long long __val) const noexcept { return static_cast<size_t>(__val); } }; template<> struct hash<unsigned short> : public __hash_base<size_t, unsigned short> { size_t operator()(unsigned short __val) const noexcept { return static_cast<size_t>(__val); } }; template<> struct hash<unsigned int> : public __hash_base<size_t, unsigned int> { size_t operator()(unsigned int __val) const noexcept { return static_cast<size_t>(__val); } }; template<> struct hash<unsigned long> : public __hash_base<size_t, unsigned long> { size_t operator()(unsigned long __val) const noexcept { return static_cast<size_t>(__val); } }; template<> struct hash<unsigned long long> : public __hash_base<size_t, unsigned long long> { size_t operator()(unsigned long long __val) const noexcept { return static_cast<size_t>(__val); } }; template<> struct hash<__int128> : public __hash_base<size_t, __int128> { size_t operator()(__int128 __val) const noexcept { return static_cast<size_t>(__val); } }; template<> struct hash<__int128 unsigned> : public __hash_base<size_t, __int128 unsigned> { size_t operator()(__int128 unsigned __val) const noexcept { return static_cast<size_t>(__val); } }; 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); } }; 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); } }; template<> struct hash<float> : public __hash_base<size_t, float> { size_t operator()(float __val) const noexcept { return __val != 0.0f ? std::_Hash_impl::hash(__val) : 0; } }; template<> struct hash<double> : public __hash_base<size_t, double> { size_t operator()(double __val) const noexcept { return __val != 0.0 ? std::_Hash_impl::hash(__val) : 0; } }; template<> struct hash<long double> : public __hash_base<size_t, long double> { __attribute__ ((__pure__)) size_t operator()(long double __val) const noexcept; }; template<typename _Hash> struct __is_fast_hash : public std::true_type { }; template<> struct __is_fast_hash<hash<long double>> : public std::false_type { }; } namespace std __attribute__ ((__visibility__ ("default"))) { template<> struct hash<string> : public __hash_base<size_t, string> { size_t operator()(const string& __s) const noexcept { return std::_Hash_impl::hash(__s.data(), __s.length()); } }; template<> struct __is_fast_hash<hash<string>> : std::false_type { }; template<> struct hash<wstring> : public __hash_base<size_t, wstring> { size_t operator()(const wstring& __s) const noexcept { return std::_Hash_impl::hash(__s.data(), __s.length() * sizeof(wchar_t)); } }; template<> struct __is_fast_hash<hash<wstring>> : std::false_type { }; template<> struct hash<u16string> : public __hash_base<size_t, u16string> { size_t operator()(const u16string& __s) const noexcept { return std::_Hash_impl::hash(__s.data(), __s.length() * sizeof(char16_t)); } }; template<> struct __is_fast_hash<hash<u16string>> : std::false_type { }; template<> struct hash<u32string> : public __hash_base<size_t, u32string> { size_t operator()(const u32string& __s) const noexcept { return std::_Hash_impl::hash(__s.data(), __s.length() * sizeof(char32_t)); } }; template<> struct __is_fast_hash<hash<u32string>> : std::false_type { }; inline namespace literals { inline namespace string_literals { __attribute ((__abi_tag__ ("cxx11"))) inline basic_string<char> operator""s(const char* __str, size_t __len) { return basic_string<char>{__str, __len}; } __attribute ((__abi_tag__ ("cxx11"))) inline basic_string<wchar_t> operator""s(const wchar_t* __str, size_t __len) { return basic_string<wchar_t>{__str, __len}; } __attribute ((__abi_tag__ ("cxx11"))) inline basic_string<char16_t> operator""s(const char16_t* __str, size_t __len) { return basic_string<char16_t>{__str, __len}; } __attribute ((__abi_tag__ ("cxx11"))) inline basic_string<char32_t> operator""s(const char32_t* __str, size_t __len) { return basic_string<char32_t>{__str, __len}; } } } } namespace std __attribute__ ((__visibility__ ("default"))) { template<typename _CharT, typename _Traits, typename _Alloc> const typename basic_string<_CharT, _Traits, _Alloc>::size_type basic_string<_CharT, _Traits, _Alloc>::npos; template<typename _CharT, typename _Traits, typename _Alloc> void basic_string<_CharT, _Traits, _Alloc>:: swap(basic_string& __s) noexcept { if (this == &__s) return; _Alloc_traits::_S_on_swap(_M_get_allocator(), __s._M_get_allocator()); if (_M_is_local()) if (__s._M_is_local()) { if (length() && __s.length()) { _CharT __tmp_data[_S_local_capacity + 1]; traits_type::copy(__tmp_data, __s._M_local_buf, _S_local_capacity + 1); traits_type::copy(__s._M_local_buf, _M_local_buf, _S_local_capacity + 1); traits_type::copy(_M_local_buf, __tmp_data, _S_local_capacity + 1); } else if (__s.length()) { traits_type::copy(_M_local_buf, __s._M_local_buf, _S_local_capacity + 1); _M_length(__s.length()); __s._M_set_length(0); return; } else if (length()) { traits_type::copy(__s._M_local_buf, _M_local_buf, _S_local_capacity + 1); __s._M_length(length()); _M_set_length(0); return; } } else { const size_type __tmp_capacity = __s._M_allocated_capacity; traits_type::copy(__s._M_local_buf, _M_local_buf, _S_local_capacity + 1); _M_data(__s._M_data()); __s._M_data(__s._M_local_buf); _M_capacity(__tmp_capacity); } else { const size_type __tmp_capacity = _M_allocated_capacity; if (__s._M_is_local()) { traits_type::copy(_M_local_buf, __s._M_local_buf, _S_local_capacity + 1); __s._M_data(_M_data()); _M_data(_M_local_buf); } else { pointer __tmp_ptr = _M_data(); _M_data(__s._M_data()); __s._M_data(__tmp_ptr); _M_capacity(__s._M_allocated_capacity); } __s._M_capacity(__tmp_capacity); } const size_type __tmp_length = length(); _M_length(__s.length()); __s._M_length(__tmp_length); } template<typename _CharT, typename _Traits, typename _Alloc> typename basic_string<_CharT, _Traits, _Alloc>::pointer basic_string<_CharT, _Traits, _Alloc>:: _M_create(size_type& __capacity, size_type __old_capacity) { if (__capacity > max_size()) std::__throw_length_error(("basic_string::_M_create")); if (__capacity > __old_capacity && __capacity < 2 * __old_capacity) { __capacity = 2 * __old_capacity; if (__capacity > max_size()) __capacity = max_size(); } return _Alloc_traits::allocate(_M_get_allocator(), __capacity + 1); } template<typename _CharT, typename _Traits, typename _Alloc> template<typename _InIterator> void basic_string<_CharT, _Traits, _Alloc>:: _M_construct(_InIterator __beg, _InIterator __end, std::input_iterator_tag) { size_type __len = 0; size_type __capacity = size_type(_S_local_capacity); while (__beg != __end && __len < __capacity) { _M_data()[__len++] = *__beg; ++__beg; } try { while (__beg != __end) { if (__len == __capacity) { __capacity = __len + 1; pointer __another = _M_create(__capacity, __len); this->_S_copy(__another, _M_data(), __len); _M_dispose(); _M_data(__another); _M_capacity(__capacity); } _M_data()[__len++] = *__beg; ++__beg; } } catch(...) { _M_dispose(); throw; } _M_set_length(__len); } template<typename _CharT, typename _Traits, typename _Alloc> template<typename _InIterator> void basic_string<_CharT, _Traits, _Alloc>:: _M_construct(_InIterator __beg, _InIterator __end, std::forward_iterator_tag) { if (__gnu_cxx::__is_null_pointer(__beg) && __beg != __end) std::__throw_logic_error(("basic_string::" "_M_construct null not valid") ); size_type __dnew = static_cast<size_type>(std::distance(__beg, __end)); if (__dnew > size_type(_S_local_capacity)) { _M_data(_M_create(__dnew, size_type(0))); _M_capacity(__dnew); } try { this->_S_copy_chars(_M_data(), __beg, __end); } catch(...) { _M_dispose(); throw; } _M_set_length(__dnew); } template<typename _CharT, typename _Traits, typename _Alloc> void basic_string<_CharT, _Traits, _Alloc>:: _M_construct(size_type __n, _CharT __c) { if (__n > size_type(_S_local_capacity)) { _M_data(_M_create(__n, size_type(0))); _M_capacity(__n); } if (__n) this->_S_assign(_M_data(), __n, __c); _M_set_length(__n); } template<typename _CharT, typename _Traits, typename _Alloc> void basic_string<_CharT, _Traits, _Alloc>:: _M_assign(const basic_string& __str) { if (this != &__str) { const size_type __rsize = __str.length(); const size_type __capacity = capacity(); if (__rsize > __capacity) { size_type __new_capacity = __rsize; pointer __tmp = _M_create(__new_capacity, __capacity); _M_dispose(); _M_data(__tmp); _M_capacity(__new_capacity); } if (__rsize) this->_S_copy(_M_data(), __str._M_data(), __rsize); _M_set_length(__rsize); } } template<typename _CharT, typename _Traits, typename _Alloc> void basic_string<_CharT, _Traits, _Alloc>:: reserve(size_type __res) { if (__res < length()) __res = length(); const size_type __capacity = capacity(); if (__res != __capacity) { if (__res > __capacity || __res > size_type(_S_local_capacity)) { pointer __tmp = _M_create(__res, __capacity); this->_S_copy(__tmp, _M_data(), length() + 1); _M_dispose(); _M_data(__tmp); _M_capacity(__res); } else if (!_M_is_local()) { this->_S_copy(_M_local_data(), _M_data(), length() + 1); _M_destroy(__capacity); _M_data(_M_local_data()); } } } template<typename _CharT, typename _Traits, typename _Alloc> void basic_string<_CharT, _Traits, _Alloc>:: _M_mutate(size_type __pos, size_type __len1, const _CharT* __s, size_type __len2) { const size_type __how_much = length() - __pos - __len1; size_type __new_capacity = length() + __len2 - __len1; pointer __r = _M_create(__new_capacity, capacity()); if (__pos) this->_S_copy(__r, _M_data(), __pos); if (__s && __len2) this->_S_copy(__r + __pos, __s, __len2); if (__how_much) this->_S_copy(__r + __pos + __len2, _M_data() + __pos + __len1, __how_much); _M_dispose(); _M_data(__r); _M_capacity(__new_capacity); } template<typename _CharT, typename _Traits, typename _Alloc> void basic_string<_CharT, _Traits, _Alloc>:: _M_erase(size_type __pos, size_type __n) { const size_type __how_much = length() - __pos - __n; if (__how_much && __n) this->_S_move(_M_data() + __pos, _M_data() + __pos + __n, __how_much); _M_set_length(length() - __n); } template<typename _CharT, typename _Traits, typename _Alloc> void basic_string<_CharT, _Traits, _Alloc>:: resize(size_type __n, _CharT __c) { const size_type __size = this->size(); if (__size < __n) this->append(__n - __size, __c); else if (__n < __size) this->_M_set_length(__n); } template<typename _CharT, typename _Traits, typename _Alloc> basic_string<_CharT, _Traits, _Alloc>& basic_string<_CharT, _Traits, _Alloc>:: _M_append(const _CharT* __s, size_type __n) { const size_type __len = __n + this->size(); if (__len <= this->capacity()) { if (__n) this->_S_copy(this->_M_data() + this->size(), __s, __n); } else this->_M_mutate(this->size(), size_type(0), __s, __n); this->_M_set_length(__len); return *this; } template<typename _CharT, typename _Traits, typename _Alloc> template<typename _InputIterator> basic_string<_CharT, _Traits, _Alloc>& basic_string<_CharT, _Traits, _Alloc>:: _M_replace_dispatch(const_iterator __i1, const_iterator __i2, _InputIterator __k1, _InputIterator __k2, std::__false_type) { const basic_string __s(__k1, __k2, this->get_allocator()); const size_type __n1 = __i2 - __i1; return _M_replace(__i1 - begin(), __n1, __s._M_data(), __s.size()); } template<typename _CharT, typename _Traits, typename _Alloc> basic_string<_CharT, _Traits, _Alloc>& basic_string<_CharT, _Traits, _Alloc>:: _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2, _CharT __c) { _M_check_length(__n1, __n2, "basic_string::_M_replace_aux"); const size_type __old_size = this->size(); const size_type __new_size = __old_size + __n2 - __n1; if (__new_size <= this->capacity()) { pointer __p = this->_M_data() + __pos1; const size_type __how_much = __old_size - __pos1 - __n1; if (__how_much && __n1 != __n2) this->_S_move(__p + __n2, __p + __n1, __how_much); } else this->_M_mutate(__pos1, __n1, 0, __n2); if (__n2) this->_S_assign(this->_M_data() + __pos1, __n2, __c); this->_M_set_length(__new_size); return *this; } template<typename _CharT, typename _Traits, typename _Alloc> basic_string<_CharT, _Traits, _Alloc>& basic_string<_CharT, _Traits, _Alloc>:: _M_replace(size_type __pos, size_type __len1, const _CharT* __s, const size_type __len2) { _M_check_length(__len1, __len2, "basic_string::_M_replace"); const size_type __old_size = this->size(); const size_type __new_size = __old_size + __len2 - __len1; if (__new_size <= this->capacity()) { pointer __p = this->_M_data() + __pos; const size_type __how_much = __old_size - __pos - __len1; if (_M_disjunct(__s)) { if (__how_much && __len1 != __len2) this->_S_move(__p + __len2, __p + __len1, __how_much); if (__len2) this->_S_copy(__p, __s, __len2); } else { if (__len2 && __len2 <= __len1) this->_S_move(__p, __s, __len2); if (__how_much && __len1 != __len2) this->_S_move(__p + __len2, __p + __len1, __how_much); if (__len2 > __len1) { if (__s + __len2 <= __p + __len1) this->_S_move(__p, __s, __len2); else if (__s >= __p + __len1) this->_S_copy(__p, __s + __len2 - __len1, __len2); else { const size_type __nleft = (__p + __len1) - __s; this->_S_move(__p, __s, __nleft); this->_S_copy(__p + __nleft, __p + __len2, __len2 - __nleft); } } } } else this->_M_mutate(__pos, __len1, __s, __len2); this->_M_set_length(__new_size); return *this; } template<typename _CharT, typename _Traits, typename _Alloc> typename basic_string<_CharT, _Traits, _Alloc>::size_type basic_string<_CharT, _Traits, _Alloc>:: copy(_CharT* __s, size_type __n, size_type __pos) const { _M_check(__pos, "basic_string::copy"); __n = _M_limit(__pos, __n); ; if (__n) _S_copy(__s, _M_data() + __pos, __n); return __n; } template<typename _CharT, typename _Traits, typename _Alloc> basic_string<_CharT, _Traits, _Alloc> operator+(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Alloc>& __rhs) { ; typedef basic_string<_CharT, _Traits, _Alloc> __string_type; typedef typename __string_type::size_type __size_type; typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template rebind<_CharT>::other _Char_alloc_type; typedef __gnu_cxx::__alloc_traits<_Char_alloc_type> _Alloc_traits; const __size_type __len = _Traits::length(__lhs); __string_type __str(_Alloc_traits::_S_select_on_copy( __rhs.get_allocator())); __str.reserve(__len + __rhs.size()); __str.append(__lhs, __len); __str.append(__rhs); return __str; } template<typename _CharT, typename _Traits, typename _Alloc> basic_string<_CharT, _Traits, _Alloc> operator+(_CharT __lhs, const basic_string<_CharT, _Traits, _Alloc>& __rhs) { typedef basic_string<_CharT, _Traits, _Alloc> __string_type; typedef typename __string_type::size_type __size_type; typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template rebind<_CharT>::other _Char_alloc_type; typedef __gnu_cxx::__alloc_traits<_Char_alloc_type> _Alloc_traits; __string_type __str(_Alloc_traits::_S_select_on_copy( __rhs.get_allocator())); const __size_type __len = __rhs.size(); __str.reserve(__len + 1); __str.append(__size_type(1), __lhs); __str.append(__rhs); return __str; } template<typename _CharT, typename _Traits, typename _Alloc> typename basic_string<_CharT, _Traits, _Alloc>::size_type basic_string<_CharT, _Traits, _Alloc>:: find(const _CharT* __s, size_type __pos, size_type __n) const noexcept { ; const size_type __size = this->size(); if (__n == 0) return __pos <= __size ? __pos : npos; if (__pos >= __size) return npos; const _CharT __elem0 = __s[0]; const _CharT* const __data = data(); const _CharT* __first = __data + __pos; const _CharT* const __last = __data + __size; size_type __len = __size - __pos; while (__len >= __n) { __first = traits_type::find(__first, __len - __n + 1, __elem0); if (!__first) return npos; if (traits_type::compare(__first, __s, __n) == 0) return __first - __data; __len = __last - ++__first; } return npos; } template<typename _CharT, typename _Traits, typename _Alloc> typename basic_string<_CharT, _Traits, _Alloc>::size_type basic_string<_CharT, _Traits, _Alloc>:: find(_CharT __c, size_type __pos) const noexcept { size_type __ret = npos; const size_type __size = this->size(); if (__pos < __size) { const _CharT* __data = _M_data(); const size_type __n = __size - __pos; const _CharT* __p = traits_type::find(__data + __pos, __n, __c); if (__p) __ret = __p - __data; } return __ret; } template<typename _CharT, typename _Traits, typename _Alloc> typename basic_string<_CharT, _Traits, _Alloc>::size_type basic_string<_CharT, _Traits, _Alloc>:: rfind(const _CharT* __s, size_type __pos, size_type __n) const noexcept { ; const size_type __size = this->size(); if (__n <= __size) { __pos = std::min(size_type(__size - __n), __pos); const _CharT* __data = _M_data(); do { if (traits_type::compare(__data + __pos, __s, __n) == 0) return __pos; } while (__pos-- > 0); } return npos; } template<typename _CharT, typename _Traits, typename _Alloc> typename basic_string<_CharT, _Traits, _Alloc>::size_type basic_string<_CharT, _Traits, _Alloc>:: rfind(_CharT __c, size_type __pos) const noexcept { size_type __size = this->size(); if (__size) { if (--__size > __pos) __size = __pos; for (++__size; __size-- > 0; ) if (traits_type::eq(_M_data()[__size], __c)) return __size; } return npos; } template<typename _CharT, typename _Traits, typename _Alloc> typename basic_string<_CharT, _Traits, _Alloc>::size_type basic_string<_CharT, _Traits, _Alloc>:: find_first_of(const _CharT* __s, size_type __pos, size_type __n) const noexcept { ; for (; __n && __pos < this->size(); ++__pos) { const _CharT* __p = traits_type::find(__s, __n, _M_data()[__pos]); if (__p) return __pos; } return npos; } template<typename _CharT, typename _Traits, typename _Alloc> typename basic_string<_CharT, _Traits, _Alloc>::size_type basic_string<_CharT, _Traits, _Alloc>:: find_last_of(const _CharT* __s, size_type __pos, size_type __n) const noexcept { ; size_type __size = this->size(); if (__size && __n) { if (--__size > __pos) __size = __pos; do { if (traits_type::find(__s, __n, _M_data()[__size])) return __size; } while (__size-- != 0); } return npos; } template<typename _CharT, typename _Traits, typename _Alloc> typename basic_string<_CharT, _Traits, _Alloc>::size_type basic_string<_CharT, _Traits, _Alloc>:: find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const noexcept { ; for (; __pos < this->size(); ++__pos) if (!traits_type::find(__s, __n, _M_data()[__pos])) return __pos; return npos; } template<typename _CharT, typename _Traits, typename _Alloc> typename basic_string<_CharT, _Traits, _Alloc>::size_type basic_string<_CharT, _Traits, _Alloc>:: find_first_not_of(_CharT __c, size_type __pos) const noexcept { for (; __pos < this->size(); ++__pos) if (!traits_type::eq(_M_data()[__pos], __c)) return __pos; return npos; } template<typename _CharT, typename _Traits, typename _Alloc> typename basic_string<_CharT, _Traits, _Alloc>::size_type basic_string<_CharT, _Traits, _Alloc>:: find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const noexcept { ; size_type __size = this->size(); if (__size) { if (--__size > __pos) __size = __pos; do { if (!traits_type::find(__s, __n, _M_data()[__size])) return __size; } while (__size--); } return npos; } template<typename _CharT, typename _Traits, typename _Alloc> typename basic_string<_CharT, _Traits, _Alloc>::size_type basic_string<_CharT, _Traits, _Alloc>:: find_last_not_of(_CharT __c, size_type __pos) const noexcept { size_type __size = this->size(); if (__size) { if (--__size > __pos) __size = __pos; do { if (!traits_type::eq(_M_data()[__size], __c)) return __size; } while (__size--); } return npos; } template<typename _CharT, typename _Traits, typename _Alloc> int basic_string<_CharT, _Traits, _Alloc>:: compare(size_type __pos, size_type __n, const basic_string& __str) const { _M_check(__pos, "basic_string::compare"); __n = _M_limit(__pos, __n); const size_type __osize = __str.size(); const size_type __len = std::min(__n, __osize); int __r = traits_type::compare(_M_data() + __pos, __str.data(), __len); if (!__r) __r = _S_compare(__n, __osize); return __r; } template<typename _CharT, typename _Traits, typename _Alloc> int basic_string<_CharT, _Traits, _Alloc>:: compare(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2) const { _M_check(__pos1, "basic_string::compare"); __str._M_check(__pos2, "basic_string::compare"); __n1 = _M_limit(__pos1, __n1); __n2 = __str._M_limit(__pos2, __n2); const size_type __len = std::min(__n1, __n2); int __r = traits_type::compare(_M_data() + __pos1, __str.data() + __pos2, __len); if (!__r) __r = _S_compare(__n1, __n2); return __r; } template<typename _CharT, typename _Traits, typename _Alloc> int basic_string<_CharT, _Traits, _Alloc>:: compare(const _CharT* __s) const noexcept { ; const size_type __size = this->size(); const size_type __osize = traits_type::length(__s); const size_type __len = std::min(__size, __osize); int __r = traits_type::compare(_M_data(), __s, __len); if (!__r) __r = _S_compare(__size, __osize); return __r; } template<typename _CharT, typename _Traits, typename _Alloc> int basic_string <_CharT, _Traits, _Alloc>:: compare(size_type __pos, size_type __n1, const _CharT* __s) const { ; _M_check(__pos, "basic_string::compare"); __n1 = _M_limit(__pos, __n1); const size_type __osize = traits_type::length(__s); const size_type __len = std::min(__n1, __osize); int __r = traits_type::compare(_M_data() + __pos, __s, __len); if (!__r) __r = _S_compare(__n1, __osize); return __r; } template<typename _CharT, typename _Traits, typename _Alloc> int basic_string <_CharT, _Traits, _Alloc>:: compare(size_type __pos, size_type __n1, const _CharT* __s, size_type __n2) const { ; _M_check(__pos, "basic_string::compare"); __n1 = _M_limit(__pos, __n1); const size_type __len = std::min(__n1, __n2); int __r = traits_type::compare(_M_data() + __pos, __s, __len); if (!__r) __r = _S_compare(__n1, __n2); return __r; } template<typename _CharT, typename _Traits, typename _Alloc> basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __in, basic_string<_CharT, _Traits, _Alloc>& __str) { typedef basic_istream<_CharT, _Traits> __istream_type; typedef basic_string<_CharT, _Traits, _Alloc> __string_type; typedef typename __istream_type::ios_base __ios_base; typedef typename __istream_type::int_type __int_type; typedef typename __string_type::size_type __size_type; typedef ctype<_CharT> __ctype_type; typedef typename __ctype_type::ctype_base __ctype_base; __size_type __extracted = 0; typename __ios_base::iostate __err = __ios_base::goodbit; typename __istream_type::sentry __cerb(__in, false); if (__cerb) { try { __str.erase(); _CharT __buf[128]; __size_type __len = 0; const streamsize __w = __in.width(); const __size_type __n = __w > 0 ? static_cast<__size_type>(__w) : __str.max_size(); const __ctype_type& __ct = use_facet<__ctype_type>(__in.getloc()); const __int_type __eof = _Traits::eof(); __int_type __c = __in.rdbuf()->sgetc(); while (__extracted < __n && !_Traits::eq_int_type(__c, __eof) && !__ct.is(__ctype_base::space, _Traits::to_char_type(__c))) { if (__len == sizeof(__buf) / sizeof(_CharT)) { __str.append(__buf, sizeof(__buf) / sizeof(_CharT)); __len = 0; } __buf[__len++] = _Traits::to_char_type(__c); ++__extracted; __c = __in.rdbuf()->snextc(); } __str.append(__buf, __len); if (_Traits::eq_int_type(__c, __eof)) __err |= __ios_base::eofbit; __in.width(0); } catch(__cxxabiv1::__forced_unwind&) { __in._M_setstate(__ios_base::badbit); throw; } catch(...) { __in._M_setstate(__ios_base::badbit); } } if (!__extracted) __err |= __ios_base::failbit; if (__err) __in.setstate(__err); return __in; } template<typename _CharT, typename _Traits, typename _Alloc> basic_istream<_CharT, _Traits>& getline(basic_istream<_CharT, _Traits>& __in, basic_string<_CharT, _Traits, _Alloc>& __str, _CharT __delim) { typedef basic_istream<_CharT, _Traits> __istream_type; typedef basic_string<_CharT, _Traits, _Alloc> __string_type; typedef typename __istream_type::ios_base __ios_base; typedef typename __istream_type::int_type __int_type; typedef typename __string_type::size_type __size_type; __size_type __extracted = 0; const __size_type __n = __str.max_size(); typename __ios_base::iostate __err = __ios_base::goodbit; typename __istream_type::sentry __cerb(__in, true); if (__cerb) { try { __str.erase(); const __int_type __idelim = _Traits::to_int_type(__delim); const __int_type __eof = _Traits::eof(); __int_type __c = __in.rdbuf()->sgetc(); while (__extracted < __n && !_Traits::eq_int_type(__c, __eof) && !_Traits::eq_int_type(__c, __idelim)) { __str += _Traits::to_char_type(__c); ++__extracted; __c = __in.rdbuf()->snextc(); } if (_Traits::eq_int_type(__c, __eof)) __err |= __ios_base::eofbit; else if (_Traits::eq_int_type(__c, __idelim)) { ++__extracted; __in.rdbuf()->sbumpc(); } else __err |= __ios_base::failbit; } catch(__cxxabiv1::__forced_unwind&) { __in._M_setstate(__ios_base::badbit); throw; } catch(...) { __in._M_setstate(__ios_base::badbit); } } if (!__extracted) __err |= __ios_base::failbit; if (__err) __in.setstate(__err); return __in; } extern template class basic_string<char>; extern template basic_istream<char>& operator>>(basic_istream<char>&, string&); extern template basic_ostream<char>& operator<<(basic_ostream<char>&, const string&); extern template basic_istream<char>& getline(basic_istream<char>&, string&, char); extern template basic_istream<char>& getline(basic_istream<char>&, string&); extern template class basic_string<wchar_t>; extern template basic_istream<wchar_t>& operator>>(basic_istream<wchar_t>&, wstring&); extern template basic_ostream<wchar_t>& operator<<(basic_ostream<wchar_t>&, const wstring&); extern template basic_istream<wchar_t>& getline(basic_istream<wchar_t>&, wstring&, wchar_t); extern template basic_istream<wchar_t>& getline(basic_istream<wchar_t>&, wstring&); } namespace std __attribute__ ((__visibility__ ("default"))) { template<bool _TrivialValueTypes> struct __uninitialized_copy { template<typename _InputIterator, typename _ForwardIterator> static _ForwardIterator __uninit_copy(_InputIterator __first, _InputIterator __last, _ForwardIterator __result) { _ForwardIterator __cur = __result; try { for (; __first != __last; ++__first, (void)++__cur) std::_Construct(std::__addressof(*__cur), *__first); return __cur; } catch(...) { std::_Destroy(__result, __cur); throw; } } }; template<> struct __uninitialized_copy<true> { template<typename _InputIterator, typename _ForwardIterator> static _ForwardIterator __uninit_copy(_InputIterator __first, _InputIterator __last, _ForwardIterator __result) { return std::copy(__first, __last, __result); } }; template<typename _InputIterator, typename _ForwardIterator> inline _ForwardIterator uninitialized_copy(_InputIterator __first, _InputIterator __last, _ForwardIterator __result) { typedef typename iterator_traits<_InputIterator>::value_type _ValueType1; typedef typename iterator_traits<_ForwardIterator>::value_type _ValueType2; static_assert(is_constructible<_ValueType2, decltype(*__first)>::value, "result type must be constructible from value type of input range"); typedef typename iterator_traits<_InputIterator>::reference _RefType1; typedef typename iterator_traits<_ForwardIterator>::reference _RefType2; const bool __assignable = is_assignable<_RefType2, _RefType1>::value; return std::__uninitialized_copy<__is_trivial(_ValueType1) && __is_trivial(_ValueType2) && __assignable>:: __uninit_copy(__first, __last, __result); } template<bool _TrivialValueType> struct __uninitialized_fill { template<typename _ForwardIterator, typename _Tp> static void __uninit_fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __x) { _ForwardIterator __cur = __first; try { for (; __cur != __last; ++__cur) std::_Construct(std::__addressof(*__cur), __x); } catch(...) { std::_Destroy(__first, __cur); throw; } } }; template<> struct __uninitialized_fill<true> { template<typename _ForwardIterator, typename _Tp> static void __uninit_fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __x) { std::fill(__first, __last, __x); } }; template<typename _ForwardIterator, typename _Tp> inline void uninitialized_fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __x) { typedef typename iterator_traits<_ForwardIterator>::value_type _ValueType; static_assert(is_constructible<_ValueType, const _Tp&>::value, "result type must be constructible from input type"); const bool __assignable = is_copy_assignable<_ValueType>::value; std::__uninitialized_fill<__is_trivial(_ValueType) && __assignable>:: __uninit_fill(__first, __last, __x); } template<bool _TrivialValueType> struct __uninitialized_fill_n { template<typename _ForwardIterator, typename _Size, typename _Tp> static _ForwardIterator __uninit_fill_n(_ForwardIterator __first, _Size __n, const _Tp& __x) { _ForwardIterator __cur = __first; try { for (; __n > 0; --__n, (void) ++__cur) std::_Construct(std::__addressof(*__cur), __x); return __cur; } catch(...) { std::_Destroy(__first, __cur); throw; } } }; template<> struct __uninitialized_fill_n<true> { template<typename _ForwardIterator, typename _Size, typename _Tp> static _ForwardIterator __uninit_fill_n(_ForwardIterator __first, _Size __n, const _Tp& __x) { return std::fill_n(__first, __n, __x); } }; template<typename _ForwardIterator, typename _Size, typename _Tp> inline _ForwardIterator uninitialized_fill_n(_ForwardIterator __first, _Size __n, const _Tp& __x) { typedef typename iterator_traits<_ForwardIterator>::value_type _ValueType; static_assert(is_constructible<_ValueType, const _Tp&>::value, "result type must be constructible from input type"); const bool __assignable = is_copy_assignable<_ValueType>::value; return __uninitialized_fill_n<__is_trivial(_ValueType) && __assignable>:: __uninit_fill_n(__first, __n, __x); } template<typename _InputIterator, typename _ForwardIterator, typename _Allocator> _ForwardIterator __uninitialized_copy_a(_InputIterator __first, _InputIterator __last, _ForwardIterator __result, _Allocator& __alloc) { _ForwardIterator __cur = __result; try { typedef __gnu_cxx::__alloc_traits<_Allocator> __traits; for (; __first != __last; ++__first, (void)++__cur) __traits::construct(__alloc, std::__addressof(*__cur), *__first); return __cur; } catch(...) { std::_Destroy(__result, __cur, __alloc); throw; } } template<typename _InputIterator, typename _ForwardIterator, typename _Tp> inline _ForwardIterator __uninitialized_copy_a(_InputIterator __first, _InputIterator __last, _ForwardIterator __result, allocator<_Tp>&) { return std::uninitialized_copy(__first, __last, __result); } template<typename _InputIterator, typename _ForwardIterator, typename _Allocator> inline _ForwardIterator __uninitialized_move_a(_InputIterator __first, _InputIterator __last, _ForwardIterator __result, _Allocator& __alloc) { return std::__uninitialized_copy_a(std::make_move_iterator(__first), std::make_move_iterator(__last), __result, __alloc); } template<typename _InputIterator, typename _ForwardIterator, typename _Allocator> inline _ForwardIterator __uninitialized_move_if_noexcept_a(_InputIterator __first, _InputIterator __last, _ForwardIterator __result, _Allocator& __alloc) { return std::__uninitialized_copy_a (std::__make_move_if_noexcept_iterator(__first), std::__make_move_if_noexcept_iterator(__last), __result, __alloc); } template<typename _ForwardIterator, typename _Tp, typename _Allocator> void __uninitialized_fill_a(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __x, _Allocator& __alloc) { _ForwardIterator __cur = __first; try { typedef __gnu_cxx::__alloc_traits<_Allocator> __traits; for (; __cur != __last; ++__cur) __traits::construct(__alloc, std::__addressof(*__cur), __x); } catch(...) { std::_Destroy(__first, __cur, __alloc); throw; } } template<typename _ForwardIterator, typename _Tp, typename _Tp2> inline void __uninitialized_fill_a(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __x, allocator<_Tp2>&) { std::uninitialized_fill(__first, __last, __x); } template<typename _ForwardIterator, typename _Size, typename _Tp, typename _Allocator> _ForwardIterator __uninitialized_fill_n_a(_ForwardIterator __first, _Size __n, const _Tp& __x, _Allocator& __alloc) { _ForwardIterator __cur = __first; try { typedef __gnu_cxx::__alloc_traits<_Allocator> __traits; for (; __n > 0; --__n, (void) ++__cur) __traits::construct(__alloc, std::__addressof(*__cur), __x); return __cur; } catch(...) { std::_Destroy(__first, __cur, __alloc); throw; } } template<typename _ForwardIterator, typename _Size, typename _Tp, typename _Tp2> inline _ForwardIterator __uninitialized_fill_n_a(_ForwardIterator __first, _Size __n, const _Tp& __x, allocator<_Tp2>&) { return std::uninitialized_fill_n(__first, __n, __x); } template<typename _InputIterator1, typename _InputIterator2, typename _ForwardIterator, typename _Allocator> inline _ForwardIterator __uninitialized_copy_move(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _ForwardIterator __result, _Allocator& __alloc) { _ForwardIterator __mid = std::__uninitialized_copy_a(__first1, __last1, __result, __alloc); try { return std::__uninitialized_move_a(__first2, __last2, __mid, __alloc); } catch(...) { std::_Destroy(__result, __mid, __alloc); throw; } } template<typename _InputIterator1, typename _InputIterator2, typename _ForwardIterator, typename _Allocator> inline _ForwardIterator __uninitialized_move_copy(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _ForwardIterator __result, _Allocator& __alloc) { _ForwardIterator __mid = std::__uninitialized_move_a(__first1, __last1, __result, __alloc); try { return std::__uninitialized_copy_a(__first2, __last2, __mid, __alloc); } catch(...) { std::_Destroy(__result, __mid, __alloc); throw; } } template<typename _ForwardIterator, typename _Tp, typename _InputIterator, typename _Allocator> inline _ForwardIterator __uninitialized_fill_move(_ForwardIterator __result, _ForwardIterator __mid, const _Tp& __x, _InputIterator __first, _InputIterator __last, _Allocator& __alloc) { std::__uninitialized_fill_a(__result, __mid, __x, __alloc); try { return std::__uninitialized_move_a(__first, __last, __mid, __alloc); } catch(...) { std::_Destroy(__result, __mid, __alloc); throw; } } template<typename _InputIterator, typename _ForwardIterator, typename _Tp, typename _Allocator> inline void __uninitialized_move_fill(_InputIterator __first1, _InputIterator __last1, _ForwardIterator __first2, _ForwardIterator __last2, const _Tp& __x, _Allocator& __alloc) { _ForwardIterator __mid2 = std::__uninitialized_move_a(__first1, __last1, __first2, __alloc); try { std::__uninitialized_fill_a(__mid2, __last2, __x, __alloc); } catch(...) { std::_Destroy(__first2, __mid2, __alloc); throw; } } template<bool _TrivialValueType> struct __uninitialized_default_1 { template<typename _ForwardIterator> static void __uninit_default(_ForwardIterator __first, _ForwardIterator __last) { _ForwardIterator __cur = __first; try { for (; __cur != __last; ++__cur) std::_Construct(std::__addressof(*__cur)); } catch(...) { std::_Destroy(__first, __cur); throw; } } }; template<> struct __uninitialized_default_1<true> { template<typename _ForwardIterator> static void __uninit_default(_ForwardIterator __first, _ForwardIterator __last) { typedef typename iterator_traits<_ForwardIterator>::value_type _ValueType; std::fill(__first, __last, _ValueType()); } }; template<bool _TrivialValueType> struct __uninitialized_default_n_1 { template<typename _ForwardIterator, typename _Size> static _ForwardIterator __uninit_default_n(_ForwardIterator __first, _Size __n) { _ForwardIterator __cur = __first; try { for (; __n > 0; --__n, (void) ++__cur) std::_Construct(std::__addressof(*__cur)); return __cur; } catch(...) { std::_Destroy(__first, __cur); throw; } } }; template<> struct __uninitialized_default_n_1<true> { template<typename _ForwardIterator, typename _Size> static _ForwardIterator __uninit_default_n(_ForwardIterator __first, _Size __n) { typedef typename iterator_traits<_ForwardIterator>::value_type _ValueType; return std::fill_n(__first, __n, _ValueType()); } }; template<typename _ForwardIterator> inline void __uninitialized_default(_ForwardIterator __first, _ForwardIterator __last) { typedef typename iterator_traits<_ForwardIterator>::value_type _ValueType; const bool __assignable = is_copy_assignable<_ValueType>::value; std::__uninitialized_default_1<__is_trivial(_ValueType) && __assignable>:: __uninit_default(__first, __last); } template<typename _ForwardIterator, typename _Size> inline _ForwardIterator __uninitialized_default_n(_ForwardIterator __first, _Size __n) { typedef typename iterator_traits<_ForwardIterator>::value_type _ValueType; const bool __assignable = is_copy_assignable<_ValueType>::value; return __uninitialized_default_n_1<__is_trivial(_ValueType) && __assignable>:: __uninit_default_n(__first, __n); } template<typename _ForwardIterator, typename _Allocator> void __uninitialized_default_a(_ForwardIterator __first, _ForwardIterator __last, _Allocator& __alloc) { _ForwardIterator __cur = __first; try { typedef __gnu_cxx::__alloc_traits<_Allocator> __traits; for (; __cur != __last; ++__cur) __traits::construct(__alloc, std::__addressof(*__cur)); } catch(...) { std::_Destroy(__first, __cur, __alloc); throw; } } template<typename _ForwardIterator, typename _Tp> inline void __uninitialized_default_a(_ForwardIterator __first, _ForwardIterator __last, allocator<_Tp>&) { std::__uninitialized_default(__first, __last); } template<typename _ForwardIterator, typename _Size, typename _Allocator> _ForwardIterator __uninitialized_default_n_a(_ForwardIterator __first, _Size __n, _Allocator& __alloc) { _ForwardIterator __cur = __first; try { typedef __gnu_cxx::__alloc_traits<_Allocator> __traits; for (; __n > 0; --__n, (void) ++__cur) __traits::construct(__alloc, std::__addressof(*__cur)); return __cur; } catch(...) { std::_Destroy(__first, __cur, __alloc); throw; } } template<typename _ForwardIterator, typename _Size, typename _Tp> inline _ForwardIterator __uninitialized_default_n_a(_ForwardIterator __first, _Size __n, allocator<_Tp>&) { return std::__uninitialized_default_n(__first, __n); } template<bool _TrivialValueType> struct __uninitialized_default_novalue_1 { template<typename _ForwardIterator> static void __uninit_default_novalue(_ForwardIterator __first, _ForwardIterator __last) { _ForwardIterator __cur = __first; try { for (; __cur != __last; ++__cur) std::_Construct_novalue(std::__addressof(*__cur)); } catch(...) { std::_Destroy(__first, __cur); throw; } } }; template<> struct __uninitialized_default_novalue_1<true> { template<typename _ForwardIterator> static void __uninit_default_novalue(_ForwardIterator __first, _ForwardIterator __last) { } }; template<bool _TrivialValueType> struct __uninitialized_default_novalue_n_1 { template<typename _ForwardIterator, typename _Size> static _ForwardIterator __uninit_default_novalue_n(_ForwardIterator __first, _Size __n) { _ForwardIterator __cur = __first; try { for (; __n > 0; --__n, (void) ++__cur) std::_Construct_novalue(std::__addressof(*__cur)); return __cur; } catch(...) { std::_Destroy(__first, __cur); throw; } } }; template<> struct __uninitialized_default_novalue_n_1<true> { template<typename _ForwardIterator, typename _Size> static _ForwardIterator __uninit_default_novalue_n(_ForwardIterator __first, _Size __n) { return std::next(__first, __n); } }; template<typename _ForwardIterator> inline void __uninitialized_default_novalue(_ForwardIterator __first, _ForwardIterator __last) { typedef typename iterator_traits<_ForwardIterator>::value_type _ValueType; std::__uninitialized_default_novalue_1< is_trivially_default_constructible<_ValueType>::value>:: __uninit_default_novalue(__first, __last); } template<typename _ForwardIterator, typename _Size> inline _ForwardIterator __uninitialized_default_novalue_n(_ForwardIterator __first, _Size __n) { typedef typename iterator_traits<_ForwardIterator>::value_type _ValueType; return __uninitialized_default_novalue_n_1< is_trivially_default_constructible<_ValueType>::value>:: __uninit_default_novalue_n(__first, __n); } template<typename _InputIterator, typename _Size, typename _ForwardIterator> _ForwardIterator __uninitialized_copy_n(_InputIterator __first, _Size __n, _ForwardIterator __result, input_iterator_tag) { _ForwardIterator __cur = __result; try { for (; __n > 0; --__n, (void) ++__first, ++__cur) std::_Construct(std::__addressof(*__cur), *__first); return __cur; } catch(...) { std::_Destroy(__result, __cur); throw; } } template<typename _RandomAccessIterator, typename _Size, typename _ForwardIterator> inline _ForwardIterator __uninitialized_copy_n(_RandomAccessIterator __first, _Size __n, _ForwardIterator __result, random_access_iterator_tag) { return std::uninitialized_copy(__first, __first + __n, __result); } template<typename _InputIterator, typename _Size, typename _ForwardIterator> pair<_InputIterator, _ForwardIterator> __uninitialized_copy_n_pair(_InputIterator __first, _Size __n, _ForwardIterator __result, input_iterator_tag) { _ForwardIterator __cur = __result; try { for (; __n > 0; --__n, (void) ++__first, ++__cur) std::_Construct(std::__addressof(*__cur), *__first); return {__first, __cur}; } catch(...) { std::_Destroy(__result, __cur); throw; } } template<typename _RandomAccessIterator, typename _Size, typename _ForwardIterator> inline pair<_RandomAccessIterator, _ForwardIterator> __uninitialized_copy_n_pair(_RandomAccessIterator __first, _Size __n, _ForwardIterator __result, random_access_iterator_tag) { auto __second_res = uninitialized_copy(__first, __first + __n, __result); auto __first_res = std::next(__first, __n); return {__first_res, __second_res}; } template<typename _InputIterator, typename _Size, typename _ForwardIterator> inline _ForwardIterator uninitialized_copy_n(_InputIterator __first, _Size __n, _ForwardIterator __result) { return std::__uninitialized_copy_n(__first, __n, __result, std::__iterator_category(__first)); } template<typename _InputIterator, typename _Size, typename _ForwardIterator> inline pair<_InputIterator, _ForwardIterator> __uninitialized_copy_n_pair(_InputIterator __first, _Size __n, _ForwardIterator __result) { return std::__uninitialized_copy_n_pair(__first, __n, __result, std::__iterator_category(__first)); } template<typename _Tp, typename _Up, typename _Allocator> inline void __relocate_object_a(_Tp* __restrict __dest, _Up* __restrict __orig, _Allocator& __alloc) noexcept(noexcept(std::allocator_traits<_Allocator>::construct(__alloc, __dest, std::move(*__orig))) && noexcept(std::allocator_traits<_Allocator>::destroy( __alloc, std::__addressof(*__orig)))) { typedef std::allocator_traits<_Allocator> __traits; __traits::construct(__alloc, __dest, std::move(*__orig)); __traits::destroy(__alloc, std::__addressof(*__orig)); } template<typename _Tp, typename = void> struct __is_bitwise_relocatable : is_trivial<_Tp> { }; template <typename _Tp, typename _Up> inline __enable_if_t<std::__is_bitwise_relocatable<_Tp>::value, _Tp*> __relocate_a_1(_Tp* __first, _Tp* __last, _Tp* __result, allocator<_Up>&) noexcept { ptrdiff_t __count = __last - __first; if (__count > 0) __builtin_memmove(__result, __first, __count * sizeof(_Tp)); return __result + __count; } template <typename _InputIterator, typename _ForwardIterator, typename _Allocator> inline _ForwardIterator __relocate_a_1(_InputIterator __first, _InputIterator __last, _ForwardIterator __result, _Allocator& __alloc) noexcept(noexcept(std::__relocate_object_a(std::addressof(*__result), std::addressof(*__first), __alloc))) { typedef typename iterator_traits<_InputIterator>::value_type _ValueType; typedef typename iterator_traits<_ForwardIterator>::value_type _ValueType2; static_assert(std::is_same<_ValueType, _ValueType2>::value, "relocation is only possible for values of the same type"); _ForwardIterator __cur = __result; for (; __first != __last; ++__first, (void)++__cur) std::__relocate_object_a(std::__addressof(*__cur), std::__addressof(*__first), __alloc); return __cur; } template <typename _InputIterator, typename _ForwardIterator, typename _Allocator> inline _ForwardIterator __relocate_a(_InputIterator __first, _InputIterator __last, _ForwardIterator __result, _Allocator& __alloc) noexcept(noexcept(__relocate_a_1(std::__niter_base(__first), std::__niter_base(__last), std::__niter_base(__result), __alloc))) { return __relocate_a_1(std::__niter_base(__first), std::__niter_base(__last), std::__niter_base(__result), __alloc); } } namespace std __attribute__ ((__visibility__ ("default"))) { namespace __detail { template<typename _Tp> inline void __return_temporary_buffer(_Tp* __p, size_t __len __attribute__((__unused__))) { ::operator delete(__p, __len * sizeof(_Tp)); } } template<typename _Tp> pair<_Tp*, ptrdiff_t> get_temporary_buffer(ptrdiff_t __len) noexcept { const ptrdiff_t __max = __gnu_cxx::__numeric_traits<ptrdiff_t>::__max / sizeof(_Tp); if (__len > __max) __len = __max; while (__len > 0) { _Tp* __tmp = static_cast<_Tp*>(::operator new(__len * sizeof(_Tp), std::nothrow)); if (__tmp != 0) return std::pair<_Tp*, ptrdiff_t>(__tmp, __len); __len /= 2; } return std::pair<_Tp*, ptrdiff_t>(static_cast<_Tp*>(0), 0); } template<typename _Tp> inline void return_temporary_buffer(_Tp* __p) { ::operator delete(__p); } template<typename _ForwardIterator, typename _Tp> class _Temporary_buffer { public: typedef _Tp value_type; typedef value_type* pointer; typedef pointer iterator; typedef ptrdiff_t size_type; protected: size_type _M_original_len; size_type _M_len; pointer _M_buffer; public: size_type size() const { return _M_len; } size_type requested_size() const { return _M_original_len; } iterator begin() { return _M_buffer; } iterator end() { return _M_buffer + _M_len; } _Temporary_buffer(_ForwardIterator __seed, size_type __original_len); ~_Temporary_buffer() { std::_Destroy(_M_buffer, _M_buffer + _M_len); std::__detail::__return_temporary_buffer(_M_buffer, _M_len); } private: _Temporary_buffer(const _Temporary_buffer&); void operator=(const _Temporary_buffer&); }; template<bool> struct __uninitialized_construct_buf_dispatch { template<typename _Pointer, typename _ForwardIterator> static void __ucr(_Pointer __first, _Pointer __last, _ForwardIterator __seed) { if (__first == __last) return; _Pointer __cur = __first; try { std::_Construct(std::__addressof(*__first), std::move(*__seed)); _Pointer __prev = __cur; ++__cur; for(; __cur != __last; ++__cur, ++__prev) std::_Construct(std::__addressof(*__cur), std::move(*__prev)); *__seed = std::move(*__prev); } catch(...) { std::_Destroy(__first, __cur); throw; } } }; template<> struct __uninitialized_construct_buf_dispatch<true> { template<typename _Pointer, typename _ForwardIterator> static void __ucr(_Pointer, _Pointer, _ForwardIterator) { } }; template<typename _Pointer, typename _ForwardIterator> inline void __uninitialized_construct_buf(_Pointer __first, _Pointer __last, _ForwardIterator __seed) { typedef typename std::iterator_traits<_Pointer>::value_type _ValueType; std::__uninitialized_construct_buf_dispatch< __has_trivial_constructor(_ValueType)>:: __ucr(__first, __last, __seed); } template<typename _ForwardIterator, typename _Tp> _Temporary_buffer<_ForwardIterator, _Tp>:: _Temporary_buffer(_ForwardIterator __seed, size_type __original_len) : _M_original_len(__original_len), _M_len(0), _M_buffer(0) { std::pair<pointer, size_type> __p( std::get_temporary_buffer<value_type>(_M_original_len)); if (__p.first) { try { std::__uninitialized_construct_buf(__p.first, __p.first + __p.second, __seed); _M_buffer = __p.first; _M_len = __p.second; } catch(...) { std::__detail::__return_temporary_buffer(__p.first, __p.second); throw; } } } } namespace std __attribute__ ((__visibility__ ("default"))) { template <class _OutputIterator, class _Tp> class raw_storage_iterator : public iterator<output_iterator_tag, void, void, void, void> { protected: _OutputIterator _M_iter; public: explicit raw_storage_iterator(_OutputIterator __x) : _M_iter(__x) {} raw_storage_iterator& operator*() { return *this; } raw_storage_iterator& operator=(const _Tp& __element) { std::_Construct(std::__addressof(*_M_iter), __element); return *this; } raw_storage_iterator& operator=(_Tp&& __element) { std::_Construct(std::__addressof(*_M_iter), std::move(__element)); return *this; } raw_storage_iterator& operator++() { ++_M_iter; return *this; } raw_storage_iterator operator++(int) { raw_storage_iterator __tmp = *this; ++_M_iter; return __tmp; } _OutputIterator base() const { return _M_iter; } }; } namespace __gnu_cxx __attribute__ ((__visibility__ ("default"))) { enum _Lock_policy { _S_single, _S_mutex, _S_atomic }; static const _Lock_policy __default_lock_policy = _S_atomic; class __concurrence_lock_error : public std::exception { public: virtual char const* what() const throw() { return "__gnu_cxx::__concurrence_lock_error"; } }; class __concurrence_unlock_error : public std::exception { public: virtual char const* what() const throw() { return "__gnu_cxx::__concurrence_unlock_error"; } }; class __concurrence_broadcast_error : public std::exception { public: virtual char const* what() const throw() { return "__gnu_cxx::__concurrence_broadcast_error"; } }; class __concurrence_wait_error : public std::exception { public: virtual char const* what() const throw() { return "__gnu_cxx::__concurrence_wait_error"; } }; inline void __throw_concurrence_lock_error() { (throw (__concurrence_lock_error())); } inline void __throw_concurrence_unlock_error() { (throw (__concurrence_unlock_error())); } inline void __throw_concurrence_broadcast_error() { (throw (__concurrence_broadcast_error())); } inline void __throw_concurrence_wait_error() { (throw (__concurrence_wait_error())); } class __mutex { private: __gthread_mutex_t _M_mutex = { { 0, 0, 0, 0, PTHREAD_MUTEX_TIMED_NP, 0, 0, { 0, 0 } } }; __mutex(const __mutex&); __mutex& operator=(const __mutex&); public: __mutex() { } void lock() { if (__gthread_active_p()) { if (__gthread_mutex_lock(&_M_mutex) != 0) __throw_concurrence_lock_error(); } } void unlock() { if (__gthread_active_p()) { if (__gthread_mutex_unlock(&_M_mutex) != 0) __throw_concurrence_unlock_error(); } } __gthread_mutex_t* gthread_mutex(void) { return &_M_mutex; } }; class __recursive_mutex { private: __gthread_recursive_mutex_t _M_mutex = { { 0, 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP, 0, 0, { 0, 0 } } }; __recursive_mutex(const __recursive_mutex&); __recursive_mutex& operator=(const __recursive_mutex&); public: __recursive_mutex() { } void lock() { if (__gthread_active_p()) { if (__gthread_recursive_mutex_lock(&_M_mutex) != 0) __throw_concurrence_lock_error(); } } void unlock() { if (__gthread_active_p()) { if (__gthread_recursive_mutex_unlock(&_M_mutex) != 0) __throw_concurrence_unlock_error(); } } __gthread_recursive_mutex_t* gthread_recursive_mutex(void) { return &_M_mutex; } }; class __scoped_lock { public: typedef __mutex __mutex_type; private: __mutex_type& _M_device; __scoped_lock(const __scoped_lock&); __scoped_lock& operator=(const __scoped_lock&); public: explicit __scoped_lock(__mutex_type& __name) : _M_device(__name) { _M_device.lock(); } ~__scoped_lock() throw() { _M_device.unlock(); } }; class __cond { private: __gthread_cond_t _M_cond = { { {0}, {0}, {0, 0}, {0, 0}, 0, 0, {0, 0} } }; __cond(const __cond&); __cond& operator=(const __cond&); public: __cond() { } void broadcast() { if (__gthread_active_p()) { if (__gthread_cond_broadcast(&_M_cond) != 0) __throw_concurrence_broadcast_error(); } } void wait(__mutex *mutex) { { if (__gthread_cond_wait(&_M_cond, mutex->gthread_mutex()) != 0) __throw_concurrence_wait_error(); } } void wait_recursive(__recursive_mutex *mutex) { { if (__gthread_cond_wait_recursive(&_M_cond, mutex->gthread_recursive_mutex()) != 0) __throw_concurrence_wait_error(); } } }; } namespace std __attribute__ ((__visibility__ ("default"))) { struct __erased_type { }; template<typename _Alloc, typename _Tp> using __is_erased_or_convertible = __or_<is_convertible<_Alloc, _Tp>, is_same<_Tp, __erased_type>>; struct allocator_arg_t { explicit allocator_arg_t() = default; }; constexpr allocator_arg_t allocator_arg = allocator_arg_t(); template<typename _Tp, typename _Alloc, typename = __void_t<>> struct __uses_allocator_helper : false_type { }; template<typename _Tp, typename _Alloc> struct __uses_allocator_helper<_Tp, _Alloc, __void_t<typename _Tp::allocator_type>> : __is_erased_or_convertible<_Alloc, typename _Tp::allocator_type>::type { }; template<typename _Tp, typename _Alloc> struct uses_allocator : __uses_allocator_helper<_Tp, _Alloc>::type { }; struct __uses_alloc_base { }; struct __uses_alloc0 : __uses_alloc_base { struct _Sink { void operator=(const void*) { } } _M_a; }; template<typename _Alloc> struct __uses_alloc1 : __uses_alloc_base { const _Alloc* _M_a; }; template<typename _Alloc> struct __uses_alloc2 : __uses_alloc_base { const _Alloc* _M_a; }; template<bool, typename _Tp, typename _Alloc, typename... _Args> struct __uses_alloc; template<typename _Tp, typename _Alloc, typename... _Args> struct __uses_alloc<true, _Tp, _Alloc, _Args...> : conditional< is_constructible<_Tp, allocator_arg_t, const _Alloc&, _Args...>::value, __uses_alloc1<_Alloc>, __uses_alloc2<_Alloc>>::type { static_assert(__or_< is_constructible<_Tp, allocator_arg_t, const _Alloc&, _Args...>, is_constructible<_Tp, _Args..., const _Alloc&>>::value, "construction with an allocator must be possible" " if uses_allocator is true"); }; template<typename _Tp, typename _Alloc, typename... _Args> struct __uses_alloc<false, _Tp, _Alloc, _Args...> : __uses_alloc0 { }; template<typename _Tp, typename _Alloc, typename... _Args> using __uses_alloc_t = __uses_alloc<uses_allocator<_Tp, _Alloc>::value, _Tp, _Alloc, _Args...>; template<typename _Tp, typename _Alloc, typename... _Args> inline __uses_alloc_t<_Tp, _Alloc, _Args...> __use_alloc(const _Alloc& __a) { __uses_alloc_t<_Tp, _Alloc, _Args...> __ret; __ret._M_a = std::__addressof(__a); return __ret; } template<typename _Tp, typename _Alloc, typename... _Args> void __use_alloc(const _Alloc&&) = delete; template<template<typename...> class _Predicate, typename _Tp, typename _Alloc, typename... _Args> struct __is_uses_allocator_predicate : conditional<uses_allocator<_Tp, _Alloc>::value, __or_<_Predicate<_Tp, allocator_arg_t, _Alloc, _Args...>, _Predicate<_Tp, _Args..., _Alloc>>, _Predicate<_Tp, _Args...>>::type { }; template<typename _Tp, typename _Alloc, typename... _Args> struct __is_uses_allocator_constructible : __is_uses_allocator_predicate<is_constructible, _Tp, _Alloc, _Args...> { }; template<typename _Tp, typename _Alloc, typename... _Args> constexpr bool __is_uses_allocator_constructible_v = __is_uses_allocator_constructible<_Tp, _Alloc, _Args...>::value; template<typename _Tp, typename _Alloc, typename... _Args> struct __is_nothrow_uses_allocator_constructible : __is_uses_allocator_predicate<is_nothrow_constructible, _Tp, _Alloc, _Args...> { }; template<typename _Tp, typename _Alloc, typename... _Args> constexpr bool __is_nothrow_uses_allocator_constructible_v = __is_nothrow_uses_allocator_constructible<_Tp, _Alloc, _Args...>::value; template<typename _Tp, typename... _Args> void __uses_allocator_construct_impl(__uses_alloc0 __a, _Tp* __ptr, _Args&&... __args) { ::new ((void*)__ptr) _Tp(std::forward<_Args>(__args)...); } template<typename _Tp, typename _Alloc, typename... _Args> void __uses_allocator_construct_impl(__uses_alloc1<_Alloc> __a, _Tp* __ptr, _Args&&... __args) { ::new ((void*)__ptr) _Tp(allocator_arg, *__a._M_a, std::forward<_Args>(__args)...); } template<typename _Tp, typename _Alloc, typename... _Args> void __uses_allocator_construct_impl(__uses_alloc2<_Alloc> __a, _Tp* __ptr, _Args&&... __args) { ::new ((void*)__ptr) _Tp(std::forward<_Args>(__args)..., *__a._M_a); } template<typename _Tp, typename _Alloc, typename... _Args> void __uses_allocator_construct(const _Alloc& __a, _Tp* __ptr, _Args&&... __args) { std::__uses_allocator_construct_impl( std::__use_alloc<_Tp, _Alloc, _Args...>(__a), __ptr, std::forward<_Args>(__args)...); } } namespace std __attribute__ ((__visibility__ ("default"))) { namespace rel_ops { template <class _Tp> inline bool operator!=(const _Tp& __x, const _Tp& __y) { return !(__x == __y); } template <class _Tp> inline bool operator>(const _Tp& __x, const _Tp& __y) { return __y < __x; } template <class _Tp> inline bool operator<=(const _Tp& __x, const _Tp& __y) { return !(__y < __x); } template <class _Tp> inline bool operator>=(const _Tp& __x, const _Tp& __y) { return !(__x < __y); } } } namespace std __attribute__ ((__visibility__ ("default"))) { template<typename _Tp> struct tuple_size; template<typename _Tp, typename _Up = typename remove_cv<_Tp>::type, typename = typename enable_if<is_same<_Tp, _Up>::value>::type, size_t = tuple_size<_Tp>::value> using __enable_if_has_tuple_size = _Tp; template<typename _Tp> struct tuple_size<const __enable_if_has_tuple_size<_Tp>> : public tuple_size<_Tp> { }; template<typename _Tp> struct tuple_size<volatile __enable_if_has_tuple_size<_Tp>> : public tuple_size<_Tp> { }; template<typename _Tp> struct tuple_size<const volatile __enable_if_has_tuple_size<_Tp>> : public tuple_size<_Tp> { }; template<std::size_t __i, typename _Tp> struct tuple_element; template<std::size_t __i, typename _Tp> using __tuple_element_t = typename tuple_element<__i, _Tp>::type; template<std::size_t __i, typename _Tp> struct tuple_element<__i, const _Tp> { typedef typename add_const<__tuple_element_t<__i, _Tp>>::type type; }; template<std::size_t __i, typename _Tp> struct tuple_element<__i, volatile _Tp> { typedef typename add_volatile<__tuple_element_t<__i, _Tp>>::type type; }; template<std::size_t __i, typename _Tp> struct tuple_element<__i, const volatile _Tp> { typedef typename add_cv<__tuple_element_t<__i, _Tp>>::type type; }; template<std::size_t __i, typename _Tp> using tuple_element_t = typename tuple_element<__i, _Tp>::type; template<typename _T1, typename _T2> struct __is_tuple_like_impl<std::pair<_T1, _T2>> : true_type { }; template<class _Tp1, class _Tp2> struct tuple_size<std::pair<_Tp1, _Tp2>> : public integral_constant<std::size_t, 2> { }; template<class _Tp1, class _Tp2> struct tuple_element<0, std::pair<_Tp1, _Tp2>> { typedef _Tp1 type; }; template<class _Tp1, class _Tp2> struct tuple_element<1, std::pair<_Tp1, _Tp2>> { typedef _Tp2 type; }; template<std::size_t _Int> struct __pair_get; template<> struct __pair_get<0> { template<typename _Tp1, typename _Tp2> static constexpr _Tp1& __get(std::pair<_Tp1, _Tp2>& __pair) noexcept { return __pair.first; } template<typename _Tp1, typename _Tp2> static constexpr _Tp1&& __move_get(std::pair<_Tp1, _Tp2>&& __pair) noexcept { return std::forward<_Tp1>(__pair.first); } template<typename _Tp1, typename _Tp2> static constexpr const _Tp1& __const_get(const std::pair<_Tp1, _Tp2>& __pair) noexcept { return __pair.first; } template<typename _Tp1, typename _Tp2> static constexpr const _Tp1&& __const_move_get(const std::pair<_Tp1, _Tp2>&& __pair) noexcept { return std::forward<const _Tp1>(__pair.first); } }; template<> struct __pair_get<1> { template<typename _Tp1, typename _Tp2> static constexpr _Tp2& __get(std::pair<_Tp1, _Tp2>& __pair) noexcept { return __pair.second; } template<typename _Tp1, typename _Tp2> static constexpr _Tp2&& __move_get(std::pair<_Tp1, _Tp2>&& __pair) noexcept { return std::forward<_Tp2>(__pair.second); } template<typename _Tp1, typename _Tp2> static constexpr const _Tp2& __const_get(const std::pair<_Tp1, _Tp2>& __pair) noexcept { return __pair.second; } template<typename _Tp1, typename _Tp2> static constexpr const _Tp2&& __const_move_get(const std::pair<_Tp1, _Tp2>&& __pair) noexcept { return std::forward<const _Tp2>(__pair.second); } }; template<std::size_t _Int, class _Tp1, class _Tp2> constexpr typename tuple_element<_Int, std::pair<_Tp1, _Tp2>>::type& get(std::pair<_Tp1, _Tp2>& __in) noexcept { return __pair_get<_Int>::__get(__in); } template<std::size_t _Int, class _Tp1, class _Tp2> constexpr typename tuple_element<_Int, std::pair<_Tp1, _Tp2>>::type&& get(std::pair<_Tp1, _Tp2>&& __in) noexcept { return __pair_get<_Int>::__move_get(std::move(__in)); } template<std::size_t _Int, class _Tp1, class _Tp2> constexpr const typename tuple_element<_Int, std::pair<_Tp1, _Tp2>>::type& get(const std::pair<_Tp1, _Tp2>& __in) noexcept { return __pair_get<_Int>::__const_get(__in); } template<std::size_t _Int, class _Tp1, class _Tp2> constexpr const typename tuple_element<_Int, std::pair<_Tp1, _Tp2>>::type&& get(const std::pair<_Tp1, _Tp2>&& __in) noexcept { return __pair_get<_Int>::__const_move_get(std::move(__in)); } template <typename _Tp, typename _Up> constexpr _Tp& get(pair<_Tp, _Up>& __p) noexcept { return __p.first; } template <typename _Tp, typename _Up> constexpr const _Tp& get(const pair<_Tp, _Up>& __p) noexcept { return __p.first; } template <typename _Tp, typename _Up> constexpr _Tp&& get(pair<_Tp, _Up>&& __p) noexcept { return std::move(__p.first); } template <typename _Tp, typename _Up> constexpr const _Tp&& get(const pair<_Tp, _Up>&& __p) noexcept { return std::move(__p.first); } template <typename _Tp, typename _Up> constexpr _Tp& get(pair<_Up, _Tp>& __p) noexcept { return __p.second; } template <typename _Tp, typename _Up> constexpr const _Tp& get(const pair<_Up, _Tp>& __p) noexcept { return __p.second; } template <typename _Tp, typename _Up> constexpr _Tp&& get(pair<_Up, _Tp>&& __p) noexcept { return std::move(__p.second); } template <typename _Tp, typename _Up> constexpr const _Tp&& get(const pair<_Up, _Tp>&& __p) noexcept { return std::move(__p.second); } template <typename _Tp, typename _Up = _Tp> inline _Tp exchange(_Tp& __obj, _Up&& __new_val) { return std::__exchange(__obj, std::forward<_Up>(__new_val)); } template<size_t... _Indexes> struct _Index_tuple { }; template<size_t _Num> struct _Build_index_tuple { using __type = _Index_tuple<__integer_pack(_Num)...>; }; template<typename _Tp, _Tp... _Idx> struct integer_sequence { typedef _Tp value_type; static constexpr size_t size() noexcept { return sizeof...(_Idx); } }; template<typename _Tp, _Tp _Num> using make_integer_sequence = integer_sequence<_Tp, __integer_pack(_Num)...>; template<size_t... _Idx> using index_sequence = integer_sequence<size_t, _Idx...>; template<size_t _Num> using make_index_sequence = make_integer_sequence<size_t, _Num>; template<typename... _Types> using index_sequence_for = make_index_sequence<sizeof...(_Types)>; } namespace std __attribute__ ((__visibility__ ("default"))) { 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; } }; 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; typedef std::__array_traits<_Tp, _Nm> _AT_Type; typename _AT_Type::_Type _M_elems; void fill(const value_type& __u) { std::fill_n(begin(), size(), __u); } void swap(array& __other) noexcept(_AT_Type::_Is_nothrow_swappable::value) { std::swap_ranges(begin(), end(), __other.begin()); } iterator begin() noexcept { return iterator(data()); } const_iterator begin() const noexcept { return const_iterator(data()); } iterator end() noexcept { return iterator(data() + _Nm); } const_iterator end() const noexcept { return const_iterator(data() + _Nm); } reverse_iterator rbegin() noexcept { return reverse_iterator(end()); } const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); } reverse_iterator rend() noexcept { return reverse_iterator(begin()); } const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); } const_iterator cbegin() const noexcept { return const_iterator(data()); } const_iterator cend() const noexcept { return const_iterator(data() + _Nm); } const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(end()); } const_reverse_iterator crend() const noexcept { return const_reverse_iterator(begin()); } constexpr size_type size() const noexcept { return _Nm; } constexpr size_type max_size() const noexcept { return _Nm; } constexpr bool empty() const noexcept { return size() == 0; } 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); } reference at(size_type __n) { if (__n >= _Nm) std::__throw_out_of_range_fmt(("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 { return __n < _Nm ? _AT_Type::_S_ref(_M_elems, __n) : (std::__throw_out_of_range_fmt(("array::at: __n (which is %zu) " ">= _Nm (which is %zu)") , __n, _Nm), _AT_Type::_S_ref(_M_elems, 0)); } reference front() noexcept { return *begin(); } constexpr const_reference front() const noexcept { return _AT_Type::_S_ref(_M_elems, 0); } 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); } pointer data() noexcept { return _AT_Type::_S_ptr(_M_elems); } const_pointer data() const noexcept { return _AT_Type::_S_ptr(_M_elems); } }; template<typename _Tp, std::size_t _Nm> inline bool operator==(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) { return std::equal(__one.begin(), __one.end(), __two.begin()); } template<typename _Tp, std::size_t _Nm> inline bool operator!=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) { return !(__one == __two); } template<typename _Tp, std::size_t _Nm> 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> inline bool operator>(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) { return __two < __one; } template<typename _Tp, std::size_t _Nm> inline bool operator<=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) { return !(__one > __two); } template<typename _Tp, std::size_t _Nm> inline bool operator>=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) { return !(__one < __two); } template<typename _Tp, std::size_t _Nm> inline typename enable_if< std::__array_traits<_Tp, _Nm>::_Is_swappable::value >::type swap(array<_Tp, _Nm>& __one, array<_Tp, _Nm>& __two) noexcept(noexcept(__one.swap(__two))) { __one.swap(__two); } template<typename _Tp, std::size_t _Nm> typename enable_if< !std::__array_traits<_Tp, _Nm>::_Is_swappable::value>::type swap(array<_Tp, _Nm>&, array<_Tp, _Nm>&) = delete; 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::__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(std::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 std::__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(std::get<_Int>(__arr)); } } namespace std __attribute__ ((__visibility__ ("default"))) { template<typename _Tp> struct tuple_size; template<typename _Tp, std::size_t _Nm> struct tuple_size<std::array<_Tp, _Nm>> : public integral_constant<std::size_t, _Nm> { }; template<std::size_t _Int, typename _Tp> struct tuple_element; template<std::size_t _Int, typename _Tp, std::size_t _Nm> struct tuple_element<_Int, std::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<std::array<_Tp, _Nm>> : true_type { }; } namespace std __attribute__ ((__visibility__ ("default"))) { 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; } 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)...); } 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 >; 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)...); } template<typename _Res, typename _Callable, typename... _Args> 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)...); } } namespace std __attribute__ ((__visibility__ ("default"))) { template<typename... _Elements> class tuple; template<typename _Tp> struct __is_empty_non_tuple : is_empty<_Tp> { }; template<typename _El0, typename... _El> struct __is_empty_non_tuple<tuple<_El0, _El...>> : false_type { }; template<typename _Tp> using __empty_not_final = typename conditional<__is_final(_Tp), false_type, __is_empty_non_tuple<_Tp>>::type; template<std::size_t _Idx, typename _Head, bool = __empty_not_final<_Head>::value> struct _Head_base; template<std::size_t _Idx, typename _Head> struct _Head_base<_Idx, _Head, true> : public _Head { constexpr _Head_base() : _Head() { } constexpr _Head_base(const _Head& __h) : _Head(__h) { } constexpr _Head_base(const _Head_base&) = default; constexpr _Head_base(_Head_base&&) = default; template<typename _UHead> constexpr _Head_base(_UHead&& __h) : _Head(std::forward<_UHead>(__h)) { } _Head_base(allocator_arg_t, __uses_alloc0) : _Head() { } template<typename _Alloc> _Head_base(allocator_arg_t, __uses_alloc1<_Alloc> __a) : _Head(allocator_arg, *__a._M_a) { } template<typename _Alloc> _Head_base(allocator_arg_t, __uses_alloc2<_Alloc> __a) : _Head(*__a._M_a) { } template<typename _UHead> _Head_base(__uses_alloc0, _UHead&& __uhead) : _Head(std::forward<_UHead>(__uhead)) { } template<typename _Alloc, typename _UHead> _Head_base(__uses_alloc1<_Alloc> __a, _UHead&& __uhead) : _Head(allocator_arg, *__a._M_a, std::forward<_UHead>(__uhead)) { } template<typename _Alloc, typename _UHead> _Head_base(__uses_alloc2<_Alloc> __a, _UHead&& __uhead) : _Head(std::forward<_UHead>(__uhead), *__a._M_a) { } static constexpr _Head& _M_head(_Head_base& __b) noexcept { return __b; } static constexpr const _Head& _M_head(const _Head_base& __b) noexcept { return __b; } }; template<std::size_t _Idx, typename _Head> struct _Head_base<_Idx, _Head, false> { constexpr _Head_base() : _M_head_impl() { } constexpr _Head_base(const _Head& __h) : _M_head_impl(__h) { } constexpr _Head_base(const _Head_base&) = default; constexpr _Head_base(_Head_base&&) = default; template<typename _UHead> constexpr _Head_base(_UHead&& __h) : _M_head_impl(std::forward<_UHead>(__h)) { } _Head_base(allocator_arg_t, __uses_alloc0) : _M_head_impl() { } template<typename _Alloc> _Head_base(allocator_arg_t, __uses_alloc1<_Alloc> __a) : _M_head_impl(allocator_arg, *__a._M_a) { } template<typename _Alloc> _Head_base(allocator_arg_t, __uses_alloc2<_Alloc> __a) : _M_head_impl(*__a._M_a) { } template<typename _UHead> _Head_base(__uses_alloc0, _UHead&& __uhead) : _M_head_impl(std::forward<_UHead>(__uhead)) { } template<typename _Alloc, typename _UHead> _Head_base(__uses_alloc1<_Alloc> __a, _UHead&& __uhead) : _M_head_impl(allocator_arg, *__a._M_a, std::forward<_UHead>(__uhead)) { } template<typename _Alloc, typename _UHead> _Head_base(__uses_alloc2<_Alloc> __a, _UHead&& __uhead) : _M_head_impl(std::forward<_UHead>(__uhead), *__a._M_a) { } static constexpr _Head& _M_head(_Head_base& __b) noexcept { return __b._M_head_impl; } static constexpr const _Head& _M_head(const _Head_base& __b) noexcept { return __b._M_head_impl; } _Head _M_head_impl; }; template<std::size_t _Idx, typename... _Elements> struct _Tuple_impl; template<std::size_t _Idx, typename _Head, typename... _Tail> struct _Tuple_impl<_Idx, _Head, _Tail...> : public _Tuple_impl<_Idx + 1, _Tail...>, private _Head_base<_Idx, _Head> { template<std::size_t, typename...> friend class _Tuple_impl; typedef _Tuple_impl<_Idx + 1, _Tail...> _Inherited; typedef _Head_base<_Idx, _Head> _Base; static constexpr _Head& _M_head(_Tuple_impl& __t) noexcept { return _Base::_M_head(__t); } static constexpr const _Head& _M_head(const _Tuple_impl& __t) noexcept { return _Base::_M_head(__t); } static constexpr _Inherited& _M_tail(_Tuple_impl& __t) noexcept { return __t; } static constexpr const _Inherited& _M_tail(const _Tuple_impl& __t) noexcept { return __t; } constexpr _Tuple_impl() : _Inherited(), _Base() { } explicit constexpr _Tuple_impl(const _Head& __head, const _Tail&... __tail) : _Inherited(__tail...), _Base(__head) { } template<typename _UHead, typename... _UTail, typename = typename enable_if<sizeof...(_Tail) == sizeof...(_UTail)>::type> explicit constexpr _Tuple_impl(_UHead&& __head, _UTail&&... __tail) : _Inherited(std::forward<_UTail>(__tail)...), _Base(std::forward<_UHead>(__head)) { } constexpr _Tuple_impl(const _Tuple_impl&) = default; _Tuple_impl& operator=(const _Tuple_impl&) = delete; constexpr _Tuple_impl(_Tuple_impl&& __in) noexcept(__and_<is_nothrow_move_constructible<_Head>, is_nothrow_move_constructible<_Inherited>>::value) : _Inherited(std::move(_M_tail(__in))), _Base(std::forward<_Head>(_M_head(__in))) { } template<typename... _UElements> constexpr _Tuple_impl(const _Tuple_impl<_Idx, _UElements...>& __in) : _Inherited(_Tuple_impl<_Idx, _UElements...>::_M_tail(__in)), _Base(_Tuple_impl<_Idx, _UElements...>::_M_head(__in)) { } template<typename _UHead, typename... _UTails> constexpr _Tuple_impl(_Tuple_impl<_Idx, _UHead, _UTails...>&& __in) : _Inherited(std::move (_Tuple_impl<_Idx, _UHead, _UTails...>::_M_tail(__in))), _Base(std::forward<_UHead> (_Tuple_impl<_Idx, _UHead, _UTails...>::_M_head(__in))) { } template<typename _Alloc> _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a) : _Inherited(__tag, __a), _Base(__tag, __use_alloc<_Head>(__a)) { } template<typename _Alloc> _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a, const _Head& __head, const _Tail&... __tail) : _Inherited(__tag, __a, __tail...), _Base(__use_alloc<_Head, _Alloc, _Head>(__a), __head) { } template<typename _Alloc, typename _UHead, typename... _UTail, typename = typename enable_if<sizeof...(_Tail) == sizeof...(_UTail)>::type> _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a, _UHead&& __head, _UTail&&... __tail) : _Inherited(__tag, __a, std::forward<_UTail>(__tail)...), _Base(__use_alloc<_Head, _Alloc, _UHead>(__a), std::forward<_UHead>(__head)) { } template<typename _Alloc> _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a, const _Tuple_impl& __in) : _Inherited(__tag, __a, _M_tail(__in)), _Base(__use_alloc<_Head, _Alloc, _Head>(__a), _M_head(__in)) { } template<typename _Alloc> _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a, _Tuple_impl&& __in) : _Inherited(__tag, __a, std::move(_M_tail(__in))), _Base(__use_alloc<_Head, _Alloc, _Head>(__a), std::forward<_Head>(_M_head(__in))) { } template<typename _Alloc, typename... _UElements> _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a, const _Tuple_impl<_Idx, _UElements...>& __in) : _Inherited(__tag, __a, _Tuple_impl<_Idx, _UElements...>::_M_tail(__in)), _Base(__use_alloc<_Head, _Alloc, _Head>(__a), _Tuple_impl<_Idx, _UElements...>::_M_head(__in)) { } template<typename _Alloc, typename _UHead, typename... _UTails> _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a, _Tuple_impl<_Idx, _UHead, _UTails...>&& __in) : _Inherited(__tag, __a, std::move (_Tuple_impl<_Idx, _UHead, _UTails...>::_M_tail(__in))), _Base(__use_alloc<_Head, _Alloc, _UHead>(__a), std::forward<_UHead> (_Tuple_impl<_Idx, _UHead, _UTails...>::_M_head(__in))) { } template<typename... _UElements> void _M_assign(const _Tuple_impl<_Idx, _UElements...>& __in) { _M_head(*this) = _Tuple_impl<_Idx, _UElements...>::_M_head(__in); _M_tail(*this)._M_assign( _Tuple_impl<_Idx, _UElements...>::_M_tail(__in)); } template<typename _UHead, typename... _UTails> void _M_assign(_Tuple_impl<_Idx, _UHead, _UTails...>&& __in) { _M_head(*this) = std::forward<_UHead> (_Tuple_impl<_Idx, _UHead, _UTails...>::_M_head(__in)); _M_tail(*this)._M_assign( std::move(_Tuple_impl<_Idx, _UHead, _UTails...>::_M_tail(__in))); } protected: void _M_swap(_Tuple_impl& __in) { using std::swap; swap(_M_head(*this), _M_head(__in)); _Inherited::_M_swap(_M_tail(__in)); } }; template<std::size_t _Idx, typename _Head> struct _Tuple_impl<_Idx, _Head> : private _Head_base<_Idx, _Head> { template<std::size_t, typename...> friend class _Tuple_impl; typedef _Head_base<_Idx, _Head> _Base; static constexpr _Head& _M_head(_Tuple_impl& __t) noexcept { return _Base::_M_head(__t); } static constexpr const _Head& _M_head(const _Tuple_impl& __t) noexcept { return _Base::_M_head(__t); } constexpr _Tuple_impl() : _Base() { } explicit constexpr _Tuple_impl(const _Head& __head) : _Base(__head) { } template<typename _UHead> explicit constexpr _Tuple_impl(_UHead&& __head) : _Base(std::forward<_UHead>(__head)) { } constexpr _Tuple_impl(const _Tuple_impl&) = default; _Tuple_impl& operator=(const _Tuple_impl&) = delete; constexpr _Tuple_impl(_Tuple_impl&& __in) noexcept(is_nothrow_move_constructible<_Head>::value) : _Base(std::forward<_Head>(_M_head(__in))) { } template<typename _UHead> constexpr _Tuple_impl(const _Tuple_impl<_Idx, _UHead>& __in) : _Base(_Tuple_impl<_Idx, _UHead>::_M_head(__in)) { } template<typename _UHead> constexpr _Tuple_impl(_Tuple_impl<_Idx, _UHead>&& __in) : _Base(std::forward<_UHead>(_Tuple_impl<_Idx, _UHead>::_M_head(__in))) { } template<typename _Alloc> _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a) : _Base(__tag, __use_alloc<_Head>(__a)) { } template<typename _Alloc> _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a, const _Head& __head) : _Base(__use_alloc<_Head, _Alloc, _Head>(__a), __head) { } template<typename _Alloc, typename _UHead> _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a, _UHead&& __head) : _Base(__use_alloc<_Head, _Alloc, _UHead>(__a), std::forward<_UHead>(__head)) { } template<typename _Alloc> _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a, const _Tuple_impl& __in) : _Base(__use_alloc<_Head, _Alloc, _Head>(__a), _M_head(__in)) { } template<typename _Alloc> _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a, _Tuple_impl&& __in) : _Base(__use_alloc<_Head, _Alloc, _Head>(__a), std::forward<_Head>(_M_head(__in))) { } template<typename _Alloc, typename _UHead> _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a, const _Tuple_impl<_Idx, _UHead>& __in) : _Base(__use_alloc<_Head, _Alloc, _Head>(__a), _Tuple_impl<_Idx, _UHead>::_M_head(__in)) { } template<typename _Alloc, typename _UHead> _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a, _Tuple_impl<_Idx, _UHead>&& __in) : _Base(__use_alloc<_Head, _Alloc, _UHead>(__a), std::forward<_UHead>(_Tuple_impl<_Idx, _UHead>::_M_head(__in))) { } template<typename _UHead> void _M_assign(const _Tuple_impl<_Idx, _UHead>& __in) { _M_head(*this) = _Tuple_impl<_Idx, _UHead>::_M_head(__in); } template<typename _UHead> void _M_assign(_Tuple_impl<_Idx, _UHead>&& __in) { _M_head(*this) = std::forward<_UHead>(_Tuple_impl<_Idx, _UHead>::_M_head(__in)); } protected: void _M_swap(_Tuple_impl& __in) { using std::swap; swap(_M_head(*this), _M_head(__in)); } }; template<bool, typename... _Types> struct _TupleConstraints { template<typename... _UTypes> static constexpr bool __is_implicitly_constructible() { return __and_<is_constructible<_Types, _UTypes>..., is_convertible<_UTypes, _Types>... >::value; } template<typename... _UTypes> static constexpr bool __is_explicitly_constructible() { return __and_<is_constructible<_Types, _UTypes>..., __not_<__and_<is_convertible<_UTypes, _Types>...>> >::value; } static constexpr bool __is_implicitly_default_constructible() { return __and_<std::__is_implicitly_default_constructible<_Types>... >::value; } static constexpr bool __is_explicitly_default_constructible() { return __and_<is_default_constructible<_Types>..., __not_<__and_< std::__is_implicitly_default_constructible<_Types>...> >>::value; } }; template<typename... _Types> struct _TupleConstraints<false, _Types...> { template<typename... _UTypes> static constexpr bool __is_implicitly_constructible() { return false; } template<typename... _UTypes> static constexpr bool __is_explicitly_constructible() { return false; } }; template<typename... _Elements> class tuple : public _Tuple_impl<0, _Elements...> { typedef _Tuple_impl<0, _Elements...> _Inherited; template<bool _Cond> using _TCC = _TupleConstraints<_Cond, _Elements...>; template<bool _Dummy> using _ImplicitDefaultCtor = __enable_if_t< _TCC<_Dummy>::__is_implicitly_default_constructible(), bool>; template<bool _Dummy> using _ExplicitDefaultCtor = __enable_if_t< _TCC<_Dummy>::__is_explicitly_default_constructible(), bool>; template<bool _Cond, typename... _Args> using _ImplicitCtor = __enable_if_t< _TCC<_Cond>::template __is_implicitly_constructible<_Args...>(), bool>; template<bool _Cond, typename... _Args> using _ExplicitCtor = __enable_if_t< _TCC<_Cond>::template __is_explicitly_constructible<_Args...>(), bool>; template<typename... _UElements> static constexpr __enable_if_t<sizeof...(_UElements) == sizeof...(_Elements), bool> __assignable() { return __and_<is_assignable<_Elements&, _UElements>...>::value; } template<typename... _UElements> static constexpr bool __nothrow_assignable() { return __and_<is_nothrow_assignable<_Elements&, _UElements>...>::value; } template<typename... _UElements> static constexpr bool __nothrow_constructible() { return __and_<is_nothrow_constructible<_Elements, _UElements>...>::value; } template<typename _Up> static constexpr bool __valid_args() { return sizeof...(_Elements) == 1 && !is_same<tuple, __remove_cvref_t<_Up>>::value; } template<typename, typename, typename... _Tail> static constexpr bool __valid_args() { return (sizeof...(_Tail) + 2) == sizeof...(_Elements); } template<typename _Tuple, typename = tuple, typename = __remove_cvref_t<_Tuple>> struct _UseOtherCtor : false_type { }; template<typename _Tuple, typename _Tp, typename _Up> struct _UseOtherCtor<_Tuple, tuple<_Tp>, tuple<_Up>> : __or_<is_convertible<_Tuple, _Tp>, is_constructible<_Tp, _Tuple>> { }; template<typename _Tuple, typename _Tp> struct _UseOtherCtor<_Tuple, tuple<_Tp>, tuple<_Tp>> : true_type { }; template<typename _Tuple> static constexpr bool __use_other_ctor() { return _UseOtherCtor<_Tuple>::value; } public: template<typename _Dummy = void, _ImplicitDefaultCtor<is_void<_Dummy>::value> = true> constexpr tuple() noexcept(__and_<is_nothrow_default_constructible<_Elements>...>::value) : _Inherited() { } template<typename _Dummy = void, _ExplicitDefaultCtor<is_void<_Dummy>::value> = false> explicit constexpr tuple() noexcept(__and_<is_nothrow_default_constructible<_Elements>...>::value) : _Inherited() { } template<bool _NotEmpty = (sizeof...(_Elements) >= 1), _ImplicitCtor<_NotEmpty, const _Elements&...> = true> constexpr tuple(const _Elements&... __elements) noexcept(__nothrow_constructible<const _Elements&...>()) : _Inherited(__elements...) { } template<bool _NotEmpty = (sizeof...(_Elements) >= 1), _ExplicitCtor<_NotEmpty, const _Elements&...> = false> explicit constexpr tuple(const _Elements&... __elements) noexcept(__nothrow_constructible<const _Elements&...>()) : _Inherited(__elements...) { } template<typename... _UElements, bool _Valid = __valid_args<_UElements...>(), _ImplicitCtor<_Valid, _UElements...> = true> constexpr tuple(_UElements&&... __elements) noexcept(__nothrow_constructible<_UElements...>()) : _Inherited(std::forward<_UElements>(__elements)...) { } template<typename... _UElements, bool _Valid = __valid_args<_UElements...>(), _ExplicitCtor<_Valid, _UElements...> = false> explicit constexpr tuple(_UElements&&... __elements) noexcept(__nothrow_constructible<_UElements...>()) : _Inherited(std::forward<_UElements>(__elements)...) { } constexpr tuple(const tuple&) = default; constexpr tuple(tuple&&) = default; template<typename... _UElements, bool _Valid = (sizeof...(_Elements) == sizeof...(_UElements)) && !__use_other_ctor<const tuple<_UElements...>&>(), _ImplicitCtor<_Valid, const _UElements&...> = true> constexpr tuple(const tuple<_UElements...>& __in) noexcept(__nothrow_constructible<const _UElements&...>()) : _Inherited(static_cast<const _Tuple_impl<0, _UElements...>&>(__in)) { } template<typename... _UElements, bool _Valid = (sizeof...(_Elements) == sizeof...(_UElements)) && !__use_other_ctor<const tuple<_UElements...>&>(), _ExplicitCtor<_Valid, const _UElements&...> = false> explicit constexpr tuple(const tuple<_UElements...>& __in) noexcept(__nothrow_constructible<const _UElements&...>()) : _Inherited(static_cast<const _Tuple_impl<0, _UElements...>&>(__in)) { } template<typename... _UElements, bool _Valid = (sizeof...(_Elements) == sizeof...(_UElements)) && !__use_other_ctor<tuple<_UElements...>&&>(), _ImplicitCtor<_Valid, _UElements...> = true> constexpr tuple(tuple<_UElements...>&& __in) noexcept(__nothrow_constructible<_UElements...>()) : _Inherited(static_cast<_Tuple_impl<0, _UElements...>&&>(__in)) { } template<typename... _UElements, bool _Valid = (sizeof...(_Elements) == sizeof...(_UElements)) && !__use_other_ctor<tuple<_UElements...>&&>(), _ExplicitCtor<_Valid, _UElements...> = false> explicit constexpr tuple(tuple<_UElements...>&& __in) noexcept(__nothrow_constructible<_UElements...>()) : _Inherited(static_cast<_Tuple_impl<0, _UElements...>&&>(__in)) { } template<typename _Alloc, _ImplicitDefaultCtor<is_object<_Alloc>::value> = true> tuple(allocator_arg_t __tag, const _Alloc& __a) : _Inherited(__tag, __a) { } template<typename _Alloc, bool _NotEmpty = (sizeof...(_Elements) >= 1), _ImplicitCtor<_NotEmpty, const _Elements&...> = true> tuple(allocator_arg_t __tag, const _Alloc& __a, const _Elements&... __elements) : _Inherited(__tag, __a, __elements...) { } template<typename _Alloc, bool _NotEmpty = (sizeof...(_Elements) >= 1), _ExplicitCtor<_NotEmpty, const _Elements&...> = false> explicit tuple(allocator_arg_t __tag, const _Alloc& __a, const _Elements&... __elements) : _Inherited(__tag, __a, __elements...) { } template<typename _Alloc, typename... _UElements, bool _Valid = __valid_args<_UElements...>(), _ImplicitCtor<_Valid, _UElements...> = true> tuple(allocator_arg_t __tag, const _Alloc& __a, _UElements&&... __elements) : _Inherited(__tag, __a, std::forward<_UElements>(__elements)...) { } template<typename _Alloc, typename... _UElements, bool _Valid = __valid_args<_UElements...>(), _ExplicitCtor<_Valid, _UElements...> = false> explicit tuple(allocator_arg_t __tag, const _Alloc& __a, _UElements&&... __elements) : _Inherited(__tag, __a, std::forward<_UElements>(__elements)...) { } template<typename _Alloc> tuple(allocator_arg_t __tag, const _Alloc& __a, const tuple& __in) : _Inherited(__tag, __a, static_cast<const _Inherited&>(__in)) { } template<typename _Alloc> tuple(allocator_arg_t __tag, const _Alloc& __a, tuple&& __in) : _Inherited(__tag, __a, static_cast<_Inherited&&>(__in)) { } template<typename _Alloc, typename... _UElements, bool _Valid = (sizeof...(_Elements) == sizeof...(_UElements)) && !__use_other_ctor<const tuple<_UElements...>&>(), _ImplicitCtor<_Valid, const _UElements&...> = true> tuple(allocator_arg_t __tag, const _Alloc& __a, const tuple<_UElements...>& __in) : _Inherited(__tag, __a, static_cast<const _Tuple_impl<0, _UElements...>&>(__in)) { } template<typename _Alloc, typename... _UElements, bool _Valid = (sizeof...(_Elements) == sizeof...(_UElements)) && !__use_other_ctor<const tuple<_UElements...>&>(), _ExplicitCtor<_Valid, const _UElements&...> = false> explicit tuple(allocator_arg_t __tag, const _Alloc& __a, const tuple<_UElements...>& __in) : _Inherited(__tag, __a, static_cast<const _Tuple_impl<0, _UElements...>&>(__in)) { } template<typename _Alloc, typename... _UElements, bool _Valid = (sizeof...(_Elements) == sizeof...(_UElements)) && !__use_other_ctor<tuple<_UElements...>&&>(), _ImplicitCtor<_Valid, _UElements...> = true> tuple(allocator_arg_t __tag, const _Alloc& __a, tuple<_UElements...>&& __in) : _Inherited(__tag, __a, static_cast<_Tuple_impl<0, _UElements...>&&>(__in)) { } template<typename _Alloc, typename... _UElements, bool _Valid = (sizeof...(_Elements) == sizeof...(_UElements)) && !__use_other_ctor<tuple<_UElements...>&&>(), _ExplicitCtor<_Valid, _UElements...> = false> explicit tuple(allocator_arg_t __tag, const _Alloc& __a, tuple<_UElements...>&& __in) : _Inherited(__tag, __a, static_cast<_Tuple_impl<0, _UElements...>&&>(__in)) { } tuple& operator=(typename conditional<__assignable<const _Elements&...>(), const tuple&, const __nonesuch&>::type __in) noexcept(__nothrow_assignable<const _Elements&...>()) { this->_M_assign(__in); return *this; } tuple& operator=(typename conditional<__assignable<_Elements...>(), tuple&&, __nonesuch&&>::type __in) noexcept(__nothrow_assignable<_Elements...>()) { this->_M_assign(std::move(__in)); return *this; } template<typename... _UElements> __enable_if_t<__assignable<const _UElements&...>(), tuple&> operator=(const tuple<_UElements...>& __in) noexcept(__nothrow_assignable<const _UElements&...>()) { this->_M_assign(__in); return *this; } template<typename... _UElements> __enable_if_t<__assignable<_UElements...>(), tuple&> operator=(tuple<_UElements...>&& __in) noexcept(__nothrow_assignable<_UElements...>()) { this->_M_assign(std::move(__in)); return *this; } void swap(tuple& __in) noexcept(__and_<__is_nothrow_swappable<_Elements>...>::value) { _Inherited::_M_swap(__in); } }; template<> class tuple<> { public: void swap(tuple&) noexcept { } tuple() = default; template<typename _Alloc> tuple(allocator_arg_t, const _Alloc&) noexcept { } template<typename _Alloc> tuple(allocator_arg_t, const _Alloc&, const tuple&) noexcept { } }; template<typename _T1, typename _T2> class tuple<_T1, _T2> : public _Tuple_impl<0, _T1, _T2> { typedef _Tuple_impl<0, _T1, _T2> _Inherited; template<bool _Dummy, typename _U1, typename _U2> using _ImplicitDefaultCtor = __enable_if_t< _TupleConstraints<_Dummy, _U1, _U2>:: __is_implicitly_default_constructible(), bool>; template<bool _Dummy, typename _U1, typename _U2> using _ExplicitDefaultCtor = __enable_if_t< _TupleConstraints<_Dummy, _U1, _U2>:: __is_explicitly_default_constructible(), bool>; template<bool _Dummy> using _TCC = _TupleConstraints<_Dummy, _T1, _T2>; template<bool _Cond, typename _U1, typename _U2> using _ImplicitCtor = __enable_if_t< _TCC<_Cond>::template __is_implicitly_constructible<_U1, _U2>(), bool>; template<bool _Cond, typename _U1, typename _U2> using _ExplicitCtor = __enable_if_t< _TCC<_Cond>::template __is_explicitly_constructible<_U1, _U2>(), bool>; template<typename _U1, typename _U2> static constexpr bool __assignable() { return __and_<is_assignable<_T1&, _U1>, is_assignable<_T2&, _U2>>::value; } template<typename _U1, typename _U2> static constexpr bool __nothrow_assignable() { return __and_<is_nothrow_assignable<_T1&, _U1>, is_nothrow_assignable<_T2&, _U2>>::value; } template<typename _U1, typename _U2> static constexpr bool __nothrow_constructible() { return __and_<is_nothrow_constructible<_T1, _U1>, is_nothrow_constructible<_T2, _U2>>::value; } static constexpr bool __nothrow_default_constructible() { return __and_<is_nothrow_default_constructible<_T1>, is_nothrow_default_constructible<_T2>>::value; } template<typename _U1> static constexpr bool __is_alloc_arg() { return is_same<__remove_cvref_t<_U1>, allocator_arg_t>::value; } public: template<bool _Dummy = true, _ImplicitDefaultCtor<_Dummy, _T1, _T2> = true> constexpr tuple() noexcept(__nothrow_default_constructible()) : _Inherited() { } template<bool _Dummy = true, _ExplicitDefaultCtor<_Dummy, _T1, _T2> = false> explicit constexpr tuple() noexcept(__nothrow_default_constructible()) : _Inherited() { } template<bool _Dummy = true, _ImplicitCtor<_Dummy, const _T1&, const _T2&> = true> constexpr tuple(const _T1& __a1, const _T2& __a2) noexcept(__nothrow_constructible<const _T1&, const _T2&>()) : _Inherited(__a1, __a2) { } template<bool _Dummy = true, _ExplicitCtor<_Dummy, const _T1&, const _T2&> = false> explicit constexpr tuple(const _T1& __a1, const _T2& __a2) noexcept(__nothrow_constructible<const _T1&, const _T2&>()) : _Inherited(__a1, __a2) { } template<typename _U1, typename _U2, _ImplicitCtor<!__is_alloc_arg<_U1>(), _U1, _U2> = true> constexpr tuple(_U1&& __a1, _U2&& __a2) noexcept(__nothrow_constructible<_U1, _U2>()) : _Inherited(std::forward<_U1>(__a1), std::forward<_U2>(__a2)) { } template<typename _U1, typename _U2, _ExplicitCtor<!__is_alloc_arg<_U1>(), _U1, _U2> = false> explicit constexpr tuple(_U1&& __a1, _U2&& __a2) noexcept(__nothrow_constructible<_U1, _U2>()) : _Inherited(std::forward<_U1>(__a1), std::forward<_U2>(__a2)) { } constexpr tuple(const tuple&) = default; constexpr tuple(tuple&&) = default; template<typename _U1, typename _U2, _ImplicitCtor<true, const _U1&, const _U2&> = true> constexpr tuple(const tuple<_U1, _U2>& __in) noexcept(__nothrow_constructible<const _U1&, const _U2&>()) : _Inherited(static_cast<const _Tuple_impl<0, _U1, _U2>&>(__in)) { } template<typename _U1, typename _U2, _ExplicitCtor<true, const _U1&, const _U2&> = false> explicit constexpr tuple(const tuple<_U1, _U2>& __in) noexcept(__nothrow_constructible<const _U1&, const _U2&>()) : _Inherited(static_cast<const _Tuple_impl<0, _U1, _U2>&>(__in)) { } template<typename _U1, typename _U2, _ImplicitCtor<true, _U1, _U2> = true> constexpr tuple(tuple<_U1, _U2>&& __in) noexcept(__nothrow_constructible<_U1, _U2>()) : _Inherited(static_cast<_Tuple_impl<0, _U1, _U2>&&>(__in)) { } template<typename _U1, typename _U2, _ExplicitCtor<true, _U1, _U2> = false> explicit constexpr tuple(tuple<_U1, _U2>&& __in) noexcept(__nothrow_constructible<_U1, _U2>()) : _Inherited(static_cast<_Tuple_impl<0, _U1, _U2>&&>(__in)) { } template<typename _U1, typename _U2, _ImplicitCtor<true, const _U1&, const _U2&> = true> constexpr tuple(const pair<_U1, _U2>& __in) noexcept(__nothrow_constructible<const _U1&, const _U2&>()) : _Inherited(__in.first, __in.second) { } template<typename _U1, typename _U2, _ExplicitCtor<true, const _U1&, const _U2&> = false> explicit constexpr tuple(const pair<_U1, _U2>& __in) noexcept(__nothrow_constructible<const _U1&, const _U2&>()) : _Inherited(__in.first, __in.second) { } template<typename _U1, typename _U2, _ImplicitCtor<true, _U1, _U2> = true> constexpr tuple(pair<_U1, _U2>&& __in) noexcept(__nothrow_constructible<_U1, _U2>()) : _Inherited(std::forward<_U1>(__in.first), std::forward<_U2>(__in.second)) { } template<typename _U1, typename _U2, _ExplicitCtor<true, _U1, _U2> = false> explicit constexpr tuple(pair<_U1, _U2>&& __in) noexcept(__nothrow_constructible<_U1, _U2>()) : _Inherited(std::forward<_U1>(__in.first), std::forward<_U2>(__in.second)) { } template<typename _Alloc, _ImplicitDefaultCtor<is_object<_Alloc>::value, _T1, _T2> = true> tuple(allocator_arg_t __tag, const _Alloc& __a) : _Inherited(__tag, __a) { } template<typename _Alloc, bool _Dummy = true, _ImplicitCtor<_Dummy, const _T1&, const _T2&> = true> tuple(allocator_arg_t __tag, const _Alloc& __a, const _T1& __a1, const _T2& __a2) : _Inherited(__tag, __a, __a1, __a2) { } template<typename _Alloc, bool _Dummy = true, _ExplicitCtor<_Dummy, const _T1&, const _T2&> = false> explicit tuple(allocator_arg_t __tag, const _Alloc& __a, const _T1& __a1, const _T2& __a2) : _Inherited(__tag, __a, __a1, __a2) { } template<typename _Alloc, typename _U1, typename _U2, _ImplicitCtor<true, _U1, _U2> = true> tuple(allocator_arg_t __tag, const _Alloc& __a, _U1&& __a1, _U2&& __a2) : _Inherited(__tag, __a, std::forward<_U1>(__a1), std::forward<_U2>(__a2)) { } template<typename _Alloc, typename _U1, typename _U2, _ExplicitCtor<true, _U1, _U2> = false> explicit tuple(allocator_arg_t __tag, const _Alloc& __a, _U1&& __a1, _U2&& __a2) : _Inherited(__tag, __a, std::forward<_U1>(__a1), std::forward<_U2>(__a2)) { } template<typename _Alloc> tuple(allocator_arg_t __tag, const _Alloc& __a, const tuple& __in) : _Inherited(__tag, __a, static_cast<const _Inherited&>(__in)) { } template<typename _Alloc> tuple(allocator_arg_t __tag, const _Alloc& __a, tuple&& __in) : _Inherited(__tag, __a, static_cast<_Inherited&&>(__in)) { } template<typename _Alloc, typename _U1, typename _U2, _ImplicitCtor<true, const _U1&, const _U2&> = true> tuple(allocator_arg_t __tag, const _Alloc& __a, const tuple<_U1, _U2>& __in) : _Inherited(__tag, __a, static_cast<const _Tuple_impl<0, _U1, _U2>&>(__in)) { } template<typename _Alloc, typename _U1, typename _U2, _ExplicitCtor<true, const _U1&, const _U2&> = false> explicit tuple(allocator_arg_t __tag, const _Alloc& __a, const tuple<_U1, _U2>& __in) : _Inherited(__tag, __a, static_cast<const _Tuple_impl<0, _U1, _U2>&>(__in)) { } template<typename _Alloc, typename _U1, typename _U2, _ImplicitCtor<true, _U1, _U2> = true> tuple(allocator_arg_t __tag, const _Alloc& __a, tuple<_U1, _U2>&& __in) : _Inherited(__tag, __a, static_cast<_Tuple_impl<0, _U1, _U2>&&>(__in)) { } template<typename _Alloc, typename _U1, typename _U2, _ExplicitCtor<true, _U1, _U2> = false> explicit tuple(allocator_arg_t __tag, const _Alloc& __a, tuple<_U1, _U2>&& __in) : _Inherited(__tag, __a, static_cast<_Tuple_impl<0, _U1, _U2>&&>(__in)) { } template<typename _Alloc, typename _U1, typename _U2, _ImplicitCtor<true, const _U1&, const _U2&> = true> tuple(allocator_arg_t __tag, const _Alloc& __a, const pair<_U1, _U2>& __in) : _Inherited(__tag, __a, __in.first, __in.second) { } template<typename _Alloc, typename _U1, typename _U2, _ExplicitCtor<true, const _U1&, const _U2&> = false> explicit tuple(allocator_arg_t __tag, const _Alloc& __a, const pair<_U1, _U2>& __in) : _Inherited(__tag, __a, __in.first, __in.second) { } template<typename _Alloc, typename _U1, typename _U2, _ImplicitCtor<true, _U1, _U2> = true> tuple(allocator_arg_t __tag, const _Alloc& __a, pair<_U1, _U2>&& __in) : _Inherited(__tag, __a, std::forward<_U1>(__in.first), std::forward<_U2>(__in.second)) { } template<typename _Alloc, typename _U1, typename _U2, _ExplicitCtor<true, _U1, _U2> = false> explicit tuple(allocator_arg_t __tag, const _Alloc& __a, pair<_U1, _U2>&& __in) : _Inherited(__tag, __a, std::forward<_U1>(__in.first), std::forward<_U2>(__in.second)) { } tuple& operator=(typename conditional<__assignable<const _T1&, const _T2&>(), const tuple&, const __nonesuch&>::type __in) noexcept(__nothrow_assignable<const _T1&, const _T2&>()) { this->_M_assign(__in); return *this; } tuple& operator=(typename conditional<__assignable<_T1, _T2>(), tuple&&, __nonesuch&&>::type __in) noexcept(__nothrow_assignable<_T1, _T2>()) { this->_M_assign(std::move(__in)); return *this; } template<typename _U1, typename _U2> __enable_if_t<__assignable<const _U1&, const _U2&>(), tuple&> operator=(const tuple<_U1, _U2>& __in) noexcept(__nothrow_assignable<const _U1&, const _U2&>()) { this->_M_assign(__in); return *this; } template<typename _U1, typename _U2> __enable_if_t<__assignable<_U1, _U2>(), tuple&> operator=(tuple<_U1, _U2>&& __in) noexcept(__nothrow_assignable<_U1, _U2>()) { this->_M_assign(std::move(__in)); return *this; } template<typename _U1, typename _U2> __enable_if_t<__assignable<const _U1&, const _U2&>(), tuple&> operator=(const pair<_U1, _U2>& __in) noexcept(__nothrow_assignable<const _U1&, const _U2&>()) { this->_M_head(*this) = __in.first; this->_M_tail(*this)._M_head(*this) = __in.second; return *this; } template<typename _U1, typename _U2> __enable_if_t<__assignable<_U1, _U2>(), tuple&> operator=(pair<_U1, _U2>&& __in) noexcept(__nothrow_assignable<_U1, _U2>()) { this->_M_head(*this) = std::forward<_U1>(__in.first); this->_M_tail(*this)._M_head(*this) = std::forward<_U2>(__in.second); return *this; } void swap(tuple& __in) noexcept(__and_<__is_nothrow_swappable<_T1>, __is_nothrow_swappable<_T2>>::value) { _Inherited::_M_swap(__in); } }; template<typename... _Elements> struct tuple_size<tuple<_Elements...>> : public integral_constant<std::size_t, sizeof...(_Elements)> { }; template<std::size_t __i, typename _Head, typename... _Tail> struct tuple_element<__i, tuple<_Head, _Tail...> > : tuple_element<__i - 1, tuple<_Tail...> > { }; template<typename _Head, typename... _Tail> struct tuple_element<0, tuple<_Head, _Tail...> > { typedef _Head type; }; template<size_t __i> struct tuple_element<__i, tuple<>> { static_assert(__i < tuple_size<tuple<>>::value, "tuple index is in range"); }; template<std::size_t __i, typename _Head, typename... _Tail> constexpr _Head& __get_helper(_Tuple_impl<__i, _Head, _Tail...>& __t) noexcept { return _Tuple_impl<__i, _Head, _Tail...>::_M_head(__t); } template<std::size_t __i, typename _Head, typename... _Tail> constexpr const _Head& __get_helper(const _Tuple_impl<__i, _Head, _Tail...>& __t) noexcept { return _Tuple_impl<__i, _Head, _Tail...>::_M_head(__t); } template<std::size_t __i, typename... _Elements> constexpr __tuple_element_t<__i, tuple<_Elements...>>& get(tuple<_Elements...>& __t) noexcept { return std::__get_helper<__i>(__t); } template<std::size_t __i, typename... _Elements> constexpr const __tuple_element_t<__i, tuple<_Elements...>>& get(const tuple<_Elements...>& __t) noexcept { return std::__get_helper<__i>(__t); } template<std::size_t __i, typename... _Elements> constexpr __tuple_element_t<__i, tuple<_Elements...>>&& get(tuple<_Elements...>&& __t) noexcept { typedef __tuple_element_t<__i, tuple<_Elements...>> __element_type; return std::forward<__element_type&&>(std::get<__i>(__t)); } template<std::size_t __i, typename... _Elements> constexpr const __tuple_element_t<__i, tuple<_Elements...>>&& get(const tuple<_Elements...>&& __t) noexcept { typedef __tuple_element_t<__i, tuple<_Elements...>> __element_type; return std::forward<const __element_type&&>(std::get<__i>(__t)); } template<typename _Head, size_t __i, typename... _Tail> constexpr _Head& __get_helper2(_Tuple_impl<__i, _Head, _Tail...>& __t) noexcept { return _Tuple_impl<__i, _Head, _Tail...>::_M_head(__t); } template<typename _Head, size_t __i, typename... _Tail> constexpr const _Head& __get_helper2(const _Tuple_impl<__i, _Head, _Tail...>& __t) noexcept { return _Tuple_impl<__i, _Head, _Tail...>::_M_head(__t); } template <typename _Tp, typename... _Types> constexpr _Tp& get(tuple<_Types...>& __t) noexcept { return std::__get_helper2<_Tp>(__t); } template <typename _Tp, typename... _Types> constexpr _Tp&& get(tuple<_Types...>&& __t) noexcept { return std::forward<_Tp&&>(std::__get_helper2<_Tp>(__t)); } template <typename _Tp, typename... _Types> constexpr const _Tp& get(const tuple<_Types...>& __t) noexcept { return std::__get_helper2<_Tp>(__t); } template <typename _Tp, typename... _Types> constexpr const _Tp&& get(const tuple<_Types...>&& __t) noexcept { return std::forward<const _Tp&&>(std::__get_helper2<_Tp>(__t)); } template<typename _Tp, typename _Up, size_t __i, size_t __size> struct __tuple_compare { static constexpr bool __eq(const _Tp& __t, const _Up& __u) { return bool(std::get<__i>(__t) == std::get<__i>(__u)) && __tuple_compare<_Tp, _Up, __i + 1, __size>::__eq(__t, __u); } static constexpr bool __less(const _Tp& __t, const _Up& __u) { return bool(std::get<__i>(__t) < std::get<__i>(__u)) || (!bool(std::get<__i>(__u) < std::get<__i>(__t)) && __tuple_compare<_Tp, _Up, __i + 1, __size>::__less(__t, __u)); } }; template<typename _Tp, typename _Up, size_t __size> struct __tuple_compare<_Tp, _Up, __size, __size> { static constexpr bool __eq(const _Tp&, const _Up&) { return true; } static constexpr bool __less(const _Tp&, const _Up&) { return false; } }; template<typename... _TElements, typename... _UElements> constexpr bool operator==(const tuple<_TElements...>& __t, const tuple<_UElements...>& __u) { static_assert(sizeof...(_TElements) == sizeof...(_UElements), "tuple objects can only be compared if they have equal sizes."); using __compare = __tuple_compare<tuple<_TElements...>, tuple<_UElements...>, 0, sizeof...(_TElements)>; return __compare::__eq(__t, __u); } template<typename... _TElements, typename... _UElements> constexpr bool operator<(const tuple<_TElements...>& __t, const tuple<_UElements...>& __u) { static_assert(sizeof...(_TElements) == sizeof...(_UElements), "tuple objects can only be compared if they have equal sizes."); using __compare = __tuple_compare<tuple<_TElements...>, tuple<_UElements...>, 0, sizeof...(_TElements)>; return __compare::__less(__t, __u); } template<typename... _TElements, typename... _UElements> constexpr bool operator!=(const tuple<_TElements...>& __t, const tuple<_UElements...>& __u) { return !(__t == __u); } template<typename... _TElements, typename... _UElements> constexpr bool operator>(const tuple<_TElements...>& __t, const tuple<_UElements...>& __u) { return __u < __t; } template<typename... _TElements, typename... _UElements> constexpr bool operator<=(const tuple<_TElements...>& __t, const tuple<_UElements...>& __u) { return !(__u < __t); } template<typename... _TElements, typename... _UElements> constexpr bool operator>=(const tuple<_TElements...>& __t, const tuple<_UElements...>& __u) { return !(__t < __u); } template<typename... _Elements> constexpr tuple<typename __decay_and_strip<_Elements>::__type...> make_tuple(_Elements&&... __args) { typedef tuple<typename __decay_and_strip<_Elements>::__type...> __result_type; return __result_type(std::forward<_Elements>(__args)...); } template<typename... _Elements> constexpr tuple<_Elements&&...> forward_as_tuple(_Elements&&... __args) noexcept { return tuple<_Elements&&...>(std::forward<_Elements>(__args)...); } template<size_t, typename, typename, size_t> struct __make_tuple_impl; template<size_t _Idx, typename _Tuple, typename... _Tp, size_t _Nm> struct __make_tuple_impl<_Idx, tuple<_Tp...>, _Tuple, _Nm> : __make_tuple_impl<_Idx + 1, tuple<_Tp..., __tuple_element_t<_Idx, _Tuple>>, _Tuple, _Nm> { }; template<std::size_t _Nm, typename _Tuple, typename... _Tp> struct __make_tuple_impl<_Nm, tuple<_Tp...>, _Tuple, _Nm> { typedef tuple<_Tp...> __type; }; template<typename _Tuple> struct __do_make_tuple : __make_tuple_impl<0, tuple<>, _Tuple, std::tuple_size<_Tuple>::value> { }; template<typename _Tuple> struct __make_tuple : public __do_make_tuple<__remove_cvref_t<_Tuple>> { }; template<typename...> struct __combine_tuples; template<> struct __combine_tuples<> { typedef tuple<> __type; }; template<typename... _Ts> struct __combine_tuples<tuple<_Ts...>> { typedef tuple<_Ts...> __type; }; template<typename... _T1s, typename... _T2s, typename... _Rem> struct __combine_tuples<tuple<_T1s...>, tuple<_T2s...>, _Rem...> { typedef typename __combine_tuples<tuple<_T1s..., _T2s...>, _Rem...>::__type __type; }; template<typename... _Tpls> struct __tuple_cat_result { typedef typename __combine_tuples <typename __make_tuple<_Tpls>::__type...>::__type __type; }; template<typename...> struct __make_1st_indices; template<> struct __make_1st_indices<> { typedef std::_Index_tuple<> __type; }; template<typename _Tp, typename... _Tpls> struct __make_1st_indices<_Tp, _Tpls...> { typedef typename std::_Build_index_tuple<std::tuple_size< typename std::remove_reference<_Tp>::type>::value>::__type __type; }; template<typename _Ret, typename _Indices, typename... _Tpls> struct __tuple_concater; template<typename _Ret, std::size_t... _Is, typename _Tp, typename... _Tpls> struct __tuple_concater<_Ret, std::_Index_tuple<_Is...>, _Tp, _Tpls...> { template<typename... _Us> static constexpr _Ret _S_do(_Tp&& __tp, _Tpls&&... __tps, _Us&&... __us) { typedef typename __make_1st_indices<_Tpls...>::__type __idx; typedef __tuple_concater<_Ret, __idx, _Tpls...> __next; return __next::_S_do(std::forward<_Tpls>(__tps)..., std::forward<_Us>(__us)..., std::get<_Is>(std::forward<_Tp>(__tp))...); } }; template<typename _Ret> struct __tuple_concater<_Ret, std::_Index_tuple<>> { template<typename... _Us> static constexpr _Ret _S_do(_Us&&... __us) { return _Ret(std::forward<_Us>(__us)...); } }; template<typename... _Tpls, typename = typename enable_if<__and_<__is_tuple_like<_Tpls>...>::value>::type> constexpr auto tuple_cat(_Tpls&&... __tpls) -> typename __tuple_cat_result<_Tpls...>::__type { typedef typename __tuple_cat_result<_Tpls...>::__type __ret; typedef typename __make_1st_indices<_Tpls...>::__type __idx; typedef __tuple_concater<__ret, __idx, _Tpls...> __concater; return __concater::_S_do(std::forward<_Tpls>(__tpls)...); } template<typename... _Elements> constexpr tuple<_Elements&...> tie(_Elements&... __args) noexcept { return tuple<_Elements&...>(__args...); } template<typename... _Elements> inline typename enable_if<__and_<__is_swappable<_Elements>...>::value >::type swap(tuple<_Elements...>& __x, tuple<_Elements...>& __y) noexcept(noexcept(__x.swap(__y))) { __x.swap(__y); } template<typename... _Elements> typename enable_if<!__and_<__is_swappable<_Elements>...>::value>::type swap(tuple<_Elements...>&, tuple<_Elements...>&) = delete; struct _Swallow_assign { template<class _Tp> constexpr const _Swallow_assign& operator=(const _Tp&) const { return *this; } }; constexpr _Swallow_assign ignore{}; template<typename... _Types, typename _Alloc> struct uses_allocator<tuple<_Types...>, _Alloc> : true_type { }; template<class _T1, class _T2> template<typename... _Args1, typename... _Args2> inline pair<_T1, _T2>:: pair(piecewise_construct_t, tuple<_Args1...> __first, tuple<_Args2...> __second) : pair(__first, __second, typename _Build_index_tuple<sizeof...(_Args1)>::__type(), typename _Build_index_tuple<sizeof...(_Args2)>::__type()) { } template<class _T1, class _T2> template<typename... _Args1, std::size_t... _Indexes1, typename... _Args2, std::size_t... _Indexes2> inline pair<_T1, _T2>:: pair(tuple<_Args1...>& __tuple1, tuple<_Args2...>& __tuple2, _Index_tuple<_Indexes1...>, _Index_tuple<_Indexes2...>) : first(std::forward<_Args1>(std::get<_Indexes1>(__tuple1))...), second(std::forward<_Args2>(std::get<_Indexes2>(__tuple2))...) { } } namespace std __attribute__ ((__visibility__ ("default"))) { template<typename> class auto_ptr; template<typename _Tp> struct default_delete { constexpr default_delete() noexcept = default; template<typename _Up, typename = _Require<is_convertible<_Up*, _Tp*>>> default_delete(const default_delete<_Up>&) noexcept { } void operator()(_Tp* __ptr) const { static_assert(!is_void<_Tp>::value, "can't delete pointer to incomplete type"); static_assert(sizeof(_Tp)>0, "can't delete pointer to incomplete type"); delete __ptr; } }; template<typename _Tp> struct default_delete<_Tp[]> { public: constexpr default_delete() noexcept = default; template<typename _Up, typename = _Require<is_convertible<_Up(*)[], _Tp(*)[]>>> default_delete(const default_delete<_Up[]>&) noexcept { } template<typename _Up> typename enable_if<is_convertible<_Up(*)[], _Tp(*)[]>::value>::type operator()(_Up* __ptr) const { static_assert(sizeof(_Tp)>0, "can't delete pointer to incomplete type"); delete [] __ptr; } }; template <typename _Tp, typename _Dp> class __uniq_ptr_impl { template <typename _Up, typename _Ep, typename = void> struct _Ptr { using type = _Up*; }; template <typename _Up, typename _Ep> struct _Ptr<_Up, _Ep, __void_t<typename remove_reference<_Ep>::type::pointer>> { using type = typename remove_reference<_Ep>::type::pointer; }; public: using _DeleterConstraint = enable_if< __and_<__not_<is_pointer<_Dp>>, is_default_constructible<_Dp>>::value>; using pointer = typename _Ptr<_Tp, _Dp>::type; static_assert( !is_rvalue_reference<_Dp>::value, "unique_ptr's deleter type must be a function object type" " or an lvalue reference type" ); __uniq_ptr_impl() = default; __uniq_ptr_impl(pointer __p) : _M_t() { _M_ptr() = __p; } template<typename _Del> __uniq_ptr_impl(pointer __p, _Del&& __d) : _M_t(__p, std::forward<_Del>(__d)) { } __uniq_ptr_impl(__uniq_ptr_impl&& __u) noexcept : _M_t(std::move(__u._M_t)) { __u._M_ptr() = nullptr; } __uniq_ptr_impl& operator=(__uniq_ptr_impl&& __u) noexcept { reset(__u.release()); _M_deleter() = std::forward<_Dp>(__u._M_deleter()); return *this; } pointer& _M_ptr() { return std::get<0>(_M_t); } pointer _M_ptr() const { return std::get<0>(_M_t); } _Dp& _M_deleter() { return std::get<1>(_M_t); } const _Dp& _M_deleter() const { return std::get<1>(_M_t); } void reset(pointer __p) noexcept { const pointer __old_p = _M_ptr(); _M_ptr() = __p; if (__old_p) _M_deleter()(__old_p); } pointer release() noexcept { pointer __p = _M_ptr(); _M_ptr() = nullptr; return __p; } void swap(__uniq_ptr_impl& __rhs) noexcept { using std::swap; swap(this->_M_ptr(), __rhs._M_ptr()); swap(this->_M_deleter(), __rhs._M_deleter()); } private: tuple<pointer, _Dp> _M_t; }; template <typename _Tp, typename _Dp, bool = is_move_constructible<_Dp>::value, bool = is_move_assignable<_Dp>::value> struct __uniq_ptr_data : __uniq_ptr_impl<_Tp, _Dp> { using __uniq_ptr_impl<_Tp, _Dp>::__uniq_ptr_impl; __uniq_ptr_data(__uniq_ptr_data&&) = default; __uniq_ptr_data& operator=(__uniq_ptr_data&&) = default; }; template <typename _Tp, typename _Dp> struct __uniq_ptr_data<_Tp, _Dp, true, false> : __uniq_ptr_impl<_Tp, _Dp> { using __uniq_ptr_impl<_Tp, _Dp>::__uniq_ptr_impl; __uniq_ptr_data(__uniq_ptr_data&&) = default; __uniq_ptr_data& operator=(__uniq_ptr_data&&) = delete; }; template <typename _Tp, typename _Dp> struct __uniq_ptr_data<_Tp, _Dp, false, true> : __uniq_ptr_impl<_Tp, _Dp> { using __uniq_ptr_impl<_Tp, _Dp>::__uniq_ptr_impl; __uniq_ptr_data(__uniq_ptr_data&&) = delete; __uniq_ptr_data& operator=(__uniq_ptr_data&&) = default; }; template <typename _Tp, typename _Dp> struct __uniq_ptr_data<_Tp, _Dp, false, false> : __uniq_ptr_impl<_Tp, _Dp> { using __uniq_ptr_impl<_Tp, _Dp>::__uniq_ptr_impl; __uniq_ptr_data(__uniq_ptr_data&&) = delete; __uniq_ptr_data& operator=(__uniq_ptr_data&&) = delete; }; template <typename _Tp, typename _Dp = default_delete<_Tp>> class unique_ptr { template <typename _Up> using _DeleterConstraint = typename __uniq_ptr_impl<_Tp, _Up>::_DeleterConstraint::type; __uniq_ptr_data<_Tp, _Dp> _M_t; public: using pointer = typename __uniq_ptr_impl<_Tp, _Dp>::pointer; using element_type = _Tp; using deleter_type = _Dp; private: template<typename _Up, typename _Ep> using __safe_conversion_up = __and_< is_convertible<typename unique_ptr<_Up, _Ep>::pointer, pointer>, __not_<is_array<_Up>> >; public: template<typename _Del = _Dp, typename = _DeleterConstraint<_Del>> constexpr unique_ptr() noexcept : _M_t() { } template<typename _Del = _Dp, typename = _DeleterConstraint<_Del>> explicit unique_ptr(pointer __p) noexcept : _M_t(__p) { } template<typename _Del = deleter_type, typename = _Require<is_copy_constructible<_Del>>> unique_ptr(pointer __p, const deleter_type& __d) noexcept : _M_t(__p, __d) { } template<typename _Del = deleter_type, typename = _Require<is_move_constructible<_Del>>> unique_ptr(pointer __p, __enable_if_t<!is_lvalue_reference<_Del>::value, _Del&&> __d) noexcept : _M_t(__p, std::move(__d)) { } template<typename _Del = deleter_type, typename _DelUnref = typename remove_reference<_Del>::type> unique_ptr(pointer, __enable_if_t<is_lvalue_reference<_Del>::value, _DelUnref&&>) = delete; template<typename _Del = _Dp, typename = _DeleterConstraint<_Del>> constexpr unique_ptr(nullptr_t) noexcept : _M_t() { } unique_ptr(unique_ptr&&) = default; template<typename _Up, typename _Ep, typename = _Require< __safe_conversion_up<_Up, _Ep>, typename conditional<is_reference<_Dp>::value, is_same<_Ep, _Dp>, is_convertible<_Ep, _Dp>>::type>> unique_ptr(unique_ptr<_Up, _Ep>&& __u) noexcept : _M_t(__u.release(), std::forward<_Ep>(__u.get_deleter())) { } template<typename _Up, typename = _Require< is_convertible<_Up*, _Tp*>, is_same<_Dp, default_delete<_Tp>>>> unique_ptr(auto_ptr<_Up>&& __u) noexcept; ~unique_ptr() noexcept { static_assert(__is_invocable<deleter_type&, pointer>::value, "unique_ptr's deleter must be invocable with a pointer"); auto& __ptr = _M_t._M_ptr(); if (__ptr != nullptr) get_deleter()(std::move(__ptr)); __ptr = pointer(); } unique_ptr& operator=(unique_ptr&&) = default; template<typename _Up, typename _Ep> typename enable_if< __and_< __safe_conversion_up<_Up, _Ep>, is_assignable<deleter_type&, _Ep&&> >::value, unique_ptr&>::type operator=(unique_ptr<_Up, _Ep>&& __u) noexcept { reset(__u.release()); get_deleter() = std::forward<_Ep>(__u.get_deleter()); return *this; } unique_ptr& operator=(nullptr_t) noexcept { reset(); return *this; } typename add_lvalue_reference<element_type>::type operator*() const { ; return *get(); } pointer operator->() const noexcept { ; return get(); } pointer get() const noexcept { return _M_t._M_ptr(); } deleter_type& get_deleter() noexcept { return _M_t._M_deleter(); } const deleter_type& get_deleter() const noexcept { return _M_t._M_deleter(); } explicit operator bool() const noexcept { return get() == pointer() ? false : true; } pointer release() noexcept { return _M_t.release(); } void reset(pointer __p = pointer()) noexcept { static_assert(__is_invocable<deleter_type&, pointer>::value, "unique_ptr's deleter must be invocable with a pointer"); _M_t.reset(std::move(__p)); } void swap(unique_ptr& __u) noexcept { static_assert(__is_swappable<_Dp>::value, "deleter must be swappable"); _M_t.swap(__u._M_t); } unique_ptr(const unique_ptr&) = delete; unique_ptr& operator=(const unique_ptr&) = delete; }; template<typename _Tp, typename _Dp> class unique_ptr<_Tp[], _Dp> { template <typename _Up> using _DeleterConstraint = typename __uniq_ptr_impl<_Tp, _Up>::_DeleterConstraint::type; __uniq_ptr_data<_Tp, _Dp> _M_t; template<typename _Up> using __remove_cv = typename remove_cv<_Up>::type; template<typename _Up> using __is_derived_Tp = __and_< is_base_of<_Tp, _Up>, __not_<is_same<__remove_cv<_Tp>, __remove_cv<_Up>>> >; public: using pointer = typename __uniq_ptr_impl<_Tp, _Dp>::pointer; using element_type = _Tp; using deleter_type = _Dp; template<typename _Up, typename _Ep, typename _UPtr = unique_ptr<_Up, _Ep>, typename _UP_pointer = typename _UPtr::pointer, typename _UP_element_type = typename _UPtr::element_type> using __safe_conversion_up = __and_< is_array<_Up>, is_same<pointer, element_type*>, is_same<_UP_pointer, _UP_element_type*>, is_convertible<_UP_element_type(*)[], element_type(*)[]> >; template<typename _Up> using __safe_conversion_raw = __and_< __or_<__or_<is_same<_Up, pointer>, is_same<_Up, nullptr_t>>, __and_<is_pointer<_Up>, is_same<pointer, element_type*>, is_convertible< typename remove_pointer<_Up>::type(*)[], element_type(*)[]> > > >; template<typename _Del = _Dp, typename = _DeleterConstraint<_Del>> constexpr unique_ptr() noexcept : _M_t() { } template<typename _Up, typename _Vp = _Dp, typename = _DeleterConstraint<_Vp>, typename = typename enable_if< __safe_conversion_raw<_Up>::value, bool>::type> explicit unique_ptr(_Up __p) noexcept : _M_t(__p) { } template<typename _Up, typename _Del = deleter_type, typename = _Require<__safe_conversion_raw<_Up>, is_copy_constructible<_Del>>> unique_ptr(_Up __p, const deleter_type& __d) noexcept : _M_t(__p, __d) { } template<typename _Up, typename _Del = deleter_type, typename = _Require<__safe_conversion_raw<_Up>, is_move_constructible<_Del>>> unique_ptr(_Up __p, __enable_if_t<!is_lvalue_reference<_Del>::value, _Del&&> __d) noexcept : _M_t(std::move(__p), std::move(__d)) { } template<typename _Up, typename _Del = deleter_type, typename _DelUnref = typename remove_reference<_Del>::type, typename = _Require<__safe_conversion_raw<_Up>>> unique_ptr(_Up, __enable_if_t<is_lvalue_reference<_Del>::value, _DelUnref&&>) = delete; unique_ptr(unique_ptr&&) = default; template<typename _Del = _Dp, typename = _DeleterConstraint<_Del>> constexpr unique_ptr(nullptr_t) noexcept : _M_t() { } template<typename _Up, typename _Ep, typename = _Require< __safe_conversion_up<_Up, _Ep>, typename conditional<is_reference<_Dp>::value, is_same<_Ep, _Dp>, is_convertible<_Ep, _Dp>>::type>> unique_ptr(unique_ptr<_Up, _Ep>&& __u) noexcept : _M_t(__u.release(), std::forward<_Ep>(__u.get_deleter())) { } ~unique_ptr() { auto& __ptr = _M_t._M_ptr(); if (__ptr != nullptr) get_deleter()(__ptr); __ptr = pointer(); } unique_ptr& operator=(unique_ptr&&) = default; template<typename _Up, typename _Ep> typename enable_if<__and_<__safe_conversion_up<_Up, _Ep>, is_assignable<deleter_type&, _Ep&&> >::value, unique_ptr&>::type operator=(unique_ptr<_Up, _Ep>&& __u) noexcept { reset(__u.release()); get_deleter() = std::forward<_Ep>(__u.get_deleter()); return *this; } unique_ptr& operator=(nullptr_t) noexcept { reset(); return *this; } typename std::add_lvalue_reference<element_type>::type operator[](size_t __i) const { ; return get()[__i]; } pointer get() const noexcept { return _M_t._M_ptr(); } deleter_type& get_deleter() noexcept { return _M_t._M_deleter(); } const deleter_type& get_deleter() const noexcept { return _M_t._M_deleter(); } explicit operator bool() const noexcept { return get() == pointer() ? false : true; } pointer release() noexcept { return _M_t.release(); } template <typename _Up, typename = _Require< __or_<is_same<_Up, pointer>, __and_<is_same<pointer, element_type*>, is_pointer<_Up>, is_convertible< typename remove_pointer<_Up>::type(*)[], element_type(*)[] > > > >> void reset(_Up __p) noexcept { _M_t.reset(std::move(__p)); } void reset(nullptr_t = nullptr) noexcept { reset(pointer()); } void swap(unique_ptr& __u) noexcept { static_assert(__is_swappable<_Dp>::value, "deleter must be swappable"); _M_t.swap(__u._M_t); } unique_ptr(const unique_ptr&) = delete; unique_ptr& operator=(const unique_ptr&) = delete; }; template<typename _Tp, typename _Dp> inline typename enable_if<__is_swappable<_Dp>::value>::type swap(unique_ptr<_Tp, _Dp>& __x, unique_ptr<_Tp, _Dp>& __y) noexcept { __x.swap(__y); } template<typename _Tp, typename _Dp> typename enable_if<!__is_swappable<_Dp>::value>::type swap(unique_ptr<_Tp, _Dp>&, unique_ptr<_Tp, _Dp>&) = delete; template<typename _Tp, typename _Dp, typename _Up, typename _Ep> inline bool operator==(const unique_ptr<_Tp, _Dp>& __x, const unique_ptr<_Up, _Ep>& __y) { return __x.get() == __y.get(); } template<typename _Tp, typename _Dp> inline bool operator==(const unique_ptr<_Tp, _Dp>& __x, nullptr_t) noexcept { return !__x; } template<typename _Tp, typename _Dp> inline bool operator==(nullptr_t, const unique_ptr<_Tp, _Dp>& __x) noexcept { return !__x; } template<typename _Tp, typename _Dp, typename _Up, typename _Ep> inline bool operator!=(const unique_ptr<_Tp, _Dp>& __x, const unique_ptr<_Up, _Ep>& __y) { return __x.get() != __y.get(); } template<typename _Tp, typename _Dp> inline bool operator!=(const unique_ptr<_Tp, _Dp>& __x, nullptr_t) noexcept { return (bool)__x; } template<typename _Tp, typename _Dp> inline bool operator!=(nullptr_t, const unique_ptr<_Tp, _Dp>& __x) noexcept { return (bool)__x; } template<typename _Tp, typename _Dp, typename _Up, typename _Ep> inline bool operator<(const unique_ptr<_Tp, _Dp>& __x, const unique_ptr<_Up, _Ep>& __y) { typedef typename std::common_type<typename unique_ptr<_Tp, _Dp>::pointer, typename unique_ptr<_Up, _Ep>::pointer>::type _CT; return std::less<_CT>()(__x.get(), __y.get()); } template<typename _Tp, typename _Dp> inline bool operator<(const unique_ptr<_Tp, _Dp>& __x, nullptr_t) { return std::less<typename unique_ptr<_Tp, _Dp>::pointer>()(__x.get(), nullptr); } template<typename _Tp, typename _Dp> inline bool operator<(nullptr_t, const unique_ptr<_Tp, _Dp>& __x) { return std::less<typename unique_ptr<_Tp, _Dp>::pointer>()(nullptr, __x.get()); } template<typename _Tp, typename _Dp, typename _Up, typename _Ep> inline bool operator<=(const unique_ptr<_Tp, _Dp>& __x, const unique_ptr<_Up, _Ep>& __y) { return !(__y < __x); } template<typename _Tp, typename _Dp> inline bool operator<=(const unique_ptr<_Tp, _Dp>& __x, nullptr_t) { return !(nullptr < __x); } template<typename _Tp, typename _Dp> inline bool operator<=(nullptr_t, const unique_ptr<_Tp, _Dp>& __x) { return !(__x < nullptr); } template<typename _Tp, typename _Dp, typename _Up, typename _Ep> inline bool operator>(const unique_ptr<_Tp, _Dp>& __x, const unique_ptr<_Up, _Ep>& __y) { return (__y < __x); } template<typename _Tp, typename _Dp> inline bool operator>(const unique_ptr<_Tp, _Dp>& __x, nullptr_t) { return std::less<typename unique_ptr<_Tp, _Dp>::pointer>()(nullptr, __x.get()); } template<typename _Tp, typename _Dp> inline bool operator>(nullptr_t, const unique_ptr<_Tp, _Dp>& __x) { return std::less<typename unique_ptr<_Tp, _Dp>::pointer>()(__x.get(), nullptr); } template<typename _Tp, typename _Dp, typename _Up, typename _Ep> inline bool operator>=(const unique_ptr<_Tp, _Dp>& __x, const unique_ptr<_Up, _Ep>& __y) { return !(__x < __y); } template<typename _Tp, typename _Dp> inline bool operator>=(const unique_ptr<_Tp, _Dp>& __x, nullptr_t) { return !(__x < nullptr); } template<typename _Tp, typename _Dp> inline bool operator>=(nullptr_t, const unique_ptr<_Tp, _Dp>& __x) { return !(nullptr < __x); } template<typename _Up, typename _Ptr = typename _Up::pointer, bool = __poison_hash<_Ptr>::__enable_hash_call> struct __uniq_ptr_hash : private __poison_hash<_Ptr> { size_t operator()(const _Up& __u) const noexcept(noexcept(std::declval<hash<_Ptr>>()(std::declval<_Ptr>()))) { return hash<_Ptr>()(__u.get()); } }; template<typename _Up, typename _Ptr> struct __uniq_ptr_hash<_Up, _Ptr, false> : private __poison_hash<_Ptr> { }; template<typename _Tp, typename _Dp> struct hash<unique_ptr<_Tp, _Dp>> : public __hash_base<size_t, unique_ptr<_Tp, _Dp>>, public __uniq_ptr_hash<unique_ptr<_Tp, _Dp>> { }; template<typename _Tp> struct _MakeUniq { typedef unique_ptr<_Tp> __single_object; }; template<typename _Tp> struct _MakeUniq<_Tp[]> { typedef unique_ptr<_Tp[]> __array; }; template<typename _Tp, size_t _Bound> struct _MakeUniq<_Tp[_Bound]> { struct __invalid_type { }; }; template<typename _Tp, typename... _Args> inline typename _MakeUniq<_Tp>::__single_object make_unique(_Args&&... __args) { return unique_ptr<_Tp>(new _Tp(std::forward<_Args>(__args)...)); } template<typename _Tp> inline typename _MakeUniq<_Tp>::__array make_unique(size_t __num) { return unique_ptr<_Tp>(new remove_extent_t<_Tp>[__num]()); } template<typename _Tp, typename... _Args> inline typename _MakeUniq<_Tp>::__invalid_type make_unique(_Args&&...) = delete; } namespace std __attribute__ ((__visibility__ ("default"))) { template<typename _Alloc> struct __allocated_ptr { using pointer = typename allocator_traits<_Alloc>::pointer; using value_type = typename allocator_traits<_Alloc>::value_type; __allocated_ptr(_Alloc& __a, pointer __ptr) noexcept : _M_alloc(std::__addressof(__a)), _M_ptr(__ptr) { } 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)) { } __allocated_ptr(__allocated_ptr&& __gd) noexcept : _M_alloc(__gd._M_alloc), _M_ptr(__gd._M_ptr) { __gd._M_ptr = nullptr; } ~__allocated_ptr() { if (_M_ptr != nullptr) std::allocator_traits<_Alloc>::deallocate(*_M_alloc, _M_ptr, 1); } __allocated_ptr& operator=(std::nullptr_t) noexcept { _M_ptr = nullptr; return *this; } value_type* get() { return std::__to_address(_M_ptr); } private: _Alloc* _M_alloc; pointer _M_ptr; }; template<typename _Alloc> __allocated_ptr<_Alloc> __allocate_guarded(_Alloc& __a) { return { __a, std::allocator_traits<_Alloc>::allocate(__a, 1) }; } } namespace std __attribute__ ((__visibility__ ("default"))) { template<typename _Res, typename... _ArgTypes> struct _Maybe_unary_or_binary_function { }; template<typename _Res, typename _T1> struct _Maybe_unary_or_binary_function<_Res, _T1> : std::unary_function<_T1, _Res> { }; template<typename _Res, typename _T1, typename _T2> struct _Maybe_unary_or_binary_function<_Res, _T1, _T2> : std::binary_function<_T1, _T2, _Res> { }; template<typename _Signature> struct _Mem_fn_traits; template<typename _Res, typename _Class, typename... _ArgTypes> struct _Mem_fn_traits_base { using __result_type = _Res; using __maybe_type = _Maybe_unary_or_binary_function<_Res, _Class*, _ArgTypes...>; using __arity = integral_constant<size_t, sizeof...(_ArgTypes)>; }; template<typename _Res, typename _Class, typename... _ArgTypes> struct _Mem_fn_traits<_Res (_Class::*)(_ArgTypes...) > : _Mem_fn_traits_base<_Res, _Class, _ArgTypes...> { using __vararg = false_type; }; template<typename _Res, typename _Class, typename... _ArgTypes> struct _Mem_fn_traits<_Res (_Class::*)(_ArgTypes... ...) > : _Mem_fn_traits_base<_Res, _Class, _ArgTypes...> { using __vararg = true_type; }; template<typename _Res, typename _Class, typename... _ArgTypes> struct _Mem_fn_traits<_Res (_Class::*)(_ArgTypes...) const > : _Mem_fn_traits_base<_Res, const _Class, _ArgTypes...> { using __vararg = false_type; }; template<typename _Res, typename _Class, typename... _ArgTypes> struct _Mem_fn_traits<_Res (_Class::*)(_ArgTypes... ...) const > : _Mem_fn_traits_base<_Res, const _Class, _ArgTypes...> { using __vararg = true_type; }; template<typename _Res, typename _Class, typename... _ArgTypes> struct _Mem_fn_traits<_Res (_Class::*)(_ArgTypes...) volatile > : _Mem_fn_traits_base<_Res, volatile _Class, _ArgTypes...> { using __vararg = false_type; }; template<typename _Res, typename _Class, typename... _ArgTypes> struct _Mem_fn_traits<_Res (_Class::*)(_ArgTypes... ...) volatile > : _Mem_fn_traits_base<_Res, volatile _Class, _ArgTypes...> { using __vararg = true_type; }; template<typename _Res, typename _Class, typename... _ArgTypes> struct _Mem_fn_traits<_Res (_Class::*)(_ArgTypes...) const volatile > : _Mem_fn_traits_base<_Res, const volatile _Class, _ArgTypes...> { using __vararg = false_type; }; template<typename _Res, typename _Class, typename... _ArgTypes> struct _Mem_fn_traits<_Res (_Class::*)(_ArgTypes... ...) const volatile > : _Mem_fn_traits_base<_Res, const volatile _Class, _ArgTypes...> { using __vararg = true_type; }; template<typename _Res, typename _Class, typename... _ArgTypes> struct _Mem_fn_traits<_Res (_Class::*)(_ArgTypes...) &> : _Mem_fn_traits_base<_Res, _Class, _ArgTypes...> { using __vararg = false_type; }; template<typename _Res, typename _Class, typename... _ArgTypes> struct _Mem_fn_traits<_Res (_Class::*)(_ArgTypes... ...) &> : _Mem_fn_traits_base<_Res, _Class, _ArgTypes...> { using __vararg = true_type; }; template<typename _Res, typename _Class, typename... _ArgTypes> struct _Mem_fn_traits<_Res (_Class::*)(_ArgTypes...) const &> : _Mem_fn_traits_base<_Res, const _Class, _ArgTypes...> { using __vararg = false_type; }; template<typename _Res, typename _Class, typename... _ArgTypes> struct _Mem_fn_traits<_Res (_Class::*)(_ArgTypes... ...) const &> : _Mem_fn_traits_base<_Res, const _Class, _ArgTypes...> { using __vararg = true_type; }; template<typename _Res, typename _Class, typename... _ArgTypes> struct _Mem_fn_traits<_Res (_Class::*)(_ArgTypes...) volatile &> : _Mem_fn_traits_base<_Res, volatile _Class, _ArgTypes...> { using __vararg = false_type; }; template<typename _Res, typename _Class, typename... _ArgTypes> struct _Mem_fn_traits<_Res (_Class::*)(_ArgTypes... ...) volatile &> : _Mem_fn_traits_base<_Res, volatile _Class, _ArgTypes...> { using __vararg = true_type; }; template<typename _Res, typename _Class, typename... _ArgTypes> struct _Mem_fn_traits<_Res (_Class::*)(_ArgTypes...) const volatile &> : _Mem_fn_traits_base<_Res, const volatile _Class, _ArgTypes...> { using __vararg = false_type; }; template<typename _Res, typename _Class, typename... _ArgTypes> struct _Mem_fn_traits<_Res (_Class::*)(_ArgTypes... ...) const volatile &> : _Mem_fn_traits_base<_Res, const volatile _Class, _ArgTypes...> { using __vararg = true_type; }; template<typename _Res, typename _Class, typename... _ArgTypes> struct _Mem_fn_traits<_Res (_Class::*)(_ArgTypes...) &&> : _Mem_fn_traits_base<_Res, _Class, _ArgTypes...> { using __vararg = false_type; }; template<typename _Res, typename _Class, typename... _ArgTypes> struct _Mem_fn_traits<_Res (_Class::*)(_ArgTypes... ...) &&> : _Mem_fn_traits_base<_Res, _Class, _ArgTypes...> { using __vararg = true_type; }; template<typename _Res, typename _Class, typename... _ArgTypes> struct _Mem_fn_traits<_Res (_Class::*)(_ArgTypes...) const &&> : _Mem_fn_traits_base<_Res, const _Class, _ArgTypes...> { using __vararg = false_type; }; template<typename _Res, typename _Class, typename... _ArgTypes> struct _Mem_fn_traits<_Res (_Class::*)(_ArgTypes... ...) const &&> : _Mem_fn_traits_base<_Res, const _Class, _ArgTypes...> { using __vararg = true_type; }; template<typename _Res, typename _Class, typename... _ArgTypes> struct _Mem_fn_traits<_Res (_Class::*)(_ArgTypes...) volatile &&> : _Mem_fn_traits_base<_Res, volatile _Class, _ArgTypes...> { using __vararg = false_type; }; template<typename _Res, typename _Class, typename... _ArgTypes> struct _Mem_fn_traits<_Res (_Class::*)(_ArgTypes... ...) volatile &&> : _Mem_fn_traits_base<_Res, volatile _Class, _ArgTypes...> { using __vararg = true_type; }; template<typename _Res, typename _Class, typename... _ArgTypes> struct _Mem_fn_traits<_Res (_Class::*)(_ArgTypes...) const volatile &&> : _Mem_fn_traits_base<_Res, const volatile _Class, _ArgTypes...> { using __vararg = false_type; }; template<typename _Res, typename _Class, typename... _ArgTypes> struct _Mem_fn_traits<_Res (_Class::*)(_ArgTypes... ...) const volatile &&> : _Mem_fn_traits_base<_Res, const volatile _Class, _ArgTypes...> { using __vararg = true_type; }; template<typename _Functor, typename = __void_t<>> struct _Maybe_get_result_type { }; template<typename _Functor> struct _Maybe_get_result_type<_Functor, __void_t<typename _Functor::result_type>> { typedef typename _Functor::result_type result_type; }; template<typename _Functor> struct _Weak_result_type_impl : _Maybe_get_result_type<_Functor> { }; template<typename _Res, typename... _ArgTypes > struct _Weak_result_type_impl<_Res(_ArgTypes...) > { typedef _Res result_type; }; template<typename _Res, typename... _ArgTypes > struct _Weak_result_type_impl<_Res(_ArgTypes......) > { typedef _Res result_type; }; template<typename _Res, typename... _ArgTypes > struct _Weak_result_type_impl<_Res(*)(_ArgTypes...) > { typedef _Res result_type; }; template<typename _Res, typename... _ArgTypes > struct _Weak_result_type_impl<_Res(*)(_ArgTypes......) > { typedef _Res result_type; }; template<typename _Functor, bool = is_member_function_pointer<_Functor>::value> struct _Weak_result_type_memfun : _Weak_result_type_impl<_Functor> { }; template<typename _MemFunPtr> struct _Weak_result_type_memfun<_MemFunPtr, true> { using result_type = typename _Mem_fn_traits<_MemFunPtr>::__result_type; }; template<typename _Func, typename _Class> struct _Weak_result_type_memfun<_Func _Class::*, false> { }; template<typename _Functor> struct _Weak_result_type : _Weak_result_type_memfun<typename remove_cv<_Functor>::type> { }; template<typename _Tp, typename = __void_t<>> struct _Refwrap_base_arg1 { }; template<typename _Tp> struct _Refwrap_base_arg1<_Tp, __void_t<typename _Tp::argument_type>> { typedef typename _Tp::argument_type argument_type; }; template<typename _Tp, typename = __void_t<>> struct _Refwrap_base_arg2 { }; template<typename _Tp> struct _Refwrap_base_arg2<_Tp, __void_t<typename _Tp::first_argument_type, typename _Tp::second_argument_type>> { typedef typename _Tp::first_argument_type first_argument_type; typedef typename _Tp::second_argument_type second_argument_type; }; template<typename _Tp> struct _Reference_wrapper_base : _Weak_result_type<_Tp>, _Refwrap_base_arg1<_Tp>, _Refwrap_base_arg2<_Tp> { }; template<typename _Res, typename _T1 > struct _Reference_wrapper_base<_Res(_T1) > : unary_function<_T1, _Res> { }; template<typename _Res, typename _T1> struct _Reference_wrapper_base<_Res(_T1) const> : unary_function<_T1, _Res> { }; template<typename _Res, typename _T1> struct _Reference_wrapper_base<_Res(_T1) volatile> : unary_function<_T1, _Res> { }; template<typename _Res, typename _T1> struct _Reference_wrapper_base<_Res(_T1) const volatile> : unary_function<_T1, _Res> { }; template<typename _Res, typename _T1, typename _T2 > struct _Reference_wrapper_base<_Res(_T1, _T2) > : binary_function<_T1, _T2, _Res> { }; template<typename _Res, typename _T1, typename _T2> struct _Reference_wrapper_base<_Res(_T1, _T2) const> : binary_function<_T1, _T2, _Res> { }; template<typename _Res, typename _T1, typename _T2> struct _Reference_wrapper_base<_Res(_T1, _T2) volatile> : binary_function<_T1, _T2, _Res> { }; template<typename _Res, typename _T1, typename _T2> struct _Reference_wrapper_base<_Res(_T1, _T2) const volatile> : binary_function<_T1, _T2, _Res> { }; template<typename _Res, typename _T1 > struct _Reference_wrapper_base<_Res(*)(_T1) > : unary_function<_T1, _Res> { }; template<typename _Res, typename _T1, typename _T2 > struct _Reference_wrapper_base<_Res(*)(_T1, _T2) > : binary_function<_T1, _T2, _Res> { }; template<typename _Tp, bool = is_member_function_pointer<_Tp>::value> struct _Reference_wrapper_base_memfun : _Reference_wrapper_base<_Tp> { }; template<typename _MemFunPtr> struct _Reference_wrapper_base_memfun<_MemFunPtr, true> : _Mem_fn_traits<_MemFunPtr>::__maybe_type { using result_type = typename _Mem_fn_traits<_MemFunPtr>::__result_type; }; template<typename _Tp> class reference_wrapper : public _Reference_wrapper_base_memfun<typename remove_cv<_Tp>::type> { _Tp* _M_data; static _Tp* _S_fun(_Tp& __r) noexcept { return std::__addressof(__r); } static void _S_fun(_Tp&&) = delete; template<typename _Up, typename _Up2 = __remove_cvref_t<_Up>> using __not_same = typename enable_if<!is_same<reference_wrapper, _Up2>::value>::type; public: typedef _Tp type; template<typename _Up, typename = __not_same<_Up>, typename = decltype(reference_wrapper::_S_fun(std::declval<_Up>()))> reference_wrapper(_Up&& __uref) noexcept(noexcept(reference_wrapper::_S_fun(std::declval<_Up>()))) : _M_data(reference_wrapper::_S_fun(std::forward<_Up>(__uref))) { } reference_wrapper(const reference_wrapper&) = default; reference_wrapper& operator=(const reference_wrapper&) = default; operator _Tp&() const noexcept { return this->get(); } _Tp& get() const noexcept { return *_M_data; } template<typename... _Args> typename result_of<_Tp&(_Args&&...)>::type operator()(_Args&&... __args) const { return std::__invoke(get(), std::forward<_Args>(__args)...); } }; template<typename _Tp> inline reference_wrapper<_Tp> ref(_Tp& __t) noexcept { return reference_wrapper<_Tp>(__t); } template<typename _Tp> inline reference_wrapper<const _Tp> cref(const _Tp& __t) noexcept { return reference_wrapper<const _Tp>(__t); } template<typename _Tp> void ref(const _Tp&&) = delete; template<typename _Tp> void cref(const _Tp&&) = delete; template<typename _Tp> inline reference_wrapper<_Tp> ref(reference_wrapper<_Tp> __t) noexcept { return __t; } template<typename _Tp> inline reference_wrapper<const _Tp> cref(reference_wrapper<_Tp> __t) noexcept { return { __t.get() }; } } namespace __gnu_cxx { template<typename _Tp> struct __aligned_membuf { struct _Tp2 { _Tp _M_t; }; alignas(__alignof__(_Tp2::_M_t)) unsigned char _M_storage[sizeof(_Tp)]; __aligned_membuf() = default; __aligned_membuf(std::nullptr_t) { } void* _M_addr() noexcept { return static_cast<void*>(&_M_storage); } const void* _M_addr() const noexcept { return static_cast<const void*>(&_M_storage); } _Tp* _M_ptr() noexcept { return static_cast<_Tp*>(_M_addr()); } const _Tp* _M_ptr() const noexcept { return static_cast<const _Tp*>(_M_addr()); } }; template<typename _Tp> struct __aligned_buffer : std::aligned_storage<sizeof(_Tp), __alignof__(_Tp)> { typename std::aligned_storage<sizeof(_Tp), __alignof__(_Tp)>::type _M_storage; __aligned_buffer() = default; __aligned_buffer(std::nullptr_t) { } void* _M_addr() noexcept { return static_cast<void*>(&_M_storage); } const void* _M_addr() const noexcept { return static_cast<const void*>(&_M_storage); } _Tp* _M_ptr() noexcept { return static_cast<_Tp*>(_M_addr()); } const _Tp* _M_ptr() const noexcept { return static_cast<const _Tp*>(_M_addr()); } }; } namespace std __attribute__ ((__visibility__ ("default"))) { template<typename> class auto_ptr; class bad_weak_ptr : public std::exception { public: virtual char const* what() const noexcept; virtual ~bad_weak_ptr() noexcept; }; inline void __throw_bad_weak_ptr() { (throw (bad_weak_ptr())); } using __gnu_cxx::_Lock_policy; using __gnu_cxx::__default_lock_policy; using __gnu_cxx::_S_single; using __gnu_cxx::_S_mutex; using __gnu_cxx::_S_atomic; template<_Lock_policy _Lp> class _Mutex_base { protected: enum { _S_need_barriers = 0 }; }; template<> class _Mutex_base<_S_mutex> : public __gnu_cxx::__mutex { protected: enum { _S_need_barriers = 1 }; }; template<_Lock_policy _Lp = __default_lock_policy> class _Sp_counted_base : public _Mutex_base<_Lp> { public: _Sp_counted_base() noexcept : _M_use_count(1), _M_weak_count(1) { } virtual ~_Sp_counted_base() noexcept { } virtual void _M_dispose() noexcept = 0; virtual void _M_destroy() noexcept { delete this; } virtual void* _M_get_deleter(const std::type_info&) noexcept = 0; void _M_add_ref_copy() { __gnu_cxx::__atomic_add_dispatch(&_M_use_count, 1); } void _M_add_ref_lock(); bool _M_add_ref_lock_nothrow(); void _M_release() noexcept { ; if (__gnu_cxx::__exchange_and_add_dispatch(&_M_use_count, -1) == 1) { ; _M_dispose(); if (_Mutex_base<_Lp>::_S_need_barriers) { __atomic_thread_fence (4); } ; if (__gnu_cxx::__exchange_and_add_dispatch(&_M_weak_count, -1) == 1) { ; _M_destroy(); } } } void _M_weak_add_ref() noexcept { __gnu_cxx::__atomic_add_dispatch(&_M_weak_count, 1); } void _M_weak_release() noexcept { ; if (__gnu_cxx::__exchange_and_add_dispatch(&_M_weak_count, -1) == 1) { ; if (_Mutex_base<_Lp>::_S_need_barriers) { __atomic_thread_fence (4); } _M_destroy(); } } long _M_get_use_count() const noexcept { return __atomic_load_n(&_M_use_count, 0); } private: _Sp_counted_base(_Sp_counted_base const&) = delete; _Sp_counted_base& operator=(_Sp_counted_base const&) = delete; _Atomic_word _M_use_count; _Atomic_word _M_weak_count; }; template<> inline void _Sp_counted_base<_S_single>:: _M_add_ref_lock() { if (_M_use_count == 0) __throw_bad_weak_ptr(); ++_M_use_count; } template<> inline void _Sp_counted_base<_S_mutex>:: _M_add_ref_lock() { __gnu_cxx::__scoped_lock sentry(*this); if (__gnu_cxx::__exchange_and_add_dispatch(&_M_use_count, 1) == 0) { _M_use_count = 0; __throw_bad_weak_ptr(); } } template<> inline void _Sp_counted_base<_S_atomic>:: _M_add_ref_lock() { _Atomic_word __count = _M_get_use_count(); do { if (__count == 0) __throw_bad_weak_ptr(); } while (!__atomic_compare_exchange_n(&_M_use_count, &__count, __count + 1, true, 4, 0)); } template<> inline bool _Sp_counted_base<_S_single>:: _M_add_ref_lock_nothrow() { if (_M_use_count == 0) return false; ++_M_use_count; return true; } template<> inline bool _Sp_counted_base<_S_mutex>:: _M_add_ref_lock_nothrow() { __gnu_cxx::__scoped_lock sentry(*this); if (__gnu_cxx::__exchange_and_add_dispatch(&_M_use_count, 1) == 0) { _M_use_count = 0; return false; } return true; } template<> inline bool _Sp_counted_base<_S_atomic>:: _M_add_ref_lock_nothrow() { _Atomic_word __count = _M_get_use_count(); do { if (__count == 0) return false; } while (!__atomic_compare_exchange_n(&_M_use_count, &__count, __count + 1, true, 4, 0)); return true; } template<> inline void _Sp_counted_base<_S_single>::_M_add_ref_copy() { ++_M_use_count; } template<> inline void _Sp_counted_base<_S_single>::_M_release() noexcept { if (--_M_use_count == 0) { _M_dispose(); if (--_M_weak_count == 0) _M_destroy(); } } template<> inline void _Sp_counted_base<_S_single>::_M_weak_add_ref() noexcept { ++_M_weak_count; } template<> inline void _Sp_counted_base<_S_single>::_M_weak_release() noexcept { if (--_M_weak_count == 0) _M_destroy(); } template<> inline long _Sp_counted_base<_S_single>::_M_get_use_count() const noexcept { return _M_use_count; } template<typename _Tp, _Lock_policy _Lp = __default_lock_policy> class __shared_ptr; template<typename _Tp, _Lock_policy _Lp = __default_lock_policy> class __weak_ptr; template<typename _Tp, _Lock_policy _Lp = __default_lock_policy> class __enable_shared_from_this; template<typename _Tp> class shared_ptr; template<typename _Tp> class weak_ptr; template<typename _Tp> struct owner_less; template<typename _Tp> class enable_shared_from_this; template<_Lock_policy _Lp = __default_lock_policy> class __weak_count; template<_Lock_policy _Lp = __default_lock_policy> class __shared_count; template<typename _Ptr, _Lock_policy _Lp> class _Sp_counted_ptr final : public _Sp_counted_base<_Lp> { public: explicit _Sp_counted_ptr(_Ptr __p) noexcept : _M_ptr(__p) { } virtual void _M_dispose() noexcept { delete _M_ptr; } virtual void _M_destroy() noexcept { delete this; } virtual void* _M_get_deleter(const std::type_info&) noexcept { return nullptr; } _Sp_counted_ptr(const _Sp_counted_ptr&) = delete; _Sp_counted_ptr& operator=(const _Sp_counted_ptr&) = delete; private: _Ptr _M_ptr; }; template<> inline void _Sp_counted_ptr<nullptr_t, _S_single>::_M_dispose() noexcept { } template<> inline void _Sp_counted_ptr<nullptr_t, _S_mutex>::_M_dispose() noexcept { } template<> inline void _Sp_counted_ptr<nullptr_t, _S_atomic>::_M_dispose() noexcept { } template<int _Nm, typename _Tp, bool __use_ebo = !__is_final(_Tp) && __is_empty(_Tp)> struct _Sp_ebo_helper; template<int _Nm, typename _Tp> struct _Sp_ebo_helper<_Nm, _Tp, true> : private _Tp { explicit _Sp_ebo_helper(const _Tp& __tp) : _Tp(__tp) { } explicit _Sp_ebo_helper(_Tp&& __tp) : _Tp(std::move(__tp)) { } static _Tp& _S_get(_Sp_ebo_helper& __eboh) { return static_cast<_Tp&>(__eboh); } }; template<int _Nm, typename _Tp> struct _Sp_ebo_helper<_Nm, _Tp, false> { explicit _Sp_ebo_helper(const _Tp& __tp) : _M_tp(__tp) { } explicit _Sp_ebo_helper(_Tp&& __tp) : _M_tp(std::move(__tp)) { } static _Tp& _S_get(_Sp_ebo_helper& __eboh) { return __eboh._M_tp; } private: _Tp _M_tp; }; template<typename _Ptr, typename _Deleter, typename _Alloc, _Lock_policy _Lp> class _Sp_counted_deleter final : public _Sp_counted_base<_Lp> { class _Impl : _Sp_ebo_helper<0, _Deleter>, _Sp_ebo_helper<1, _Alloc> { typedef _Sp_ebo_helper<0, _Deleter> _Del_base; typedef _Sp_ebo_helper<1, _Alloc> _Alloc_base; public: _Impl(_Ptr __p, _Deleter __d, const _Alloc& __a) noexcept : _M_ptr(__p), _Del_base(std::move(__d)), _Alloc_base(__a) { } _Deleter& _M_del() noexcept { return _Del_base::_S_get(*this); } _Alloc& _M_alloc() noexcept { return _Alloc_base::_S_get(*this); } _Ptr _M_ptr; }; public: using __allocator_type = __alloc_rebind<_Alloc, _Sp_counted_deleter>; _Sp_counted_deleter(_Ptr __p, _Deleter __d) noexcept : _M_impl(__p, std::move(__d), _Alloc()) { } _Sp_counted_deleter(_Ptr __p, _Deleter __d, const _Alloc& __a) noexcept : _M_impl(__p, std::move(__d), __a) { } ~_Sp_counted_deleter() noexcept { } virtual void _M_dispose() noexcept { _M_impl._M_del()(_M_impl._M_ptr); } virtual void _M_destroy() noexcept { __allocator_type __a(_M_impl._M_alloc()); __allocated_ptr<__allocator_type> __guard_ptr{ __a, this }; this->~_Sp_counted_deleter(); } virtual void* _M_get_deleter(const std::type_info& __ti) noexcept { return __ti == typeid(_Deleter) ? std::__addressof(_M_impl._M_del()) : nullptr; } private: _Impl _M_impl; }; struct _Sp_make_shared_tag { private: template<typename _Tp, typename _Alloc, _Lock_policy _Lp> friend class _Sp_counted_ptr_inplace; static const type_info& _S_ti() noexcept __attribute__ ((__visibility__ ("default"))) { alignas(type_info) static constexpr char __tag[sizeof(type_info)] = { }; return reinterpret_cast<const type_info&>(__tag); } static bool _S_eq(const type_info&) noexcept; }; template<typename _Alloc> struct _Sp_alloc_shared_tag { const _Alloc& _M_a; }; template<typename _Tp, typename _Alloc, _Lock_policy _Lp> class _Sp_counted_ptr_inplace final : public _Sp_counted_base<_Lp> { class _Impl : _Sp_ebo_helper<0, _Alloc> { typedef _Sp_ebo_helper<0, _Alloc> _A_base; public: explicit _Impl(_Alloc __a) noexcept : _A_base(__a) { } _Alloc& _M_alloc() noexcept { return _A_base::_S_get(*this); } __gnu_cxx::__aligned_buffer<_Tp> _M_storage; }; public: using __allocator_type = __alloc_rebind<_Alloc, _Sp_counted_ptr_inplace>; template<typename... _Args> _Sp_counted_ptr_inplace(_Alloc __a, _Args&&... __args) : _M_impl(__a) { allocator_traits<_Alloc>::construct(__a, _M_ptr(), std::forward<_Args>(__args)...); } ~_Sp_counted_ptr_inplace() noexcept { } virtual void _M_dispose() noexcept { allocator_traits<_Alloc>::destroy(_M_impl._M_alloc(), _M_ptr()); } virtual void _M_destroy() noexcept { __allocator_type __a(_M_impl._M_alloc()); __allocated_ptr<__allocator_type> __guard_ptr{ __a, this }; this->~_Sp_counted_ptr_inplace(); } private: friend class __shared_count<_Lp>; virtual void* _M_get_deleter(const std::type_info& __ti) noexcept override { auto __ptr = const_cast<typename remove_cv<_Tp>::type*>(_M_ptr()); if (&__ti == &_Sp_make_shared_tag::_S_ti() || __ti == typeid(_Sp_make_shared_tag) ) return __ptr; return nullptr; } _Tp* _M_ptr() noexcept { return _M_impl._M_storage._M_ptr(); } _Impl _M_impl; }; struct __sp_array_delete { template<typename _Yp> void operator()(_Yp* __p) const { delete[] __p; } }; template<_Lock_policy _Lp> class __shared_count { template<typename _Tp> struct __not_alloc_shared_tag { using type = void; }; template<typename _Tp> struct __not_alloc_shared_tag<_Sp_alloc_shared_tag<_Tp>> { }; public: constexpr __shared_count() noexcept : _M_pi(0) { } template<typename _Ptr> explicit __shared_count(_Ptr __p) : _M_pi(0) { try { _M_pi = new _Sp_counted_ptr<_Ptr, _Lp>(__p); } catch(...) { delete __p; throw; } } template<typename _Ptr> __shared_count(_Ptr __p, false_type) : __shared_count(__p) { } template<typename _Ptr> __shared_count(_Ptr __p, true_type) : __shared_count(__p, __sp_array_delete{}, allocator<void>()) { } template<typename _Ptr, typename _Deleter, typename = typename __not_alloc_shared_tag<_Deleter>::type> __shared_count(_Ptr __p, _Deleter __d) : __shared_count(__p, std::move(__d), allocator<void>()) { } template<typename _Ptr, typename _Deleter, typename _Alloc, typename = typename __not_alloc_shared_tag<_Deleter>::type> __shared_count(_Ptr __p, _Deleter __d, _Alloc __a) : _M_pi(0) { typedef _Sp_counted_deleter<_Ptr, _Deleter, _Alloc, _Lp> _Sp_cd_type; try { typename _Sp_cd_type::__allocator_type __a2(__a); auto __guard = std::__allocate_guarded(__a2); _Sp_cd_type* __mem = __guard.get(); ::new (__mem) _Sp_cd_type(__p, std::move(__d), std::move(__a)); _M_pi = __mem; __guard = nullptr; } catch(...) { __d(__p); throw; } } template<typename _Tp, typename _Alloc, typename... _Args> __shared_count(_Tp*& __p, _Sp_alloc_shared_tag<_Alloc> __a, _Args&&... __args) { typedef _Sp_counted_ptr_inplace<_Tp, _Alloc, _Lp> _Sp_cp_type; typename _Sp_cp_type::__allocator_type __a2(__a._M_a); auto __guard = std::__allocate_guarded(__a2); _Sp_cp_type* __mem = __guard.get(); auto __pi = ::new (__mem) _Sp_cp_type(__a._M_a, std::forward<_Args>(__args)...); __guard = nullptr; _M_pi = __pi; __p = __pi->_M_ptr(); } template<typename _Tp> explicit __shared_count(std::auto_ptr<_Tp>&& __r); template<typename _Tp, typename _Del> explicit __shared_count(std::unique_ptr<_Tp, _Del>&& __r) : _M_pi(0) { if (__r.get() == nullptr) return; using _Ptr = typename unique_ptr<_Tp, _Del>::pointer; using _Del2 = typename conditional<is_reference<_Del>::value, reference_wrapper<typename remove_reference<_Del>::type>, _Del>::type; using _Sp_cd_type = _Sp_counted_deleter<_Ptr, _Del2, allocator<void>, _Lp>; using _Alloc = allocator<_Sp_cd_type>; using _Alloc_traits = allocator_traits<_Alloc>; _Alloc __a; _Sp_cd_type* __mem = _Alloc_traits::allocate(__a, 1); _Alloc_traits::construct(__a, __mem, __r.release(), __r.get_deleter()); _M_pi = __mem; } explicit __shared_count(const __weak_count<_Lp>& __r); explicit __shared_count(const __weak_count<_Lp>& __r, std::nothrow_t); ~__shared_count() noexcept { if (_M_pi != nullptr) _M_pi->_M_release(); } __shared_count(const __shared_count& __r) noexcept : _M_pi(__r._M_pi) { if (_M_pi != 0) _M_pi->_M_add_ref_copy(); } __shared_count& operator=(const __shared_count& __r) noexcept { _Sp_counted_base<_Lp>* __tmp = __r._M_pi; if (__tmp != _M_pi) { if (__tmp != 0) __tmp->_M_add_ref_copy(); if (_M_pi != 0) _M_pi->_M_release(); _M_pi = __tmp; } return *this; } void _M_swap(__shared_count& __r) noexcept { _Sp_counted_base<_Lp>* __tmp = __r._M_pi; __r._M_pi = _M_pi; _M_pi = __tmp; } long _M_get_use_count() const noexcept { return _M_pi != 0 ? _M_pi->_M_get_use_count() : 0; } bool _M_unique() const noexcept { return this->_M_get_use_count() == 1; } void* _M_get_deleter(const std::type_info& __ti) const noexcept { return _M_pi ? _M_pi->_M_get_deleter(__ti) : nullptr; } bool _M_less(const __shared_count& __rhs) const noexcept { return std::less<_Sp_counted_base<_Lp>*>()(this->_M_pi, __rhs._M_pi); } bool _M_less(const __weak_count<_Lp>& __rhs) const noexcept { return std::less<_Sp_counted_base<_Lp>*>()(this->_M_pi, __rhs._M_pi); } friend inline bool operator==(const __shared_count& __a, const __shared_count& __b) noexcept { return __a._M_pi == __b._M_pi; } private: friend class __weak_count<_Lp>; _Sp_counted_base<_Lp>* _M_pi; }; template<_Lock_policy _Lp> class __weak_count { public: constexpr __weak_count() noexcept : _M_pi(nullptr) { } __weak_count(const __shared_count<_Lp>& __r) noexcept : _M_pi(__r._M_pi) { if (_M_pi != nullptr) _M_pi->_M_weak_add_ref(); } __weak_count(const __weak_count& __r) noexcept : _M_pi(__r._M_pi) { if (_M_pi != nullptr) _M_pi->_M_weak_add_ref(); } __weak_count(__weak_count&& __r) noexcept : _M_pi(__r._M_pi) { __r._M_pi = nullptr; } ~__weak_count() noexcept { if (_M_pi != nullptr) _M_pi->_M_weak_release(); } __weak_count& operator=(const __shared_count<_Lp>& __r) noexcept { _Sp_counted_base<_Lp>* __tmp = __r._M_pi; if (__tmp != nullptr) __tmp->_M_weak_add_ref(); if (_M_pi != nullptr) _M_pi->_M_weak_release(); _M_pi = __tmp; return *this; } __weak_count& operator=(const __weak_count& __r) noexcept { _Sp_counted_base<_Lp>* __tmp = __r._M_pi; if (__tmp != nullptr) __tmp->_M_weak_add_ref(); if (_M_pi != nullptr) _M_pi->_M_weak_release(); _M_pi = __tmp; return *this; } __weak_count& operator=(__weak_count&& __r) noexcept { if (_M_pi != nullptr) _M_pi->_M_weak_release(); _M_pi = __r._M_pi; __r._M_pi = nullptr; return *this; } void _M_swap(__weak_count& __r) noexcept { _Sp_counted_base<_Lp>* __tmp = __r._M_pi; __r._M_pi = _M_pi; _M_pi = __tmp; } long _M_get_use_count() const noexcept { return _M_pi != nullptr ? _M_pi->_M_get_use_count() : 0; } bool _M_less(const __weak_count& __rhs) const noexcept { return std::less<_Sp_counted_base<_Lp>*>()(this->_M_pi, __rhs._M_pi); } bool _M_less(const __shared_count<_Lp>& __rhs) const noexcept { return std::less<_Sp_counted_base<_Lp>*>()(this->_M_pi, __rhs._M_pi); } friend inline bool operator==(const __weak_count& __a, const __weak_count& __b) noexcept { return __a._M_pi == __b._M_pi; } private: friend class __shared_count<_Lp>; _Sp_counted_base<_Lp>* _M_pi; }; template<_Lock_policy _Lp> inline __shared_count<_Lp>::__shared_count(const __weak_count<_Lp>& __r) : _M_pi(__r._M_pi) { if (_M_pi != nullptr) _M_pi->_M_add_ref_lock(); else __throw_bad_weak_ptr(); } template<_Lock_policy _Lp> inline __shared_count<_Lp>:: __shared_count(const __weak_count<_Lp>& __r, std::nothrow_t) : _M_pi(__r._M_pi) { if (_M_pi != nullptr) if (!_M_pi->_M_add_ref_lock_nothrow()) _M_pi = nullptr; } template<typename _Yp_ptr, typename _Tp_ptr> struct __sp_compatible_with : false_type { }; template<typename _Yp, typename _Tp> struct __sp_compatible_with<_Yp*, _Tp*> : is_convertible<_Yp*, _Tp*>::type { }; template<typename _Up, size_t _Nm> struct __sp_compatible_with<_Up(*)[_Nm], _Up(*)[]> : true_type { }; template<typename _Up, size_t _Nm> struct __sp_compatible_with<_Up(*)[_Nm], const _Up(*)[]> : true_type { }; template<typename _Up, size_t _Nm> struct __sp_compatible_with<_Up(*)[_Nm], volatile _Up(*)[]> : true_type { }; template<typename _Up, size_t _Nm> struct __sp_compatible_with<_Up(*)[_Nm], const volatile _Up(*)[]> : true_type { }; template<typename _Up, size_t _Nm, typename _Yp, typename = void> struct __sp_is_constructible_arrN : false_type { }; template<typename _Up, size_t _Nm, typename _Yp> struct __sp_is_constructible_arrN<_Up, _Nm, _Yp, __void_t<_Yp[_Nm]>> : is_convertible<_Yp(*)[_Nm], _Up(*)[_Nm]>::type { }; template<typename _Up, typename _Yp, typename = void> struct __sp_is_constructible_arr : false_type { }; template<typename _Up, typename _Yp> struct __sp_is_constructible_arr<_Up, _Yp, __void_t<_Yp[]>> : is_convertible<_Yp(*)[], _Up(*)[]>::type { }; template<typename _Tp, typename _Yp> struct __sp_is_constructible; template<typename _Up, size_t _Nm, typename _Yp> struct __sp_is_constructible<_Up[_Nm], _Yp> : __sp_is_constructible_arrN<_Up, _Nm, _Yp>::type { }; template<typename _Up, typename _Yp> struct __sp_is_constructible<_Up[], _Yp> : __sp_is_constructible_arr<_Up, _Yp>::type { }; template<typename _Tp, typename _Yp> struct __sp_is_constructible : is_convertible<_Yp*, _Tp*>::type { }; template<typename _Tp, _Lock_policy _Lp, bool = is_array<_Tp>::value, bool = is_void<_Tp>::value> class __shared_ptr_access { public: using element_type = _Tp; element_type& operator*() const noexcept { ; return *_M_get(); } element_type* operator->() const noexcept { ; return _M_get(); } private: element_type* _M_get() const noexcept { return static_cast<const __shared_ptr<_Tp, _Lp>*>(this)->get(); } }; template<typename _Tp, _Lock_policy _Lp> class __shared_ptr_access<_Tp, _Lp, false, true> { public: using element_type = _Tp; element_type* operator->() const noexcept { auto __ptr = static_cast<const __shared_ptr<_Tp, _Lp>*>(this)->get(); ; return __ptr; } }; template<typename _Tp, _Lock_policy _Lp> class __shared_ptr_access<_Tp, _Lp, true, false> { public: using element_type = typename remove_extent<_Tp>::type; [[__deprecated__("shared_ptr<T[]>::operator* is absent from C++17")]] element_type& operator*() const noexcept { ; return *_M_get(); } [[__deprecated__("shared_ptr<T[]>::operator-> is absent from C++17")]] element_type* operator->() const noexcept { ; return _M_get(); } element_type& operator[](ptrdiff_t __i) const { ; ; return _M_get()[__i]; } private: element_type* _M_get() const noexcept { return static_cast<const __shared_ptr<_Tp, _Lp>*>(this)->get(); } }; template<typename _Tp, _Lock_policy _Lp> class __shared_ptr : public __shared_ptr_access<_Tp, _Lp> { public: using element_type = typename remove_extent<_Tp>::type; private: template<typename _Yp> using _SafeConv = typename enable_if<__sp_is_constructible<_Tp, _Yp>::value>::type; template<typename _Yp, typename _Res = void> using _Compatible = typename enable_if<__sp_compatible_with<_Yp*, _Tp*>::value, _Res>::type; template<typename _Yp> using _Assignable = _Compatible<_Yp, __shared_ptr&>; template<typename _Yp, typename _Del, typename _Res = void, typename _Ptr = typename unique_ptr<_Yp, _Del>::pointer> using _UniqCompatible = typename enable_if<__and_< __sp_compatible_with<_Yp*, _Tp*>, is_convertible<_Ptr, element_type*> >::value, _Res>::type; template<typename _Yp, typename _Del> using _UniqAssignable = _UniqCompatible<_Yp, _Del, __shared_ptr&>; public: constexpr __shared_ptr() noexcept : _M_ptr(0), _M_refcount() { } template<typename _Yp, typename = _SafeConv<_Yp>> explicit __shared_ptr(_Yp* __p) : _M_ptr(__p), _M_refcount(__p, typename is_array<_Tp>::type()) { static_assert( !is_void<_Yp>::value, "incomplete type" ); static_assert( sizeof(_Yp) > 0, "incomplete type" ); _M_enable_shared_from_this_with(__p); } template<typename _Yp, typename _Deleter, typename = _SafeConv<_Yp>> __shared_ptr(_Yp* __p, _Deleter __d) : _M_ptr(__p), _M_refcount(__p, std::move(__d)) { static_assert(__is_invocable<_Deleter&, _Yp*&>::value, "deleter expression d(p) is well-formed"); _M_enable_shared_from_this_with(__p); } template<typename _Yp, typename _Deleter, typename _Alloc, typename = _SafeConv<_Yp>> __shared_ptr(_Yp* __p, _Deleter __d, _Alloc __a) : _M_ptr(__p), _M_refcount(__p, std::move(__d), std::move(__a)) { static_assert(__is_invocable<_Deleter&, _Yp*&>::value, "deleter expression d(p) is well-formed"); _M_enable_shared_from_this_with(__p); } template<typename _Deleter> __shared_ptr(nullptr_t __p, _Deleter __d) : _M_ptr(0), _M_refcount(__p, std::move(__d)) { } template<typename _Deleter, typename _Alloc> __shared_ptr(nullptr_t __p, _Deleter __d, _Alloc __a) : _M_ptr(0), _M_refcount(__p, std::move(__d), std::move(__a)) { } template<typename _Yp> __shared_ptr(const __shared_ptr<_Yp, _Lp>& __r, element_type* __p) noexcept : _M_ptr(__p), _M_refcount(__r._M_refcount) { } template<typename _Yp> __shared_ptr(__shared_ptr<_Yp, _Lp>&& __r, element_type* __p) noexcept : _M_ptr(__p), _M_refcount() { _M_refcount._M_swap(__r._M_refcount); __r._M_ptr = 0; } __shared_ptr(const __shared_ptr&) noexcept = default; __shared_ptr& operator=(const __shared_ptr&) noexcept = default; ~__shared_ptr() = default; template<typename _Yp, typename = _Compatible<_Yp>> __shared_ptr(const __shared_ptr<_Yp, _Lp>& __r) noexcept : _M_ptr(__r._M_ptr), _M_refcount(__r._M_refcount) { } __shared_ptr(__shared_ptr&& __r) noexcept : _M_ptr(__r._M_ptr), _M_refcount() { _M_refcount._M_swap(__r._M_refcount); __r._M_ptr = 0; } template<typename _Yp, typename = _Compatible<_Yp>> __shared_ptr(__shared_ptr<_Yp, _Lp>&& __r) noexcept : _M_ptr(__r._M_ptr), _M_refcount() { _M_refcount._M_swap(__r._M_refcount); __r._M_ptr = 0; } template<typename _Yp, typename = _Compatible<_Yp>> explicit __shared_ptr(const __weak_ptr<_Yp, _Lp>& __r) : _M_refcount(__r._M_refcount) { _M_ptr = __r._M_ptr; } template<typename _Yp, typename _Del, typename = _UniqCompatible<_Yp, _Del>> __shared_ptr(unique_ptr<_Yp, _Del>&& __r) : _M_ptr(__r.get()), _M_refcount() { auto __raw = __to_address(__r.get()); _M_refcount = __shared_count<_Lp>(std::move(__r)); _M_enable_shared_from_this_with(__raw); } protected: template<typename _Tp1, typename _Del, typename enable_if<__and_< __not_<is_array<_Tp>>, is_array<_Tp1>, is_convertible<typename unique_ptr<_Tp1, _Del>::pointer, _Tp*> >::value, bool>::type = true> __shared_ptr(unique_ptr<_Tp1, _Del>&& __r, __sp_array_delete) : _M_ptr(__r.get()), _M_refcount() { auto __raw = __to_address(__r.get()); _M_refcount = __shared_count<_Lp>(std::move(__r)); _M_enable_shared_from_this_with(__raw); } public: template<typename _Yp, typename = _Compatible<_Yp>> __shared_ptr(auto_ptr<_Yp>&& __r); constexpr __shared_ptr(nullptr_t) noexcept : __shared_ptr() { } template<typename _Yp> _Assignable<_Yp> operator=(const __shared_ptr<_Yp, _Lp>& __r) noexcept { _M_ptr = __r._M_ptr; _M_refcount = __r._M_refcount; return *this; } template<typename _Yp> _Assignable<_Yp> operator=(auto_ptr<_Yp>&& __r) { __shared_ptr(std::move(__r)).swap(*this); return *this; } __shared_ptr& operator=(__shared_ptr&& __r) noexcept { __shared_ptr(std::move(__r)).swap(*this); return *this; } template<class _Yp> _Assignable<_Yp> operator=(__shared_ptr<_Yp, _Lp>&& __r) noexcept { __shared_ptr(std::move(__r)).swap(*this); return *this; } template<typename _Yp, typename _Del> _UniqAssignable<_Yp, _Del> operator=(unique_ptr<_Yp, _Del>&& __r) { __shared_ptr(std::move(__r)).swap(*this); return *this; } void reset() noexcept { __shared_ptr().swap(*this); } template<typename _Yp> _SafeConv<_Yp> reset(_Yp* __p) { ; __shared_ptr(__p).swap(*this); } template<typename _Yp, typename _Deleter> _SafeConv<_Yp> reset(_Yp* __p, _Deleter __d) { __shared_ptr(__p, std::move(__d)).swap(*this); } template<typename _Yp, typename _Deleter, typename _Alloc> _SafeConv<_Yp> reset(_Yp* __p, _Deleter __d, _Alloc __a) { __shared_ptr(__p, std::move(__d), std::move(__a)).swap(*this); } element_type* get() const noexcept { return _M_ptr; } explicit operator bool() const { return _M_ptr == 0 ? false : true; } bool unique() const noexcept { return _M_refcount._M_unique(); } long use_count() const noexcept { return _M_refcount._M_get_use_count(); } void swap(__shared_ptr<_Tp, _Lp>& __other) noexcept { std::swap(_M_ptr, __other._M_ptr); _M_refcount._M_swap(__other._M_refcount); } template<typename _Tp1> bool owner_before(__shared_ptr<_Tp1, _Lp> const& __rhs) const noexcept { return _M_refcount._M_less(__rhs._M_refcount); } template<typename _Tp1> bool owner_before(__weak_ptr<_Tp1, _Lp> const& __rhs) const noexcept { return _M_refcount._M_less(__rhs._M_refcount); } protected: template<typename _Alloc, typename... _Args> __shared_ptr(_Sp_alloc_shared_tag<_Alloc> __tag, _Args&&... __args) : _M_ptr(), _M_refcount(_M_ptr, __tag, std::forward<_Args>(__args)...) { _M_enable_shared_from_this_with(_M_ptr); } template<typename _Tp1, _Lock_policy _Lp1, typename _Alloc, typename... _Args> friend __shared_ptr<_Tp1, _Lp1> __allocate_shared(const _Alloc& __a, _Args&&... __args); __shared_ptr(const __weak_ptr<_Tp, _Lp>& __r, std::nothrow_t) : _M_refcount(__r._M_refcount, std::nothrow) { _M_ptr = _M_refcount._M_get_use_count() ? __r._M_ptr : nullptr; } friend class __weak_ptr<_Tp, _Lp>; private: template<typename _Yp> using __esft_base_t = decltype(__enable_shared_from_this_base( std::declval<const __shared_count<_Lp>&>(), std::declval<_Yp*>())); template<typename _Yp, typename = void> struct __has_esft_base : false_type { }; template<typename _Yp> struct __has_esft_base<_Yp, __void_t<__esft_base_t<_Yp>>> : __not_<is_array<_Tp>> { }; template<typename _Yp, typename _Yp2 = typename remove_cv<_Yp>::type> typename enable_if<__has_esft_base<_Yp2>::value>::type _M_enable_shared_from_this_with(_Yp* __p) noexcept { if (auto __base = __enable_shared_from_this_base(_M_refcount, __p)) __base->_M_weak_assign(const_cast<_Yp2*>(__p), _M_refcount); } template<typename _Yp, typename _Yp2 = typename remove_cv<_Yp>::type> typename enable_if<!__has_esft_base<_Yp2>::value>::type _M_enable_shared_from_this_with(_Yp*) noexcept { } void* _M_get_deleter(const std::type_info& __ti) const noexcept { return _M_refcount._M_get_deleter(__ti); } template<typename _Tp1, _Lock_policy _Lp1> friend class __shared_ptr; template<typename _Tp1, _Lock_policy _Lp1> friend class __weak_ptr; template<typename _Del, typename _Tp1, _Lock_policy _Lp1> friend _Del* get_deleter(const __shared_ptr<_Tp1, _Lp1>&) noexcept; template<typename _Del, typename _Tp1> friend _Del* get_deleter(const shared_ptr<_Tp1>&) noexcept; element_type* _M_ptr; __shared_count<_Lp> _M_refcount; }; template<typename _Tp1, typename _Tp2, _Lock_policy _Lp> inline bool operator==(const __shared_ptr<_Tp1, _Lp>& __a, const __shared_ptr<_Tp2, _Lp>& __b) noexcept { return __a.get() == __b.get(); } template<typename _Tp, _Lock_policy _Lp> inline bool operator==(const __shared_ptr<_Tp, _Lp>& __a, nullptr_t) noexcept { return !__a; } template<typename _Tp, _Lock_policy _Lp> inline bool operator==(nullptr_t, const __shared_ptr<_Tp, _Lp>& __a) noexcept { return !__a; } template<typename _Tp1, typename _Tp2, _Lock_policy _Lp> inline bool operator!=(const __shared_ptr<_Tp1, _Lp>& __a, const __shared_ptr<_Tp2, _Lp>& __b) noexcept { return __a.get() != __b.get(); } template<typename _Tp, _Lock_policy _Lp> inline bool operator!=(const __shared_ptr<_Tp, _Lp>& __a, nullptr_t) noexcept { return (bool)__a; } template<typename _Tp, _Lock_policy _Lp> inline bool operator!=(nullptr_t, const __shared_ptr<_Tp, _Lp>& __a) noexcept { return (bool)__a; } template<typename _Tp, typename _Up, _Lock_policy _Lp> inline bool operator<(const __shared_ptr<_Tp, _Lp>& __a, const __shared_ptr<_Up, _Lp>& __b) noexcept { using _Tp_elt = typename __shared_ptr<_Tp, _Lp>::element_type; using _Up_elt = typename __shared_ptr<_Up, _Lp>::element_type; using _Vp = typename common_type<_Tp_elt*, _Up_elt*>::type; return less<_Vp>()(__a.get(), __b.get()); } template<typename _Tp, _Lock_policy _Lp> inline bool operator<(const __shared_ptr<_Tp, _Lp>& __a, nullptr_t) noexcept { using _Tp_elt = typename __shared_ptr<_Tp, _Lp>::element_type; return less<_Tp_elt*>()(__a.get(), nullptr); } template<typename _Tp, _Lock_policy _Lp> inline bool operator<(nullptr_t, const __shared_ptr<_Tp, _Lp>& __a) noexcept { using _Tp_elt = typename __shared_ptr<_Tp, _Lp>::element_type; return less<_Tp_elt*>()(nullptr, __a.get()); } template<typename _Tp1, typename _Tp2, _Lock_policy _Lp> inline bool operator<=(const __shared_ptr<_Tp1, _Lp>& __a, const __shared_ptr<_Tp2, _Lp>& __b) noexcept { return !(__b < __a); } template<typename _Tp, _Lock_policy _Lp> inline bool operator<=(const __shared_ptr<_Tp, _Lp>& __a, nullptr_t) noexcept { return !(nullptr < __a); } template<typename _Tp, _Lock_policy _Lp> inline bool operator<=(nullptr_t, const __shared_ptr<_Tp, _Lp>& __a) noexcept { return !(__a < nullptr); } template<typename _Tp1, typename _Tp2, _Lock_policy _Lp> inline bool operator>(const __shared_ptr<_Tp1, _Lp>& __a, const __shared_ptr<_Tp2, _Lp>& __b) noexcept { return (__b < __a); } template<typename _Tp, _Lock_policy _Lp> inline bool operator>(const __shared_ptr<_Tp, _Lp>& __a, nullptr_t) noexcept { return nullptr < __a; } template<typename _Tp, _Lock_policy _Lp> inline bool operator>(nullptr_t, const __shared_ptr<_Tp, _Lp>& __a) noexcept { return __a < nullptr; } template<typename _Tp1, typename _Tp2, _Lock_policy _Lp> inline bool operator>=(const __shared_ptr<_Tp1, _Lp>& __a, const __shared_ptr<_Tp2, _Lp>& __b) noexcept { return !(__a < __b); } template<typename _Tp, _Lock_policy _Lp> inline bool operator>=(const __shared_ptr<_Tp, _Lp>& __a, nullptr_t) noexcept { return !(__a < nullptr); } template<typename _Tp, _Lock_policy _Lp> inline bool operator>=(nullptr_t, const __shared_ptr<_Tp, _Lp>& __a) noexcept { return !(nullptr < __a); } template<typename _Tp, _Lock_policy _Lp> inline void swap(__shared_ptr<_Tp, _Lp>& __a, __shared_ptr<_Tp, _Lp>& __b) noexcept { __a.swap(__b); } template<typename _Tp, typename _Tp1, _Lock_policy _Lp> inline __shared_ptr<_Tp, _Lp> static_pointer_cast(const __shared_ptr<_Tp1, _Lp>& __r) noexcept { using _Sp = __shared_ptr<_Tp, _Lp>; return _Sp(__r, static_cast<typename _Sp::element_type*>(__r.get())); } template<typename _Tp, typename _Tp1, _Lock_policy _Lp> inline __shared_ptr<_Tp, _Lp> const_pointer_cast(const __shared_ptr<_Tp1, _Lp>& __r) noexcept { using _Sp = __shared_ptr<_Tp, _Lp>; return _Sp(__r, const_cast<typename _Sp::element_type*>(__r.get())); } template<typename _Tp, typename _Tp1, _Lock_policy _Lp> inline __shared_ptr<_Tp, _Lp> dynamic_pointer_cast(const __shared_ptr<_Tp1, _Lp>& __r) noexcept { using _Sp = __shared_ptr<_Tp, _Lp>; if (auto* __p = dynamic_cast<typename _Sp::element_type*>(__r.get())) return _Sp(__r, __p); return _Sp(); } template<typename _Tp, _Lock_policy _Lp> class __weak_ptr { template<typename _Yp, typename _Res = void> using _Compatible = typename enable_if<__sp_compatible_with<_Yp*, _Tp*>::value, _Res>::type; template<typename _Yp> using _Assignable = _Compatible<_Yp, __weak_ptr&>; public: using element_type = typename remove_extent<_Tp>::type; constexpr __weak_ptr() noexcept : _M_ptr(nullptr), _M_refcount() { } __weak_ptr(const __weak_ptr&) noexcept = default; ~__weak_ptr() = default; template<typename _Yp, typename = _Compatible<_Yp>> __weak_ptr(const __weak_ptr<_Yp, _Lp>& __r) noexcept : _M_refcount(__r._M_refcount) { _M_ptr = __r.lock().get(); } template<typename _Yp, typename = _Compatible<_Yp>> __weak_ptr(const __shared_ptr<_Yp, _Lp>& __r) noexcept : _M_ptr(__r._M_ptr), _M_refcount(__r._M_refcount) { } __weak_ptr(__weak_ptr&& __r) noexcept : _M_ptr(__r._M_ptr), _M_refcount(std::move(__r._M_refcount)) { __r._M_ptr = nullptr; } template<typename _Yp, typename = _Compatible<_Yp>> __weak_ptr(__weak_ptr<_Yp, _Lp>&& __r) noexcept : _M_ptr(__r.lock().get()), _M_refcount(std::move(__r._M_refcount)) { __r._M_ptr = nullptr; } __weak_ptr& operator=(const __weak_ptr& __r) noexcept = default; template<typename _Yp> _Assignable<_Yp> operator=(const __weak_ptr<_Yp, _Lp>& __r) noexcept { _M_ptr = __r.lock().get(); _M_refcount = __r._M_refcount; return *this; } template<typename _Yp> _Assignable<_Yp> operator=(const __shared_ptr<_Yp, _Lp>& __r) noexcept { _M_ptr = __r._M_ptr; _M_refcount = __r._M_refcount; return *this; } __weak_ptr& operator=(__weak_ptr&& __r) noexcept { _M_ptr = __r._M_ptr; _M_refcount = std::move(__r._M_refcount); __r._M_ptr = nullptr; return *this; } template<typename _Yp> _Assignable<_Yp> operator=(__weak_ptr<_Yp, _Lp>&& __r) noexcept { _M_ptr = __r.lock().get(); _M_refcount = std::move(__r._M_refcount); __r._M_ptr = nullptr; return *this; } __shared_ptr<_Tp, _Lp> lock() const noexcept { return __shared_ptr<element_type, _Lp>(*this, std::nothrow); } long use_count() const noexcept { return _M_refcount._M_get_use_count(); } bool expired() const noexcept { return _M_refcount._M_get_use_count() == 0; } template<typename _Tp1> bool owner_before(const __shared_ptr<_Tp1, _Lp>& __rhs) const noexcept { return _M_refcount._M_less(__rhs._M_refcount); } template<typename _Tp1> bool owner_before(const __weak_ptr<_Tp1, _Lp>& __rhs) const noexcept { return _M_refcount._M_less(__rhs._M_refcount); } void reset() noexcept { __weak_ptr().swap(*this); } void swap(__weak_ptr& __s) noexcept { std::swap(_M_ptr, __s._M_ptr); _M_refcount._M_swap(__s._M_refcount); } private: void _M_assign(_Tp* __ptr, const __shared_count<_Lp>& __refcount) noexcept { if (use_count() == 0) { _M_ptr = __ptr; _M_refcount = __refcount; } } template<typename _Tp1, _Lock_policy _Lp1> friend class __shared_ptr; template<typename _Tp1, _Lock_policy _Lp1> friend class __weak_ptr; friend class __enable_shared_from_this<_Tp, _Lp>; friend class enable_shared_from_this<_Tp>; element_type* _M_ptr; __weak_count<_Lp> _M_refcount; }; template<typename _Tp, _Lock_policy _Lp> inline void swap(__weak_ptr<_Tp, _Lp>& __a, __weak_ptr<_Tp, _Lp>& __b) noexcept { __a.swap(__b); } template<typename _Tp, typename _Tp1> struct _Sp_owner_less : public binary_function<_Tp, _Tp, bool> { bool operator()(const _Tp& __lhs, const _Tp& __rhs) const noexcept { return __lhs.owner_before(__rhs); } bool operator()(const _Tp& __lhs, const _Tp1& __rhs) const noexcept { return __lhs.owner_before(__rhs); } bool operator()(const _Tp1& __lhs, const _Tp& __rhs) const noexcept { return __lhs.owner_before(__rhs); } }; template<> struct _Sp_owner_less<void, void> { template<typename _Tp, typename _Up> auto operator()(const _Tp& __lhs, const _Up& __rhs) const noexcept -> decltype(__lhs.owner_before(__rhs)) { return __lhs.owner_before(__rhs); } using is_transparent = void; }; template<typename _Tp, _Lock_policy _Lp> struct owner_less<__shared_ptr<_Tp, _Lp>> : public _Sp_owner_less<__shared_ptr<_Tp, _Lp>, __weak_ptr<_Tp, _Lp>> { }; template<typename _Tp, _Lock_policy _Lp> struct owner_less<__weak_ptr<_Tp, _Lp>> : public _Sp_owner_less<__weak_ptr<_Tp, _Lp>, __shared_ptr<_Tp, _Lp>> { }; template<typename _Tp, _Lock_policy _Lp> class __enable_shared_from_this { protected: constexpr __enable_shared_from_this() noexcept { } __enable_shared_from_this(const __enable_shared_from_this&) noexcept { } __enable_shared_from_this& operator=(const __enable_shared_from_this&) noexcept { return *this; } ~__enable_shared_from_this() { } public: __shared_ptr<_Tp, _Lp> shared_from_this() { return __shared_ptr<_Tp, _Lp>(this->_M_weak_this); } __shared_ptr<const _Tp, _Lp> shared_from_this() const { return __shared_ptr<const _Tp, _Lp>(this->_M_weak_this); } __weak_ptr<_Tp, _Lp> weak_from_this() noexcept { return this->_M_weak_this; } __weak_ptr<const _Tp, _Lp> weak_from_this() const noexcept { return this->_M_weak_this; } private: template<typename _Tp1> void _M_weak_assign(_Tp1* __p, const __shared_count<_Lp>& __n) const noexcept { _M_weak_this._M_assign(__p, __n); } friend const __enable_shared_from_this* __enable_shared_from_this_base(const __shared_count<_Lp>&, const __enable_shared_from_this* __p) { return __p; } template<typename, _Lock_policy> friend class __shared_ptr; mutable __weak_ptr<_Tp, _Lp> _M_weak_this; }; template<typename _Tp, _Lock_policy _Lp = __default_lock_policy, typename _Alloc, typename... _Args> inline __shared_ptr<_Tp, _Lp> __allocate_shared(const _Alloc& __a, _Args&&... __args) { return __shared_ptr<_Tp, _Lp>(_Sp_alloc_shared_tag<_Alloc>{__a}, std::forward<_Args>(__args)...); } template<typename _Tp, _Lock_policy _Lp = __default_lock_policy, typename... _Args> inline __shared_ptr<_Tp, _Lp> __make_shared(_Args&&... __args) { typedef typename std::remove_const<_Tp>::type _Tp_nc; return std::__allocate_shared<_Tp, _Lp>(std::allocator<_Tp_nc>(), std::forward<_Args>(__args)...); } template<typename _Tp, _Lock_policy _Lp> struct hash<__shared_ptr<_Tp, _Lp>> : public __hash_base<size_t, __shared_ptr<_Tp, _Lp>> { size_t operator()(const __shared_ptr<_Tp, _Lp>& __s) const noexcept { return hash<typename __shared_ptr<_Tp, _Lp>::element_type*>()( __s.get()); } }; } namespace std __attribute__ ((__visibility__ ("default"))) { template<typename _Ch, typename _Tr, typename _Tp, _Lock_policy _Lp> inline std::basic_ostream<_Ch, _Tr>& operator<<(std::basic_ostream<_Ch, _Tr>& __os, const __shared_ptr<_Tp, _Lp>& __p) { __os << __p.get(); return __os; } template<typename _Del, typename _Tp, _Lock_policy _Lp> inline _Del* get_deleter(const __shared_ptr<_Tp, _Lp>& __p) noexcept { return static_cast<_Del*>(__p._M_get_deleter(typeid(_Del))); } template<typename _Del, typename _Tp> inline _Del* get_deleter(const shared_ptr<_Tp>& __p) noexcept { return static_cast<_Del*>(__p._M_get_deleter(typeid(_Del))); } template<typename _Tp> class shared_ptr : public __shared_ptr<_Tp> { template<typename... _Args> using _Constructible = typename enable_if< is_constructible<__shared_ptr<_Tp>, _Args...>::value >::type; template<typename _Arg> using _Assignable = typename enable_if< is_assignable<__shared_ptr<_Tp>&, _Arg>::value, shared_ptr& >::type; public: using element_type = typename __shared_ptr<_Tp>::element_type; constexpr shared_ptr() noexcept : __shared_ptr<_Tp>() { } shared_ptr(const shared_ptr&) noexcept = default; template<typename _Yp, typename = _Constructible<_Yp*>> explicit shared_ptr(_Yp* __p) : __shared_ptr<_Tp>(__p) { } template<typename _Yp, typename _Deleter, typename = _Constructible<_Yp*, _Deleter>> shared_ptr(_Yp* __p, _Deleter __d) : __shared_ptr<_Tp>(__p, std::move(__d)) { } template<typename _Deleter> shared_ptr(nullptr_t __p, _Deleter __d) : __shared_ptr<_Tp>(__p, std::move(__d)) { } template<typename _Yp, typename _Deleter, typename _Alloc, typename = _Constructible<_Yp*, _Deleter, _Alloc>> shared_ptr(_Yp* __p, _Deleter __d, _Alloc __a) : __shared_ptr<_Tp>(__p, std::move(__d), std::move(__a)) { } template<typename _Deleter, typename _Alloc> shared_ptr(nullptr_t __p, _Deleter __d, _Alloc __a) : __shared_ptr<_Tp>(__p, std::move(__d), std::move(__a)) { } template<typename _Yp> shared_ptr(const shared_ptr<_Yp>& __r, element_type* __p) noexcept : __shared_ptr<_Tp>(__r, __p) { } template<typename _Yp, typename = _Constructible<const shared_ptr<_Yp>&>> shared_ptr(const shared_ptr<_Yp>& __r) noexcept : __shared_ptr<_Tp>(__r) { } shared_ptr(shared_ptr&& __r) noexcept : __shared_ptr<_Tp>(std::move(__r)) { } template<typename _Yp, typename = _Constructible<shared_ptr<_Yp>>> shared_ptr(shared_ptr<_Yp>&& __r) noexcept : __shared_ptr<_Tp>(std::move(__r)) { } template<typename _Yp, typename = _Constructible<const weak_ptr<_Yp>&>> explicit shared_ptr(const weak_ptr<_Yp>& __r) : __shared_ptr<_Tp>(__r) { } template<typename _Yp, typename = _Constructible<auto_ptr<_Yp>>> shared_ptr(auto_ptr<_Yp>&& __r); template<typename _Yp, typename _Del, typename = _Constructible<unique_ptr<_Yp, _Del>>> shared_ptr(unique_ptr<_Yp, _Del>&& __r) : __shared_ptr<_Tp>(std::move(__r)) { } template<typename _Yp, typename _Del, _Constructible<unique_ptr<_Yp, _Del>, __sp_array_delete>* = 0> shared_ptr(unique_ptr<_Yp, _Del>&& __r) : __shared_ptr<_Tp>(std::move(__r), __sp_array_delete()) { } constexpr shared_ptr(nullptr_t) noexcept : shared_ptr() { } shared_ptr& operator=(const shared_ptr&) noexcept = default; template<typename _Yp> _Assignable<const shared_ptr<_Yp>&> operator=(const shared_ptr<_Yp>& __r) noexcept { this->__shared_ptr<_Tp>::operator=(__r); return *this; } template<typename _Yp> _Assignable<auto_ptr<_Yp>> operator=(auto_ptr<_Yp>&& __r) { this->__shared_ptr<_Tp>::operator=(std::move(__r)); return *this; } shared_ptr& operator=(shared_ptr&& __r) noexcept { this->__shared_ptr<_Tp>::operator=(std::move(__r)); return *this; } template<class _Yp> _Assignable<shared_ptr<_Yp>> operator=(shared_ptr<_Yp>&& __r) noexcept { this->__shared_ptr<_Tp>::operator=(std::move(__r)); return *this; } template<typename _Yp, typename _Del> _Assignable<unique_ptr<_Yp, _Del>> operator=(unique_ptr<_Yp, _Del>&& __r) { this->__shared_ptr<_Tp>::operator=(std::move(__r)); return *this; } private: template<typename _Alloc, typename... _Args> shared_ptr(_Sp_alloc_shared_tag<_Alloc> __tag, _Args&&... __args) : __shared_ptr<_Tp>(__tag, std::forward<_Args>(__args)...) { } template<typename _Yp, typename _Alloc, typename... _Args> friend shared_ptr<_Yp> allocate_shared(const _Alloc& __a, _Args&&... __args); shared_ptr(const weak_ptr<_Tp>& __r, std::nothrow_t) : __shared_ptr<_Tp>(__r, std::nothrow) { } friend class weak_ptr<_Tp>; }; template<typename _Tp, typename _Up> inline bool operator==(const shared_ptr<_Tp>& __a, const shared_ptr<_Up>& __b) noexcept { return __a.get() == __b.get(); } template<typename _Tp> inline bool operator==(const shared_ptr<_Tp>& __a, nullptr_t) noexcept { return !__a; } template<typename _Tp> inline bool operator==(nullptr_t, const shared_ptr<_Tp>& __a) noexcept { return !__a; } template<typename _Tp, typename _Up> inline bool operator!=(const shared_ptr<_Tp>& __a, const shared_ptr<_Up>& __b) noexcept { return __a.get() != __b.get(); } template<typename _Tp> inline bool operator!=(const shared_ptr<_Tp>& __a, nullptr_t) noexcept { return (bool)__a; } template<typename _Tp> inline bool operator!=(nullptr_t, const shared_ptr<_Tp>& __a) noexcept { return (bool)__a; } template<typename _Tp, typename _Up> inline bool operator<(const shared_ptr<_Tp>& __a, const shared_ptr<_Up>& __b) noexcept { using _Tp_elt = typename shared_ptr<_Tp>::element_type; using _Up_elt = typename shared_ptr<_Up>::element_type; using _Vp = typename common_type<_Tp_elt*, _Up_elt*>::type; return less<_Vp>()(__a.get(), __b.get()); } template<typename _Tp> inline bool operator<(const shared_ptr<_Tp>& __a, nullptr_t) noexcept { using _Tp_elt = typename shared_ptr<_Tp>::element_type; return less<_Tp_elt*>()(__a.get(), nullptr); } template<typename _Tp> inline bool operator<(nullptr_t, const shared_ptr<_Tp>& __a) noexcept { using _Tp_elt = typename shared_ptr<_Tp>::element_type; return less<_Tp_elt*>()(nullptr, __a.get()); } template<typename _Tp, typename _Up> inline bool operator<=(const shared_ptr<_Tp>& __a, const shared_ptr<_Up>& __b) noexcept { return !(__b < __a); } template<typename _Tp> inline bool operator<=(const shared_ptr<_Tp>& __a, nullptr_t) noexcept { return !(nullptr < __a); } template<typename _Tp> inline bool operator<=(nullptr_t, const shared_ptr<_Tp>& __a) noexcept { return !(__a < nullptr); } template<typename _Tp, typename _Up> inline bool operator>(const shared_ptr<_Tp>& __a, const shared_ptr<_Up>& __b) noexcept { return (__b < __a); } template<typename _Tp> inline bool operator>(const shared_ptr<_Tp>& __a, nullptr_t) noexcept { return nullptr < __a; } template<typename _Tp> inline bool operator>(nullptr_t, const shared_ptr<_Tp>& __a) noexcept { return __a < nullptr; } template<typename _Tp, typename _Up> inline bool operator>=(const shared_ptr<_Tp>& __a, const shared_ptr<_Up>& __b) noexcept { return !(__a < __b); } template<typename _Tp> inline bool operator>=(const shared_ptr<_Tp>& __a, nullptr_t) noexcept { return !(__a < nullptr); } template<typename _Tp> inline bool operator>=(nullptr_t, const shared_ptr<_Tp>& __a) noexcept { return !(nullptr < __a); } template<typename _Tp> inline void swap(shared_ptr<_Tp>& __a, shared_ptr<_Tp>& __b) noexcept { __a.swap(__b); } template<typename _Tp, typename _Up> inline shared_ptr<_Tp> static_pointer_cast(const shared_ptr<_Up>& __r) noexcept { using _Sp = shared_ptr<_Tp>; return _Sp(__r, static_cast<typename _Sp::element_type*>(__r.get())); } template<typename _Tp, typename _Up> inline shared_ptr<_Tp> const_pointer_cast(const shared_ptr<_Up>& __r) noexcept { using _Sp = shared_ptr<_Tp>; return _Sp(__r, const_cast<typename _Sp::element_type*>(__r.get())); } template<typename _Tp, typename _Up> inline shared_ptr<_Tp> dynamic_pointer_cast(const shared_ptr<_Up>& __r) noexcept { using _Sp = shared_ptr<_Tp>; if (auto* __p = dynamic_cast<typename _Sp::element_type*>(__r.get())) return _Sp(__r, __p); return _Sp(); } template<typename _Tp> class weak_ptr : public __weak_ptr<_Tp> { template<typename _Arg> using _Constructible = typename enable_if< is_constructible<__weak_ptr<_Tp>, _Arg>::value >::type; template<typename _Arg> using _Assignable = typename enable_if< is_assignable<__weak_ptr<_Tp>&, _Arg>::value, weak_ptr& >::type; public: constexpr weak_ptr() noexcept = default; template<typename _Yp, typename = _Constructible<const shared_ptr<_Yp>&>> weak_ptr(const shared_ptr<_Yp>& __r) noexcept : __weak_ptr<_Tp>(__r) { } weak_ptr(const weak_ptr&) noexcept = default; template<typename _Yp, typename = _Constructible<const weak_ptr<_Yp>&>> weak_ptr(const weak_ptr<_Yp>& __r) noexcept : __weak_ptr<_Tp>(__r) { } weak_ptr(weak_ptr&&) noexcept = default; template<typename _Yp, typename = _Constructible<weak_ptr<_Yp>>> weak_ptr(weak_ptr<_Yp>&& __r) noexcept : __weak_ptr<_Tp>(std::move(__r)) { } weak_ptr& operator=(const weak_ptr& __r) noexcept = default; template<typename _Yp> _Assignable<const weak_ptr<_Yp>&> operator=(const weak_ptr<_Yp>& __r) noexcept { this->__weak_ptr<_Tp>::operator=(__r); return *this; } template<typename _Yp> _Assignable<const shared_ptr<_Yp>&> operator=(const shared_ptr<_Yp>& __r) noexcept { this->__weak_ptr<_Tp>::operator=(__r); return *this; } weak_ptr& operator=(weak_ptr&& __r) noexcept = default; template<typename _Yp> _Assignable<weak_ptr<_Yp>> operator=(weak_ptr<_Yp>&& __r) noexcept { this->__weak_ptr<_Tp>::operator=(std::move(__r)); return *this; } shared_ptr<_Tp> lock() const noexcept { return shared_ptr<_Tp>(*this, std::nothrow); } }; template<typename _Tp> inline void swap(weak_ptr<_Tp>& __a, weak_ptr<_Tp>& __b) noexcept { __a.swap(__b); } template<typename _Tp = void> struct owner_less; template<> struct owner_less<void> : _Sp_owner_less<void, void> { }; template<typename _Tp> struct owner_less<shared_ptr<_Tp>> : public _Sp_owner_less<shared_ptr<_Tp>, weak_ptr<_Tp>> { }; template<typename _Tp> struct owner_less<weak_ptr<_Tp>> : public _Sp_owner_less<weak_ptr<_Tp>, shared_ptr<_Tp>> { }; template<typename _Tp> class enable_shared_from_this { protected: constexpr enable_shared_from_this() noexcept { } enable_shared_from_this(const enable_shared_from_this&) noexcept { } enable_shared_from_this& operator=(const enable_shared_from_this&) noexcept { return *this; } ~enable_shared_from_this() { } public: shared_ptr<_Tp> shared_from_this() { return shared_ptr<_Tp>(this->_M_weak_this); } shared_ptr<const _Tp> shared_from_this() const { return shared_ptr<const _Tp>(this->_M_weak_this); } weak_ptr<_Tp> weak_from_this() noexcept { return this->_M_weak_this; } weak_ptr<const _Tp> weak_from_this() const noexcept { return this->_M_weak_this; } private: template<typename _Tp1> void _M_weak_assign(_Tp1* __p, const __shared_count<>& __n) const noexcept { _M_weak_this._M_assign(__p, __n); } friend const enable_shared_from_this* __enable_shared_from_this_base(const __shared_count<>&, const enable_shared_from_this* __p) { return __p; } template<typename, _Lock_policy> friend class __shared_ptr; mutable weak_ptr<_Tp> _M_weak_this; }; template<typename _Tp, typename _Alloc, typename... _Args> inline shared_ptr<_Tp> allocate_shared(const _Alloc& __a, _Args&&... __args) { return shared_ptr<_Tp>(_Sp_alloc_shared_tag<_Alloc>{__a}, std::forward<_Args>(__args)...); } template<typename _Tp, typename... _Args> inline shared_ptr<_Tp> make_shared(_Args&&... __args) { typedef typename std::remove_cv<_Tp>::type _Tp_nc; return std::allocate_shared<_Tp>(std::allocator<_Tp_nc>(), std::forward<_Args>(__args)...); } template<typename _Tp> struct hash<shared_ptr<_Tp>> : public __hash_base<size_t, shared_ptr<_Tp>> { size_t operator()(const shared_ptr<_Tp>& __s) const noexcept { return std::hash<typename shared_ptr<_Tp>::element_type*>()(__s.get()); } }; } namespace std __attribute__ ((__visibility__ ("default"))) { typedef enum memory_order { memory_order_relaxed, memory_order_consume, memory_order_acquire, memory_order_release, memory_order_acq_rel, memory_order_seq_cst } memory_order; enum __memory_order_modifier { __memory_order_mask = 0x0ffff, __memory_order_modifier_mask = 0xffff0000, __memory_order_hle_acquire = 0x10000, __memory_order_hle_release = 0x20000 }; constexpr memory_order operator|(memory_order __m, __memory_order_modifier __mod) { return memory_order(int(__m) | int(__mod)); } constexpr memory_order operator&(memory_order __m, __memory_order_modifier __mod) { return memory_order(int(__m) & int(__mod)); } constexpr memory_order __cmpexch_failure_order2(memory_order __m) noexcept { return __m == memory_order_acq_rel ? memory_order_acquire : __m == memory_order_release ? memory_order_relaxed : __m; } constexpr memory_order __cmpexch_failure_order(memory_order __m) noexcept { return memory_order(__cmpexch_failure_order2(__m & __memory_order_mask) | __memory_order_modifier(__m & __memory_order_modifier_mask)); } inline __attribute__((__always_inline__)) void atomic_thread_fence(memory_order __m) noexcept { __atomic_thread_fence(int(__m)); } inline __attribute__((__always_inline__)) void atomic_signal_fence(memory_order __m) noexcept { __atomic_signal_fence(int(__m)); } template<typename _Tp> inline _Tp kill_dependency(_Tp __y) noexcept { _Tp __ret(__y); return __ret; } template<typename _IntTp> struct __atomic_base; template<typename _Tp> struct atomic; template<typename _Tp> struct atomic<_Tp*>; typedef bool __atomic_flag_data_type; extern "C" { struct __atomic_flag_base { __atomic_flag_data_type _M_i ; }; } struct atomic_flag : public __atomic_flag_base { atomic_flag() noexcept = default; ~atomic_flag() noexcept = default; atomic_flag(const atomic_flag&) = delete; atomic_flag& operator=(const atomic_flag&) = delete; atomic_flag& operator=(const atomic_flag&) volatile = delete; constexpr atomic_flag(bool __i) noexcept : __atomic_flag_base{ _S_init(__i) } { } inline __attribute__((__always_inline__)) bool test_and_set(memory_order __m = memory_order_seq_cst) noexcept { return __atomic_test_and_set (&_M_i, int(__m)); } inline __attribute__((__always_inline__)) bool test_and_set(memory_order __m = memory_order_seq_cst) volatile noexcept { return __atomic_test_and_set (&_M_i, int(__m)); } inline __attribute__((__always_inline__)) void clear(memory_order __m = memory_order_seq_cst) noexcept { memory_order __b = __m & __memory_order_mask; ; ; ; __atomic_clear (&_M_i, int(__m)); } inline __attribute__((__always_inline__)) void clear(memory_order __m = memory_order_seq_cst) volatile noexcept { memory_order __b = __m & __memory_order_mask; ; ; ; __atomic_clear (&_M_i, int(__m)); } private: static constexpr __atomic_flag_data_type _S_init(bool __i) { return __i ? 1 : 0; } }; template<typename _ITp> struct __atomic_base { using value_type = _ITp; using difference_type = value_type; private: typedef _ITp __int_type; static constexpr int _S_alignment = sizeof(_ITp) > alignof(_ITp) ? sizeof(_ITp) : alignof(_ITp); alignas(_S_alignment) __int_type _M_i ; public: __atomic_base() noexcept = default; ~__atomic_base() noexcept = default; __atomic_base(const __atomic_base&) = delete; __atomic_base& operator=(const __atomic_base&) = delete; __atomic_base& operator=(const __atomic_base&) volatile = delete; constexpr __atomic_base(__int_type __i) noexcept : _M_i (__i) { } operator __int_type() const noexcept { return load(); } operator __int_type() const volatile noexcept { return load(); } __int_type operator=(__int_type __i) noexcept { store(__i); return __i; } __int_type operator=(__int_type __i) volatile noexcept { store(__i); return __i; } __int_type operator++(int) noexcept { return fetch_add(1); } __int_type operator++(int) volatile noexcept { return fetch_add(1); } __int_type operator--(int) noexcept { return fetch_sub(1); } __int_type operator--(int) volatile noexcept { return fetch_sub(1); } __int_type operator++() noexcept { return __atomic_add_fetch(&_M_i, 1, int(memory_order_seq_cst)); } __int_type operator++() volatile noexcept { return __atomic_add_fetch(&_M_i, 1, int(memory_order_seq_cst)); } __int_type operator--() noexcept { return __atomic_sub_fetch(&_M_i, 1, int(memory_order_seq_cst)); } __int_type operator--() volatile noexcept { return __atomic_sub_fetch(&_M_i, 1, int(memory_order_seq_cst)); } __int_type operator+=(__int_type __i) noexcept { return __atomic_add_fetch(&_M_i, __i, int(memory_order_seq_cst)); } __int_type operator+=(__int_type __i) volatile noexcept { return __atomic_add_fetch(&_M_i, __i, int(memory_order_seq_cst)); } __int_type operator-=(__int_type __i) noexcept { return __atomic_sub_fetch(&_M_i, __i, int(memory_order_seq_cst)); } __int_type operator-=(__int_type __i) volatile noexcept { return __atomic_sub_fetch(&_M_i, __i, int(memory_order_seq_cst)); } __int_type operator&=(__int_type __i) noexcept { return __atomic_and_fetch(&_M_i, __i, int(memory_order_seq_cst)); } __int_type operator&=(__int_type __i) volatile noexcept { return __atomic_and_fetch(&_M_i, __i, int(memory_order_seq_cst)); } __int_type operator|=(__int_type __i) noexcept { return __atomic_or_fetch(&_M_i, __i, int(memory_order_seq_cst)); } __int_type operator|=(__int_type __i) volatile noexcept { return __atomic_or_fetch(&_M_i, __i, int(memory_order_seq_cst)); } __int_type operator^=(__int_type __i) noexcept { return __atomic_xor_fetch(&_M_i, __i, int(memory_order_seq_cst)); } __int_type operator^=(__int_type __i) volatile noexcept { return __atomic_xor_fetch(&_M_i, __i, int(memory_order_seq_cst)); } bool is_lock_free() const noexcept { return __atomic_is_lock_free(sizeof(_M_i), reinterpret_cast<void *>(-_S_alignment)); } bool is_lock_free() const volatile noexcept { return __atomic_is_lock_free(sizeof(_M_i), reinterpret_cast<void *>(-_S_alignment)); } inline __attribute__((__always_inline__)) void store(__int_type __i, memory_order __m = memory_order_seq_cst) noexcept { memory_order __b = __m & __memory_order_mask; ; ; ; __atomic_store_n(&_M_i, __i, int(__m)); } inline __attribute__((__always_inline__)) void store(__int_type __i, memory_order __m = memory_order_seq_cst) volatile noexcept { memory_order __b = __m & __memory_order_mask; ; ; ; __atomic_store_n(&_M_i, __i, int(__m)); } inline __attribute__((__always_inline__)) __int_type load(memory_order __m = memory_order_seq_cst) const noexcept { memory_order __b = __m & __memory_order_mask; ; ; return __atomic_load_n(&_M_i, int(__m)); } inline __attribute__((__always_inline__)) __int_type load(memory_order __m = memory_order_seq_cst) const volatile noexcept { memory_order __b = __m & __memory_order_mask; ; ; return __atomic_load_n(&_M_i, int(__m)); } inline __attribute__((__always_inline__)) __int_type exchange(__int_type __i, memory_order __m = memory_order_seq_cst) noexcept { return __atomic_exchange_n(&_M_i, __i, int(__m)); } inline __attribute__((__always_inline__)) __int_type exchange(__int_type __i, memory_order __m = memory_order_seq_cst) volatile noexcept { return __atomic_exchange_n(&_M_i, __i, int(__m)); } inline __attribute__((__always_inline__)) bool compare_exchange_weak(__int_type& __i1, __int_type __i2, memory_order __m1, memory_order __m2) noexcept { memory_order __b2 = __m2 & __memory_order_mask; memory_order __b1 = __m1 & __memory_order_mask; ; ; ; return __atomic_compare_exchange_n(&_M_i, &__i1, __i2, 1, int(__m1), int(__m2)); } inline __attribute__((__always_inline__)) bool compare_exchange_weak(__int_type& __i1, __int_type __i2, memory_order __m1, memory_order __m2) volatile noexcept { memory_order __b2 = __m2 & __memory_order_mask; memory_order __b1 = __m1 & __memory_order_mask; ; ; ; return __atomic_compare_exchange_n(&_M_i, &__i1, __i2, 1, int(__m1), int(__m2)); } inline __attribute__((__always_inline__)) bool compare_exchange_weak(__int_type& __i1, __int_type __i2, memory_order __m = memory_order_seq_cst) noexcept { return compare_exchange_weak(__i1, __i2, __m, __cmpexch_failure_order(__m)); } inline __attribute__((__always_inline__)) bool compare_exchange_weak(__int_type& __i1, __int_type __i2, memory_order __m = memory_order_seq_cst) volatile noexcept { return compare_exchange_weak(__i1, __i2, __m, __cmpexch_failure_order(__m)); } inline __attribute__((__always_inline__)) bool compare_exchange_strong(__int_type& __i1, __int_type __i2, memory_order __m1, memory_order __m2) noexcept { memory_order __b2 = __m2 & __memory_order_mask; memory_order __b1 = __m1 & __memory_order_mask; ; ; ; return __atomic_compare_exchange_n(&_M_i, &__i1, __i2, 0, int(__m1), int(__m2)); } inline __attribute__((__always_inline__)) bool compare_exchange_strong(__int_type& __i1, __int_type __i2, memory_order __m1, memory_order __m2) volatile noexcept { memory_order __b2 = __m2 & __memory_order_mask; memory_order __b1 = __m1 & __memory_order_mask; ; ; ; return __atomic_compare_exchange_n(&_M_i, &__i1, __i2, 0, int(__m1), int(__m2)); } inline __attribute__((__always_inline__)) bool compare_exchange_strong(__int_type& __i1, __int_type __i2, memory_order __m = memory_order_seq_cst) noexcept { return compare_exchange_strong(__i1, __i2, __m, __cmpexch_failure_order(__m)); } inline __attribute__((__always_inline__)) bool compare_exchange_strong(__int_type& __i1, __int_type __i2, memory_order __m = memory_order_seq_cst) volatile noexcept { return compare_exchange_strong(__i1, __i2, __m, __cmpexch_failure_order(__m)); } inline __attribute__((__always_inline__)) __int_type fetch_add(__int_type __i, memory_order __m = memory_order_seq_cst) noexcept { return __atomic_fetch_add(&_M_i, __i, int(__m)); } inline __attribute__((__always_inline__)) __int_type fetch_add(__int_type __i, memory_order __m = memory_order_seq_cst) volatile noexcept { return __atomic_fetch_add(&_M_i, __i, int(__m)); } inline __attribute__((__always_inline__)) __int_type fetch_sub(__int_type __i, memory_order __m = memory_order_seq_cst) noexcept { return __atomic_fetch_sub(&_M_i, __i, int(__m)); } inline __attribute__((__always_inline__)) __int_type fetch_sub(__int_type __i, memory_order __m = memory_order_seq_cst) volatile noexcept { return __atomic_fetch_sub(&_M_i, __i, int(__m)); } inline __attribute__((__always_inline__)) __int_type fetch_and(__int_type __i, memory_order __m = memory_order_seq_cst) noexcept { return __atomic_fetch_and(&_M_i, __i, int(__m)); } inline __attribute__((__always_inline__)) __int_type fetch_and(__int_type __i, memory_order __m = memory_order_seq_cst) volatile noexcept { return __atomic_fetch_and(&_M_i, __i, int(__m)); } inline __attribute__((__always_inline__)) __int_type fetch_or(__int_type __i, memory_order __m = memory_order_seq_cst) noexcept { return __atomic_fetch_or(&_M_i, __i, int(__m)); } inline __attribute__((__always_inline__)) __int_type fetch_or(__int_type __i, memory_order __m = memory_order_seq_cst) volatile noexcept { return __atomic_fetch_or(&_M_i, __i, int(__m)); } inline __attribute__((__always_inline__)) __int_type fetch_xor(__int_type __i, memory_order __m = memory_order_seq_cst) noexcept { return __atomic_fetch_xor(&_M_i, __i, int(__m)); } inline __attribute__((__always_inline__)) __int_type fetch_xor(__int_type __i, memory_order __m = memory_order_seq_cst) volatile noexcept { return __atomic_fetch_xor(&_M_i, __i, int(__m)); } }; template<typename _PTp> struct __atomic_base<_PTp*> { private: typedef _PTp* __pointer_type; __pointer_type _M_p ; constexpr ptrdiff_t _M_type_size(ptrdiff_t __d) const { return __d * sizeof(_PTp); } constexpr ptrdiff_t _M_type_size(ptrdiff_t __d) const volatile { return __d * sizeof(_PTp); } public: __atomic_base() noexcept = default; ~__atomic_base() noexcept = default; __atomic_base(const __atomic_base&) = delete; __atomic_base& operator=(const __atomic_base&) = delete; __atomic_base& operator=(const __atomic_base&) volatile = delete; constexpr __atomic_base(__pointer_type __p) noexcept : _M_p (__p) { } operator __pointer_type() const noexcept { return load(); } operator __pointer_type() const volatile noexcept { return load(); } __pointer_type operator=(__pointer_type __p) noexcept { store(__p); return __p; } __pointer_type operator=(__pointer_type __p) volatile noexcept { store(__p); return __p; } __pointer_type operator++(int) noexcept { return fetch_add(1); } __pointer_type operator++(int) volatile noexcept { return fetch_add(1); } __pointer_type operator--(int) noexcept { return fetch_sub(1); } __pointer_type operator--(int) volatile noexcept { return fetch_sub(1); } __pointer_type operator++() noexcept { return __atomic_add_fetch(&_M_p, _M_type_size(1), int(memory_order_seq_cst)); } __pointer_type operator++() volatile noexcept { return __atomic_add_fetch(&_M_p, _M_type_size(1), int(memory_order_seq_cst)); } __pointer_type operator--() noexcept { return __atomic_sub_fetch(&_M_p, _M_type_size(1), int(memory_order_seq_cst)); } __pointer_type operator--() volatile noexcept { return __atomic_sub_fetch(&_M_p, _M_type_size(1), int(memory_order_seq_cst)); } __pointer_type operator+=(ptrdiff_t __d) noexcept { return __atomic_add_fetch(&_M_p, _M_type_size(__d), int(memory_order_seq_cst)); } __pointer_type operator+=(ptrdiff_t __d) volatile noexcept { return __atomic_add_fetch(&_M_p, _M_type_size(__d), int(memory_order_seq_cst)); } __pointer_type operator-=(ptrdiff_t __d) noexcept { return __atomic_sub_fetch(&_M_p, _M_type_size(__d), int(memory_order_seq_cst)); } __pointer_type operator-=(ptrdiff_t __d) volatile noexcept { return __atomic_sub_fetch(&_M_p, _M_type_size(__d), int(memory_order_seq_cst)); } bool is_lock_free() const noexcept { return __atomic_is_lock_free(sizeof(_M_p), reinterpret_cast<void *>(-__alignof(_M_p))); } bool is_lock_free() const volatile noexcept { return __atomic_is_lock_free(sizeof(_M_p), reinterpret_cast<void *>(-__alignof(_M_p))); } inline __attribute__((__always_inline__)) void store(__pointer_type __p, memory_order __m = memory_order_seq_cst) noexcept { memory_order __b = __m & __memory_order_mask; ; ; ; __atomic_store_n(&_M_p, __p, int(__m)); } inline __attribute__((__always_inline__)) void store(__pointer_type __p, memory_order __m = memory_order_seq_cst) volatile noexcept { memory_order __b = __m & __memory_order_mask; ; ; ; __atomic_store_n(&_M_p, __p, int(__m)); } inline __attribute__((__always_inline__)) __pointer_type load(memory_order __m = memory_order_seq_cst) const noexcept { memory_order __b = __m & __memory_order_mask; ; ; return __atomic_load_n(&_M_p, int(__m)); } inline __attribute__((__always_inline__)) __pointer_type load(memory_order __m = memory_order_seq_cst) const volatile noexcept { memory_order __b = __m & __memory_order_mask; ; ; return __atomic_load_n(&_M_p, int(__m)); } inline __attribute__((__always_inline__)) __pointer_type exchange(__pointer_type __p, memory_order __m = memory_order_seq_cst) noexcept { return __atomic_exchange_n(&_M_p, __p, int(__m)); } inline __attribute__((__always_inline__)) __pointer_type exchange(__pointer_type __p, memory_order __m = memory_order_seq_cst) volatile noexcept { return __atomic_exchange_n(&_M_p, __p, int(__m)); } inline __attribute__((__always_inline__)) bool compare_exchange_strong(__pointer_type& __p1, __pointer_type __p2, memory_order __m1, memory_order __m2) noexcept { memory_order __b2 = __m2 & __memory_order_mask; memory_order __b1 = __m1 & __memory_order_mask; ; ; ; return __atomic_compare_exchange_n(&_M_p, &__p1, __p2, 0, int(__m1), int(__m2)); } inline __attribute__((__always_inline__)) bool compare_exchange_strong(__pointer_type& __p1, __pointer_type __p2, memory_order __m1, memory_order __m2) volatile noexcept { memory_order __b2 = __m2 & __memory_order_mask; memory_order __b1 = __m1 & __memory_order_mask; ; ; ; return __atomic_compare_exchange_n(&_M_p, &__p1, __p2, 0, int(__m1), int(__m2)); } inline __attribute__((__always_inline__)) __pointer_type fetch_add(ptrdiff_t __d, memory_order __m = memory_order_seq_cst) noexcept { return __atomic_fetch_add(&_M_p, _M_type_size(__d), int(__m)); } inline __attribute__((__always_inline__)) __pointer_type fetch_add(ptrdiff_t __d, memory_order __m = memory_order_seq_cst) volatile noexcept { return __atomic_fetch_add(&_M_p, _M_type_size(__d), int(__m)); } inline __attribute__((__always_inline__)) __pointer_type fetch_sub(ptrdiff_t __d, memory_order __m = memory_order_seq_cst) noexcept { return __atomic_fetch_sub(&_M_p, _M_type_size(__d), int(__m)); } inline __attribute__((__always_inline__)) __pointer_type fetch_sub(ptrdiff_t __d, memory_order __m = memory_order_seq_cst) volatile noexcept { return __atomic_fetch_sub(&_M_p, _M_type_size(__d), int(__m)); } }; } namespace std __attribute__ ((__visibility__ ("default"))) { struct _Sp_locker { _Sp_locker(const _Sp_locker&) = delete; _Sp_locker& operator=(const _Sp_locker&) = delete; explicit _Sp_locker(const void*) noexcept; _Sp_locker(const void*, const void*) noexcept; ~_Sp_locker(); private: unsigned char _M_key1; unsigned char _M_key2; }; template<typename _Tp, _Lock_policy _Lp> inline bool atomic_is_lock_free(const __shared_ptr<_Tp, _Lp>* __p) { return __gthread_active_p() == 0; } template<typename _Tp> inline bool atomic_is_lock_free(const shared_ptr<_Tp>* __p) { return std::atomic_is_lock_free<_Tp, __default_lock_policy>(__p); } template<typename _Tp> inline shared_ptr<_Tp> atomic_load_explicit(const shared_ptr<_Tp>* __p, memory_order) { _Sp_locker __lock{__p}; return *__p; } template<typename _Tp> inline shared_ptr<_Tp> atomic_load(const shared_ptr<_Tp>* __p) { return std::atomic_load_explicit(__p, memory_order_seq_cst); } template<typename _Tp, _Lock_policy _Lp> inline __shared_ptr<_Tp, _Lp> atomic_load_explicit(const __shared_ptr<_Tp, _Lp>* __p, memory_order) { _Sp_locker __lock{__p}; return *__p; } template<typename _Tp, _Lock_policy _Lp> inline __shared_ptr<_Tp, _Lp> atomic_load(const __shared_ptr<_Tp, _Lp>* __p) { return std::atomic_load_explicit(__p, memory_order_seq_cst); } template<typename _Tp> inline void atomic_store_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r, memory_order) { _Sp_locker __lock{__p}; __p->swap(__r); } template<typename _Tp> inline void atomic_store(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r) { std::atomic_store_explicit(__p, std::move(__r), memory_order_seq_cst); } template<typename _Tp, _Lock_policy _Lp> inline void atomic_store_explicit(__shared_ptr<_Tp, _Lp>* __p, __shared_ptr<_Tp, _Lp> __r, memory_order) { _Sp_locker __lock{__p}; __p->swap(__r); } template<typename _Tp, _Lock_policy _Lp> inline void atomic_store(__shared_ptr<_Tp, _Lp>* __p, __shared_ptr<_Tp, _Lp> __r) { std::atomic_store_explicit(__p, std::move(__r), memory_order_seq_cst); } template<typename _Tp> inline shared_ptr<_Tp> atomic_exchange_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r, memory_order) { _Sp_locker __lock{__p}; __p->swap(__r); return __r; } template<typename _Tp> inline shared_ptr<_Tp> atomic_exchange(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r) { return std::atomic_exchange_explicit(__p, std::move(__r), memory_order_seq_cst); } template<typename _Tp, _Lock_policy _Lp> inline __shared_ptr<_Tp, _Lp> atomic_exchange_explicit(__shared_ptr<_Tp, _Lp>* __p, __shared_ptr<_Tp, _Lp> __r, memory_order) { _Sp_locker __lock{__p}; __p->swap(__r); return __r; } template<typename _Tp, _Lock_policy _Lp> inline __shared_ptr<_Tp, _Lp> atomic_exchange(__shared_ptr<_Tp, _Lp>* __p, __shared_ptr<_Tp, _Lp> __r) { return std::atomic_exchange_explicit(__p, std::move(__r), memory_order_seq_cst); } template<typename _Tp> bool atomic_compare_exchange_strong_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v, shared_ptr<_Tp> __w, memory_order, memory_order) { shared_ptr<_Tp> __x; _Sp_locker __lock{__p, __v}; owner_less<shared_ptr<_Tp>> __less; if (*__p == *__v && !__less(*__p, *__v) && !__less(*__v, *__p)) { __x = std::move(*__p); *__p = std::move(__w); return true; } __x = std::move(*__v); *__v = *__p; return false; } template<typename _Tp> inline bool atomic_compare_exchange_strong(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v, shared_ptr<_Tp> __w) { return std::atomic_compare_exchange_strong_explicit(__p, __v, std::move(__w), memory_order_seq_cst, memory_order_seq_cst); } template<typename _Tp> inline bool atomic_compare_exchange_weak_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v, shared_ptr<_Tp> __w, memory_order __success, memory_order __failure) { return std::atomic_compare_exchange_strong_explicit(__p, __v, std::move(__w), __success, __failure); } template<typename _Tp> inline bool atomic_compare_exchange_weak(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v, shared_ptr<_Tp> __w) { return std::atomic_compare_exchange_weak_explicit(__p, __v, std::move(__w), memory_order_seq_cst, memory_order_seq_cst); } template<typename _Tp, _Lock_policy _Lp> bool atomic_compare_exchange_strong_explicit(__shared_ptr<_Tp, _Lp>* __p, __shared_ptr<_Tp, _Lp>* __v, __shared_ptr<_Tp, _Lp> __w, memory_order, memory_order) { __shared_ptr<_Tp, _Lp> __x; _Sp_locker __lock{__p, __v}; owner_less<__shared_ptr<_Tp, _Lp>> __less; if (*__p == *__v && !__less(*__p, *__v) && !__less(*__v, *__p)) { __x = std::move(*__p); *__p = std::move(__w); return true; } __x = std::move(*__v); *__v = *__p; return false; } template<typename _Tp, _Lock_policy _Lp> inline bool atomic_compare_exchange_strong(__shared_ptr<_Tp, _Lp>* __p, __shared_ptr<_Tp, _Lp>* __v, __shared_ptr<_Tp, _Lp> __w) { return std::atomic_compare_exchange_strong_explicit(__p, __v, std::move(__w), memory_order_seq_cst, memory_order_seq_cst); } template<typename _Tp, _Lock_policy _Lp> inline bool atomic_compare_exchange_weak_explicit(__shared_ptr<_Tp, _Lp>* __p, __shared_ptr<_Tp, _Lp>* __v, __shared_ptr<_Tp, _Lp> __w, memory_order __success, memory_order __failure) { return std::atomic_compare_exchange_strong_explicit(__p, __v, std::move(__w), __success, __failure); } template<typename _Tp, _Lock_policy _Lp> inline bool atomic_compare_exchange_weak(__shared_ptr<_Tp, _Lp>* __p, __shared_ptr<_Tp, _Lp>* __v, __shared_ptr<_Tp, _Lp> __w) { return std::atomic_compare_exchange_weak_explicit(__p, __v, std::move(__w), memory_order_seq_cst, memory_order_seq_cst); } } namespace std __attribute__ ((__visibility__ ("default"))) { template<typename _Tp1> struct auto_ptr_ref { _Tp1* _M_ptr; explicit auto_ptr_ref(_Tp1* __p): _M_ptr(__p) { } } __attribute__ ((__deprecated__)); template<typename _Tp> class auto_ptr { private: _Tp* _M_ptr; public: typedef _Tp element_type; explicit auto_ptr(element_type* __p = 0) throw() : _M_ptr(__p) { } auto_ptr(auto_ptr& __a) throw() : _M_ptr(__a.release()) { } template<typename _Tp1> auto_ptr(auto_ptr<_Tp1>& __a) throw() : _M_ptr(__a.release()) { } auto_ptr& operator=(auto_ptr& __a) throw() { reset(__a.release()); return *this; } template<typename _Tp1> auto_ptr& operator=(auto_ptr<_Tp1>& __a) throw() { reset(__a.release()); return *this; } ~auto_ptr() { delete _M_ptr; } element_type& operator*() const throw() { ; return *_M_ptr; } element_type* operator->() const throw() { ; return _M_ptr; } element_type* get() const throw() { return _M_ptr; } element_type* release() throw() { element_type* __tmp = _M_ptr; _M_ptr = 0; return __tmp; } void reset(element_type* __p = 0) throw() { if (__p != _M_ptr) { delete _M_ptr; _M_ptr = __p; } } 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()); } } __attribute__ ((__deprecated__)); template<> class auto_ptr<void> { public: typedef void element_type; } __attribute__ ((__deprecated__)); 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() { 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()) { } } namespace std __attribute__ ((__visibility__ ("default"))) { inline void* align(size_t __align, size_t __size, void*& __ptr, size_t& __space) noexcept { const auto __intptr = reinterpret_cast<uintptr_t>(__ptr); const auto __aligned = (__intptr - 1u + __align) & -__align; const auto __diff = __aligned - __intptr; if ((__size + __diff) > __space) return nullptr; else { __space -= __diff; return __ptr = reinterpret_cast<void*>(__aligned); } } enum class pointer_safety { relaxed, preferred, strict }; inline void declare_reachable(void*) { } template <typename _Tp> inline _Tp* undeclare_reachable(_Tp* __p) { return __p; } inline void declare_no_pointers(char*, size_t) { } inline void undeclare_no_pointers(char*, size_t) { } inline pointer_safety get_pointer_safety() noexcept { return pointer_safety::relaxed; } } namespace std __attribute__ ((__visibility__ ("default"))) { template<typename _IIter, typename _Predicate> bool all_of(_IIter, _IIter, _Predicate); template<typename _IIter, typename _Predicate> bool any_of(_IIter, _IIter, _Predicate); template<typename _FIter, typename _Tp> bool binary_search(_FIter, _FIter, const _Tp&); template<typename _FIter, typename _Tp, typename _Compare> bool binary_search(_FIter, _FIter, const _Tp&, _Compare); template<typename _IIter, typename _OIter> _OIter copy(_IIter, _IIter, _OIter); template<typename _BIter1, typename _BIter2> _BIter2 copy_backward(_BIter1, _BIter1, _BIter2); template<typename _IIter, typename _OIter, typename _Predicate> _OIter copy_if(_IIter, _IIter, _OIter, _Predicate); template<typename _IIter, typename _Size, typename _OIter> _OIter copy_n(_IIter, _Size, _OIter); template<typename _FIter, typename _Tp> pair<_FIter, _FIter> equal_range(_FIter, _FIter, const _Tp&); template<typename _FIter, typename _Tp, typename _Compare> pair<_FIter, _FIter> equal_range(_FIter, _FIter, const _Tp&, _Compare); template<typename _FIter, typename _Tp> void fill(_FIter, _FIter, const _Tp&); template<typename _OIter, typename _Size, typename _Tp> _OIter fill_n(_OIter, _Size, const _Tp&); template<typename _FIter1, typename _FIter2> _FIter1 find_end(_FIter1, _FIter1, _FIter2, _FIter2); template<typename _FIter1, typename _FIter2, typename _BinaryPredicate> _FIter1 find_end(_FIter1, _FIter1, _FIter2, _FIter2, _BinaryPredicate); template<typename _IIter, typename _Predicate> _IIter find_if_not(_IIter, _IIter, _Predicate); template<typename _IIter1, typename _IIter2> bool includes(_IIter1, _IIter1, _IIter2, _IIter2); template<typename _IIter1, typename _IIter2, typename _Compare> 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); template<typename _RAIter> bool is_heap(_RAIter, _RAIter); template<typename _RAIter, typename _Compare> bool is_heap(_RAIter, _RAIter, _Compare); template<typename _RAIter> _RAIter is_heap_until(_RAIter, _RAIter); template<typename _RAIter, typename _Compare> _RAIter is_heap_until(_RAIter, _RAIter, _Compare); template<typename _IIter, typename _Predicate> bool is_partitioned(_IIter, _IIter, _Predicate); template<typename _FIter1, typename _FIter2> bool is_permutation(_FIter1, _FIter1, _FIter2); template<typename _FIter1, typename _FIter2, typename _BinaryPredicate> bool is_permutation(_FIter1, _FIter1, _FIter2, _BinaryPredicate); template<typename _FIter> bool is_sorted(_FIter, _FIter); template<typename _FIter, typename _Compare> bool is_sorted(_FIter, _FIter, _Compare); template<typename _FIter> _FIter is_sorted_until(_FIter, _FIter); template<typename _FIter, typename _Compare> _FIter is_sorted_until(_FIter, _FIter, _Compare); template<typename _FIter1, typename _FIter2> void iter_swap(_FIter1, _FIter2); template<typename _FIter, typename _Tp> _FIter lower_bound(_FIter, _FIter, const _Tp&); template<typename _FIter, typename _Tp, typename _Compare> _FIter lower_bound(_FIter, _FIter, const _Tp&, _Compare); template<typename _RAIter> void make_heap(_RAIter, _RAIter); template<typename _RAIter, typename _Compare> void make_heap(_RAIter, _RAIter, _Compare); template<typename _Tp> constexpr const _Tp& max(const _Tp&, const _Tp&); template<typename _Tp, typename _Compare> constexpr const _Tp& max(const _Tp&, const _Tp&, _Compare); template<typename _Tp> constexpr const _Tp& min(const _Tp&, const _Tp&); template<typename _Tp, typename _Compare> constexpr const _Tp& min(const _Tp&, const _Tp&, _Compare); template<typename _Tp> constexpr pair<const _Tp&, const _Tp&> minmax(const _Tp&, const _Tp&); template<typename _Tp, typename _Compare> constexpr pair<const _Tp&, const _Tp&> minmax(const _Tp&, const _Tp&, _Compare); template<typename _FIter> constexpr pair<_FIter, _FIter> minmax_element(_FIter, _FIter); template<typename _FIter, typename _Compare> constexpr pair<_FIter, _FIter> minmax_element(_FIter, _FIter, _Compare); template<typename _Tp> constexpr _Tp min(initializer_list<_Tp>); template<typename _Tp, typename _Compare> constexpr _Tp min(initializer_list<_Tp>, _Compare); template<typename _Tp> constexpr _Tp max(initializer_list<_Tp>); template<typename _Tp, typename _Compare> constexpr _Tp max(initializer_list<_Tp>, _Compare); template<typename _Tp> constexpr pair<_Tp, _Tp> minmax(initializer_list<_Tp>); template<typename _Tp, typename _Compare> constexpr pair<_Tp, _Tp> minmax(initializer_list<_Tp>, _Compare); template<typename _BIter> bool next_permutation(_BIter, _BIter); template<typename _BIter, typename _Compare> bool next_permutation(_BIter, _BIter, _Compare); template<typename _IIter, typename _Predicate> bool none_of(_IIter, _IIter, _Predicate); template<typename _IIter, typename _RAIter> _RAIter partial_sort_copy(_IIter, _IIter, _RAIter, _RAIter); template<typename _IIter, typename _RAIter, typename _Compare> _RAIter partial_sort_copy(_IIter, _IIter, _RAIter, _RAIter, _Compare); template<typename _IIter, typename _OIter1, typename _OIter2, typename _Predicate> pair<_OIter1, _OIter2> partition_copy(_IIter, _IIter, _OIter1, _OIter2, _Predicate); template<typename _FIter, typename _Predicate> _FIter partition_point(_FIter, _FIter, _Predicate); template<typename _RAIter> void pop_heap(_RAIter, _RAIter); template<typename _RAIter, typename _Compare> void pop_heap(_RAIter, _RAIter, _Compare); template<typename _BIter> bool prev_permutation(_BIter, _BIter); template<typename _BIter, typename _Compare> bool prev_permutation(_BIter, _BIter, _Compare); template<typename _RAIter> void push_heap(_RAIter, _RAIter); template<typename _RAIter, typename _Compare> void push_heap(_RAIter, _RAIter, _Compare); template<typename _FIter, typename _Tp> _FIter remove(_FIter, _FIter, const _Tp&); template<typename _FIter, typename _Predicate> _FIter remove_if(_FIter, _FIter, _Predicate); template<typename _IIter, typename _OIter, typename _Tp> _OIter remove_copy(_IIter, _IIter, _OIter, const _Tp&); template<typename _IIter, typename _OIter, typename _Predicate> _OIter remove_copy_if(_IIter, _IIter, _OIter, _Predicate); template<typename _IIter, typename _OIter, typename _Tp> _OIter replace_copy(_IIter, _IIter, _OIter, const _Tp&, const _Tp&); template<typename _Iter, typename _OIter, typename _Predicate, typename _Tp> _OIter replace_copy_if(_Iter, _Iter, _OIter, _Predicate, const _Tp&); template<typename _BIter> void reverse(_BIter, _BIter); template<typename _BIter, typename _OIter> _OIter reverse_copy(_BIter, _BIter, _OIter); inline namespace _V2 { template<typename _FIter> _FIter rotate(_FIter, _FIter, _FIter); } template<typename _FIter, typename _OIter> _OIter rotate_copy(_FIter, _FIter, _FIter, _OIter); template<typename _RAIter, typename _UGenerator> void shuffle(_RAIter, _RAIter, _UGenerator&&); template<typename _RAIter> void sort_heap(_RAIter, _RAIter); template<typename _RAIter, typename _Compare> void sort_heap(_RAIter, _RAIter, _Compare); template<typename _BIter, typename _Predicate> _BIter stable_partition(_BIter, _BIter, _Predicate); template<typename _FIter1, typename _FIter2> _FIter2 swap_ranges(_FIter1, _FIter1, _FIter2); template<typename _FIter> _FIter unique(_FIter, _FIter); template<typename _FIter, typename _BinaryPredicate> _FIter unique(_FIter, _FIter, _BinaryPredicate); template<typename _FIter, typename _Tp> _FIter upper_bound(_FIter, _FIter, const _Tp&); template<typename _FIter, typename _Tp, typename _Compare> _FIter upper_bound(_FIter, _FIter, const _Tp&, _Compare); template<typename _FIter> _FIter adjacent_find(_FIter, _FIter); template<typename _FIter, typename _BinaryPredicate> _FIter adjacent_find(_FIter, _FIter, _BinaryPredicate); template<typename _IIter, typename _Tp> typename iterator_traits<_IIter>::difference_type count(_IIter, _IIter, const _Tp&); template<typename _IIter, typename _Predicate> typename iterator_traits<_IIter>::difference_type count_if(_IIter, _IIter, _Predicate); template<typename _IIter1, typename _IIter2> bool equal(_IIter1, _IIter1, _IIter2); template<typename _IIter1, typename _IIter2, typename _BinaryPredicate> bool equal(_IIter1, _IIter1, _IIter2, _BinaryPredicate); template<typename _IIter, typename _Tp> _IIter find(_IIter, _IIter, const _Tp&); template<typename _FIter1, typename _FIter2> _FIter1 find_first_of(_FIter1, _FIter1, _FIter2, _FIter2); template<typename _FIter1, typename _FIter2, typename _BinaryPredicate> _FIter1 find_first_of(_FIter1, _FIter1, _FIter2, _FIter2, _BinaryPredicate); template<typename _IIter, typename _Predicate> _IIter find_if(_IIter, _IIter, _Predicate); template<typename _IIter, typename _Funct> _Funct for_each(_IIter, _IIter, _Funct); template<typename _FIter, typename _Generator> void generate(_FIter, _FIter, _Generator); template<typename _OIter, typename _Size, typename _Generator> _OIter generate_n(_OIter, _Size, _Generator); template<typename _IIter1, typename _IIter2> bool lexicographical_compare(_IIter1, _IIter1, _IIter2, _IIter2); template<typename _IIter1, typename _IIter2, typename _Compare> bool lexicographical_compare(_IIter1, _IIter1, _IIter2, _IIter2, _Compare); template<typename _FIter> constexpr _FIter max_element(_FIter, _FIter); template<typename _FIter, typename _Compare> constexpr _FIter max_element(_FIter, _FIter, _Compare); template<typename _IIter1, typename _IIter2, typename _OIter> _OIter merge(_IIter1, _IIter1, _IIter2, _IIter2, _OIter); template<typename _IIter1, typename _IIter2, typename _OIter, typename _Compare> _OIter merge(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare); template<typename _FIter> constexpr _FIter min_element(_FIter, _FIter); template<typename _FIter, typename _Compare> constexpr _FIter min_element(_FIter, _FIter, _Compare); template<typename _IIter1, typename _IIter2> pair<_IIter1, _IIter2> mismatch(_IIter1, _IIter1, _IIter2); template<typename _IIter1, typename _IIter2, typename _BinaryPredicate> pair<_IIter1, _IIter2> mismatch(_IIter1, _IIter1, _IIter2, _BinaryPredicate); template<typename _RAIter> void nth_element(_RAIter, _RAIter, _RAIter); template<typename _RAIter, typename _Compare> void nth_element(_RAIter, _RAIter, _RAIter, _Compare); template<typename _RAIter> void partial_sort(_RAIter, _RAIter, _RAIter); template<typename _RAIter, typename _Compare> void partial_sort(_RAIter, _RAIter, _RAIter, _Compare); template<typename _BIter, typename _Predicate> _BIter partition(_BIter, _BIter, _Predicate); template<typename _RAIter> void random_shuffle(_RAIter, _RAIter); template<typename _RAIter, typename _Generator> void random_shuffle(_RAIter, _RAIter, _Generator&&); template<typename _FIter, typename _Tp> void replace(_FIter, _FIter, const _Tp&, const _Tp&); template<typename _FIter, typename _Predicate, typename _Tp> void replace_if(_FIter, _FIter, _Predicate, const _Tp&); template<typename _FIter1, typename _FIter2> _FIter1 search(_FIter1, _FIter1, _FIter2, _FIter2); template<typename _FIter1, typename _FIter2, typename _BinaryPredicate> _FIter1 search(_FIter1, _FIter1, _FIter2, _FIter2, _BinaryPredicate); template<typename _FIter, typename _Size, typename _Tp> _FIter search_n(_FIter, _FIter, _Size, const _Tp&); template<typename _FIter, typename _Size, typename _Tp, typename _BinaryPredicate> _FIter search_n(_FIter, _FIter, _Size, const _Tp&, _BinaryPredicate); template<typename _IIter1, typename _IIter2, typename _OIter> _OIter set_difference(_IIter1, _IIter1, _IIter2, _IIter2, _OIter); template<typename _IIter1, typename _IIter2, typename _OIter, typename _Compare> _OIter set_difference(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare); template<typename _IIter1, typename _IIter2, typename _OIter> _OIter set_intersection(_IIter1, _IIter1, _IIter2, _IIter2, _OIter); template<typename _IIter1, typename _IIter2, typename _OIter, typename _Compare> _OIter set_intersection(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare); template<typename _IIter1, typename _IIter2, typename _OIter> _OIter set_symmetric_difference(_IIter1, _IIter1, _IIter2, _IIter2, _OIter); template<typename _IIter1, typename _IIter2, typename _OIter, typename _Compare> _OIter set_symmetric_difference(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare); template<typename _IIter1, typename _IIter2, typename _OIter> _OIter set_union(_IIter1, _IIter1, _IIter2, _IIter2, _OIter); template<typename _IIter1, typename _IIter2, typename _OIter, typename _Compare> _OIter set_union(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare); template<typename _RAIter> void sort(_RAIter, _RAIter); template<typename _RAIter, typename _Compare> 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> _OIter transform(_IIter, _IIter, _OIter, _UnaryOperation); template<typename _IIter1, typename _IIter2, typename _OIter, typename _BinaryOperation> _OIter transform(_IIter1, _IIter1, _IIter2, _OIter, _BinaryOperation); template<typename _IIter, typename _OIter> _OIter unique_copy(_IIter, _IIter, _OIter); template<typename _IIter, typename _OIter, typename _BinaryPredicate> _OIter unique_copy(_IIter, _IIter, _OIter, _BinaryPredicate); } namespace std __attribute__ ((__visibility__ ("default"))) { template<typename _RandomAccessIterator, typename _Distance, typename _Compare> _Distance __is_heap_until(_RandomAccessIterator __first, _Distance __n, _Compare& __comp) { _Distance __parent = 0; for (_Distance __child = 1; __child < __n; ++__child) { if (__comp(__first + __parent, __first + __child)) return __child; if ((__child & 1) == 0) ++__parent; } return __n; } template<typename _RandomAccessIterator, typename _Distance> inline bool __is_heap(_RandomAccessIterator __first, _Distance __n) { __gnu_cxx::__ops::_Iter_less_iter __comp; return std::__is_heap_until(__first, __n, __comp) == __n; } template<typename _RandomAccessIterator, typename _Compare, typename _Distance> inline bool __is_heap(_RandomAccessIterator __first, _Compare __comp, _Distance __n) { typedef __decltype(__comp) _Cmp; __gnu_cxx::__ops::_Iter_comp_iter<_Cmp> __cmp(std::move(__comp)); return std::__is_heap_until(__first, __n, __cmp) == __n; } template<typename _RandomAccessIterator> inline bool __is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) { return std::__is_heap(__first, std::distance(__first, __last)); } template<typename _RandomAccessIterator, typename _Compare> inline bool __is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { return std::__is_heap(__first, std::move(__comp), std::distance(__first, __last)); } template<typename _RandomAccessIterator, typename _Distance, typename _Tp, typename _Compare> void __push_heap(_RandomAccessIterator __first, _Distance __holeIndex, _Distance __topIndex, _Tp __value, _Compare& __comp) { _Distance __parent = (__holeIndex - 1) / 2; while (__holeIndex > __topIndex && __comp(__first + __parent, __value)) { *(__first + __holeIndex) = std::move(*(__first + __parent)); __holeIndex = __parent; __parent = (__holeIndex - 1) / 2; } *(__first + __holeIndex) = std::move(__value); } template<typename _RandomAccessIterator> inline void push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) { typedef typename iterator_traits<_RandomAccessIterator>::value_type _ValueType; typedef typename iterator_traits<_RandomAccessIterator>::difference_type _DistanceType; ; ; ; __gnu_cxx::__ops::_Iter_less_val __comp; _ValueType __value = std::move(*(__last - 1)); std::__push_heap(__first, _DistanceType((__last - __first) - 1), _DistanceType(0), std::move(__value), __comp); } template<typename _RandomAccessIterator, typename _Compare> inline void push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { typedef typename iterator_traits<_RandomAccessIterator>::value_type _ValueType; typedef typename iterator_traits<_RandomAccessIterator>::difference_type _DistanceType; ; ; ; __decltype(__gnu_cxx::__ops::__iter_comp_val(std::move(__comp))) __cmp(std::move(__comp)); _ValueType __value = std::move(*(__last - 1)); std::__push_heap(__first, _DistanceType((__last - __first) - 1), _DistanceType(0), std::move(__value), __cmp); } template<typename _RandomAccessIterator, typename _Distance, typename _Tp, typename _Compare> void __adjust_heap(_RandomAccessIterator __first, _Distance __holeIndex, _Distance __len, _Tp __value, _Compare __comp) { const _Distance __topIndex = __holeIndex; _Distance __secondChild = __holeIndex; while (__secondChild < (__len - 1) / 2) { __secondChild = 2 * (__secondChild + 1); if (__comp(__first + __secondChild, __first + (__secondChild - 1))) __secondChild--; *(__first + __holeIndex) = std::move(*(__first + __secondChild)); __holeIndex = __secondChild; } if ((__len & 1) == 0 && __secondChild == (__len - 2) / 2) { __secondChild = 2 * (__secondChild + 1); *(__first + __holeIndex) = std::move(*(__first + (__secondChild - 1))) ; __holeIndex = __secondChild - 1; } __decltype(__gnu_cxx::__ops::__iter_comp_val(std::move(__comp))) __cmp(std::move(__comp)); std::__push_heap(__first, __holeIndex, __topIndex, std::move(__value), __cmp); } template<typename _RandomAccessIterator, typename _Compare> inline void __pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _RandomAccessIterator __result, _Compare& __comp) { typedef typename iterator_traits<_RandomAccessIterator>::value_type _ValueType; typedef typename iterator_traits<_RandomAccessIterator>::difference_type _DistanceType; _ValueType __value = std::move(*__result); *__result = std::move(*__first); std::__adjust_heap(__first, _DistanceType(0), _DistanceType(__last - __first), std::move(__value), __comp); } template<typename _RandomAccessIterator> inline void pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) { ; ; ; ; if (__last - __first > 1) { --__last; __gnu_cxx::__ops::_Iter_less_iter __comp; std::__pop_heap(__first, __last, __last, __comp); } } template<typename _RandomAccessIterator, typename _Compare> inline void pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { ; ; ; ; if (__last - __first > 1) { typedef __decltype(__comp) _Cmp; __gnu_cxx::__ops::_Iter_comp_iter<_Cmp> __cmp(std::move(__comp)); --__last; std::__pop_heap(__first, __last, __last, __cmp); } } template<typename _RandomAccessIterator, typename _Compare> void __make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare& __comp) { typedef typename iterator_traits<_RandomAccessIterator>::value_type _ValueType; typedef typename iterator_traits<_RandomAccessIterator>::difference_type _DistanceType; if (__last - __first < 2) return; const _DistanceType __len = __last - __first; _DistanceType __parent = (__len - 2) / 2; while (true) { _ValueType __value = std::move(*(__first + __parent)); std::__adjust_heap(__first, __parent, __len, std::move(__value), __comp); if (__parent == 0) return; __parent--; } } template<typename _RandomAccessIterator> inline void make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) { ; ; __gnu_cxx::__ops::_Iter_less_iter __comp; std::__make_heap(__first, __last, __comp); } template<typename _RandomAccessIterator, typename _Compare> inline void make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { ; ; typedef __decltype(__comp) _Cmp; __gnu_cxx::__ops::_Iter_comp_iter<_Cmp> __cmp(std::move(__comp)); std::__make_heap(__first, __last, __cmp); } template<typename _RandomAccessIterator, typename _Compare> void __sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare& __comp) { while (__last - __first > 1) { --__last; std::__pop_heap(__first, __last, __last, __comp); } } template<typename _RandomAccessIterator> inline void sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) { ; ; ; __gnu_cxx::__ops::_Iter_less_iter __comp; std::__sort_heap(__first, __last, __comp); } template<typename _RandomAccessIterator, typename _Compare> inline void sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { ; ; ; typedef __decltype(__comp) _Cmp; __gnu_cxx::__ops::_Iter_comp_iter<_Cmp> __cmp(std::move(__comp)); std::__sort_heap(__first, __last, __cmp); } template<typename _RandomAccessIterator> inline _RandomAccessIterator is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last) { ; ; __gnu_cxx::__ops::_Iter_less_iter __comp; return __first + std::__is_heap_until(__first, std::distance(__first, __last), __comp); } template<typename _RandomAccessIterator, typename _Compare> inline _RandomAccessIterator is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { ; ; typedef __decltype(__comp) _Cmp; __gnu_cxx::__ops::_Iter_comp_iter<_Cmp> __cmp(std::move(__comp)); return __first + std::__is_heap_until(__first, std::distance(__first, __last), __cmp); } template<typename _RandomAccessIterator> inline bool is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) { return std::is_heap_until(__first, __last) == __last; } template<typename _RandomAccessIterator, typename _Compare> inline bool is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { ; ; const auto __dist = std::distance(__first, __last); typedef __decltype(__comp) _Cmp; __gnu_cxx::__ops::_Iter_comp_iter<_Cmp> __cmp(std::move(__comp)); return std::__is_heap_until(__first, __dist, __cmp) == __dist; } } namespace std __attribute__ ((__visibility__ ("default"))) { enum float_round_style { round_indeterminate = -1, round_toward_zero = 0, round_to_nearest = 1, round_toward_infinity = 2, round_toward_neg_infinity = 3 }; enum float_denorm_style { denorm_indeterminate = -1, denorm_absent = 0, denorm_present = 1 }; struct __numeric_limits_base { static constexpr bool is_specialized = false; static constexpr int digits = 0; static constexpr int digits10 = 0; static constexpr int max_digits10 = 0; static constexpr bool is_signed = false; static constexpr bool is_integer = false; static constexpr bool is_exact = false; static constexpr int radix = 0; static constexpr int min_exponent = 0; static constexpr int min_exponent10 = 0; static constexpr int max_exponent = 0; static constexpr int max_exponent10 = 0; static constexpr bool has_infinity = false; static constexpr bool has_quiet_NaN = false; static constexpr bool has_signaling_NaN = false; static constexpr float_denorm_style has_denorm = denorm_absent; static constexpr bool has_denorm_loss = false; static constexpr bool is_iec559 = false; static constexpr bool is_bounded = false; static constexpr bool is_modulo = false; static constexpr bool traps = false; static constexpr bool tinyness_before = false; static constexpr float_round_style round_style = round_toward_zero; }; template<typename _Tp> struct numeric_limits : public __numeric_limits_base { static constexpr _Tp min() noexcept { return _Tp(); } static constexpr _Tp max() noexcept { return _Tp(); } static constexpr _Tp lowest() noexcept { return _Tp(); } static constexpr _Tp epsilon() noexcept { return _Tp(); } static constexpr _Tp round_error() noexcept { return _Tp(); } static constexpr _Tp infinity() noexcept { return _Tp(); } static constexpr _Tp quiet_NaN() noexcept { return _Tp(); } static constexpr _Tp signaling_NaN() noexcept { return _Tp(); } static constexpr _Tp denorm_min() noexcept { return _Tp(); } }; template<typename _Tp> struct numeric_limits<const _Tp> : public numeric_limits<_Tp> { }; template<typename _Tp> struct numeric_limits<volatile _Tp> : public numeric_limits<_Tp> { }; template<typename _Tp> struct numeric_limits<const volatile _Tp> : public numeric_limits<_Tp> { }; template<> struct numeric_limits<bool> { static constexpr bool is_specialized = true; static constexpr bool min() noexcept { return false; } static constexpr bool max() noexcept { return true; } static constexpr bool lowest() noexcept { return min(); } static constexpr int digits = 1; static constexpr int digits10 = 0; static constexpr int max_digits10 = 0; static constexpr bool is_signed = false; static constexpr bool is_integer = true; static constexpr bool is_exact = true; static constexpr int radix = 2; static constexpr bool epsilon() noexcept { return false; } static constexpr bool round_error() noexcept { return false; } static constexpr int min_exponent = 0; static constexpr int min_exponent10 = 0; static constexpr int max_exponent = 0; static constexpr int max_exponent10 = 0; static constexpr bool has_infinity = false; static constexpr bool has_quiet_NaN = false; static constexpr bool has_signaling_NaN = false; static constexpr float_denorm_style has_denorm = denorm_absent; static constexpr bool has_denorm_loss = false; static constexpr bool infinity() noexcept { return false; } static constexpr bool quiet_NaN() noexcept { return false; } static constexpr bool signaling_NaN() noexcept { return false; } static constexpr bool denorm_min() noexcept { return false; } static constexpr bool is_iec559 = false; static constexpr bool is_bounded = true; static constexpr bool is_modulo = false; static constexpr bool traps = true; static constexpr bool tinyness_before = false; static constexpr float_round_style round_style = round_toward_zero; }; template<> struct numeric_limits<char> { static constexpr bool is_specialized = true; static constexpr char min() noexcept { return (((char)(-1) < 0) ? -(((char)(-1) < 0) ? (((((char)1 << ((sizeof(char) * 8 - ((char)(-1) < 0)) - 1)) - 1) << 1) + 1) : ~(char)0) - 1 : (char)0); } static constexpr char max() noexcept { return (((char)(-1) < 0) ? (((((char)1 << ((sizeof(char) * 8 - ((char)(-1) < 0)) - 1)) - 1) << 1) + 1) : ~(char)0); } static constexpr char lowest() noexcept { return min(); } static constexpr int digits = (sizeof(char) * 8 - ((char)(-1) < 0)); static constexpr int digits10 = ((sizeof(char) * 8 - ((char)(-1) < 0)) * 643L / 2136); static constexpr int max_digits10 = 0; static constexpr bool is_signed = ((char)(-1) < 0); static constexpr bool is_integer = true; static constexpr bool is_exact = true; static constexpr int radix = 2; static constexpr char epsilon() noexcept { return 0; } static constexpr char round_error() noexcept { return 0; } static constexpr int min_exponent = 0; static constexpr int min_exponent10 = 0; static constexpr int max_exponent = 0; static constexpr int max_exponent10 = 0; static constexpr bool has_infinity = false; static constexpr bool has_quiet_NaN = false; static constexpr bool has_signaling_NaN = false; static constexpr float_denorm_style has_denorm = denorm_absent; static constexpr bool has_denorm_loss = false; static constexpr char infinity() noexcept { return char(); } static constexpr char quiet_NaN() noexcept { return char(); } static constexpr char signaling_NaN() noexcept { return char(); } static constexpr char denorm_min() noexcept { return static_cast<char>(0); } static constexpr bool is_iec559 = false; static constexpr bool is_bounded = true; static constexpr bool is_modulo = !is_signed; static constexpr bool traps = true; static constexpr bool tinyness_before = false; static constexpr float_round_style round_style = round_toward_zero; }; template<> struct numeric_limits<signed char> { static constexpr bool is_specialized = true; static constexpr signed char min() noexcept { return -0x7f - 1; } static constexpr signed char max() noexcept { return 0x7f; } static constexpr signed char lowest() noexcept { return min(); } static constexpr int digits = (sizeof(signed char) * 8 - ((signed char)(-1) < 0)); static constexpr int digits10 = ((sizeof(signed char) * 8 - ((signed char)(-1) < 0)) * 643L / 2136); static constexpr int max_digits10 = 0; static constexpr bool is_signed = true; static constexpr bool is_integer = true; static constexpr bool is_exact = true; static constexpr int radix = 2; static constexpr signed char epsilon() noexcept { return 0; } static constexpr signed char round_error() noexcept { return 0; } static constexpr int min_exponent = 0; static constexpr int min_exponent10 = 0; static constexpr int max_exponent = 0; static constexpr int max_exponent10 = 0; static constexpr bool has_infinity = false; static constexpr bool has_quiet_NaN = false; static constexpr bool has_signaling_NaN = false; static constexpr float_denorm_style has_denorm = denorm_absent; static constexpr bool has_denorm_loss = false; static constexpr signed char infinity() noexcept { return static_cast<signed char>(0); } static constexpr signed char quiet_NaN() noexcept { return static_cast<signed char>(0); } static constexpr signed char signaling_NaN() noexcept { return static_cast<signed char>(0); } static constexpr signed char denorm_min() noexcept { return static_cast<signed char>(0); } static constexpr bool is_iec559 = false; static constexpr bool is_bounded = true; static constexpr bool is_modulo = false; static constexpr bool traps = true; static constexpr bool tinyness_before = false; static constexpr float_round_style round_style = round_toward_zero; }; template<> struct numeric_limits<unsigned char> { static constexpr bool is_specialized = true; static constexpr unsigned char min() noexcept { return 0; } static constexpr unsigned char max() noexcept { return 0x7f * 2U + 1; } static constexpr unsigned char lowest() noexcept { return min(); } static constexpr int digits = (sizeof(unsigned char) * 8 - ((unsigned char)(-1) < 0)); static constexpr int digits10 = ((sizeof(unsigned char) * 8 - ((unsigned char)(-1) < 0)) * 643L / 2136); static constexpr int max_digits10 = 0; static constexpr bool is_signed = false; static constexpr bool is_integer = true; static constexpr bool is_exact = true; static constexpr int radix = 2; static constexpr unsigned char epsilon() noexcept { return 0; } static constexpr unsigned char round_error() noexcept { return 0; } static constexpr int min_exponent = 0; static constexpr int min_exponent10 = 0; static constexpr int max_exponent = 0; static constexpr int max_exponent10 = 0; static constexpr bool has_infinity = false; static constexpr bool has_quiet_NaN = false; static constexpr bool has_signaling_NaN = false; static constexpr float_denorm_style has_denorm = denorm_absent; static constexpr bool has_denorm_loss = false; static constexpr unsigned char infinity() noexcept { return static_cast<unsigned char>(0); } static constexpr unsigned char quiet_NaN() noexcept { return static_cast<unsigned char>(0); } static constexpr unsigned char signaling_NaN() noexcept { return static_cast<unsigned char>(0); } static constexpr unsigned char denorm_min() noexcept { return static_cast<unsigned char>(0); } static constexpr bool is_iec559 = false; static constexpr bool is_bounded = true; static constexpr bool is_modulo = true; static constexpr bool traps = true; static constexpr bool tinyness_before = false; static constexpr float_round_style round_style = round_toward_zero; }; template<> struct numeric_limits<wchar_t> { static constexpr bool is_specialized = true; static constexpr wchar_t min() noexcept { return (((wchar_t)(-1) < 0) ? -(((wchar_t)(-1) < 0) ? (((((wchar_t)1 << ((sizeof(wchar_t) * 8 - ((wchar_t)(-1) < 0)) - 1)) - 1) << 1) + 1) : ~(wchar_t)0) - 1 : (wchar_t)0); } static constexpr wchar_t max() noexcept { return (((wchar_t)(-1) < 0) ? (((((wchar_t)1 << ((sizeof(wchar_t) * 8 - ((wchar_t)(-1) < 0)) - 1)) - 1) << 1) + 1) : ~(wchar_t)0); } static constexpr wchar_t lowest() noexcept { return min(); } static constexpr int digits = (sizeof(wchar_t) * 8 - ((wchar_t)(-1) < 0)); static constexpr int digits10 = ((sizeof(wchar_t) * 8 - ((wchar_t)(-1) < 0)) * 643L / 2136); static constexpr int max_digits10 = 0; static constexpr bool is_signed = ((wchar_t)(-1) < 0); static constexpr bool is_integer = true; static constexpr bool is_exact = true; static constexpr int radix = 2; static constexpr wchar_t epsilon() noexcept { return 0; } static constexpr wchar_t round_error() noexcept { return 0; } static constexpr int min_exponent = 0; static constexpr int min_exponent10 = 0; static constexpr int max_exponent = 0; static constexpr int max_exponent10 = 0; static constexpr bool has_infinity = false; static constexpr bool has_quiet_NaN = false; static constexpr bool has_signaling_NaN = false; static constexpr float_denorm_style has_denorm = denorm_absent; static constexpr bool has_denorm_loss = false; static constexpr wchar_t infinity() noexcept { return wchar_t(); } static constexpr wchar_t quiet_NaN() noexcept { return wchar_t(); } static constexpr wchar_t signaling_NaN() noexcept { return wchar_t(); } static constexpr wchar_t denorm_min() noexcept { return wchar_t(); } static constexpr bool is_iec559 = false; static constexpr bool is_bounded = true; static constexpr bool is_modulo = !is_signed; static constexpr bool traps = true; static constexpr bool tinyness_before = false; static constexpr float_round_style round_style = round_toward_zero; }; template<> struct numeric_limits<char16_t> { static constexpr bool is_specialized = true; static constexpr char16_t min() noexcept { return (((char16_t)(-1) < 0) ? -(((char16_t)(-1) < 0) ? (((((char16_t)1 << ((sizeof(char16_t) * 8 - ((char16_t)(-1) < 0)) - 1)) - 1) << 1) + 1) : ~(char16_t)0) - 1 : (char16_t)0); } static constexpr char16_t max() noexcept { return (((char16_t)(-1) < 0) ? (((((char16_t)1 << ((sizeof(char16_t) * 8 - ((char16_t)(-1) < 0)) - 1)) - 1) << 1) + 1) : ~(char16_t)0); } static constexpr char16_t lowest() noexcept { return min(); } static constexpr int digits = (sizeof(char16_t) * 8 - ((char16_t)(-1) < 0)); static constexpr int digits10 = ((sizeof(char16_t) * 8 - ((char16_t)(-1) < 0)) * 643L / 2136); static constexpr int max_digits10 = 0; static constexpr bool is_signed = ((char16_t)(-1) < 0); static constexpr bool is_integer = true; static constexpr bool is_exact = true; static constexpr int radix = 2; static constexpr char16_t epsilon() noexcept { return 0; } static constexpr char16_t round_error() noexcept { return 0; } static constexpr int min_exponent = 0; static constexpr int min_exponent10 = 0; static constexpr int max_exponent = 0; static constexpr int max_exponent10 = 0; static constexpr bool has_infinity = false; static constexpr bool has_quiet_NaN = false; static constexpr bool has_signaling_NaN = false; static constexpr float_denorm_style has_denorm = denorm_absent; static constexpr bool has_denorm_loss = false; static constexpr char16_t infinity() noexcept { return char16_t(); } static constexpr char16_t quiet_NaN() noexcept { return char16_t(); } static constexpr char16_t signaling_NaN() noexcept { return char16_t(); } static constexpr char16_t denorm_min() noexcept { return char16_t(); } static constexpr bool is_iec559 = false; static constexpr bool is_bounded = true; static constexpr bool is_modulo = !is_signed; static constexpr bool traps = true; static constexpr bool tinyness_before = false; static constexpr float_round_style round_style = round_toward_zero; }; template<> struct numeric_limits<char32_t> { static constexpr bool is_specialized = true; static constexpr char32_t min() noexcept { return (((char32_t)(-1) < 0) ? -(((char32_t)(-1) < 0) ? (((((char32_t)1 << ((sizeof(char32_t) * 8 - ((char32_t)(-1) < 0)) - 1)) - 1) << 1) + 1) : ~(char32_t)0) - 1 : (char32_t)0); } static constexpr char32_t max() noexcept { return (((char32_t)(-1) < 0) ? (((((char32_t)1 << ((sizeof(char32_t) * 8 - ((char32_t)(-1) < 0)) - 1)) - 1) << 1) + 1) : ~(char32_t)0); } static constexpr char32_t lowest() noexcept { return min(); } static constexpr int digits = (sizeof(char32_t) * 8 - ((char32_t)(-1) < 0)); static constexpr int digits10 = ((sizeof(char32_t) * 8 - ((char32_t)(-1) < 0)) * 643L / 2136); static constexpr int max_digits10 = 0; static constexpr bool is_signed = ((char32_t)(-1) < 0); static constexpr bool is_integer = true; static constexpr bool is_exact = true; static constexpr int radix = 2; static constexpr char32_t epsilon() noexcept { return 0; } static constexpr char32_t round_error() noexcept { return 0; } static constexpr int min_exponent = 0; static constexpr int min_exponent10 = 0; static constexpr int max_exponent = 0; static constexpr int max_exponent10 = 0; static constexpr bool has_infinity = false; static constexpr bool has_quiet_NaN = false; static constexpr bool has_signaling_NaN = false; static constexpr float_denorm_style has_denorm = denorm_absent; static constexpr bool has_denorm_loss = false; static constexpr char32_t infinity() noexcept { return char32_t(); } static constexpr char32_t quiet_NaN() noexcept { return char32_t(); } static constexpr char32_t signaling_NaN() noexcept { return char32_t(); } static constexpr char32_t denorm_min() noexcept { return char32_t(); } static constexpr bool is_iec559 = false; static constexpr bool is_bounded = true; static constexpr bool is_modulo = !is_signed; static constexpr bool traps = true; static constexpr bool tinyness_before = false; static constexpr float_round_style round_style = round_toward_zero; }; template<> struct numeric_limits<short> { static constexpr bool is_specialized = true; static constexpr short min() noexcept { return -0x7fff - 1; } static constexpr short max() noexcept { return 0x7fff; } static constexpr short lowest() noexcept { return min(); } static constexpr int digits = (sizeof(short) * 8 - ((short)(-1) < 0)); static constexpr int digits10 = ((sizeof(short) * 8 - ((short)(-1) < 0)) * 643L / 2136); static constexpr int max_digits10 = 0; static constexpr bool is_signed = true; static constexpr bool is_integer = true; static constexpr bool is_exact = true; static constexpr int radix = 2; static constexpr short epsilon() noexcept { return 0; } static constexpr short round_error() noexcept { return 0; } static constexpr int min_exponent = 0; static constexpr int min_exponent10 = 0; static constexpr int max_exponent = 0; static constexpr int max_exponent10 = 0; static constexpr bool has_infinity = false; static constexpr bool has_quiet_NaN = false; static constexpr bool has_signaling_NaN = false; static constexpr float_denorm_style has_denorm = denorm_absent; static constexpr bool has_denorm_loss = false; static constexpr short infinity() noexcept { return short(); } static constexpr short quiet_NaN() noexcept { return short(); } static constexpr short signaling_NaN() noexcept { return short(); } static constexpr short denorm_min() noexcept { return short(); } static constexpr bool is_iec559 = false; static constexpr bool is_bounded = true; static constexpr bool is_modulo = false; static constexpr bool traps = true; static constexpr bool tinyness_before = false; static constexpr float_round_style round_style = round_toward_zero; }; template<> struct numeric_limits<unsigned short> { static constexpr bool is_specialized = true; static constexpr unsigned short min() noexcept { return 0; } static constexpr unsigned short max() noexcept { return 0x7fff * 2U + 1; } static constexpr unsigned short lowest() noexcept { return min(); } static constexpr int digits = (sizeof(unsigned short) * 8 - ((unsigned short)(-1) < 0)); static constexpr int digits10 = ((sizeof(unsigned short) * 8 - ((unsigned short)(-1) < 0)) * 643L / 2136); static constexpr int max_digits10 = 0; static constexpr bool is_signed = false; static constexpr bool is_integer = true; static constexpr bool is_exact = true; static constexpr int radix = 2; static constexpr unsigned short epsilon() noexcept { return 0; } static constexpr unsigned short round_error() noexcept { return 0; } static constexpr int min_exponent = 0; static constexpr int min_exponent10 = 0; static constexpr int max_exponent = 0; static constexpr int max_exponent10 = 0; static constexpr bool has_infinity = false; static constexpr bool has_quiet_NaN = false; static constexpr bool has_signaling_NaN = false; static constexpr float_denorm_style has_denorm = denorm_absent; static constexpr bool has_denorm_loss = false; static constexpr unsigned short infinity() noexcept { return static_cast<unsigned short>(0); } static constexpr unsigned short quiet_NaN() noexcept { return static_cast<unsigned short>(0); } static constexpr unsigned short signaling_NaN() noexcept { return static_cast<unsigned short>(0); } static constexpr unsigned short denorm_min() noexcept { return static_cast<unsigned short>(0); } static constexpr bool is_iec559 = false; static constexpr bool is_bounded = true; static constexpr bool is_modulo = true; static constexpr bool traps = true; static constexpr bool tinyness_before = false; static constexpr float_round_style round_style = round_toward_zero; }; template<> struct numeric_limits<int> { static constexpr bool is_specialized = true; static constexpr int min() noexcept { return -0x7fffffff - 1; } static constexpr int max() noexcept { return 0x7fffffff; } static constexpr int lowest() noexcept { return min(); } static constexpr int digits = (sizeof(int) * 8 - ((int)(-1) < 0)); static constexpr int digits10 = ((sizeof(int) * 8 - ((int)(-1) < 0)) * 643L / 2136); static constexpr int max_digits10 = 0; static constexpr bool is_signed = true; static constexpr bool is_integer = true; static constexpr bool is_exact = true; static constexpr int radix = 2; static constexpr int epsilon() noexcept { return 0; } static constexpr int round_error() noexcept { return 0; } static constexpr int min_exponent = 0; static constexpr int min_exponent10 = 0; static constexpr int max_exponent = 0; static constexpr int max_exponent10 = 0; static constexpr bool has_infinity = false; static constexpr bool has_quiet_NaN = false; static constexpr bool has_signaling_NaN = false; static constexpr float_denorm_style has_denorm = denorm_absent; static constexpr bool has_denorm_loss = false; static constexpr int infinity() noexcept { return static_cast<int>(0); } static constexpr int quiet_NaN() noexcept { return static_cast<int>(0); } static constexpr int signaling_NaN() noexcept { return static_cast<int>(0); } static constexpr int denorm_min() noexcept { return static_cast<int>(0); } static constexpr bool is_iec559 = false; static constexpr bool is_bounded = true; static constexpr bool is_modulo = false; static constexpr bool traps = true; static constexpr bool tinyness_before = false; static constexpr float_round_style round_style = round_toward_zero; }; template<> struct numeric_limits<unsigned int> { static constexpr bool is_specialized = true; static constexpr unsigned int min() noexcept { return 0; } static constexpr unsigned int max() noexcept { return 0x7fffffff * 2U + 1; } static constexpr unsigned int lowest() noexcept { return min(); } static constexpr int digits = (sizeof(unsigned int) * 8 - ((unsigned int)(-1) < 0)); static constexpr int digits10 = ((sizeof(unsigned int) * 8 - ((unsigned int)(-1) < 0)) * 643L / 2136); static constexpr int max_digits10 = 0; static constexpr bool is_signed = false; static constexpr bool is_integer = true; static constexpr bool is_exact = true; static constexpr int radix = 2; static constexpr unsigned int epsilon() noexcept { return 0; } static constexpr unsigned int round_error() noexcept { return 0; } static constexpr int min_exponent = 0; static constexpr int min_exponent10 = 0; static constexpr int max_exponent = 0; static constexpr int max_exponent10 = 0; static constexpr bool has_infinity = false; static constexpr bool has_quiet_NaN = false; static constexpr bool has_signaling_NaN = false; static constexpr float_denorm_style has_denorm = denorm_absent; static constexpr bool has_denorm_loss = false; static constexpr unsigned int infinity() noexcept { return static_cast<unsigned int>(0); } static constexpr unsigned int quiet_NaN() noexcept { return static_cast<unsigned int>(0); } static constexpr unsigned int signaling_NaN() noexcept { return static_cast<unsigned int>(0); } static constexpr unsigned int denorm_min() noexcept { return static_cast<unsigned int>(0); } static constexpr bool is_iec559 = false; static constexpr bool is_bounded = true; static constexpr bool is_modulo = true; static constexpr bool traps = true; static constexpr bool tinyness_before = false; static constexpr float_round_style round_style = round_toward_zero; }; template<> struct numeric_limits<long> { static constexpr bool is_specialized = true; static constexpr long min() noexcept { return -0x7fffffffffffffffL - 1; } static constexpr long max() noexcept { return 0x7fffffffffffffffL; } static constexpr long lowest() noexcept { return min(); } static constexpr int digits = (sizeof(long) * 8 - ((long)(-1) < 0)); static constexpr int digits10 = ((sizeof(long) * 8 - ((long)(-1) < 0)) * 643L / 2136); static constexpr int max_digits10 = 0; static constexpr bool is_signed = true; static constexpr bool is_integer = true; static constexpr bool is_exact = true; static constexpr int radix = 2; static constexpr long epsilon() noexcept { return 0; } static constexpr long round_error() noexcept { return 0; } static constexpr int min_exponent = 0; static constexpr int min_exponent10 = 0; static constexpr int max_exponent = 0; static constexpr int max_exponent10 = 0; static constexpr bool has_infinity = false; static constexpr bool has_quiet_NaN = false; static constexpr bool has_signaling_NaN = false; static constexpr float_denorm_style has_denorm = denorm_absent; static constexpr bool has_denorm_loss = false; static constexpr long infinity() noexcept { return static_cast<long>(0); } static constexpr long quiet_NaN() noexcept { return static_cast<long>(0); } static constexpr long signaling_NaN() noexcept { return static_cast<long>(0); } static constexpr long denorm_min() noexcept { return static_cast<long>(0); } static constexpr bool is_iec559 = false; static constexpr bool is_bounded = true; static constexpr bool is_modulo = false; static constexpr bool traps = true; static constexpr bool tinyness_before = false; static constexpr float_round_style round_style = round_toward_zero; }; template<> struct numeric_limits<unsigned long> { static constexpr bool is_specialized = true; static constexpr unsigned long min() noexcept { return 0; } static constexpr unsigned long max() noexcept { return 0x7fffffffffffffffL * 2UL + 1; } static constexpr unsigned long lowest() noexcept { return min(); } static constexpr int digits = (sizeof(unsigned long) * 8 - ((unsigned long)(-1) < 0)); static constexpr int digits10 = ((sizeof(unsigned long) * 8 - ((unsigned long)(-1) < 0)) * 643L / 2136); static constexpr int max_digits10 = 0; static constexpr bool is_signed = false; static constexpr bool is_integer = true; static constexpr bool is_exact = true; static constexpr int radix = 2; static constexpr unsigned long epsilon() noexcept { return 0; } static constexpr unsigned long round_error() noexcept { return 0; } static constexpr int min_exponent = 0; static constexpr int min_exponent10 = 0; static constexpr int max_exponent = 0; static constexpr int max_exponent10 = 0; static constexpr bool has_infinity = false; static constexpr bool has_quiet_NaN = false; static constexpr bool has_signaling_NaN = false; static constexpr float_denorm_style has_denorm = denorm_absent; static constexpr bool has_denorm_loss = false; static constexpr unsigned long infinity() noexcept { return static_cast<unsigned long>(0); } static constexpr unsigned long quiet_NaN() noexcept { return static_cast<unsigned long>(0); } static constexpr unsigned long signaling_NaN() noexcept { return static_cast<unsigned long>(0); } static constexpr unsigned long denorm_min() noexcept { return static_cast<unsigned long>(0); } static constexpr bool is_iec559 = false; static constexpr bool is_bounded = true; static constexpr bool is_modulo = true; static constexpr bool traps = true; static constexpr bool tinyness_before = false; static constexpr float_round_style round_style = round_toward_zero; }; template<> struct numeric_limits<long long> { static constexpr bool is_specialized = true; static constexpr long long min() noexcept { return -0x7fffffffffffffffLL - 1; } static constexpr long long max() noexcept { return 0x7fffffffffffffffLL; } static constexpr long long lowest() noexcept { return min(); } static constexpr int digits = (sizeof(long long) * 8 - ((long long)(-1) < 0)); static constexpr int digits10 = ((sizeof(long long) * 8 - ((long long)(-1) < 0)) * 643L / 2136); static constexpr int max_digits10 = 0; static constexpr bool is_signed = true; static constexpr bool is_integer = true; static constexpr bool is_exact = true; static constexpr int radix = 2; static constexpr long long epsilon() noexcept { return 0; } static constexpr long long round_error() noexcept { return 0; } static constexpr int min_exponent = 0; static constexpr int min_exponent10 = 0; static constexpr int max_exponent = 0; static constexpr int max_exponent10 = 0; static constexpr bool has_infinity = false; static constexpr bool has_quiet_NaN = false; static constexpr bool has_signaling_NaN = false; static constexpr float_denorm_style has_denorm = denorm_absent; static constexpr bool has_denorm_loss = false; static constexpr long long infinity() noexcept { return static_cast<long long>(0); } static constexpr long long quiet_NaN() noexcept { return static_cast<long long>(0); } static constexpr long long signaling_NaN() noexcept { return static_cast<long long>(0); } static constexpr long long denorm_min() noexcept { return static_cast<long long>(0); } static constexpr bool is_iec559 = false; static constexpr bool is_bounded = true; static constexpr bool is_modulo = false; static constexpr bool traps = true; static constexpr bool tinyness_before = false; static constexpr float_round_style round_style = round_toward_zero; }; template<> struct numeric_limits<unsigned long long> { static constexpr bool is_specialized = true; static constexpr unsigned long long min() noexcept { return 0; } static constexpr unsigned long long max() noexcept { return 0x7fffffffffffffffLL * 2ULL + 1; } static constexpr unsigned long long lowest() noexcept { return min(); } static constexpr int digits = (sizeof(unsigned long long) * 8 - ((unsigned long long)(-1) < 0)); static constexpr int digits10 = ((sizeof(unsigned long long) * 8 - ((unsigned long long)(-1) < 0)) * 643L / 2136); static constexpr int max_digits10 = 0; static constexpr bool is_signed = false; static constexpr bool is_integer = true; static constexpr bool is_exact = true; static constexpr int radix = 2; static constexpr unsigned long long epsilon() noexcept { return 0; } static constexpr unsigned long long round_error() noexcept { return 0; } static constexpr int min_exponent = 0; static constexpr int min_exponent10 = 0; static constexpr int max_exponent = 0; static constexpr int max_exponent10 = 0; static constexpr bool has_infinity = false; static constexpr bool has_quiet_NaN = false; static constexpr bool has_signaling_NaN = false; static constexpr float_denorm_style has_denorm = denorm_absent; static constexpr bool has_denorm_loss = false; static constexpr unsigned long long infinity() noexcept { return static_cast<unsigned long long>(0); } static constexpr unsigned long long quiet_NaN() noexcept { return static_cast<unsigned long long>(0); } static constexpr unsigned long long signaling_NaN() noexcept { return static_cast<unsigned long long>(0); } static constexpr unsigned long long denorm_min() noexcept { return static_cast<unsigned long long>(0); } static constexpr bool is_iec559 = false; static constexpr bool is_bounded = true; static constexpr bool is_modulo = true; static constexpr bool traps = true; static constexpr bool tinyness_before = false; static constexpr float_round_style round_style = round_toward_zero; }; template<> struct numeric_limits<__int128> { static constexpr bool is_specialized = true; static constexpr __int128 min() noexcept { return (((__int128)(-1) < 0) ? -(((__int128)(-1) < 0) ? (((((__int128)1 << ((128 - ((__int128)(-1) < 0)) - 1)) - 1) << 1) + 1) : ~(__int128)0) - 1 : (__int128)0); } static constexpr __int128 max() noexcept { return (((__int128)(-1) < 0) ? (((((__int128)1 << ((128 - ((__int128)(-1) < 0)) - 1)) - 1) << 1) + 1) : ~(__int128)0); } static constexpr int digits = 128 - 1; static constexpr int digits10 = (128 - 1) * 643L / 2136; static constexpr bool is_signed = true; static constexpr bool is_integer = true; static constexpr bool is_exact = true; static constexpr int radix = 2; static constexpr __int128 epsilon() noexcept { return 0; } static constexpr __int128 round_error() noexcept { return 0; } static constexpr __int128 lowest() noexcept { return min(); } static constexpr int max_digits10 = 0; static constexpr int min_exponent = 0; static constexpr int min_exponent10 = 0; static constexpr int max_exponent = 0; static constexpr int max_exponent10 = 0; static constexpr bool has_infinity = false; static constexpr bool has_quiet_NaN = false; static constexpr bool has_signaling_NaN = false; static constexpr float_denorm_style has_denorm = denorm_absent; static constexpr bool has_denorm_loss = false; static constexpr __int128 infinity() noexcept { return static_cast<__int128>(0); } static constexpr __int128 quiet_NaN() noexcept { return static_cast<__int128>(0); } static constexpr __int128 signaling_NaN() noexcept { return static_cast<__int128>(0); } static constexpr __int128 denorm_min() noexcept { return static_cast<__int128>(0); } static constexpr bool is_iec559 = false; static constexpr bool is_bounded = true; static constexpr bool is_modulo = false; static constexpr bool traps = true; static constexpr bool tinyness_before = false; static constexpr float_round_style round_style = round_toward_zero; }; template<> struct numeric_limits<unsigned __int128> { static constexpr bool is_specialized = true; static constexpr unsigned __int128 min() noexcept { return 0; } static constexpr unsigned __int128 max() noexcept { return (((unsigned __int128)(-1) < 0) ? (((((unsigned __int128)1 << ((128 - ((unsigned __int128)(-1) < 0)) - 1)) - 1) << 1) + 1) : ~(unsigned __int128)0); } static constexpr unsigned __int128 lowest() noexcept { return min(); } static constexpr int max_digits10 = 0; static constexpr int digits = 128; static constexpr int digits10 = 128 * 643L / 2136; static constexpr bool is_signed = false; static constexpr bool is_integer = true; static constexpr bool is_exact = true; static constexpr int radix = 2; static constexpr unsigned __int128 epsilon() noexcept { return 0; } static constexpr unsigned __int128 round_error() noexcept { return 0; } static constexpr int min_exponent = 0; static constexpr int min_exponent10 = 0; static constexpr int max_exponent = 0; static constexpr int max_exponent10 = 0; static constexpr bool has_infinity = false; static constexpr bool has_quiet_NaN = false; static constexpr bool has_signaling_NaN = false; static constexpr float_denorm_style has_denorm = denorm_absent; static constexpr bool has_denorm_loss = false; static constexpr unsigned __int128 infinity() noexcept { return static_cast<unsigned __int128>(0); } static constexpr unsigned __int128 quiet_NaN() noexcept { return static_cast<unsigned __int128>(0); } static constexpr unsigned __int128 signaling_NaN() noexcept { return static_cast<unsigned __int128>(0); } static constexpr unsigned __int128 denorm_min() noexcept { return static_cast<unsigned __int128>(0); } static constexpr bool is_iec559 = false; static constexpr bool is_bounded = true; static constexpr bool is_modulo = true; static constexpr bool traps = true; static constexpr bool tinyness_before = false; static constexpr float_round_style round_style = round_toward_zero; }; template<> struct numeric_limits<float> { static constexpr bool is_specialized = true; static constexpr float min() noexcept { return 1.17549435082228750796873653722224568e-38F; } static constexpr float max() noexcept { return 3.40282346638528859811704183484516925e+38F; } static constexpr float lowest() noexcept { return -3.40282346638528859811704183484516925e+38F; } static constexpr int digits = 24; static constexpr int digits10 = 6; static constexpr int max_digits10 = (2 + (24) * 643L / 2136); static constexpr bool is_signed = true; static constexpr bool is_integer = false; static constexpr bool is_exact = false; static constexpr int radix = 2; static constexpr float epsilon() noexcept { return 1.19209289550781250000000000000000000e-7F; } static constexpr float round_error() noexcept { return 0.5F; } static constexpr int min_exponent = (-125); static constexpr int min_exponent10 = (-37); static constexpr int max_exponent = 128; static constexpr int max_exponent10 = 38; static constexpr bool has_infinity = 1; static constexpr bool has_quiet_NaN = 1; static constexpr bool has_signaling_NaN = has_quiet_NaN; static constexpr float_denorm_style has_denorm = bool(1) ? denorm_present : denorm_absent; static constexpr bool has_denorm_loss = false; static constexpr float infinity() noexcept { return __builtin_huge_valf(); } static constexpr float quiet_NaN() noexcept { return __builtin_nanf(""); } static constexpr float signaling_NaN() noexcept { return __builtin_nansf(""); } static constexpr float denorm_min() noexcept { return 1.40129846432481707092372958328991613e-45F; } static constexpr bool is_iec559 = has_infinity && has_quiet_NaN && has_denorm == denorm_present; static constexpr bool is_bounded = true; static constexpr bool is_modulo = false; static constexpr bool traps = false; static constexpr bool tinyness_before = false; static constexpr float_round_style round_style = round_to_nearest; }; template<> struct numeric_limits<double> { static constexpr bool is_specialized = true; static constexpr double min() noexcept { return double(2.22507385850720138309023271733240406e-308L); } static constexpr double max() noexcept { return double(1.79769313486231570814527423731704357e+308L); } static constexpr double lowest() noexcept { return -double(1.79769313486231570814527423731704357e+308L); } static constexpr int digits = 53; static constexpr int digits10 = 15; static constexpr int max_digits10 = (2 + (53) * 643L / 2136); static constexpr bool is_signed = true; static constexpr bool is_integer = false; static constexpr bool is_exact = false; static constexpr int radix = 2; static constexpr double epsilon() noexcept { return double(2.22044604925031308084726333618164062e-16L); } static constexpr double round_error() noexcept { return 0.5; } static constexpr int min_exponent = (-1021); static constexpr int min_exponent10 = (-307); static constexpr int max_exponent = 1024; static constexpr int max_exponent10 = 308; static constexpr bool has_infinity = 1; static constexpr bool has_quiet_NaN = 1; static constexpr bool has_signaling_NaN = has_quiet_NaN; static constexpr float_denorm_style has_denorm = bool(1) ? denorm_present : denorm_absent; static constexpr bool has_denorm_loss = false; static constexpr double infinity() noexcept { return __builtin_huge_val(); } static constexpr double quiet_NaN() noexcept { return __builtin_nan(""); } static constexpr double signaling_NaN() noexcept { return __builtin_nans(""); } static constexpr double denorm_min() noexcept { return double(4.94065645841246544176568792868221372e-324L); } static constexpr bool is_iec559 = has_infinity && has_quiet_NaN && has_denorm == denorm_present; static constexpr bool is_bounded = true; static constexpr bool is_modulo = false; static constexpr bool traps = false; static constexpr bool tinyness_before = false; static constexpr float_round_style round_style = round_to_nearest; }; template<> struct numeric_limits<long double> { static constexpr bool is_specialized = true; static constexpr long double min() noexcept { return 3.36210314311209350626267781732175260e-4932L; } static constexpr long double max() noexcept { return 1.18973149535723176502126385303097021e+4932L; } static constexpr long double lowest() noexcept { return -1.18973149535723176502126385303097021e+4932L; } static constexpr int digits = 64; static constexpr int digits10 = 18; static constexpr int max_digits10 = (2 + (64) * 643L / 2136); static constexpr bool is_signed = true; static constexpr bool is_integer = false; static constexpr bool is_exact = false; static constexpr int radix = 2; static constexpr long double epsilon() noexcept { return 1.08420217248550443400745280086994171e-19L; } static constexpr long double round_error() noexcept { return 0.5L; } static constexpr int min_exponent = (-16381); static constexpr int min_exponent10 = (-4931); static constexpr int max_exponent = 16384; static constexpr int max_exponent10 = 4932; static constexpr bool has_infinity = 1; static constexpr bool has_quiet_NaN = 1; static constexpr bool has_signaling_NaN = has_quiet_NaN; static constexpr float_denorm_style has_denorm = bool(1) ? denorm_present : denorm_absent; static constexpr bool has_denorm_loss = false; static constexpr long double infinity() noexcept { return __builtin_huge_vall(); } static constexpr long double quiet_NaN() noexcept { return __builtin_nanl(""); } static constexpr long double signaling_NaN() noexcept { return __builtin_nansl(""); } static constexpr long double denorm_min() noexcept { return 3.64519953188247460252840593361941982e-4951L; } static constexpr bool is_iec559 = has_infinity && has_quiet_NaN && has_denorm == denorm_present; static constexpr bool is_bounded = true; static constexpr bool is_modulo = false; static constexpr bool traps = false; static constexpr bool tinyness_before = false; static constexpr float_round_style round_style = round_to_nearest; }; } namespace std __attribute__ ((__visibility__ ("default"))) { namespace __detail { template<typename _Tp> inline bool _Power_of_2(_Tp __x) { return ((__x - 1) & __x) == 0; } } template<typename _IntType = int> class uniform_int_distribution { static_assert(std::is_integral<_IntType>::value, "template argument must be an integral type"); public: typedef _IntType result_type; struct param_type { typedef uniform_int_distribution<_IntType> distribution_type; param_type() : param_type(0) { } explicit param_type(_IntType __a, _IntType __b = numeric_limits<_IntType>::max()) : _M_a(__a), _M_b(__b) { ; } result_type a() const { return _M_a; } result_type b() const { return _M_b; } friend bool operator==(const param_type& __p1, const param_type& __p2) { return __p1._M_a == __p2._M_a && __p1._M_b == __p2._M_b; } friend bool operator!=(const param_type& __p1, const param_type& __p2) { return !(__p1 == __p2); } private: _IntType _M_a; _IntType _M_b; }; public: uniform_int_distribution() : uniform_int_distribution(0) { } explicit uniform_int_distribution(_IntType __a, _IntType __b = numeric_limits<_IntType>::max()) : _M_param(__a, __b) { } explicit uniform_int_distribution(const param_type& __p) : _M_param(__p) { } void reset() { } result_type a() const { return _M_param.a(); } result_type b() const { return _M_param.b(); } param_type param() const { return _M_param; } void param(const param_type& __param) { _M_param = __param; } result_type min() const { return this->a(); } result_type max() const { return this->b(); } template<typename _UniformRandomNumberGenerator> result_type operator()(_UniformRandomNumberGenerator& __urng) { return this->operator()(__urng, _M_param); } template<typename _UniformRandomNumberGenerator> result_type operator()(_UniformRandomNumberGenerator& __urng, const param_type& __p); template<typename _ForwardIterator, typename _UniformRandomNumberGenerator> void __generate(_ForwardIterator __f, _ForwardIterator __t, _UniformRandomNumberGenerator& __urng) { this->__generate(__f, __t, __urng, _M_param); } template<typename _ForwardIterator, typename _UniformRandomNumberGenerator> void __generate(_ForwardIterator __f, _ForwardIterator __t, _UniformRandomNumberGenerator& __urng, const param_type& __p) { this->__generate_impl(__f, __t, __urng, __p); } template<typename _UniformRandomNumberGenerator> void __generate(result_type* __f, result_type* __t, _UniformRandomNumberGenerator& __urng, const param_type& __p) { this->__generate_impl(__f, __t, __urng, __p); } friend bool operator==(const uniform_int_distribution& __d1, const uniform_int_distribution& __d2) { return __d1._M_param == __d2._M_param; } private: template<typename _ForwardIterator, typename _UniformRandomNumberGenerator> void __generate_impl(_ForwardIterator __f, _ForwardIterator __t, _UniformRandomNumberGenerator& __urng, const param_type& __p); param_type _M_param; }; template<typename _IntType> template<typename _UniformRandomNumberGenerator> typename uniform_int_distribution<_IntType>::result_type uniform_int_distribution<_IntType>:: operator()(_UniformRandomNumberGenerator& __urng, const param_type& __param) { typedef typename _UniformRandomNumberGenerator::result_type _Gresult_type; typedef typename std::make_unsigned<result_type>::type __utype; typedef typename std::common_type<_Gresult_type, __utype>::type __uctype; const __uctype __urngmin = __urng.min(); const __uctype __urngmax = __urng.max(); const __uctype __urngrange = __urngmax - __urngmin; const __uctype __urange = __uctype(__param.b()) - __uctype(__param.a()); __uctype __ret; if (__urngrange > __urange) { const __uctype __uerange = __urange + 1; const __uctype __scaling = __urngrange / __uerange; const __uctype __past = __uerange * __scaling; do __ret = __uctype(__urng()) - __urngmin; while (__ret >= __past); __ret /= __scaling; } else if (__urngrange < __urange) { __uctype __tmp; do { const __uctype __uerngrange = __urngrange + 1; __tmp = (__uerngrange * operator() (__urng, param_type(0, __urange / __uerngrange))); __ret = __tmp + (__uctype(__urng()) - __urngmin); } while (__ret > __urange || __ret < __tmp); } else __ret = __uctype(__urng()) - __urngmin; return __ret + __param.a(); } template<typename _IntType> template<typename _ForwardIterator, typename _UniformRandomNumberGenerator> void uniform_int_distribution<_IntType>:: __generate_impl(_ForwardIterator __f, _ForwardIterator __t, _UniformRandomNumberGenerator& __urng, const param_type& __param) { typedef typename _UniformRandomNumberGenerator::result_type _Gresult_type; typedef typename std::make_unsigned<result_type>::type __utype; typedef typename std::common_type<_Gresult_type, __utype>::type __uctype; const __uctype __urngmin = __urng.min(); const __uctype __urngmax = __urng.max(); const __uctype __urngrange = __urngmax - __urngmin; const __uctype __urange = __uctype(__param.b()) - __uctype(__param.a()); __uctype __ret; if (__urngrange > __urange) { if (__detail::_Power_of_2(__urngrange + 1) && __detail::_Power_of_2(__urange + 1)) { while (__f != __t) { __ret = __uctype(__urng()) - __urngmin; *__f++ = (__ret & __urange) + __param.a(); } } else { const __uctype __uerange = __urange + 1; const __uctype __scaling = __urngrange / __uerange; const __uctype __past = __uerange * __scaling; while (__f != __t) { do __ret = __uctype(__urng()) - __urngmin; while (__ret >= __past); *__f++ = __ret / __scaling + __param.a(); } } } else if (__urngrange < __urange) { __uctype __tmp; while (__f != __t) { do { const __uctype __uerngrange = __urngrange + 1; __tmp = (__uerngrange * operator() (__urng, param_type(0, __urange / __uerngrange))); __ret = __tmp + (__uctype(__urng()) - __urngmin); } while (__ret > __urange || __ret < __tmp); *__f++ = __ret; } } else while (__f != __t) *__f++ = __uctype(__urng()) - __urngmin + __param.a(); } } namespace std __attribute__ ((__visibility__ ("default"))) { template<typename _Iterator, typename _Compare> void __move_median_to_first(_Iterator __result,_Iterator __a, _Iterator __b, _Iterator __c, _Compare __comp) { if (__comp(__a, __b)) { if (__comp(__b, __c)) std::iter_swap(__result, __b); else if (__comp(__a, __c)) std::iter_swap(__result, __c); else std::iter_swap(__result, __a); } else if (__comp(__a, __c)) std::iter_swap(__result, __a); else if (__comp(__b, __c)) std::iter_swap(__result, __c); else std::iter_swap(__result, __b); } template<typename _InputIterator, typename _Predicate> inline _InputIterator __find_if_not(_InputIterator __first, _InputIterator __last, _Predicate __pred) { return std::__find_if(__first, __last, __gnu_cxx::__ops::__negate(__pred), std::__iterator_category(__first)); } template<typename _InputIterator, typename _Predicate, typename _Distance> _InputIterator __find_if_not_n(_InputIterator __first, _Distance& __len, _Predicate __pred) { for (; __len; --__len, (void) ++__first) if (!__pred(__first)) break; return __first; } template<typename _ForwardIterator1, typename _ForwardIterator2, typename _BinaryPredicate> _ForwardIterator1 __search(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2, _BinaryPredicate __predicate) { if (__first1 == __last1 || __first2 == __last2) return __first1; _ForwardIterator2 __p1(__first2); if (++__p1 == __last2) return std::__find_if(__first1, __last1, __gnu_cxx::__ops::__iter_comp_iter(__predicate, __first2)); _ForwardIterator1 __current = __first1; for (;;) { __first1 = std::__find_if(__first1, __last1, __gnu_cxx::__ops::__iter_comp_iter(__predicate, __first2)); if (__first1 == __last1) return __last1; _ForwardIterator2 __p = __p1; __current = __first1; if (++__current == __last1) return __last1; while (__predicate(__current, __p)) { if (++__p == __last2) return __first1; if (++__current == __last1) return __last1; } ++__first1; } return __first1; } template<typename _ForwardIterator, typename _Integer, typename _UnaryPredicate> _ForwardIterator __search_n_aux(_ForwardIterator __first, _ForwardIterator __last, _Integer __count, _UnaryPredicate __unary_pred, std::forward_iterator_tag) { __first = std::__find_if(__first, __last, __unary_pred); while (__first != __last) { typename iterator_traits<_ForwardIterator>::difference_type __n = __count; _ForwardIterator __i = __first; ++__i; while (__i != __last && __n != 1 && __unary_pred(__i)) { ++__i; --__n; } if (__n == 1) return __first; if (__i == __last) return __last; __first = std::__find_if(++__i, __last, __unary_pred); } return __last; } template<typename _RandomAccessIter, typename _Integer, typename _UnaryPredicate> _RandomAccessIter __search_n_aux(_RandomAccessIter __first, _RandomAccessIter __last, _Integer __count, _UnaryPredicate __unary_pred, std::random_access_iterator_tag) { typedef typename std::iterator_traits<_RandomAccessIter>::difference_type _DistanceType; _DistanceType __tailSize = __last - __first; _DistanceType __remainder = __count; while (__remainder <= __tailSize) { __first += __remainder; __tailSize -= __remainder; _RandomAccessIter __backTrack = __first; while (__unary_pred(--__backTrack)) { if (--__remainder == 0) return (__first - __count); } __remainder = __count + 1 - (__first - __backTrack); } return __last; } template<typename _ForwardIterator, typename _Integer, typename _UnaryPredicate> _ForwardIterator __search_n(_ForwardIterator __first, _ForwardIterator __last, _Integer __count, _UnaryPredicate __unary_pred) { if (__count <= 0) return __first; if (__count == 1) return std::__find_if(__first, __last, __unary_pred); return std::__search_n_aux(__first, __last, __count, __unary_pred, std::__iterator_category(__first)); } template<typename _ForwardIterator1, typename _ForwardIterator2, typename _BinaryPredicate> _ForwardIterator1 __find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2, forward_iterator_tag, forward_iterator_tag, _BinaryPredicate __comp) { if (__first2 == __last2) return __last1; _ForwardIterator1 __result = __last1; while (1) { _ForwardIterator1 __new_result = std::__search(__first1, __last1, __first2, __last2, __comp); if (__new_result == __last1) return __result; else { __result = __new_result; __first1 = __new_result; ++__first1; } } } template<typename _BidirectionalIterator1, typename _BidirectionalIterator2, typename _BinaryPredicate> _BidirectionalIterator1 __find_end(_BidirectionalIterator1 __first1, _BidirectionalIterator1 __last1, _BidirectionalIterator2 __first2, _BidirectionalIterator2 __last2, bidirectional_iterator_tag, bidirectional_iterator_tag, _BinaryPredicate __comp) { typedef reverse_iterator<_BidirectionalIterator1> _RevIterator1; typedef reverse_iterator<_BidirectionalIterator2> _RevIterator2; _RevIterator1 __rlast1(__first1); _RevIterator2 __rlast2(__first2); _RevIterator1 __rresult = std::__search(_RevIterator1(__last1), __rlast1, _RevIterator2(__last2), __rlast2, __comp); if (__rresult == __rlast1) return __last1; else { _BidirectionalIterator1 __result = __rresult.base(); std::advance(__result, -std::distance(__first2, __last2)); return __result; } } template<typename _ForwardIterator1, typename _ForwardIterator2> inline _ForwardIterator1 find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) { ; ; return std::__find_end(__first1, __last1, __first2, __last2, std::__iterator_category(__first1), std::__iterator_category(__first2), __gnu_cxx::__ops::__iter_equal_to_iter()); } template<typename _ForwardIterator1, typename _ForwardIterator2, typename _BinaryPredicate> inline _ForwardIterator1 find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2, _BinaryPredicate __comp) { ; ; return std::__find_end(__first1, __last1, __first2, __last2, std::__iterator_category(__first1), std::__iterator_category(__first2), __gnu_cxx::__ops::__iter_comp_iter(__comp)); } template<typename _InputIterator, typename _Predicate> inline bool all_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) { return __last == std::find_if_not(__first, __last, __pred); } template<typename _InputIterator, typename _Predicate> inline bool none_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) { return __last == std::find_if(__first, __last, __pred); } template<typename _InputIterator, typename _Predicate> inline bool any_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) { return !std::none_of(__first, __last, __pred); } template<typename _InputIterator, typename _Predicate> inline _InputIterator find_if_not(_InputIterator __first, _InputIterator __last, _Predicate __pred) { ; return std::__find_if_not(__first, __last, __gnu_cxx::__ops::__pred_iter(__pred)); } template<typename _InputIterator, typename _Predicate> inline bool is_partitioned(_InputIterator __first, _InputIterator __last, _Predicate __pred) { __first = std::find_if_not(__first, __last, __pred); if (__first == __last) return true; ++__first; return std::none_of(__first, __last, __pred); } template<typename _ForwardIterator, typename _Predicate> _ForwardIterator partition_point(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) { ; typedef typename iterator_traits<_ForwardIterator>::difference_type _DistanceType; _DistanceType __len = std::distance(__first, __last); while (__len > 0) { _DistanceType __half = __len >> 1; _ForwardIterator __middle = __first; std::advance(__middle, __half); if (__pred(*__middle)) { __first = __middle; ++__first; __len = __len - __half - 1; } else __len = __half; } return __first; } template<typename _InputIterator, typename _OutputIterator, typename _Predicate> _OutputIterator __remove_copy_if(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _Predicate __pred) { for (; __first != __last; ++__first) if (!__pred(__first)) { *__result = *__first; ++__result; } return __result; } template<typename _InputIterator, typename _OutputIterator, typename _Tp> inline _OutputIterator remove_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, const _Tp& __value) { ; return std::__remove_copy_if(__first, __last, __result, __gnu_cxx::__ops::__iter_equals_val(__value)); } template<typename _InputIterator, typename _OutputIterator, typename _Predicate> inline _OutputIterator remove_copy_if(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _Predicate __pred) { ; return std::__remove_copy_if(__first, __last, __result, __gnu_cxx::__ops::__pred_iter(__pred)); } template<typename _InputIterator, typename _OutputIterator, typename _Predicate> _OutputIterator copy_if(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _Predicate __pred) { ; for (; __first != __last; ++__first) if (__pred(*__first)) { *__result = *__first; ++__result; } return __result; } template<typename _InputIterator, typename _Size, typename _OutputIterator> _OutputIterator __copy_n_a(_InputIterator __first, _Size __n, _OutputIterator __result) { if (__n > 0) { while (true) { *__result = *__first; ++__result; if (--__n > 0) ++__first; else break; } } return __result; } template<typename _CharT, typename _Size> __enable_if_t<__is_char<_CharT>::__value, _CharT*> __copy_n_a(istreambuf_iterator<_CharT, char_traits<_CharT>>, _Size, _CharT*); template<typename _InputIterator, typename _Size, typename _OutputIterator> _OutputIterator __copy_n(_InputIterator __first, _Size __n, _OutputIterator __result, input_iterator_tag) { return std::__niter_wrap(__result, __copy_n_a(__first, __n, std::__niter_base(__result))); } template<typename _RandomAccessIterator, typename _Size, typename _OutputIterator> inline _OutputIterator __copy_n(_RandomAccessIterator __first, _Size __n, _OutputIterator __result, random_access_iterator_tag) { return std::copy(__first, __first + __n, __result); } template<typename _InputIterator, typename _Size, typename _OutputIterator> inline _OutputIterator copy_n(_InputIterator __first, _Size __n, _OutputIterator __result) { ; ; return std::__copy_n(__first, __n, __result, std::__iterator_category(__first)); } template<typename _InputIterator, typename _OutputIterator1, typename _OutputIterator2, typename _Predicate> pair<_OutputIterator1, _OutputIterator2> partition_copy(_InputIterator __first, _InputIterator __last, _OutputIterator1 __out_true, _OutputIterator2 __out_false, _Predicate __pred) { ; for (; __first != __last; ++__first) if (__pred(*__first)) { *__out_true = *__first; ++__out_true; } else { *__out_false = *__first; ++__out_false; } return pair<_OutputIterator1, _OutputIterator2>(__out_true, __out_false); } template<typename _ForwardIterator, typename _Predicate> _ForwardIterator __remove_if(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) { __first = std::__find_if(__first, __last, __pred); if (__first == __last) return __first; _ForwardIterator __result = __first; ++__first; for (; __first != __last; ++__first) if (!__pred(__first)) { *__result = std::move(*__first); ++__result; } return __result; } template<typename _ForwardIterator, typename _Tp> inline _ForwardIterator remove(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) { ; return std::__remove_if(__first, __last, __gnu_cxx::__ops::__iter_equals_val(__value)); } template<typename _ForwardIterator, typename _Predicate> inline _ForwardIterator remove_if(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) { ; return std::__remove_if(__first, __last, __gnu_cxx::__ops::__pred_iter(__pred)); } template<typename _ForwardIterator, typename _BinaryPredicate> _ForwardIterator __adjacent_find(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __binary_pred) { if (__first == __last) return __last; _ForwardIterator __next = __first; while (++__next != __last) { if (__binary_pred(__first, __next)) return __first; __first = __next; } return __last; } template<typename _ForwardIterator, typename _BinaryPredicate> _ForwardIterator __unique(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __binary_pred) { __first = std::__adjacent_find(__first, __last, __binary_pred); if (__first == __last) return __last; _ForwardIterator __dest = __first; ++__first; while (++__first != __last) if (!__binary_pred(__dest, __first)) *++__dest = std::move(*__first); return ++__dest; } template<typename _ForwardIterator> inline _ForwardIterator unique(_ForwardIterator __first, _ForwardIterator __last) { ; return std::__unique(__first, __last, __gnu_cxx::__ops::__iter_equal_to_iter()); } template<typename _ForwardIterator, typename _BinaryPredicate> inline _ForwardIterator unique(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __binary_pred) { ; return std::__unique(__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__binary_pred)); } template<typename _ForwardIterator, typename _OutputIterator, typename _BinaryPredicate> _OutputIterator __unique_copy(_ForwardIterator __first, _ForwardIterator __last, _OutputIterator __result, _BinaryPredicate __binary_pred, forward_iterator_tag, output_iterator_tag) { _ForwardIterator __next = __first; *__result = *__first; while (++__next != __last) if (!__binary_pred(__first, __next)) { __first = __next; *++__result = *__first; } return ++__result; } template<typename _InputIterator, typename _OutputIterator, typename _BinaryPredicate> _OutputIterator __unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryPredicate __binary_pred, input_iterator_tag, output_iterator_tag) { typename iterator_traits<_InputIterator>::value_type __value = *__first; __decltype(__gnu_cxx::__ops::__iter_comp_val(__binary_pred)) __rebound_pred = __gnu_cxx::__ops::__iter_comp_val(__binary_pred); *__result = __value; while (++__first != __last) if (!__rebound_pred(__first, __value)) { __value = *__first; *++__result = __value; } return ++__result; } template<typename _InputIterator, typename _ForwardIterator, typename _BinaryPredicate> _ForwardIterator __unique_copy(_InputIterator __first, _InputIterator __last, _ForwardIterator __result, _BinaryPredicate __binary_pred, input_iterator_tag, forward_iterator_tag) { *__result = *__first; while (++__first != __last) if (!__binary_pred(__result, __first)) *++__result = *__first; return ++__result; } template<typename _BidirectionalIterator> void __reverse(_BidirectionalIterator __first, _BidirectionalIterator __last, bidirectional_iterator_tag) { while (true) if (__first == __last || __first == --__last) return; else { std::iter_swap(__first, __last); ++__first; } } template<typename _RandomAccessIterator> void __reverse(_RandomAccessIterator __first, _RandomAccessIterator __last, random_access_iterator_tag) { if (__first == __last) return; --__last; while (__first < __last) { std::iter_swap(__first, __last); ++__first; --__last; } } template<typename _BidirectionalIterator> inline void reverse(_BidirectionalIterator __first, _BidirectionalIterator __last) { ; std::__reverse(__first, __last, std::__iterator_category(__first)); } template<typename _BidirectionalIterator, typename _OutputIterator> _OutputIterator reverse_copy(_BidirectionalIterator __first, _BidirectionalIterator __last, _OutputIterator __result) { ; while (__first != __last) { --__last; *__result = *__last; ++__result; } return __result; } template<typename _EuclideanRingElement> _EuclideanRingElement __gcd(_EuclideanRingElement __m, _EuclideanRingElement __n) { while (__n != 0) { _EuclideanRingElement __t = __m % __n; __m = __n; __n = __t; } return __m; } inline namespace _V2 { template<typename _ForwardIterator> _ForwardIterator __rotate(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last, forward_iterator_tag) { if (__first == __middle) return __last; else if (__last == __middle) return __first; _ForwardIterator __first2 = __middle; do { std::iter_swap(__first, __first2); ++__first; ++__first2; if (__first == __middle) __middle = __first2; } while (__first2 != __last); _ForwardIterator __ret = __first; __first2 = __middle; while (__first2 != __last) { std::iter_swap(__first, __first2); ++__first; ++__first2; if (__first == __middle) __middle = __first2; else if (__first2 == __last) __first2 = __middle; } return __ret; } template<typename _BidirectionalIterator> _BidirectionalIterator __rotate(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last, bidirectional_iterator_tag) { if (__first == __middle) return __last; else if (__last == __middle) return __first; std::__reverse(__first, __middle, bidirectional_iterator_tag()); std::__reverse(__middle, __last, bidirectional_iterator_tag()); while (__first != __middle && __middle != __last) { std::iter_swap(__first, --__last); ++__first; } if (__first == __middle) { std::__reverse(__middle, __last, bidirectional_iterator_tag()); return __last; } else { std::__reverse(__first, __middle, bidirectional_iterator_tag()); return __first; } } template<typename _RandomAccessIterator> _RandomAccessIterator __rotate(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last, random_access_iterator_tag) { if (__first == __middle) return __last; else if (__last == __middle) return __first; typedef typename iterator_traits<_RandomAccessIterator>::difference_type _Distance; typedef typename iterator_traits<_RandomAccessIterator>::value_type _ValueType; _Distance __n = __last - __first; _Distance __k = __middle - __first; if (__k == __n - __k) { std::swap_ranges(__first, __middle, __middle); return __middle; } _RandomAccessIterator __p = __first; _RandomAccessIterator __ret = __first + (__last - __middle); for (;;) { if (__k < __n - __k) { if (__is_pod(_ValueType) && __k == 1) { _ValueType __t = std::move(*__p); std::move(__p + 1, __p + __n, __p); *(__p + __n - 1) = std::move(__t); return __ret; } _RandomAccessIterator __q = __p + __k; for (_Distance __i = 0; __i < __n - __k; ++ __i) { std::iter_swap(__p, __q); ++__p; ++__q; } __n %= __k; if (__n == 0) return __ret; std::swap(__n, __k); __k = __n - __k; } else { __k = __n - __k; if (__is_pod(_ValueType) && __k == 1) { _ValueType __t = std::move(*(__p + __n - 1)); std::move_backward(__p, __p + __n - 1, __p + __n); *__p = std::move(__t); return __ret; } _RandomAccessIterator __q = __p + __n; __p = __q - __k; for (_Distance __i = 0; __i < __n - __k; ++ __i) { --__p; --__q; std::iter_swap(__p, __q); } __n %= __k; if (__n == 0) return __ret; std::swap(__n, __k); } } } template<typename _ForwardIterator> inline _ForwardIterator rotate(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last) { ; ; return std::__rotate(__first, __middle, __last, std::__iterator_category(__first)); } } template<typename _ForwardIterator, typename _OutputIterator> inline _OutputIterator rotate_copy(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last, _OutputIterator __result) { ; ; return std::copy(__first, __middle, std::copy(__middle, __last, __result)); } template<typename _ForwardIterator, typename _Predicate> _ForwardIterator __partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred, forward_iterator_tag) { if (__first == __last) return __first; while (__pred(*__first)) if (++__first == __last) return __first; _ForwardIterator __next = __first; while (++__next != __last) if (__pred(*__next)) { std::iter_swap(__first, __next); ++__first; } return __first; } template<typename _BidirectionalIterator, typename _Predicate> _BidirectionalIterator __partition(_BidirectionalIterator __first, _BidirectionalIterator __last, _Predicate __pred, bidirectional_iterator_tag) { while (true) { while (true) if (__first == __last) return __first; else if (__pred(*__first)) ++__first; else break; --__last; while (true) if (__first == __last) return __first; else if (!bool(__pred(*__last))) --__last; else break; std::iter_swap(__first, __last); ++__first; } } template<typename _ForwardIterator, typename _Pointer, typename _Predicate, typename _Distance> _ForwardIterator __stable_partition_adaptive(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred, _Distance __len, _Pointer __buffer, _Distance __buffer_size) { if (__len == 1) return __first; if (__len <= __buffer_size) { _ForwardIterator __result1 = __first; _Pointer __result2 = __buffer; *__result2 = std::move(*__first); ++__result2; ++__first; for (; __first != __last; ++__first) if (__pred(__first)) { *__result1 = std::move(*__first); ++__result1; } else { *__result2 = std::move(*__first); ++__result2; } std::move(__buffer, __result2, __result1); return __result1; } _ForwardIterator __middle = __first; std::advance(__middle, __len / 2); _ForwardIterator __left_split = std::__stable_partition_adaptive(__first, __middle, __pred, __len / 2, __buffer, __buffer_size); _Distance __right_len = __len - __len / 2; _ForwardIterator __right_split = std::__find_if_not_n(__middle, __right_len, __pred); if (__right_len) __right_split = std::__stable_partition_adaptive(__right_split, __last, __pred, __right_len, __buffer, __buffer_size); return std::rotate(__left_split, __middle, __right_split); } template<typename _ForwardIterator, typename _Predicate> _ForwardIterator __stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) { __first = std::__find_if_not(__first, __last, __pred); if (__first == __last) return __first; typedef typename iterator_traits<_ForwardIterator>::value_type _ValueType; typedef typename iterator_traits<_ForwardIterator>::difference_type _DistanceType; _Temporary_buffer<_ForwardIterator, _ValueType> __buf(__first, std::distance(__first, __last)); return std::__stable_partition_adaptive(__first, __last, __pred, _DistanceType(__buf.requested_size()), __buf.begin(), _DistanceType(__buf.size())); } template<typename _ForwardIterator, typename _Predicate> inline _ForwardIterator stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) { ; return std::__stable_partition(__first, __last, __gnu_cxx::__ops::__pred_iter(__pred)); } template<typename _RandomAccessIterator, typename _Compare> void __heap_select(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last, _Compare __comp) { std::__make_heap(__first, __middle, __comp); for (_RandomAccessIterator __i = __middle; __i < __last; ++__i) if (__comp(__i, __first)) std::__pop_heap(__first, __middle, __i, __comp); } template<typename _InputIterator, typename _RandomAccessIterator, typename _Compare> _RandomAccessIterator __partial_sort_copy(_InputIterator __first, _InputIterator __last, _RandomAccessIterator __result_first, _RandomAccessIterator __result_last, _Compare __comp) { typedef typename iterator_traits<_InputIterator>::value_type _InputValueType; typedef iterator_traits<_RandomAccessIterator> _RItTraits; typedef typename _RItTraits::difference_type _DistanceType; if (__result_first == __result_last) return __result_last; _RandomAccessIterator __result_real_last = __result_first; while (__first != __last && __result_real_last != __result_last) { *__result_real_last = *__first; ++__result_real_last; ++__first; } std::__make_heap(__result_first, __result_real_last, __comp); while (__first != __last) { if (__comp(__first, __result_first)) std::__adjust_heap(__result_first, _DistanceType(0), _DistanceType(__result_real_last - __result_first), _InputValueType(*__first), __comp); ++__first; } std::__sort_heap(__result_first, __result_real_last, __comp); return __result_real_last; } template<typename _InputIterator, typename _RandomAccessIterator> inline _RandomAccessIterator partial_sort_copy(_InputIterator __first, _InputIterator __last, _RandomAccessIterator __result_first, _RandomAccessIterator __result_last) { ; ; ; return std::__partial_sort_copy(__first, __last, __result_first, __result_last, __gnu_cxx::__ops::__iter_less_iter()); } template<typename _InputIterator, typename _RandomAccessIterator, typename _Compare> inline _RandomAccessIterator partial_sort_copy(_InputIterator __first, _InputIterator __last, _RandomAccessIterator __result_first, _RandomAccessIterator __result_last, _Compare __comp) { ; ; ; return std::__partial_sort_copy(__first, __last, __result_first, __result_last, __gnu_cxx::__ops::__iter_comp_iter(__comp)); } template<typename _RandomAccessIterator, typename _Compare> void __unguarded_linear_insert(_RandomAccessIterator __last, _Compare __comp) { typename iterator_traits<_RandomAccessIterator>::value_type __val = std::move(*__last); _RandomAccessIterator __next = __last; --__next; while (__comp(__val, __next)) { *__last = std::move(*__next); __last = __next; --__next; } *__last = std::move(__val); } template<typename _RandomAccessIterator, typename _Compare> void __insertion_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { if (__first == __last) return; for (_RandomAccessIterator __i = __first + 1; __i != __last; ++__i) { if (__comp(__i, __first)) { typename iterator_traits<_RandomAccessIterator>::value_type __val = std::move(*__i); std::move_backward(__first, __i, __i + 1); *__first = std::move(__val); } else std::__unguarded_linear_insert(__i, __gnu_cxx::__ops::__val_comp_iter(__comp)); } } template<typename _RandomAccessIterator, typename _Compare> inline void __unguarded_insertion_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { for (_RandomAccessIterator __i = __first; __i != __last; ++__i) std::__unguarded_linear_insert(__i, __gnu_cxx::__ops::__val_comp_iter(__comp)); } enum { _S_threshold = 16 }; template<typename _RandomAccessIterator, typename _Compare> void __final_insertion_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { if (__last - __first > int(_S_threshold)) { std::__insertion_sort(__first, __first + int(_S_threshold), __comp); std::__unguarded_insertion_sort(__first + int(_S_threshold), __last, __comp); } else std::__insertion_sort(__first, __last, __comp); } template<typename _RandomAccessIterator, typename _Compare> _RandomAccessIterator __unguarded_partition(_RandomAccessIterator __first, _RandomAccessIterator __last, _RandomAccessIterator __pivot, _Compare __comp) { while (true) { while (__comp(__first, __pivot)) ++__first; --__last; while (__comp(__pivot, __last)) --__last; if (!(__first < __last)) return __first; std::iter_swap(__first, __last); ++__first; } } template<typename _RandomAccessIterator, typename _Compare> inline _RandomAccessIterator __unguarded_partition_pivot(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { _RandomAccessIterator __mid = __first + (__last - __first) / 2; std::__move_median_to_first(__first, __first + 1, __mid, __last - 1, __comp); return std::__unguarded_partition(__first + 1, __last, __first, __comp); } template<typename _RandomAccessIterator, typename _Compare> inline void __partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last, _Compare __comp) { std::__heap_select(__first, __middle, __last, __comp); std::__sort_heap(__first, __middle, __comp); } template<typename _RandomAccessIterator, typename _Size, typename _Compare> void __introsort_loop(_RandomAccessIterator __first, _RandomAccessIterator __last, _Size __depth_limit, _Compare __comp) { while (__last - __first > int(_S_threshold)) { if (__depth_limit == 0) { std::__partial_sort(__first, __last, __last, __comp); return; } --__depth_limit; _RandomAccessIterator __cut = std::__unguarded_partition_pivot(__first, __last, __comp); std::__introsort_loop(__cut, __last, __depth_limit, __comp); __last = __cut; } } template<typename _RandomAccessIterator, typename _Compare> inline void __sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { if (__first != __last) { std::__introsort_loop(__first, __last, std::__lg(__last - __first) * 2, __comp); std::__final_insertion_sort(__first, __last, __comp); } } template<typename _RandomAccessIterator, typename _Size, typename _Compare> void __introselect(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last, _Size __depth_limit, _Compare __comp) { while (__last - __first > 3) { if (__depth_limit == 0) { std::__heap_select(__first, __nth + 1, __last, __comp); std::iter_swap(__first, __nth); return; } --__depth_limit; _RandomAccessIterator __cut = std::__unguarded_partition_pivot(__first, __last, __comp); if (__cut <= __nth) __first = __cut; else __last = __cut; } std::__insertion_sort(__first, __last, __comp); } template<typename _ForwardIterator, typename _Tp, typename _Compare> inline _ForwardIterator lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __val, _Compare __comp) { ; return std::__lower_bound(__first, __last, __val, __gnu_cxx::__ops::__iter_comp_val(__comp)); } template<typename _ForwardIterator, typename _Tp, typename _Compare> _ForwardIterator __upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __val, _Compare __comp) { typedef typename iterator_traits<_ForwardIterator>::difference_type _DistanceType; _DistanceType __len = std::distance(__first, __last); while (__len > 0) { _DistanceType __half = __len >> 1; _ForwardIterator __middle = __first; std::advance(__middle, __half); if (__comp(__val, __middle)) __len = __half; else { __first = __middle; ++__first; __len = __len - __half - 1; } } return __first; } template<typename _ForwardIterator, typename _Tp> inline _ForwardIterator upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __val) { ; return std::__upper_bound(__first, __last, __val, __gnu_cxx::__ops::__val_less_iter()); } template<typename _ForwardIterator, typename _Tp, typename _Compare> inline _ForwardIterator upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __val, _Compare __comp) { ; return std::__upper_bound(__first, __last, __val, __gnu_cxx::__ops::__val_comp_iter(__comp)); } template<typename _ForwardIterator, typename _Tp, typename _CompareItTp, typename _CompareTpIt> pair<_ForwardIterator, _ForwardIterator> __equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __val, _CompareItTp __comp_it_val, _CompareTpIt __comp_val_it) { typedef typename iterator_traits<_ForwardIterator>::difference_type _DistanceType; _DistanceType __len = std::distance(__first, __last); while (__len > 0) { _DistanceType __half = __len >> 1; _ForwardIterator __middle = __first; std::advance(__middle, __half); if (__comp_it_val(__middle, __val)) { __first = __middle; ++__first; __len = __len - __half - 1; } else if (__comp_val_it(__val, __middle)) __len = __half; else { _ForwardIterator __left = std::__lower_bound(__first, __middle, __val, __comp_it_val); std::advance(__first, __len); _ForwardIterator __right = std::__upper_bound(++__middle, __first, __val, __comp_val_it); return pair<_ForwardIterator, _ForwardIterator>(__left, __right); } } return pair<_ForwardIterator, _ForwardIterator>(__first, __first); } template<typename _ForwardIterator, typename _Tp> inline pair<_ForwardIterator, _ForwardIterator> equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __val) { ; ; return std::__equal_range(__first, __last, __val, __gnu_cxx::__ops::__iter_less_val(), __gnu_cxx::__ops::__val_less_iter()); } template<typename _ForwardIterator, typename _Tp, typename _Compare> inline pair<_ForwardIterator, _ForwardIterator> equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __val, _Compare __comp) { ; ; return std::__equal_range(__first, __last, __val, __gnu_cxx::__ops::__iter_comp_val(__comp), __gnu_cxx::__ops::__val_comp_iter(__comp)); } template<typename _ForwardIterator, typename _Tp> bool binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __val) { ; ; _ForwardIterator __i = std::__lower_bound(__first, __last, __val, __gnu_cxx::__ops::__iter_less_val()); return __i != __last && !(__val < *__i); } template<typename _ForwardIterator, typename _Tp, typename _Compare> bool binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __val, _Compare __comp) { ; ; _ForwardIterator __i = std::__lower_bound(__first, __last, __val, __gnu_cxx::__ops::__iter_comp_val(__comp)); return __i != __last && !bool(__comp(__val, *__i)); } template<typename _InputIterator1, typename _InputIterator2, typename _OutputIterator, typename _Compare> void __move_merge_adaptive(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) { while (__first1 != __last1 && __first2 != __last2) { if (__comp(__first2, __first1)) { *__result = std::move(*__first2); ++__first2; } else { *__result = std::move(*__first1); ++__first1; } ++__result; } if (__first1 != __last1) std::move(__first1, __last1, __result); } template<typename _BidirectionalIterator1, typename _BidirectionalIterator2, typename _BidirectionalIterator3, typename _Compare> void __move_merge_adaptive_backward(_BidirectionalIterator1 __first1, _BidirectionalIterator1 __last1, _BidirectionalIterator2 __first2, _BidirectionalIterator2 __last2, _BidirectionalIterator3 __result, _Compare __comp) { if (__first1 == __last1) { std::move_backward(__first2, __last2, __result); return; } else if (__first2 == __last2) return; --__last1; --__last2; while (true) { if (__comp(__last2, __last1)) { *--__result = std::move(*__last1); if (__first1 == __last1) { std::move_backward(__first2, ++__last2, __result); return; } --__last1; } else { *--__result = std::move(*__last2); if (__first2 == __last2) return; --__last2; } } } template<typename _BidirectionalIterator1, typename _BidirectionalIterator2, typename _Distance> _BidirectionalIterator1 __rotate_adaptive(_BidirectionalIterator1 __first, _BidirectionalIterator1 __middle, _BidirectionalIterator1 __last, _Distance __len1, _Distance __len2, _BidirectionalIterator2 __buffer, _Distance __buffer_size) { _BidirectionalIterator2 __buffer_end; if (__len1 > __len2 && __len2 <= __buffer_size) { if (__len2) { __buffer_end = std::move(__middle, __last, __buffer); std::move_backward(__first, __middle, __last); return std::move(__buffer, __buffer_end, __first); } else return __first; } else if (__len1 <= __buffer_size) { if (__len1) { __buffer_end = std::move(__first, __middle, __buffer); std::move(__middle, __last, __first); return std::move_backward(__buffer, __buffer_end, __last); } else return __last; } else return std::rotate(__first, __middle, __last); } template<typename _BidirectionalIterator, typename _Distance, typename _Pointer, typename _Compare> void __merge_adaptive(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last, _Distance __len1, _Distance __len2, _Pointer __buffer, _Distance __buffer_size, _Compare __comp) { if (__len1 <= __len2 && __len1 <= __buffer_size) { _Pointer __buffer_end = std::move(__first, __middle, __buffer); std::__move_merge_adaptive(__buffer, __buffer_end, __middle, __last, __first, __comp); } else if (__len2 <= __buffer_size) { _Pointer __buffer_end = std::move(__middle, __last, __buffer); std::__move_merge_adaptive_backward(__first, __middle, __buffer, __buffer_end, __last, __comp); } else { _BidirectionalIterator __first_cut = __first; _BidirectionalIterator __second_cut = __middle; _Distance __len11 = 0; _Distance __len22 = 0; if (__len1 > __len2) { __len11 = __len1 / 2; std::advance(__first_cut, __len11); __second_cut = std::__lower_bound(__middle, __last, *__first_cut, __gnu_cxx::__ops::__iter_comp_val(__comp)); __len22 = std::distance(__middle, __second_cut); } else { __len22 = __len2 / 2; std::advance(__second_cut, __len22); __first_cut = std::__upper_bound(__first, __middle, *__second_cut, __gnu_cxx::__ops::__val_comp_iter(__comp)); __len11 = std::distance(__first, __first_cut); } _BidirectionalIterator __new_middle = std::__rotate_adaptive(__first_cut, __middle, __second_cut, __len1 - __len11, __len22, __buffer, __buffer_size); std::__merge_adaptive(__first, __first_cut, __new_middle, __len11, __len22, __buffer, __buffer_size, __comp); std::__merge_adaptive(__new_middle, __second_cut, __last, __len1 - __len11, __len2 - __len22, __buffer, __buffer_size, __comp); } } template<typename _BidirectionalIterator, typename _Distance, typename _Compare> void __merge_without_buffer(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last, _Distance __len1, _Distance __len2, _Compare __comp) { if (__len1 == 0 || __len2 == 0) return; if (__len1 + __len2 == 2) { if (__comp(__middle, __first)) std::iter_swap(__first, __middle); return; } _BidirectionalIterator __first_cut = __first; _BidirectionalIterator __second_cut = __middle; _Distance __len11 = 0; _Distance __len22 = 0; if (__len1 > __len2) { __len11 = __len1 / 2; std::advance(__first_cut, __len11); __second_cut = std::__lower_bound(__middle, __last, *__first_cut, __gnu_cxx::__ops::__iter_comp_val(__comp)); __len22 = std::distance(__middle, __second_cut); } else { __len22 = __len2 / 2; std::advance(__second_cut, __len22); __first_cut = std::__upper_bound(__first, __middle, *__second_cut, __gnu_cxx::__ops::__val_comp_iter(__comp)); __len11 = std::distance(__first, __first_cut); } _BidirectionalIterator __new_middle = std::rotate(__first_cut, __middle, __second_cut); std::__merge_without_buffer(__first, __first_cut, __new_middle, __len11, __len22, __comp); std::__merge_without_buffer(__new_middle, __second_cut, __last, __len1 - __len11, __len2 - __len22, __comp); } template<typename _BidirectionalIterator, typename _Compare> void __inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last, _Compare __comp) { typedef typename iterator_traits<_BidirectionalIterator>::value_type _ValueType; typedef typename iterator_traits<_BidirectionalIterator>::difference_type _DistanceType; if (__first == __middle || __middle == __last) return; const _DistanceType __len1 = std::distance(__first, __middle); const _DistanceType __len2 = std::distance(__middle, __last); typedef _Temporary_buffer<_BidirectionalIterator, _ValueType> _TmpBuf; _TmpBuf __buf(__first, __len1 + __len2); if (__buf.begin() == 0) std::__merge_without_buffer (__first, __middle, __last, __len1, __len2, __comp); else std::__merge_adaptive (__first, __middle, __last, __len1, __len2, __buf.begin(), _DistanceType(__buf.size()), __comp); } template<typename _BidirectionalIterator> inline void inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last) { ; ; ; std::__inplace_merge(__first, __middle, __last, __gnu_cxx::__ops::__iter_less_iter()); } template<typename _BidirectionalIterator, typename _Compare> inline void inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last, _Compare __comp) { ; ; ; std::__inplace_merge(__first, __middle, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp)); } template<typename _InputIterator, typename _OutputIterator, typename _Compare> _OutputIterator __move_merge(_InputIterator __first1, _InputIterator __last1, _InputIterator __first2, _InputIterator __last2, _OutputIterator __result, _Compare __comp) { while (__first1 != __last1 && __first2 != __last2) { if (__comp(__first2, __first1)) { *__result = std::move(*__first2); ++__first2; } else { *__result = std::move(*__first1); ++__first1; } ++__result; } return std::move(__first2, __last2, std::move(__first1, __last1, __result)) ; } template<typename _RandomAccessIterator1, typename _RandomAccessIterator2, typename _Distance, typename _Compare> void __merge_sort_loop(_RandomAccessIterator1 __first, _RandomAccessIterator1 __last, _RandomAccessIterator2 __result, _Distance __step_size, _Compare __comp) { const _Distance __two_step = 2 * __step_size; while (__last - __first >= __two_step) { __result = std::__move_merge(__first, __first + __step_size, __first + __step_size, __first + __two_step, __result, __comp); __first += __two_step; } __step_size = std::min(_Distance(__last - __first), __step_size); std::__move_merge(__first, __first + __step_size, __first + __step_size, __last, __result, __comp); } template<typename _RandomAccessIterator, typename _Distance, typename _Compare> void __chunk_insertion_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Distance __chunk_size, _Compare __comp) { while (__last - __first >= __chunk_size) { std::__insertion_sort(__first, __first + __chunk_size, __comp); __first += __chunk_size; } std::__insertion_sort(__first, __last, __comp); } enum { _S_chunk_size = 7 }; template<typename _RandomAccessIterator, typename _Pointer, typename _Compare> void __merge_sort_with_buffer(_RandomAccessIterator __first, _RandomAccessIterator __last, _Pointer __buffer, _Compare __comp) { typedef typename iterator_traits<_RandomAccessIterator>::difference_type _Distance; const _Distance __len = __last - __first; const _Pointer __buffer_last = __buffer + __len; _Distance __step_size = _S_chunk_size; std::__chunk_insertion_sort(__first, __last, __step_size, __comp); while (__step_size < __len) { std::__merge_sort_loop(__first, __last, __buffer, __step_size, __comp); __step_size *= 2; std::__merge_sort_loop(__buffer, __buffer_last, __first, __step_size, __comp); __step_size *= 2; } } template<typename _RandomAccessIterator, typename _Pointer, typename _Distance, typename _Compare> void __stable_sort_adaptive(_RandomAccessIterator __first, _RandomAccessIterator __last, _Pointer __buffer, _Distance __buffer_size, _Compare __comp) { const _Distance __len = (__last - __first + 1) / 2; const _RandomAccessIterator __middle = __first + __len; if (__len > __buffer_size) { std::__stable_sort_adaptive(__first, __middle, __buffer, __buffer_size, __comp); std::__stable_sort_adaptive(__middle, __last, __buffer, __buffer_size, __comp); } else { std::__merge_sort_with_buffer(__first, __middle, __buffer, __comp); std::__merge_sort_with_buffer(__middle, __last, __buffer, __comp); } std::__merge_adaptive(__first, __middle, __last, _Distance(__middle - __first), _Distance(__last - __middle), __buffer, __buffer_size, __comp); } template<typename _RandomAccessIterator, typename _Compare> void __inplace_stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { if (__last - __first < 15) { std::__insertion_sort(__first, __last, __comp); return; } _RandomAccessIterator __middle = __first + (__last - __first) / 2; std::__inplace_stable_sort(__first, __middle, __comp); std::__inplace_stable_sort(__middle, __last, __comp); std::__merge_without_buffer(__first, __middle, __last, __middle - __first, __last - __middle, __comp); } template<typename _InputIterator1, typename _InputIterator2, typename _Compare> bool __includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _Compare __comp) { while (__first1 != __last1 && __first2 != __last2) if (__comp(__first2, __first1)) return false; else if (__comp(__first1, __first2)) ++__first1; else { ++__first1; ++__first2; } return __first2 == __last2; } template<typename _InputIterator1, typename _InputIterator2> inline bool includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) { ; ; ; ; return std::__includes(__first1, __last1, __first2, __last2, __gnu_cxx::__ops::__iter_less_iter()); } template<typename _InputIterator1, typename _InputIterator2, typename _Compare> inline bool includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _Compare __comp) { ; ; ; ; return std::__includes(__first1, __last1, __first2, __last2, __gnu_cxx::__ops::__iter_comp_iter(__comp)); } template<typename _BidirectionalIterator, typename _Compare> bool __next_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp) { if (__first == __last) return false; _BidirectionalIterator __i = __first; ++__i; if (__i == __last) return false; __i = __last; --__i; for(;;) { _BidirectionalIterator __ii = __i; --__i; if (__comp(__i, __ii)) { _BidirectionalIterator __j = __last; while (!__comp(__i, --__j)) {} std::iter_swap(__i, __j); std::__reverse(__ii, __last, std::__iterator_category(__first)); return true; } if (__i == __first) { std::__reverse(__first, __last, std::__iterator_category(__first)); return false; } } } template<typename _BidirectionalIterator> inline bool next_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last) { ; ; return std::__next_permutation (__first, __last, __gnu_cxx::__ops::__iter_less_iter()); } template<typename _BidirectionalIterator, typename _Compare> inline bool next_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp) { ; ; return std::__next_permutation (__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp)); } template<typename _BidirectionalIterator, typename _Compare> bool __prev_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp) { if (__first == __last) return false; _BidirectionalIterator __i = __first; ++__i; if (__i == __last) return false; __i = __last; --__i; for(;;) { _BidirectionalIterator __ii = __i; --__i; if (__comp(__ii, __i)) { _BidirectionalIterator __j = __last; while (!__comp(--__j, __i)) {} std::iter_swap(__i, __j); std::__reverse(__ii, __last, std::__iterator_category(__first)); return true; } if (__i == __first) { std::__reverse(__first, __last, std::__iterator_category(__first)); return false; } } } template<typename _BidirectionalIterator> inline bool prev_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last) { ; ; return std::__prev_permutation(__first, __last, __gnu_cxx::__ops::__iter_less_iter()); } template<typename _BidirectionalIterator, typename _Compare> inline bool prev_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp) { ; ; return std::__prev_permutation(__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp)); } template<typename _InputIterator, typename _OutputIterator, typename _Predicate, typename _Tp> _OutputIterator __replace_copy_if(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _Predicate __pred, const _Tp& __new_value) { for (; __first != __last; ++__first, (void)++__result) if (__pred(__first)) *__result = __new_value; else *__result = *__first; return __result; } template<typename _InputIterator, typename _OutputIterator, typename _Tp> inline _OutputIterator replace_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, const _Tp& __old_value, const _Tp& __new_value) { ; return std::__replace_copy_if(__first, __last, __result, __gnu_cxx::__ops::__iter_equals_val(__old_value), __new_value); } template<typename _InputIterator, typename _OutputIterator, typename _Predicate, typename _Tp> inline _OutputIterator replace_copy_if(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _Predicate __pred, const _Tp& __new_value) { ; return std::__replace_copy_if(__first, __last, __result, __gnu_cxx::__ops::__pred_iter(__pred), __new_value); } template<typename _ForwardIterator> inline bool is_sorted(_ForwardIterator __first, _ForwardIterator __last) { return std::is_sorted_until(__first, __last) == __last; } template<typename _ForwardIterator, typename _Compare> inline bool is_sorted(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) { return std::is_sorted_until(__first, __last, __comp) == __last; } template<typename _ForwardIterator, typename _Compare> _ForwardIterator __is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) { if (__first == __last) return __last; _ForwardIterator __next = __first; for (++__next; __next != __last; __first = __next, (void)++__next) if (__comp(__next, __first)) return __next; return __next; } template<typename _ForwardIterator> inline _ForwardIterator is_sorted_until(_ForwardIterator __first, _ForwardIterator __last) { ; ; return std::__is_sorted_until(__first, __last, __gnu_cxx::__ops::__iter_less_iter()); } template<typename _ForwardIterator, typename _Compare> inline _ForwardIterator is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) { ; ; return std::__is_sorted_until(__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp)); } template<typename _Tp> constexpr inline pair<const _Tp&, const _Tp&> minmax(const _Tp& __a, const _Tp& __b) { return __b < __a ? pair<const _Tp&, const _Tp&>(__b, __a) : pair<const _Tp&, const _Tp&>(__a, __b); } template<typename _Tp, typename _Compare> constexpr inline pair<const _Tp&, const _Tp&> minmax(const _Tp& __a, const _Tp& __b, _Compare __comp) { return __comp(__b, __a) ? pair<const _Tp&, const _Tp&>(__b, __a) : pair<const _Tp&, const _Tp&>(__a, __b); } template<typename _ForwardIterator, typename _Compare> constexpr pair<_ForwardIterator, _ForwardIterator> __minmax_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) { _ForwardIterator __next = __first; if (__first == __last || ++__next == __last) return std::make_pair(__first, __first); _ForwardIterator __min{}, __max{}; if (__comp(__next, __first)) { __min = __next; __max = __first; } else { __min = __first; __max = __next; } __first = __next; ++__first; while (__first != __last) { __next = __first; if (++__next == __last) { if (__comp(__first, __min)) __min = __first; else if (!__comp(__first, __max)) __max = __first; break; } if (__comp(__next, __first)) { if (__comp(__next, __min)) __min = __next; if (!__comp(__first, __max)) __max = __first; } else { if (__comp(__first, __min)) __min = __first; if (!__comp(__next, __max)) __max = __next; } __first = __next; ++__first; } return std::make_pair(__min, __max); } template<typename _ForwardIterator> constexpr inline pair<_ForwardIterator, _ForwardIterator> minmax_element(_ForwardIterator __first, _ForwardIterator __last) { ; ; return std::__minmax_element(__first, __last, __gnu_cxx::__ops::__iter_less_iter()); } template<typename _ForwardIterator, typename _Compare> constexpr inline pair<_ForwardIterator, _ForwardIterator> minmax_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) { ; ; return std::__minmax_element(__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp)); } template<typename _Tp> constexpr inline _Tp min(initializer_list<_Tp> __l) { return *std::min_element(__l.begin(), __l.end()); } template<typename _Tp, typename _Compare> constexpr inline _Tp min(initializer_list<_Tp> __l, _Compare __comp) { return *std::min_element(__l.begin(), __l.end(), __comp); } template<typename _Tp> constexpr inline _Tp max(initializer_list<_Tp> __l) { return *std::max_element(__l.begin(), __l.end()); } template<typename _Tp, typename _Compare> constexpr inline _Tp max(initializer_list<_Tp> __l, _Compare __comp) { return *std::max_element(__l.begin(), __l.end(), __comp); } template<typename _Tp> constexpr inline pair<_Tp, _Tp> minmax(initializer_list<_Tp> __l) { pair<const _Tp*, const _Tp*> __p = std::minmax_element(__l.begin(), __l.end()); return std::make_pair(*__p.first, *__p.second); } template<typename _Tp, typename _Compare> constexpr inline pair<_Tp, _Tp> minmax(initializer_list<_Tp> __l, _Compare __comp) { pair<const _Tp*, const _Tp*> __p = std::minmax_element(__l.begin(), __l.end(), __comp); return std::make_pair(*__p.first, *__p.second); } template<typename _ForwardIterator1, typename _ForwardIterator2, typename _BinaryPredicate> inline bool is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _BinaryPredicate __pred) { ; return std::__is_permutation(__first1, __last1, __first2, __gnu_cxx::__ops::__iter_comp_iter(__pred)); } template<typename _ForwardIterator1, typename _ForwardIterator2, typename _BinaryPredicate> bool __is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2, _BinaryPredicate __pred) { using _Cat1 = typename iterator_traits<_ForwardIterator1>::iterator_category; using _Cat2 = typename iterator_traits<_ForwardIterator2>::iterator_category; using _It1_is_RA = is_same<_Cat1, random_access_iterator_tag>; using _It2_is_RA = is_same<_Cat2, random_access_iterator_tag>; constexpr bool __ra_iters = _It1_is_RA() && _It2_is_RA(); if (__ra_iters) { auto __d1 = std::distance(__first1, __last1); auto __d2 = std::distance(__first2, __last2); if (__d1 != __d2) return false; } for (; __first1 != __last1 && __first2 != __last2; ++__first1, (void)++__first2) if (!__pred(__first1, __first2)) break; if (__ra_iters) { if (__first1 == __last1) return true; } else { auto __d1 = std::distance(__first1, __last1); auto __d2 = std::distance(__first2, __last2); if (__d1 == 0 && __d2 == 0) return true; if (__d1 != __d2) return false; } for (_ForwardIterator1 __scan = __first1; __scan != __last1; ++__scan) { if (__scan != std::__find_if(__first1, __scan, __gnu_cxx::__ops::__iter_comp_iter(__pred, __scan))) continue; auto __matches = std::__count_if(__first2, __last2, __gnu_cxx::__ops::__iter_comp_iter(__pred, __scan)); if (0 == __matches || std::__count_if(__scan, __last1, __gnu_cxx::__ops::__iter_comp_iter(__pred, __scan)) != __matches) return false; } return true; } template<typename _ForwardIterator1, typename _ForwardIterator2> inline bool is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) { ; ; return std::__is_permutation(__first1, __last1, __first2, __last2, __gnu_cxx::__ops::__iter_equal_to_iter()); } template<typename _ForwardIterator1, typename _ForwardIterator2, typename _BinaryPredicate> inline bool is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2, _BinaryPredicate __pred) { ; ; return std::__is_permutation(__first1, __last1, __first2, __last2, __gnu_cxx::__ops::__iter_comp_iter(__pred)); } template<typename _IntType, typename _UniformRandomBitGenerator> pair<_IntType, _IntType> __gen_two_uniform_ints(_IntType __b0, _IntType __b1, _UniformRandomBitGenerator&& __g) { _IntType __x = uniform_int_distribution<_IntType>{0, (__b0 * __b1) - 1}(__g); return std::make_pair(__x / __b1, __x % __b1); } template<typename _RandomAccessIterator, typename _UniformRandomNumberGenerator> void shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last, _UniformRandomNumberGenerator&& __g) { ; if (__first == __last) return; typedef typename iterator_traits<_RandomAccessIterator>::difference_type _DistanceType; typedef typename std::make_unsigned<_DistanceType>::type __ud_type; typedef typename std::uniform_int_distribution<__ud_type> __distr_type; typedef typename __distr_type::param_type __p_type; typedef typename remove_reference<_UniformRandomNumberGenerator>::type _Gen; typedef typename common_type<typename _Gen::result_type, __ud_type>::type __uc_type; const __uc_type __urngrange = __g.max() - __g.min(); const __uc_type __urange = __uc_type(__last - __first); if (__urngrange / __urange >= __urange) { _RandomAccessIterator __i = __first + 1; if ((__urange % 2) == 0) { __distr_type __d{0, 1}; std::iter_swap(__i++, __first + __d(__g)); } while (__i != __last) { const __uc_type __swap_range = __uc_type(__i - __first) + 1; const pair<__uc_type, __uc_type> __pospos = __gen_two_uniform_ints(__swap_range, __swap_range + 1, __g); std::iter_swap(__i++, __first + __pospos.first); std::iter_swap(__i++, __first + __pospos.second); } return; } __distr_type __d; for (_RandomAccessIterator __i = __first + 1; __i != __last; ++__i) std::iter_swap(__i, __first + __d(__g, __p_type(0, __i - __first))); } template<typename _InputIterator, typename _Function> _Function for_each(_InputIterator __first, _InputIterator __last, _Function __f) { ; for (; __first != __last; ++__first) __f(*__first); return __f; } template<typename _InputIterator, typename _Tp> inline _InputIterator find(_InputIterator __first, _InputIterator __last, const _Tp& __val) { ; return std::__find_if(__first, __last, __gnu_cxx::__ops::__iter_equals_val(__val)); } template<typename _InputIterator, typename _Predicate> inline _InputIterator find_if(_InputIterator __first, _InputIterator __last, _Predicate __pred) { ; return std::__find_if(__first, __last, __gnu_cxx::__ops::__pred_iter(__pred)); } template<typename _InputIterator, typename _ForwardIterator> _InputIterator find_first_of(_InputIterator __first1, _InputIterator __last1, _ForwardIterator __first2, _ForwardIterator __last2) { ; ; for (; __first1 != __last1; ++__first1) for (_ForwardIterator __iter = __first2; __iter != __last2; ++__iter) if (*__first1 == *__iter) return __first1; return __last1; } template<typename _InputIterator, typename _ForwardIterator, typename _BinaryPredicate> _InputIterator find_first_of(_InputIterator __first1, _InputIterator __last1, _ForwardIterator __first2, _ForwardIterator __last2, _BinaryPredicate __comp) { ; ; for (; __first1 != __last1; ++__first1) for (_ForwardIterator __iter = __first2; __iter != __last2; ++__iter) if (__comp(*__first1, *__iter)) return __first1; return __last1; } template<typename _ForwardIterator> inline _ForwardIterator adjacent_find(_ForwardIterator __first, _ForwardIterator __last) { ; return std::__adjacent_find(__first, __last, __gnu_cxx::__ops::__iter_equal_to_iter()); } template<typename _ForwardIterator, typename _BinaryPredicate> inline _ForwardIterator adjacent_find(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __binary_pred) { ; return std::__adjacent_find(__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__binary_pred)); } template<typename _InputIterator, typename _Tp> inline typename iterator_traits<_InputIterator>::difference_type count(_InputIterator __first, _InputIterator __last, const _Tp& __value) { ; return std::__count_if(__first, __last, __gnu_cxx::__ops::__iter_equals_val(__value)); } template<typename _InputIterator, typename _Predicate> inline typename iterator_traits<_InputIterator>::difference_type count_if(_InputIterator __first, _InputIterator __last, _Predicate __pred) { ; return std::__count_if(__first, __last, __gnu_cxx::__ops::__pred_iter(__pred)); } template<typename _ForwardIterator1, typename _ForwardIterator2> inline _ForwardIterator1 search(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) { ; ; return std::__search(__first1, __last1, __first2, __last2, __gnu_cxx::__ops::__iter_equal_to_iter()); } template<typename _ForwardIterator1, typename _ForwardIterator2, typename _BinaryPredicate> inline _ForwardIterator1 search(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2, _BinaryPredicate __predicate) { ; ; return std::__search(__first1, __last1, __first2, __last2, __gnu_cxx::__ops::__iter_comp_iter(__predicate)); } template<typename _ForwardIterator, typename _Integer, typename _Tp> inline _ForwardIterator search_n(_ForwardIterator __first, _ForwardIterator __last, _Integer __count, const _Tp& __val) { ; return std::__search_n(__first, __last, __count, __gnu_cxx::__ops::__iter_equals_val(__val)); } template<typename _ForwardIterator, typename _Integer, typename _Tp, typename _BinaryPredicate> inline _ForwardIterator search_n(_ForwardIterator __first, _ForwardIterator __last, _Integer __count, const _Tp& __val, _BinaryPredicate __binary_pred) { ; return std::__search_n(__first, __last, __count, __gnu_cxx::__ops::__iter_comp_val(__binary_pred, __val)); } template<typename _InputIterator, typename _OutputIterator, typename _UnaryOperation> _OutputIterator transform(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _UnaryOperation __unary_op) { ; for (; __first != __last; ++__first, (void)++__result) *__result = __unary_op(*__first); return __result; } template<typename _InputIterator1, typename _InputIterator2, typename _OutputIterator, typename _BinaryOperation> _OutputIterator transform(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _OutputIterator __result, _BinaryOperation __binary_op) { ; for (; __first1 != __last1; ++__first1, (void)++__first2, ++__result) *__result = __binary_op(*__first1, *__first2); return __result; } template<typename _ForwardIterator, typename _Tp> void replace(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __old_value, const _Tp& __new_value) { ; for (; __first != __last; ++__first) if (*__first == __old_value) *__first = __new_value; } template<typename _ForwardIterator, typename _Predicate, typename _Tp> void replace_if(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred, const _Tp& __new_value) { ; for (; __first != __last; ++__first) if (__pred(*__first)) *__first = __new_value; } template<typename _ForwardIterator, typename _Generator> void generate(_ForwardIterator __first, _ForwardIterator __last, _Generator __gen) { ; for (; __first != __last; ++__first) *__first = __gen(); } template<typename _OutputIterator, typename _Size, typename _Generator> _OutputIterator generate_n(_OutputIterator __first, _Size __n, _Generator __gen) { typedef __decltype(std::__size_to_integer(__n)) _IntSize; for (_IntSize __niter = std::__size_to_integer(__n); __niter > 0; --__niter, (void) ++__first) *__first = __gen(); return __first; } template<typename _InputIterator, typename _OutputIterator> inline _OutputIterator unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result) { ; if (__first == __last) return __result; return std::__unique_copy(__first, __last, __result, __gnu_cxx::__ops::__iter_equal_to_iter(), std::__iterator_category(__first), std::__iterator_category(__result)); } template<typename _InputIterator, typename _OutputIterator, typename _BinaryPredicate> inline _OutputIterator unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryPredicate __binary_pred) { ; if (__first == __last) return __result; return std::__unique_copy(__first, __last, __result, __gnu_cxx::__ops::__iter_comp_iter(__binary_pred), std::__iterator_category(__first), std::__iterator_category(__result)); } template<typename _RandomAccessIterator> inline void random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last) { ; if (__first != __last) for (_RandomAccessIterator __i = __first + 1; __i != __last; ++__i) { _RandomAccessIterator __j = __first + std::rand() % ((__i - __first) + 1); if (__i != __j) std::iter_swap(__i, __j); } } template<typename _RandomAccessIterator, typename _RandomNumberGenerator> void random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last, _RandomNumberGenerator&& __rand) { ; if (__first == __last) return; for (_RandomAccessIterator __i = __first + 1; __i != __last; ++__i) { _RandomAccessIterator __j = __first + __rand((__i - __first) + 1); if (__i != __j) std::iter_swap(__i, __j); } } template<typename _ForwardIterator, typename _Predicate> inline _ForwardIterator partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) { ; return std::__partition(__first, __last, __pred, std::__iterator_category(__first)); } template<typename _RandomAccessIterator> inline void partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last) { ; ; ; std::__partial_sort(__first, __middle, __last, __gnu_cxx::__ops::__iter_less_iter()); } template<typename _RandomAccessIterator, typename _Compare> inline void partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last, _Compare __comp) { ; ; ; std::__partial_sort(__first, __middle, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp)); } template<typename _RandomAccessIterator> inline void nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last) { ; ; ; if (__first == __last || __nth == __last) return; std::__introselect(__first, __nth, __last, std::__lg(__last - __first) * 2, __gnu_cxx::__ops::__iter_less_iter()); } template<typename _RandomAccessIterator, typename _Compare> inline void nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last, _Compare __comp) { ; ; ; if (__first == __last || __nth == __last) return; std::__introselect(__first, __nth, __last, std::__lg(__last - __first) * 2, __gnu_cxx::__ops::__iter_comp_iter(__comp)); } template<typename _RandomAccessIterator> inline void sort(_RandomAccessIterator __first, _RandomAccessIterator __last) { ; ; std::__sort(__first, __last, __gnu_cxx::__ops::__iter_less_iter()); } template<typename _RandomAccessIterator, typename _Compare> inline void sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { ; ; std::__sort(__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp)); } template<typename _InputIterator1, typename _InputIterator2, typename _OutputIterator, typename _Compare> _OutputIterator __merge(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) { while (__first1 != __last1 && __first2 != __last2) { if (__comp(__first2, __first1)) { *__result = *__first2; ++__first2; } else { *__result = *__first1; ++__first1; } ++__result; } return std::copy(__first2, __last2, std::copy(__first1, __last1, __result)); } template<typename _InputIterator1, typename _InputIterator2, typename _OutputIterator> inline _OutputIterator merge(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result) { ; ; ; ; return std::__merge(__first1, __last1, __first2, __last2, __result, __gnu_cxx::__ops::__iter_less_iter()); } template<typename _InputIterator1, typename _InputIterator2, typename _OutputIterator, typename _Compare> inline _OutputIterator merge(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) { ; ; ; ; return std::__merge(__first1, __last1, __first2, __last2, __result, __gnu_cxx::__ops::__iter_comp_iter(__comp)); } template<typename _RandomAccessIterator, typename _Compare> inline void __stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { typedef typename iterator_traits<_RandomAccessIterator>::value_type _ValueType; typedef typename iterator_traits<_RandomAccessIterator>::difference_type _DistanceType; typedef _Temporary_buffer<_RandomAccessIterator, _ValueType> _TmpBuf; _TmpBuf __buf(__first, std::distance(__first, __last)); if (__buf.begin() == 0) std::__inplace_stable_sort(__first, __last, __comp); else std::__stable_sort_adaptive(__first, __last, __buf.begin(), _DistanceType(__buf.size()), __comp); } template<typename _RandomAccessIterator> inline void stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last) { ; ; std::__stable_sort(__first, __last, __gnu_cxx::__ops::__iter_less_iter()); } template<typename _RandomAccessIterator, typename _Compare> inline void stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { ; ; std::__stable_sort(__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp)); } template<typename _InputIterator1, typename _InputIterator2, typename _OutputIterator, typename _Compare> _OutputIterator __set_union(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) { while (__first1 != __last1 && __first2 != __last2) { if (__comp(__first1, __first2)) { *__result = *__first1; ++__first1; } else if (__comp(__first2, __first1)) { *__result = *__first2; ++__first2; } else { *__result = *__first1; ++__first1; ++__first2; } ++__result; } return std::copy(__first2, __last2, std::copy(__first1, __last1, __result)); } template<typename _InputIterator1, typename _InputIterator2, typename _OutputIterator> inline _OutputIterator set_union(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result) { ; ; ; ; return std::__set_union(__first1, __last1, __first2, __last2, __result, __gnu_cxx::__ops::__iter_less_iter()); } template<typename _InputIterator1, typename _InputIterator2, typename _OutputIterator, typename _Compare> inline _OutputIterator set_union(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) { ; ; ; ; return std::__set_union(__first1, __last1, __first2, __last2, __result, __gnu_cxx::__ops::__iter_comp_iter(__comp)); } template<typename _InputIterator1, typename _InputIterator2, typename _OutputIterator, typename _Compare> _OutputIterator __set_intersection(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) { while (__first1 != __last1 && __first2 != __last2) if (__comp(__first1, __first2)) ++__first1; else if (__comp(__first2, __first1)) ++__first2; else { *__result = *__first1; ++__first1; ++__first2; ++__result; } return __result; } template<typename _InputIterator1, typename _InputIterator2, typename _OutputIterator> inline _OutputIterator set_intersection(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result) { ; ; ; ; return std::__set_intersection(__first1, __last1, __first2, __last2, __result, __gnu_cxx::__ops::__iter_less_iter()); } template<typename _InputIterator1, typename _InputIterator2, typename _OutputIterator, typename _Compare> inline _OutputIterator set_intersection(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) { ; ; ; ; return std::__set_intersection(__first1, __last1, __first2, __last2, __result, __gnu_cxx::__ops::__iter_comp_iter(__comp)); } template<typename _InputIterator1, typename _InputIterator2, typename _OutputIterator, typename _Compare> _OutputIterator __set_difference(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) { while (__first1 != __last1 && __first2 != __last2) if (__comp(__first1, __first2)) { *__result = *__first1; ++__first1; ++__result; } else if (__comp(__first2, __first1)) ++__first2; else { ++__first1; ++__first2; } return std::copy(__first1, __last1, __result); } template<typename _InputIterator1, typename _InputIterator2, typename _OutputIterator> inline _OutputIterator set_difference(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result) { ; ; ; ; return std::__set_difference(__first1, __last1, __first2, __last2, __result, __gnu_cxx::__ops::__iter_less_iter()); } template<typename _InputIterator1, typename _InputIterator2, typename _OutputIterator, typename _Compare> inline _OutputIterator set_difference(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) { ; ; ; ; return std::__set_difference(__first1, __last1, __first2, __last2, __result, __gnu_cxx::__ops::__iter_comp_iter(__comp)); } template<typename _InputIterator1, typename _InputIterator2, typename _OutputIterator, typename _Compare> _OutputIterator __set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) { while (__first1 != __last1 && __first2 != __last2) if (__comp(__first1, __first2)) { *__result = *__first1; ++__first1; ++__result; } else if (__comp(__first2, __first1)) { *__result = *__first2; ++__first2; ++__result; } else { ++__first1; ++__first2; } return std::copy(__first2, __last2, std::copy(__first1, __last1, __result)); } template<typename _InputIterator1, typename _InputIterator2, typename _OutputIterator> inline _OutputIterator set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result) { ; ; ; ; return std::__set_symmetric_difference(__first1, __last1, __first2, __last2, __result, __gnu_cxx::__ops::__iter_less_iter()); } template<typename _InputIterator1, typename _InputIterator2, typename _OutputIterator, typename _Compare> inline _OutputIterator set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) { ; ; ; ; return std::__set_symmetric_difference(__first1, __last1, __first2, __last2, __result, __gnu_cxx::__ops::__iter_comp_iter(__comp)); } template<typename _ForwardIterator, typename _Compare> constexpr _ForwardIterator __min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) { if (__first == __last) return __first; _ForwardIterator __result = __first; while (++__first != __last) if (__comp(__first, __result)) __result = __first; return __result; } template<typename _ForwardIterator> constexpr _ForwardIterator inline min_element(_ForwardIterator __first, _ForwardIterator __last) { ; ; return std::__min_element(__first, __last, __gnu_cxx::__ops::__iter_less_iter()); } template<typename _ForwardIterator, typename _Compare> constexpr inline _ForwardIterator min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) { ; ; return std::__min_element(__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp)); } template<typename _ForwardIterator, typename _Compare> constexpr _ForwardIterator __max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) { if (__first == __last) return __first; _ForwardIterator __result = __first; while (++__first != __last) if (__comp(__result, __first)) __result = __first; return __result; } template<typename _ForwardIterator> constexpr inline _ForwardIterator max_element(_ForwardIterator __first, _ForwardIterator __last) { ; ; return std::__max_element(__first, __last, __gnu_cxx::__ops::__iter_less_iter()); } template<typename _ForwardIterator, typename _Compare> constexpr inline _ForwardIterator max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) { ; ; return std::__max_element(__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp)); } template<typename _InputIterator, typename _RandomAccessIterator, typename _Size, typename _UniformRandomBitGenerator> _RandomAccessIterator __sample(_InputIterator __first, _InputIterator __last, input_iterator_tag, _RandomAccessIterator __out, random_access_iterator_tag, _Size __n, _UniformRandomBitGenerator&& __g) { using __distrib_type = uniform_int_distribution<_Size>; using __param_type = typename __distrib_type::param_type; __distrib_type __d{}; _Size __sample_sz = 0; while (__first != __last && __sample_sz != __n) { __out[__sample_sz++] = *__first; ++__first; } for (auto __pop_sz = __sample_sz; __first != __last; ++__first, (void) ++__pop_sz) { const auto __k = __d(__g, __param_type{0, __pop_sz}); if (__k < __n) __out[__k] = *__first; } return __out + __sample_sz; } template<typename _ForwardIterator, typename _OutputIterator, typename _Cat, typename _Size, typename _UniformRandomBitGenerator> _OutputIterator __sample(_ForwardIterator __first, _ForwardIterator __last, forward_iterator_tag, _OutputIterator __out, _Cat, _Size __n, _UniformRandomBitGenerator&& __g) { using __distrib_type = uniform_int_distribution<_Size>; using __param_type = typename __distrib_type::param_type; using _USize = make_unsigned_t<_Size>; using _Gen = remove_reference_t<_UniformRandomBitGenerator>; using __uc_type = common_type_t<typename _Gen::result_type, _USize>; __distrib_type __d{}; _Size __unsampled_sz = std::distance(__first, __last); __n = std::min(__n, __unsampled_sz); const __uc_type __urngrange = __g.max() - __g.min(); if (__urngrange / __uc_type(__unsampled_sz) >= __uc_type(__unsampled_sz)) { while (__n != 0 && __unsampled_sz >= 2) { const pair<_Size, _Size> __p = __gen_two_uniform_ints(__unsampled_sz, __unsampled_sz - 1, __g); --__unsampled_sz; if (__p.first < __n) { *__out++ = *__first; --__n; } ++__first; if (__n == 0) break; --__unsampled_sz; if (__p.second < __n) { *__out++ = *__first; --__n; } ++__first; } } for (; __n != 0; ++__first) if (__d(__g, __param_type{0, --__unsampled_sz}) < __n) { *__out++ = *__first; --__n; } return __out; } } namespace std __attribute__ ((__visibility__ ("default"))) { class bad_function_call : public std::exception { public: virtual ~bad_function_call() noexcept; const char* what() const noexcept; }; template<typename _Tp> struct __is_location_invariant : is_trivially_copyable<_Tp>::type { }; class _Undefined_class; union _Nocopy_types { void* _M_object; const void* _M_const_object; void (*_M_function_pointer)(); void (_Undefined_class::*_M_member_pointer)(); }; union [[gnu::may_alias]] _Any_data { void* _M_access() { return &_M_pod_data[0]; } const void* _M_access() const { return &_M_pod_data[0]; } template<typename _Tp> _Tp& _M_access() { return *static_cast<_Tp*>(_M_access()); } template<typename _Tp> const _Tp& _M_access() const { return *static_cast<const _Tp*>(_M_access()); } _Nocopy_types _M_unused; char _M_pod_data[sizeof(_Nocopy_types)]; }; enum _Manager_operation { __get_type_info, __get_functor_ptr, __clone_functor, __destroy_functor }; template<typename _Signature> class function; class _Function_base { public: static const size_t _M_max_size = sizeof(_Nocopy_types); static const size_t _M_max_align = __alignof__(_Nocopy_types); template<typename _Functor> class _Base_manager { protected: static const bool __stored_locally = (__is_location_invariant<_Functor>::value && sizeof(_Functor) <= _M_max_size && __alignof__(_Functor) <= _M_max_align && (_M_max_align % __alignof__(_Functor) == 0)); typedef integral_constant<bool, __stored_locally> _Local_storage; static _Functor* _M_get_pointer(const _Any_data& __source) { if (__stored_locally) { const _Functor& __f = __source._M_access<_Functor>(); return const_cast<_Functor*>(std::__addressof(__f)); } else return __source._M_access<_Functor*>(); } static void _M_clone(_Any_data& __dest, const _Any_data& __source, true_type) { ::new (__dest._M_access()) _Functor(__source._M_access<_Functor>()); } static void _M_clone(_Any_data& __dest, const _Any_data& __source, false_type) { __dest._M_access<_Functor*>() = new _Functor(*__source._M_access<const _Functor*>()); } static void _M_destroy(_Any_data& __victim, true_type) { __victim._M_access<_Functor>().~_Functor(); } static void _M_destroy(_Any_data& __victim, false_type) { delete __victim._M_access<_Functor*>(); } public: static bool _M_manager(_Any_data& __dest, const _Any_data& __source, _Manager_operation __op) { switch (__op) { case __get_type_info: __dest._M_access<const type_info*>() = &typeid(_Functor); break; case __get_functor_ptr: __dest._M_access<_Functor*>() = _M_get_pointer(__source); break; case __clone_functor: _M_clone(__dest, __source, _Local_storage()); break; case __destroy_functor: _M_destroy(__dest, _Local_storage()); break; } return false; } static void _M_init_functor(_Any_data& __functor, _Functor&& __f) { _M_init_functor(__functor, std::move(__f), _Local_storage()); } template<typename _Signature> static bool _M_not_empty_function(const function<_Signature>& __f) { return static_cast<bool>(__f); } template<typename _Tp> static bool _M_not_empty_function(_Tp* __fp) { return __fp != nullptr; } template<typename _Class, typename _Tp> static bool _M_not_empty_function(_Tp _Class::* __mp) { return __mp != nullptr; } template<typename _Tp> static bool _M_not_empty_function(const _Tp&) { return true; } private: static void _M_init_functor(_Any_data& __functor, _Functor&& __f, true_type) { ::new (__functor._M_access()) _Functor(std::move(__f)); } static void _M_init_functor(_Any_data& __functor, _Functor&& __f, false_type) { __functor._M_access<_Functor*>() = new _Functor(std::move(__f)); } }; _Function_base() : _M_manager(nullptr) { } ~_Function_base() { if (_M_manager) _M_manager(_M_functor, _M_functor, __destroy_functor); } bool _M_empty() const { return !_M_manager; } typedef bool (*_Manager_type)(_Any_data&, const _Any_data&, _Manager_operation); _Any_data _M_functor; _Manager_type _M_manager; }; template<typename _Signature, typename _Functor> class _Function_handler; template<typename _Res, typename _Functor, typename... _ArgTypes> class _Function_handler<_Res(_ArgTypes...), _Functor> : public _Function_base::_Base_manager<_Functor> { typedef _Function_base::_Base_manager<_Functor> _Base; public: static bool _M_manager(_Any_data& __dest, const _Any_data& __source, _Manager_operation __op) { switch (__op) { case __get_type_info: __dest._M_access<const type_info*>() = &typeid(_Functor); break; case __get_functor_ptr: __dest._M_access<_Functor*>() = _Base::_M_get_pointer(__source); break; default: _Base::_M_manager(__dest, __source, __op); } return false; } static _Res _M_invoke(const _Any_data& __functor, _ArgTypes&&... __args) { return std::__invoke_r<_Res>(*_Base::_M_get_pointer(__functor), std::forward<_ArgTypes>(__args)...); } }; template<typename _Res, typename... _ArgTypes> class function<_Res(_ArgTypes...)> : public _Maybe_unary_or_binary_function<_Res, _ArgTypes...>, private _Function_base { template<typename _Func, typename _Res2 = __invoke_result<_Func&, _ArgTypes...>> struct _Callable : __is_invocable_impl<_Res2, _Res>::type { }; template<typename _Tp> struct _Callable<function, _Tp> : false_type { }; template<typename _Cond, typename _Tp> using _Requires = typename enable_if<_Cond::value, _Tp>::type; public: typedef _Res result_type; function() noexcept : _Function_base() { } function(nullptr_t) noexcept : _Function_base() { } function(const function& __x); function(function&& __x) noexcept : _Function_base() { __x.swap(*this); } template<typename _Functor, typename = _Requires<__not_<is_same<_Functor, function>>, void>, typename = _Requires<_Callable<_Functor>, void>> function(_Functor); function& operator=(const function& __x) { function(__x).swap(*this); return *this; } function& operator=(function&& __x) noexcept { function(std::move(__x)).swap(*this); return *this; } function& operator=(nullptr_t) noexcept { if (_M_manager) { _M_manager(_M_functor, _M_functor, __destroy_functor); _M_manager = nullptr; _M_invoker = nullptr; } return *this; } template<typename _Functor> _Requires<_Callable<typename decay<_Functor>::type>, function&> operator=(_Functor&& __f) { function(std::forward<_Functor>(__f)).swap(*this); return *this; } template<typename _Functor> function& operator=(reference_wrapper<_Functor> __f) noexcept { function(__f).swap(*this); return *this; } void swap(function& __x) noexcept { std::swap(_M_functor, __x._M_functor); std::swap(_M_manager, __x._M_manager); std::swap(_M_invoker, __x._M_invoker); } explicit operator bool() const noexcept { return !_M_empty(); } _Res operator()(_ArgTypes... __args) const; const type_info& target_type() const noexcept; template<typename _Functor> _Functor* target() noexcept; template<typename _Functor> const _Functor* target() const noexcept; private: using _Invoker_type = _Res (*)(const _Any_data&, _ArgTypes&&...); _Invoker_type _M_invoker; }; template<typename _Res, typename... _ArgTypes> function<_Res(_ArgTypes...)>:: function(const function& __x) : _Function_base() { if (static_cast<bool>(__x)) { __x._M_manager(_M_functor, __x._M_functor, __clone_functor); _M_invoker = __x._M_invoker; _M_manager = __x._M_manager; } } template<typename _Res, typename... _ArgTypes> template<typename _Functor, typename, typename> function<_Res(_ArgTypes...)>:: function(_Functor __f) : _Function_base() { typedef _Function_handler<_Res(_ArgTypes...), _Functor> _My_handler; if (_My_handler::_M_not_empty_function(__f)) { _My_handler::_M_init_functor(_M_functor, std::move(__f)); _M_invoker = &_My_handler::_M_invoke; _M_manager = &_My_handler::_M_manager; } } template<typename _Res, typename... _ArgTypes> _Res function<_Res(_ArgTypes...)>:: operator()(_ArgTypes... __args) const { if (_M_empty()) __throw_bad_function_call(); return _M_invoker(_M_functor, std::forward<_ArgTypes>(__args)...); } template<typename _Res, typename... _ArgTypes> const type_info& function<_Res(_ArgTypes...)>:: target_type() const noexcept { if (_M_manager) { _Any_data __typeinfo_result; _M_manager(__typeinfo_result, _M_functor, __get_type_info); return *__typeinfo_result._M_access<const type_info*>(); } else return typeid(void); } template<typename _Res, typename... _ArgTypes> template<typename _Functor> _Functor* function<_Res(_ArgTypes...)>:: target() noexcept { const function* __const_this = this; const _Functor* __func = __const_this->template target<_Functor>(); return const_cast<_Functor*>(__func); } template<typename _Res, typename... _ArgTypes> template<typename _Functor> const _Functor* function<_Res(_ArgTypes...)>:: target() const noexcept { if (typeid(_Functor) == target_type() && _M_manager) { _Any_data __ptr; _M_manager(__ptr, _M_functor, __get_functor_ptr); return __ptr._M_access<const _Functor*>(); } else return nullptr; } template<typename _Res, typename... _Args> inline bool operator==(const function<_Res(_Args...)>& __f, nullptr_t) noexcept { return !static_cast<bool>(__f); } template<typename _Res, typename... _Args> inline bool operator==(nullptr_t, const function<_Res(_Args...)>& __f) noexcept { return !static_cast<bool>(__f); } template<typename _Res, typename... _Args> inline bool operator!=(const function<_Res(_Args...)>& __f, nullptr_t) noexcept { return static_cast<bool>(__f); } template<typename _Res, typename... _Args> inline bool operator!=(nullptr_t, const function<_Res(_Args...)>& __f) noexcept { return static_cast<bool>(__f); } template<typename _Res, typename... _Args> inline void swap(function<_Res(_Args...)>& __x, function<_Res(_Args...)>& __y) noexcept { __x.swap(__y); } } namespace std __attribute__ ((__visibility__ ("default"))) { template<typename _MemFunPtr, bool __is_mem_fn = is_member_function_pointer<_MemFunPtr>::value> class _Mem_fn_base : public _Mem_fn_traits<_MemFunPtr>::__maybe_type { using _Traits = _Mem_fn_traits<_MemFunPtr>; using _Arity = typename _Traits::__arity; using _Varargs = typename _Traits::__vararg; template<typename _Func, typename... _BoundArgs> friend struct _Bind_check_arity; _MemFunPtr _M_pmf; public: using result_type = typename _Traits::__result_type; explicit constexpr _Mem_fn_base(_MemFunPtr __pmf) noexcept : _M_pmf(__pmf) { } template<typename... _Args> auto operator()(_Args&&... __args) const noexcept(noexcept( std::__invoke(_M_pmf, std::forward<_Args>(__args)...))) -> decltype(std::__invoke(_M_pmf, std::forward<_Args>(__args)...)) { return std::__invoke(_M_pmf, std::forward<_Args>(__args)...); } }; template<typename _MemObjPtr> class _Mem_fn_base<_MemObjPtr, false> { using _Arity = integral_constant<size_t, 0>; using _Varargs = false_type; template<typename _Func, typename... _BoundArgs> friend struct _Bind_check_arity; _MemObjPtr _M_pm; public: explicit constexpr _Mem_fn_base(_MemObjPtr __pm) noexcept : _M_pm(__pm) { } template<typename _Tp> auto operator()(_Tp&& __obj) const noexcept(noexcept(std::__invoke(_M_pm, std::forward<_Tp>(__obj)))) -> decltype(std::__invoke(_M_pm, std::forward<_Tp>(__obj))) { return std::__invoke(_M_pm, std::forward<_Tp>(__obj)); } }; template<typename _MemberPointer> struct _Mem_fn; template<typename _Res, typename _Class> struct _Mem_fn<_Res _Class::*> : _Mem_fn_base<_Res _Class::*> { using _Mem_fn_base<_Res _Class::*>::_Mem_fn_base; }; template<typename _Tp, typename _Class> inline _Mem_fn<_Tp _Class::*> mem_fn(_Tp _Class::* __pm) noexcept { return _Mem_fn<_Tp _Class::*>(__pm); } template<typename _Tp> struct is_bind_expression : public false_type { }; template<typename _Tp> struct is_placeholder : public integral_constant<int, 0> { }; template<int _Num> struct _Placeholder { }; namespace placeholders { extern const _Placeholder<1> _1; extern const _Placeholder<2> _2; extern const _Placeholder<3> _3; extern const _Placeholder<4> _4; extern const _Placeholder<5> _5; extern const _Placeholder<6> _6; extern const _Placeholder<7> _7; extern const _Placeholder<8> _8; extern const _Placeholder<9> _9; extern const _Placeholder<10> _10; extern const _Placeholder<11> _11; extern const _Placeholder<12> _12; extern const _Placeholder<13> _13; extern const _Placeholder<14> _14; extern const _Placeholder<15> _15; extern const _Placeholder<16> _16; extern const _Placeholder<17> _17; extern const _Placeholder<18> _18; extern const _Placeholder<19> _19; extern const _Placeholder<20> _20; extern const _Placeholder<21> _21; extern const _Placeholder<22> _22; extern const _Placeholder<23> _23; extern const _Placeholder<24> _24; extern const _Placeholder<25> _25; extern const _Placeholder<26> _26; extern const _Placeholder<27> _27; extern const _Placeholder<28> _28; extern const _Placeholder<29> _29; } template<int _Num> struct is_placeholder<_Placeholder<_Num> > : public integral_constant<int, _Num> { }; template<int _Num> struct is_placeholder<const _Placeholder<_Num> > : public integral_constant<int, _Num> { }; template<std::size_t __i, typename _Tuple> using _Safe_tuple_element_t = typename enable_if<(__i < tuple_size<_Tuple>::value), tuple_element<__i, _Tuple>>::type::type; template<typename _Arg, bool _IsBindExp = is_bind_expression<_Arg>::value, bool _IsPlaceholder = (is_placeholder<_Arg>::value > 0)> class _Mu; template<typename _Tp> class _Mu<reference_wrapper<_Tp>, false, false> { public: template<typename _CVRef, typename _Tuple> _Tp& operator()(_CVRef& __arg, _Tuple&) const volatile { return __arg.get(); } }; template<typename _Arg> class _Mu<_Arg, true, false> { public: template<typename _CVArg, typename... _Args> auto operator()(_CVArg& __arg, tuple<_Args...>& __tuple) const volatile -> decltype(__arg(declval<_Args>()...)) { typedef typename _Build_index_tuple<sizeof...(_Args)>::__type _Indexes; return this->__call(__arg, __tuple, _Indexes()); } private: template<typename _CVArg, typename... _Args, std::size_t... _Indexes> auto __call(_CVArg& __arg, tuple<_Args...>& __tuple, const _Index_tuple<_Indexes...>&) const volatile -> decltype(__arg(declval<_Args>()...)) { return __arg(std::get<_Indexes>(std::move(__tuple))...); } }; template<typename _Arg> class _Mu<_Arg, false, true> { public: template<typename _Tuple> _Safe_tuple_element_t<(is_placeholder<_Arg>::value - 1), _Tuple>&& operator()(const volatile _Arg&, _Tuple& __tuple) const volatile { return ::std::get<(is_placeholder<_Arg>::value - 1)>(std::move(__tuple)); } }; template<typename _Arg> class _Mu<_Arg, false, false> { public: template<typename _CVArg, typename _Tuple> _CVArg&& operator()(_CVArg&& __arg, _Tuple&) const volatile { return std::forward<_CVArg>(__arg); } }; template<std::size_t _Ind, typename... _Tp> inline auto __volget(volatile tuple<_Tp...>& __tuple) -> __tuple_element_t<_Ind, tuple<_Tp...>> volatile& { return std::get<_Ind>(const_cast<tuple<_Tp...>&>(__tuple)); } template<std::size_t _Ind, typename... _Tp> inline auto __volget(const volatile tuple<_Tp...>& __tuple) -> __tuple_element_t<_Ind, tuple<_Tp...>> const volatile& { return std::get<_Ind>(const_cast<const tuple<_Tp...>&>(__tuple)); } template<typename _Signature> struct _Bind; template<typename _Functor, typename... _Bound_args> class _Bind<_Functor(_Bound_args...)> : public _Weak_result_type<_Functor> { typedef typename _Build_index_tuple<sizeof...(_Bound_args)>::__type _Bound_indexes; _Functor _M_f; tuple<_Bound_args...> _M_bound_args; template<typename _Result, typename... _Args, std::size_t... _Indexes> _Result __call(tuple<_Args...>&& __args, _Index_tuple<_Indexes...>) { return std::__invoke(_M_f, _Mu<_Bound_args>()(std::get<_Indexes>(_M_bound_args), __args)... ); } template<typename _Result, typename... _Args, std::size_t... _Indexes> _Result __call_c(tuple<_Args...>&& __args, _Index_tuple<_Indexes...>) const { return std::__invoke(_M_f, _Mu<_Bound_args>()(std::get<_Indexes>(_M_bound_args), __args)... ); } template<typename _Result, typename... _Args, std::size_t... _Indexes> _Result __call_v(tuple<_Args...>&& __args, _Index_tuple<_Indexes...>) volatile { return std::__invoke(_M_f, _Mu<_Bound_args>()(__volget<_Indexes>(_M_bound_args), __args)... ); } template<typename _Result, typename... _Args, std::size_t... _Indexes> _Result __call_c_v(tuple<_Args...>&& __args, _Index_tuple<_Indexes...>) const volatile { return std::__invoke(_M_f, _Mu<_Bound_args>()(__volget<_Indexes>(_M_bound_args), __args)... ); } template<typename _BoundArg, typename _CallArgs> using _Mu_type = decltype( _Mu<typename remove_cv<_BoundArg>::type>()( std::declval<_BoundArg&>(), std::declval<_CallArgs&>()) ); template<typename _Fn, typename _CallArgs, typename... _BArgs> using _Res_type_impl = typename result_of< _Fn&(_Mu_type<_BArgs, _CallArgs>&&...) >::type; template<typename _CallArgs> using _Res_type = _Res_type_impl<_Functor, _CallArgs, _Bound_args...>; template<typename _CallArgs> using __dependent = typename enable_if<bool(tuple_size<_CallArgs>::value+1), _Functor>::type; template<typename _CallArgs, template<class> class __cv_quals> using _Res_type_cv = _Res_type_impl< typename __cv_quals<__dependent<_CallArgs>>::type, _CallArgs, typename __cv_quals<_Bound_args>::type...>; public: template<typename... _Args> explicit _Bind(const _Functor& __f, _Args&&... __args) : _M_f(__f), _M_bound_args(std::forward<_Args>(__args)...) { } template<typename... _Args> explicit _Bind(_Functor&& __f, _Args&&... __args) : _M_f(std::move(__f)), _M_bound_args(std::forward<_Args>(__args)...) { } _Bind(const _Bind&) = default; _Bind(_Bind&&) = default; template<typename... _Args, typename _Result = _Res_type<tuple<_Args...>>> _Result operator()(_Args&&... __args) { return this->__call<_Result>( std::forward_as_tuple(std::forward<_Args>(__args)...), _Bound_indexes()); } template<typename... _Args, typename _Result = _Res_type_cv<tuple<_Args...>, add_const>> _Result operator()(_Args&&... __args) const { return this->__call_c<_Result>( std::forward_as_tuple(std::forward<_Args>(__args)...), _Bound_indexes()); } template<typename... _Args, typename _Result = _Res_type_cv<tuple<_Args...>, add_volatile>> _Result operator()(_Args&&... __args) volatile { return this->__call_v<_Result>( std::forward_as_tuple(std::forward<_Args>(__args)...), _Bound_indexes()); } template<typename... _Args, typename _Result = _Res_type_cv<tuple<_Args...>, add_cv>> _Result operator()(_Args&&... __args) const volatile { return this->__call_c_v<_Result>( std::forward_as_tuple(std::forward<_Args>(__args)...), _Bound_indexes()); } }; template<typename _Result, typename _Signature> struct _Bind_result; template<typename _Result, typename _Functor, typename... _Bound_args> class _Bind_result<_Result, _Functor(_Bound_args...)> { typedef typename _Build_index_tuple<sizeof...(_Bound_args)>::__type _Bound_indexes; _Functor _M_f; tuple<_Bound_args...> _M_bound_args; template<typename _Res, typename... _Args, std::size_t... _Indexes> _Res __call(tuple<_Args...>&& __args, _Index_tuple<_Indexes...>) { return std::__invoke_r<_Res>(_M_f, _Mu<_Bound_args>() (std::get<_Indexes>(_M_bound_args), __args)...); } template<typename _Res, typename... _Args, std::size_t... _Indexes> _Res __call(tuple<_Args...>&& __args, _Index_tuple<_Indexes...>) const { return std::__invoke_r<_Res>(_M_f, _Mu<_Bound_args>() (std::get<_Indexes>(_M_bound_args), __args)...); } template<typename _Res, typename... _Args, std::size_t... _Indexes> _Res __call(tuple<_Args...>&& __args, _Index_tuple<_Indexes...>) volatile { return std::__invoke_r<_Res>(_M_f, _Mu<_Bound_args>() (__volget<_Indexes>(_M_bound_args), __args)...); } template<typename _Res, typename... _Args, std::size_t... _Indexes> _Res __call(tuple<_Args...>&& __args, _Index_tuple<_Indexes...>) const volatile { return std::__invoke_r<_Res>(_M_f, _Mu<_Bound_args>() (__volget<_Indexes>(_M_bound_args), __args)...); } public: typedef _Result result_type; template<typename... _Args> explicit _Bind_result(const _Functor& __f, _Args&&... __args) : _M_f(__f), _M_bound_args(std::forward<_Args>(__args)...) { } template<typename... _Args> explicit _Bind_result(_Functor&& __f, _Args&&... __args) : _M_f(std::move(__f)), _M_bound_args(std::forward<_Args>(__args)...) { } _Bind_result(const _Bind_result&) = default; _Bind_result(_Bind_result&&) = default; template<typename... _Args> result_type operator()(_Args&&... __args) { return this->__call<_Result>( std::forward_as_tuple(std::forward<_Args>(__args)...), _Bound_indexes()); } template<typename... _Args> result_type operator()(_Args&&... __args) const { return this->__call<_Result>( std::forward_as_tuple(std::forward<_Args>(__args)...), _Bound_indexes()); } template<typename... _Args> result_type operator()(_Args&&... __args) volatile { return this->__call<_Result>( std::forward_as_tuple(std::forward<_Args>(__args)...), _Bound_indexes()); } template<typename... _Args> result_type operator()(_Args&&... __args) const volatile { return this->__call<_Result>( std::forward_as_tuple(std::forward<_Args>(__args)...), _Bound_indexes()); } }; template<typename _Signature> struct is_bind_expression<_Bind<_Signature> > : public true_type { }; template<typename _Signature> struct is_bind_expression<const _Bind<_Signature> > : public true_type { }; template<typename _Signature> struct is_bind_expression<volatile _Bind<_Signature> > : public true_type { }; template<typename _Signature> struct is_bind_expression<const volatile _Bind<_Signature>> : public true_type { }; template<typename _Result, typename _Signature> struct is_bind_expression<_Bind_result<_Result, _Signature>> : public true_type { }; template<typename _Result, typename _Signature> struct is_bind_expression<const _Bind_result<_Result, _Signature>> : public true_type { }; template<typename _Result, typename _Signature> struct is_bind_expression<volatile _Bind_result<_Result, _Signature>> : public true_type { }; template<typename _Result, typename _Signature> struct is_bind_expression<const volatile _Bind_result<_Result, _Signature>> : public true_type { }; template<typename _Func, typename... _BoundArgs> struct _Bind_check_arity { }; template<typename _Ret, typename... _Args, typename... _BoundArgs> struct _Bind_check_arity<_Ret (*)(_Args...), _BoundArgs...> { static_assert(sizeof...(_BoundArgs) == sizeof...(_Args), "Wrong number of arguments for function"); }; template<typename _Ret, typename... _Args, typename... _BoundArgs> struct _Bind_check_arity<_Ret (*)(_Args......), _BoundArgs...> { static_assert(sizeof...(_BoundArgs) >= sizeof...(_Args), "Wrong number of arguments for function"); }; template<typename _Tp, typename _Class, typename... _BoundArgs> struct _Bind_check_arity<_Tp _Class::*, _BoundArgs...> { using _Arity = typename _Mem_fn<_Tp _Class::*>::_Arity; using _Varargs = typename _Mem_fn<_Tp _Class::*>::_Varargs; static_assert(_Varargs::value ? sizeof...(_BoundArgs) >= _Arity::value + 1 : sizeof...(_BoundArgs) == _Arity::value + 1, "Wrong number of arguments for pointer-to-member"); }; template<typename _Tp, typename _Tp2 = typename decay<_Tp>::type> using __is_socketlike = __or_<is_integral<_Tp2>, is_enum<_Tp2>>; template<bool _SocketLike, typename _Func, typename... _BoundArgs> struct _Bind_helper : _Bind_check_arity<typename decay<_Func>::type, _BoundArgs...> { typedef typename decay<_Func>::type __func_type; typedef _Bind<__func_type(typename decay<_BoundArgs>::type...)> type; }; template<typename _Func, typename... _BoundArgs> struct _Bind_helper<true, _Func, _BoundArgs...> { }; template<typename _Func, typename... _BoundArgs> inline typename _Bind_helper<__is_socketlike<_Func>::value, _Func, _BoundArgs...>::type bind(_Func&& __f, _BoundArgs&&... __args) { typedef _Bind_helper<false, _Func, _BoundArgs...> __helper_type; return typename __helper_type::type(std::forward<_Func>(__f), std::forward<_BoundArgs>(__args)...); } template<typename _Result, typename _Func, typename... _BoundArgs> struct _Bindres_helper : _Bind_check_arity<typename decay<_Func>::type, _BoundArgs...> { typedef typename decay<_Func>::type __functor_type; typedef _Bind_result<_Result, __functor_type(typename decay<_BoundArgs>::type...)> type; }; template<typename _Result, typename _Func, typename... _BoundArgs> inline typename _Bindres_helper<_Result, _Func, _BoundArgs...>::type bind(_Func&& __f, _BoundArgs&&... __args) { typedef _Bindres_helper<_Result, _Func, _BoundArgs...> __helper_type; return typename __helper_type::type(std::forward<_Func>(__f), std::forward<_BoundArgs>(__args)...); } template<typename _Fn> class _Not_fn { template<typename _Fn2, typename... _Args> using __inv_res_t = typename __invoke_result<_Fn2, _Args...>::type; template<typename _Tp> static decltype(!std::declval<_Tp>()) _S_not() noexcept(noexcept(!std::declval<_Tp>())); public: template<typename _Fn2> constexpr _Not_fn(_Fn2&& __fn, int) : _M_fn(std::forward<_Fn2>(__fn)) { } _Not_fn(const _Not_fn& __fn) = default; _Not_fn(_Not_fn&& __fn) = default; ~_Not_fn() = default; template<typename... _Args> decltype(_S_not<__inv_res_t<_Fn &, _Args...>>()) operator()(_Args&&... __args) & noexcept(__is_nothrow_invocable<_Fn &, _Args...>::value && noexcept(_S_not<__inv_res_t<_Fn &, _Args...>>())) { return !std::__invoke(std::forward< _Fn & >(_M_fn), std::forward<_Args>(__args)...); } template<typename... _Args> decltype(_S_not<__inv_res_t<_Fn const &, _Args...>>()) operator()(_Args&&... __args) const & noexcept(__is_nothrow_invocable<_Fn const &, _Args...>::value && noexcept(_S_not<__inv_res_t<_Fn const &, _Args...>>())) { return !std::__invoke(std::forward< _Fn const & >(_M_fn), std::forward<_Args>(__args)...); } template<typename... _Args> decltype(_S_not<__inv_res_t<_Fn &&, _Args...>>()) operator()(_Args&&... __args) && noexcept(__is_nothrow_invocable<_Fn &&, _Args...>::value && noexcept(_S_not<__inv_res_t<_Fn &&, _Args...>>())) { return !std::__invoke(std::forward< _Fn && >(_M_fn), std::forward<_Args>(__args)...); } template<typename... _Args> decltype(_S_not<__inv_res_t<_Fn const &&, _Args...>>()) operator()(_Args&&... __args) const && noexcept(__is_nothrow_invocable<_Fn const &&, _Args...>::value && noexcept(_S_not<__inv_res_t<_Fn const &&, _Args...>>())) { return !std::__invoke(std::forward< _Fn const && >(_M_fn), std::forward<_Args>(__args)...); } private: _Fn _M_fn; }; template<typename _Tp, typename _Pred> struct __is_byte_like : false_type { }; template<typename _Tp> struct __is_byte_like<_Tp, equal_to<_Tp>> : __bool_constant<sizeof(_Tp) == 1 && is_integral<_Tp>::value> { }; template<typename _Tp> struct __is_byte_like<_Tp, equal_to<void>> : __bool_constant<sizeof(_Tp) == 1 && is_integral<_Tp>::value> { }; } namespace std __attribute__ ((__visibility__ ("default"))) { template<typename _Tp, typename _Alloc> struct _Vector_base { typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template rebind<_Tp>::other _Tp_alloc_type; typedef typename __gnu_cxx::__alloc_traits<_Tp_alloc_type>::pointer pointer; struct _Vector_impl_data { pointer _M_start; pointer _M_finish; pointer _M_end_of_storage; _Vector_impl_data() noexcept : _M_start(), _M_finish(), _M_end_of_storage() { } _Vector_impl_data(_Vector_impl_data&& __x) noexcept : _M_start(__x._M_start), _M_finish(__x._M_finish), _M_end_of_storage(__x._M_end_of_storage) { __x._M_start = __x._M_finish = __x._M_end_of_storage = pointer(); } void _M_copy_data(_Vector_impl_data const& __x) noexcept { _M_start = __x._M_start; _M_finish = __x._M_finish; _M_end_of_storage = __x._M_end_of_storage; } void _M_swap_data(_Vector_impl_data& __x) noexcept { _Vector_impl_data __tmp; __tmp._M_copy_data(*this); _M_copy_data(__x); __x._M_copy_data(__tmp); } }; struct _Vector_impl : public _Tp_alloc_type, public _Vector_impl_data { _Vector_impl() noexcept(is_nothrow_default_constructible<_Tp_alloc_type>::value) : _Tp_alloc_type() { } _Vector_impl(_Tp_alloc_type const& __a) noexcept : _Tp_alloc_type(__a) { } _Vector_impl(_Vector_impl&& __x) noexcept : _Tp_alloc_type(std::move(__x)), _Vector_impl_data(std::move(__x)) { } _Vector_impl(_Tp_alloc_type&& __a) noexcept : _Tp_alloc_type(std::move(__a)) { } _Vector_impl(_Tp_alloc_type&& __a, _Vector_impl&& __rv) noexcept : _Tp_alloc_type(std::move(__a)), _Vector_impl_data(std::move(__rv)) { } }; public: typedef _Alloc allocator_type; _Tp_alloc_type& _M_get_Tp_allocator() noexcept { return this->_M_impl; } const _Tp_alloc_type& _M_get_Tp_allocator() const noexcept { return this->_M_impl; } allocator_type get_allocator() const noexcept { return allocator_type(_M_get_Tp_allocator()); } _Vector_base() = default; _Vector_base(const allocator_type& __a) noexcept : _M_impl(__a) { } _Vector_base(size_t __n) : _M_impl() { _M_create_storage(__n); } _Vector_base(size_t __n, const allocator_type& __a) : _M_impl(__a) { _M_create_storage(__n); } _Vector_base(_Vector_base&&) = default; _Vector_base(_Tp_alloc_type&& __a) noexcept : _M_impl(std::move(__a)) { } _Vector_base(_Vector_base&& __x, const allocator_type& __a) : _M_impl(__a) { if (__x.get_allocator() == __a) this->_M_impl._M_swap_data(__x._M_impl); else { size_t __n = __x._M_impl._M_finish - __x._M_impl._M_start; _M_create_storage(__n); } } _Vector_base(const allocator_type& __a, _Vector_base&& __x) : _M_impl(_Tp_alloc_type(__a), std::move(__x._M_impl)) { } ~_Vector_base() noexcept { _M_deallocate(_M_impl._M_start, _M_impl._M_end_of_storage - _M_impl._M_start); } public: _Vector_impl _M_impl; pointer _M_allocate(size_t __n) { typedef __gnu_cxx::__alloc_traits<_Tp_alloc_type> _Tr; return __n != 0 ? _Tr::allocate(_M_impl, __n) : pointer(); } void _M_deallocate(pointer __p, size_t __n) { typedef __gnu_cxx::__alloc_traits<_Tp_alloc_type> _Tr; if (__p) _Tr::deallocate(_M_impl, __p, __n); } protected: void _M_create_storage(size_t __n) { this->_M_impl._M_start = this->_M_allocate(__n); this->_M_impl._M_finish = this->_M_impl._M_start; this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n; } }; template<typename _Tp, typename _Alloc = std::allocator<_Tp> > class vector : protected _Vector_base<_Tp, _Alloc> { static_assert(is_same<typename remove_cv<_Tp>::type, _Tp>::value, "std::vector must have a non-const, non-volatile value_type"); typedef _Vector_base<_Tp, _Alloc> _Base; typedef typename _Base::_Tp_alloc_type _Tp_alloc_type; typedef __gnu_cxx::__alloc_traits<_Tp_alloc_type> _Alloc_traits; public: typedef _Tp value_type; typedef typename _Base::pointer pointer; typedef typename _Alloc_traits::const_pointer const_pointer; typedef typename _Alloc_traits::reference reference; typedef typename _Alloc_traits::const_reference const_reference; typedef __gnu_cxx::__normal_iterator<pointer, vector> iterator; typedef __gnu_cxx::__normal_iterator<const_pointer, vector> const_iterator; typedef std::reverse_iterator<const_iterator> const_reverse_iterator; typedef std::reverse_iterator<iterator> reverse_iterator; typedef size_t size_type; typedef ptrdiff_t difference_type; typedef _Alloc allocator_type; private: static constexpr bool _S_nothrow_relocate(true_type) { return noexcept(std::__relocate_a(std::declval<pointer>(), std::declval<pointer>(), std::declval<pointer>(), std::declval<_Tp_alloc_type&>())); } static constexpr bool _S_nothrow_relocate(false_type) { return false; } static constexpr bool _S_use_relocate() { return _S_nothrow_relocate(__is_move_insertable<_Tp_alloc_type>{}); } static pointer _S_do_relocate(pointer __first, pointer __last, pointer __result, _Tp_alloc_type& __alloc, true_type) noexcept { return std::__relocate_a(__first, __last, __result, __alloc); } static pointer _S_do_relocate(pointer, pointer, pointer __result, _Tp_alloc_type&, false_type) noexcept { return __result; } static pointer _S_relocate(pointer __first, pointer __last, pointer __result, _Tp_alloc_type& __alloc) noexcept { using __do_it = __bool_constant<_S_use_relocate()>; return _S_do_relocate(__first, __last, __result, __alloc, __do_it{}); } protected: using _Base::_M_allocate; using _Base::_M_deallocate; using _Base::_M_impl; using _Base::_M_get_Tp_allocator; public: vector() = default; explicit vector(const allocator_type& __a) noexcept : _Base(__a) { } explicit vector(size_type __n, const allocator_type& __a = allocator_type()) : _Base(_S_check_init_len(__n, __a), __a) { _M_default_initialize(__n); } vector(size_type __n, const value_type& __value, const allocator_type& __a = allocator_type()) : _Base(_S_check_init_len(__n, __a), __a) { _M_fill_initialize(__n, __value); } vector(const vector& __x) : _Base(__x.size(), _Alloc_traits::_S_select_on_copy(__x._M_get_Tp_allocator())) { this->_M_impl._M_finish = std::__uninitialized_copy_a(__x.begin(), __x.end(), this->_M_impl._M_start, _M_get_Tp_allocator()); } vector(vector&&) noexcept = default; vector(const vector& __x, const allocator_type& __a) : _Base(__x.size(), __a) { this->_M_impl._M_finish = std::__uninitialized_copy_a(__x.begin(), __x.end(), this->_M_impl._M_start, _M_get_Tp_allocator()); } private: vector(vector&& __rv, const allocator_type& __m, true_type) noexcept : _Base(__m, std::move(__rv)) { } vector(vector&& __rv, const allocator_type& __m, false_type) : _Base(__m) { if (__rv.get_allocator() == __m) this->_M_impl._M_swap_data(__rv._M_impl); else if (!__rv.empty()) { this->_M_create_storage(__rv.size()); this->_M_impl._M_finish = std::__uninitialized_move_a(__rv.begin(), __rv.end(), this->_M_impl._M_start, _M_get_Tp_allocator()); __rv.clear(); } } public: vector(vector&& __rv, const allocator_type& __m) noexcept( noexcept( vector(std::declval<vector&&>(), std::declval<const allocator_type&>(), std::declval<typename _Alloc_traits::is_always_equal>())) ) : vector(std::move(__rv), __m, typename _Alloc_traits::is_always_equal{}) { } vector(initializer_list<value_type> __l, const allocator_type& __a = allocator_type()) : _Base(__a) { _M_range_initialize(__l.begin(), __l.end(), random_access_iterator_tag()); } template<typename _InputIterator, typename = std::_RequireInputIter<_InputIterator>> vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a = allocator_type()) : _Base(__a) { _M_range_initialize(__first, __last, std::__iterator_category(__first)); } ~vector() noexcept { std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish, _M_get_Tp_allocator()); ; } vector& operator=(const vector& __x); vector& operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move()) { constexpr bool __move_storage = _Alloc_traits::_S_propagate_on_move_assign() || _Alloc_traits::_S_always_equal(); _M_move_assign(std::move(__x), __bool_constant<__move_storage>()); return *this; } vector& operator=(initializer_list<value_type> __l) { this->_M_assign_aux(__l.begin(), __l.end(), random_access_iterator_tag()); return *this; } void assign(size_type __n, const value_type& __val) { _M_fill_assign(__n, __val); } template<typename _InputIterator, typename = std::_RequireInputIter<_InputIterator>> void assign(_InputIterator __first, _InputIterator __last) { _M_assign_dispatch(__first, __last, __false_type()); } void assign(initializer_list<value_type> __l) { this->_M_assign_aux(__l.begin(), __l.end(), random_access_iterator_tag()); } using _Base::get_allocator; iterator begin() noexcept { return iterator(this->_M_impl._M_start); } const_iterator begin() const noexcept { return const_iterator(this->_M_impl._M_start); } iterator end() noexcept { return iterator(this->_M_impl._M_finish); } const_iterator end() const noexcept { return const_iterator(this->_M_impl._M_finish); } reverse_iterator rbegin() noexcept { return reverse_iterator(end()); } const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); } reverse_iterator rend() noexcept { return reverse_iterator(begin()); } const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); } const_iterator cbegin() const noexcept { return const_iterator(this->_M_impl._M_start); } const_iterator cend() const noexcept { return const_iterator(this->_M_impl._M_finish); } const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(end()); } const_reverse_iterator crend() const noexcept { return const_reverse_iterator(begin()); } size_type size() const noexcept { return size_type(this->_M_impl._M_finish - this->_M_impl._M_start); } size_type max_size() const noexcept { return _S_max_size(_M_get_Tp_allocator()); } void resize(size_type __new_size) { if (__new_size > size()) _M_default_append(__new_size - size()); else if (__new_size < size()) _M_erase_at_end(this->_M_impl._M_start + __new_size); } void resize(size_type __new_size, const value_type& __x) { if (__new_size > size()) _M_fill_insert(end(), __new_size - size(), __x); else if (__new_size < size()) _M_erase_at_end(this->_M_impl._M_start + __new_size); } void shrink_to_fit() { _M_shrink_to_fit(); } size_type capacity() const noexcept { return size_type(this->_M_impl._M_end_of_storage - this->_M_impl._M_start); } bool empty() const noexcept { return begin() == end(); } void reserve(size_type __n); reference operator[](size_type __n) noexcept { ; return *(this->_M_impl._M_start + __n); } const_reference operator[](size_type __n) const noexcept { ; return *(this->_M_impl._M_start + __n); } protected: void _M_range_check(size_type __n) const { if (__n >= this->size()) __throw_out_of_range_fmt(("vector::_M_range_check: __n " "(which is %zu) >= this->size() " "(which is %zu)") , __n, this->size()); } public: reference at(size_type __n) { _M_range_check(__n); return (*this)[__n]; } const_reference at(size_type __n) const { _M_range_check(__n); return (*this)[__n]; } reference front() noexcept { ; return *begin(); } const_reference front() const noexcept { ; return *begin(); } reference back() noexcept { ; return *(end() - 1); } const_reference back() const noexcept { ; return *(end() - 1); } _Tp* data() noexcept { return _M_data_ptr(this->_M_impl._M_start); } const _Tp* data() const noexcept { return _M_data_ptr(this->_M_impl._M_start); } void push_back(const value_type& __x) { if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage) { ; _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish, __x); ++this->_M_impl._M_finish; ; } else _M_realloc_insert(end(), __x); } void push_back(value_type&& __x) { emplace_back(std::move(__x)); } template<typename... _Args> void emplace_back(_Args&&... __args); void pop_back() noexcept { ; --this->_M_impl._M_finish; _Alloc_traits::destroy(this->_M_impl, this->_M_impl._M_finish); ; } template<typename... _Args> iterator emplace(const_iterator __position, _Args&&... __args) { return _M_emplace_aux(__position, std::forward<_Args>(__args)...); } iterator insert(const_iterator __position, const value_type& __x); iterator insert(const_iterator __position, value_type&& __x) { return _M_insert_rval(__position, std::move(__x)); } iterator insert(const_iterator __position, initializer_list<value_type> __l) { auto __offset = __position - cbegin(); _M_range_insert(begin() + __offset, __l.begin(), __l.end(), std::random_access_iterator_tag()); return begin() + __offset; } iterator insert(const_iterator __position, size_type __n, const value_type& __x) { difference_type __offset = __position - cbegin(); _M_fill_insert(begin() + __offset, __n, __x); return begin() + __offset; } template<typename _InputIterator, typename = std::_RequireInputIter<_InputIterator>> iterator insert(const_iterator __position, _InputIterator __first, _InputIterator __last) { difference_type __offset = __position - cbegin(); _M_insert_dispatch(begin() + __offset, __first, __last, __false_type()); return begin() + __offset; } iterator erase(const_iterator __position) { return _M_erase(begin() + (__position - cbegin())); } iterator erase(const_iterator __first, const_iterator __last) { const auto __beg = begin(); const auto __cbeg = cbegin(); return _M_erase(__beg + (__first - __cbeg), __beg + (__last - __cbeg)); } void swap(vector& __x) noexcept { ; this->_M_impl._M_swap_data(__x._M_impl); _Alloc_traits::_S_on_swap(_M_get_Tp_allocator(), __x._M_get_Tp_allocator()); } void clear() noexcept { _M_erase_at_end(this->_M_impl._M_start); } protected: template<typename _ForwardIterator> pointer _M_allocate_and_copy(size_type __n, _ForwardIterator __first, _ForwardIterator __last) { pointer __result = this->_M_allocate(__n); try { std::__uninitialized_copy_a(__first, __last, __result, _M_get_Tp_allocator()); return __result; } catch(...) { _M_deallocate(__result, __n); throw; } } template<typename _InputIterator> void _M_range_initialize(_InputIterator __first, _InputIterator __last, std::input_iterator_tag) { try { for (; __first != __last; ++__first) emplace_back(*__first); } catch(...) { clear(); throw; } } template<typename _ForwardIterator> void _M_range_initialize(_ForwardIterator __first, _ForwardIterator __last, std::forward_iterator_tag) { const size_type __n = std::distance(__first, __last); this->_M_impl._M_start = this->_M_allocate(_S_check_init_len(__n, _M_get_Tp_allocator())); this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n; this->_M_impl._M_finish = std::__uninitialized_copy_a(__first, __last, this->_M_impl._M_start, _M_get_Tp_allocator()); } void _M_fill_initialize(size_type __n, const value_type& __value) { this->_M_impl._M_finish = std::__uninitialized_fill_n_a(this->_M_impl._M_start, __n, __value, _M_get_Tp_allocator()); } void _M_default_initialize(size_type __n) { this->_M_impl._M_finish = std::__uninitialized_default_n_a(this->_M_impl._M_start, __n, _M_get_Tp_allocator()); } template<typename _Integer> void _M_assign_dispatch(_Integer __n, _Integer __val, __true_type) { _M_fill_assign(__n, __val); } template<typename _InputIterator> void _M_assign_dispatch(_InputIterator __first, _InputIterator __last, __false_type) { _M_assign_aux(__first, __last, std::__iterator_category(__first)); } template<typename _InputIterator> void _M_assign_aux(_InputIterator __first, _InputIterator __last, std::input_iterator_tag); template<typename _ForwardIterator> void _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last, std::forward_iterator_tag); void _M_fill_assign(size_type __n, const value_type& __val); template<typename _Integer> void _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __val, __true_type) { _M_fill_insert(__pos, __n, __val); } template<typename _InputIterator> void _M_insert_dispatch(iterator __pos, _InputIterator __first, _InputIterator __last, __false_type) { _M_range_insert(__pos, __first, __last, std::__iterator_category(__first)); } template<typename _InputIterator> void _M_range_insert(iterator __pos, _InputIterator __first, _InputIterator __last, std::input_iterator_tag); template<typename _ForwardIterator> void _M_range_insert(iterator __pos, _ForwardIterator __first, _ForwardIterator __last, std::forward_iterator_tag); void _M_fill_insert(iterator __pos, size_type __n, const value_type& __x); void _M_default_append(size_type __n); bool _M_shrink_to_fit(); struct _Temporary_value { template<typename... _Args> explicit _Temporary_value(vector* __vec, _Args&&... __args) : _M_this(__vec) { _Alloc_traits::construct(_M_this->_M_impl, _M_ptr(), std::forward<_Args>(__args)...); } ~_Temporary_value() { _Alloc_traits::destroy(_M_this->_M_impl, _M_ptr()); } value_type& _M_val() { return *_M_ptr(); } private: _Tp* _M_ptr() { return reinterpret_cast<_Tp*>(&__buf); } vector* _M_this; typename aligned_storage<sizeof(_Tp), alignof(_Tp)>::type __buf; }; template<typename _Arg> void _M_insert_aux(iterator __position, _Arg&& __arg); template<typename... _Args> void _M_realloc_insert(iterator __position, _Args&&... __args); iterator _M_insert_rval(const_iterator __position, value_type&& __v); template<typename... _Args> iterator _M_emplace_aux(const_iterator __position, _Args&&... __args); iterator _M_emplace_aux(const_iterator __position, value_type&& __v) { return _M_insert_rval(__position, std::move(__v)); } size_type _M_check_len(size_type __n, const char* __s) const { if (max_size() - size() < __n) __throw_length_error((__s)); const size_type __len = size() + (std::max)(size(), __n); return (__len < size() || __len > max_size()) ? max_size() : __len; } static size_type _S_check_init_len(size_type __n, const allocator_type& __a) { if (__n > _S_max_size(_Tp_alloc_type(__a))) __throw_length_error( ("cannot create std::vector larger than max_size()")); return __n; } static size_type _S_max_size(const _Tp_alloc_type& __a) noexcept { const size_t __diffmax = __gnu_cxx::__numeric_traits<ptrdiff_t>::__max / sizeof(_Tp); const size_t __allocmax = _Alloc_traits::max_size(__a); return (std::min)(__diffmax, __allocmax); } void _M_erase_at_end(pointer __pos) noexcept { if (size_type __n = this->_M_impl._M_finish - __pos) { std::_Destroy(__pos, this->_M_impl._M_finish, _M_get_Tp_allocator()); this->_M_impl._M_finish = __pos; ; } } iterator _M_erase(iterator __position); iterator _M_erase(iterator __first, iterator __last); private: void _M_move_assign(vector&& __x, true_type) noexcept { vector __tmp(get_allocator()); this->_M_impl._M_swap_data(__x._M_impl); __tmp._M_impl._M_swap_data(__x._M_impl); std::__alloc_on_move(_M_get_Tp_allocator(), __x._M_get_Tp_allocator()); } void _M_move_assign(vector&& __x, false_type) { if (__x._M_get_Tp_allocator() == this->_M_get_Tp_allocator()) _M_move_assign(std::move(__x), true_type()); else { this->_M_assign_aux(std::make_move_iterator(__x.begin()), std::make_move_iterator(__x.end()), std::random_access_iterator_tag()); __x.clear(); } } template<typename _Up> _Up* _M_data_ptr(_Up* __ptr) const noexcept { return __ptr; } template<typename _Ptr> typename std::pointer_traits<_Ptr>::element_type* _M_data_ptr(_Ptr __ptr) const { return empty() ? nullptr : std::__to_address(__ptr); } }; template<typename _Tp, typename _Alloc> inline bool operator==(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y) { return (__x.size() == __y.size() && std::equal(__x.begin(), __x.end(), __y.begin())); } template<typename _Tp, typename _Alloc> inline bool operator<(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y) { return std::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end()); } template<typename _Tp, typename _Alloc> inline bool operator!=(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y) { return !(__x == __y); } template<typename _Tp, typename _Alloc> inline bool operator>(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y) { return __y < __x; } template<typename _Tp, typename _Alloc> inline bool operator<=(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y) { return !(__y < __x); } template<typename _Tp, typename _Alloc> inline bool operator>=(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y) { return !(__x < __y); } template<typename _Tp, typename _Alloc> inline void swap(vector<_Tp, _Alloc>& __x, vector<_Tp, _Alloc>& __y) noexcept(noexcept(__x.swap(__y))) { __x.swap(__y); } } namespace std __attribute__ ((__visibility__ ("default"))) { typedef unsigned long _Bit_type; enum { _S_word_bit = int(8 * sizeof(_Bit_type)) }; struct _Bit_reference { _Bit_type * _M_p; _Bit_type _M_mask; _Bit_reference(_Bit_type * __x, _Bit_type __y) : _M_p(__x), _M_mask(__y) { } _Bit_reference() noexcept : _M_p(0), _M_mask(0) { } _Bit_reference(const _Bit_reference&) = default; operator bool() const noexcept { return !!(*_M_p & _M_mask); } _Bit_reference& operator=(bool __x) noexcept { if (__x) *_M_p |= _M_mask; else *_M_p &= ~_M_mask; return *this; } _Bit_reference& operator=(const _Bit_reference& __x) noexcept { return *this = bool(__x); } bool operator==(const _Bit_reference& __x) const { return bool(*this) == bool(__x); } bool operator<(const _Bit_reference& __x) const { return !bool(*this) && bool(__x); } void flip() noexcept { *_M_p ^= _M_mask; } }; inline void swap(_Bit_reference __x, _Bit_reference __y) noexcept { bool __tmp = __x; __x = __y; __y = __tmp; } inline void swap(_Bit_reference __x, bool& __y) noexcept { bool __tmp = __x; __x = __y; __y = __tmp; } inline void swap(bool& __x, _Bit_reference __y) noexcept { bool __tmp = __x; __x = __y; __y = __tmp; } struct _Bit_iterator_base : public std::iterator<std::random_access_iterator_tag, bool> { _Bit_type * _M_p; unsigned int _M_offset; _Bit_iterator_base(_Bit_type * __x, unsigned int __y) : _M_p(__x), _M_offset(__y) { } void _M_bump_up() { if (_M_offset++ == int(_S_word_bit) - 1) { _M_offset = 0; ++_M_p; } } void _M_bump_down() { if (_M_offset-- == 0) { _M_offset = int(_S_word_bit) - 1; --_M_p; } } void _M_incr(ptrdiff_t __i) { difference_type __n = __i + _M_offset; _M_p += __n / int(_S_word_bit); __n = __n % int(_S_word_bit); if (__n < 0) { __n += int(_S_word_bit); --_M_p; } _M_offset = static_cast<unsigned int>(__n); } friend bool operator==(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) { return __x._M_p == __y._M_p && __x._M_offset == __y._M_offset; } friend bool operator<(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) { return __x._M_p < __y._M_p || (__x._M_p == __y._M_p && __x._M_offset < __y._M_offset); } friend bool operator!=(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) { return !(__x == __y); } friend bool operator>(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) { return __y < __x; } friend bool operator<=(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) { return !(__y < __x); } friend bool operator>=(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) { return !(__x < __y); } friend ptrdiff_t operator-(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) { return (int(_S_word_bit) * (__x._M_p - __y._M_p) + __x._M_offset - __y._M_offset); } }; struct _Bit_iterator : public _Bit_iterator_base { typedef _Bit_reference reference; typedef _Bit_reference* pointer; typedef _Bit_iterator iterator; _Bit_iterator() : _Bit_iterator_base(0, 0) { } _Bit_iterator(_Bit_type * __x, unsigned int __y) : _Bit_iterator_base(__x, __y) { } iterator _M_const_cast() const { return *this; } reference operator*() const { return reference(_M_p, 1UL << _M_offset); } iterator& operator++() { _M_bump_up(); return *this; } iterator operator++(int) { iterator __tmp = *this; _M_bump_up(); return __tmp; } iterator& operator--() { _M_bump_down(); return *this; } iterator operator--(int) { iterator __tmp = *this; _M_bump_down(); return __tmp; } iterator& operator+=(difference_type __i) { _M_incr(__i); return *this; } iterator& operator-=(difference_type __i) { *this += -__i; return *this; } reference operator[](difference_type __i) const { return *(*this + __i); } friend iterator operator+(const iterator& __x, difference_type __n) { iterator __tmp = __x; __tmp += __n; return __tmp; } friend iterator operator+(difference_type __n, const iterator& __x) { return __x + __n; } friend iterator operator-(const iterator& __x, difference_type __n) { iterator __tmp = __x; __tmp -= __n; return __tmp; } }; struct _Bit_const_iterator : public _Bit_iterator_base { typedef bool reference; typedef bool const_reference; typedef const bool* pointer; typedef _Bit_const_iterator const_iterator; _Bit_const_iterator() : _Bit_iterator_base(0, 0) { } _Bit_const_iterator(_Bit_type * __x, unsigned int __y) : _Bit_iterator_base(__x, __y) { } _Bit_const_iterator(const _Bit_iterator& __x) : _Bit_iterator_base(__x._M_p, __x._M_offset) { } _Bit_iterator _M_const_cast() const { return _Bit_iterator(_M_p, _M_offset); } const_reference operator*() const { return _Bit_reference(_M_p, 1UL << _M_offset); } const_iterator& operator++() { _M_bump_up(); return *this; } const_iterator operator++(int) { const_iterator __tmp = *this; _M_bump_up(); return __tmp; } const_iterator& operator--() { _M_bump_down(); return *this; } const_iterator operator--(int) { const_iterator __tmp = *this; _M_bump_down(); return __tmp; } const_iterator& operator+=(difference_type __i) { _M_incr(__i); return *this; } const_iterator& operator-=(difference_type __i) { *this += -__i; return *this; } const_reference operator[](difference_type __i) const { return *(*this + __i); } friend const_iterator operator+(const const_iterator& __x, difference_type __n) { const_iterator __tmp = __x; __tmp += __n; return __tmp; } friend const_iterator operator-(const const_iterator& __x, difference_type __n) { const_iterator __tmp = __x; __tmp -= __n; return __tmp; } friend const_iterator operator+(difference_type __n, const const_iterator& __x) { return __x + __n; } }; inline void __fill_bvector(_Bit_type * __v, unsigned int __first, unsigned int __last, bool __x) { const _Bit_type __fmask = ~0ul << __first; const _Bit_type __lmask = ~0ul >> (_S_word_bit - __last); const _Bit_type __mask = __fmask & __lmask; if (__x) *__v |= __mask; else *__v &= ~__mask; } inline void fill(_Bit_iterator __first, _Bit_iterator __last, const bool& __x) { if (__first._M_p != __last._M_p) { _Bit_type* __first_p = __first._M_p; if (__first._M_offset != 0) __fill_bvector(__first_p++, __first._M_offset, _S_word_bit, __x); __builtin_memset(__first_p, __x ? ~0 : 0, (__last._M_p - __first_p) * sizeof(_Bit_type)); if (__last._M_offset != 0) __fill_bvector(__last._M_p, 0, __last._M_offset, __x); } else if (__first._M_offset != __last._M_offset) __fill_bvector(__first._M_p, __first._M_offset, __last._M_offset, __x); } template<typename _Alloc> struct _Bvector_base { typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template rebind<_Bit_type>::other _Bit_alloc_type; typedef typename __gnu_cxx::__alloc_traits<_Bit_alloc_type> _Bit_alloc_traits; typedef typename _Bit_alloc_traits::pointer _Bit_pointer; struct _Bvector_impl_data { _Bit_iterator _M_start; _Bit_iterator _M_finish; _Bit_pointer _M_end_of_storage; _Bvector_impl_data() noexcept : _M_start(), _M_finish(), _M_end_of_storage() { } _Bvector_impl_data(_Bvector_impl_data&& __x) noexcept : _M_start(__x._M_start), _M_finish(__x._M_finish) , _M_end_of_storage(__x._M_end_of_storage) { __x._M_reset(); } void _M_move_data(_Bvector_impl_data&& __x) noexcept { this->_M_start = __x._M_start; this->_M_finish = __x._M_finish; this->_M_end_of_storage = __x._M_end_of_storage; __x._M_reset(); } void _M_reset() noexcept { _M_start = _M_finish = _Bit_iterator(); _M_end_of_storage = _Bit_pointer(); } }; struct _Bvector_impl : public _Bit_alloc_type, public _Bvector_impl_data { public: _Bvector_impl() noexcept(is_nothrow_default_constructible<_Bit_alloc_type>::value) : _Bit_alloc_type() { } _Bvector_impl(const _Bit_alloc_type& __a) noexcept : _Bit_alloc_type(__a) { } _Bvector_impl(_Bvector_impl&&) = default; _Bit_type* _M_end_addr() const noexcept { if (this->_M_end_of_storage) return std::__addressof(this->_M_end_of_storage[-1]) + 1; return 0; } }; public: typedef _Alloc allocator_type; _Bit_alloc_type& _M_get_Bit_allocator() noexcept { return this->_M_impl; } const _Bit_alloc_type& _M_get_Bit_allocator() const noexcept { return this->_M_impl; } allocator_type get_allocator() const noexcept { return allocator_type(_M_get_Bit_allocator()); } _Bvector_base() = default; _Bvector_base(const allocator_type& __a) : _M_impl(__a) { } _Bvector_base(_Bvector_base&&) = default; ~_Bvector_base() { this->_M_deallocate(); } protected: _Bvector_impl _M_impl; _Bit_pointer _M_allocate(size_t __n) { return _Bit_alloc_traits::allocate(_M_impl, _S_nword(__n)); } void _M_deallocate() { if (_M_impl._M_start._M_p) { const size_t __n = _M_impl._M_end_addr() - _M_impl._M_start._M_p; _Bit_alloc_traits::deallocate(_M_impl, _M_impl._M_end_of_storage - __n, __n); _M_impl._M_reset(); } } void _M_move_data(_Bvector_base&& __x) noexcept { _M_impl._M_move_data(std::move(__x._M_impl)); } static size_t _S_nword(size_t __n) { return (__n + int(_S_word_bit) - 1) / int(_S_word_bit); } }; } namespace std __attribute__ ((__visibility__ ("default"))) { template<typename _Alloc> class vector<bool, _Alloc> : protected _Bvector_base<_Alloc> { typedef _Bvector_base<_Alloc> _Base; typedef typename _Base::_Bit_pointer _Bit_pointer; typedef typename _Base::_Bit_alloc_traits _Bit_alloc_traits; friend struct std::hash<vector>; public: typedef bool value_type; typedef size_t size_type; typedef ptrdiff_t difference_type; typedef _Bit_reference reference; typedef bool const_reference; typedef _Bit_reference* pointer; typedef const bool* const_pointer; typedef _Bit_iterator iterator; typedef _Bit_const_iterator const_iterator; typedef std::reverse_iterator<const_iterator> const_reverse_iterator; typedef std::reverse_iterator<iterator> reverse_iterator; typedef _Alloc allocator_type; allocator_type get_allocator() const { return _Base::get_allocator(); } protected: using _Base::_M_allocate; using _Base::_M_deallocate; using _Base::_S_nword; using _Base::_M_get_Bit_allocator; public: vector() = default; explicit vector(const allocator_type& __a) : _Base(__a) { } explicit vector(size_type __n, const allocator_type& __a = allocator_type()) : vector(__n, false, __a) { } vector(size_type __n, const bool& __value, const allocator_type& __a = allocator_type()) : _Base(__a) { _M_initialize(__n); _M_initialize_value(__value); } vector(const vector& __x) : _Base(_Bit_alloc_traits::_S_select_on_copy(__x._M_get_Bit_allocator())) { _M_initialize(__x.size()); _M_copy_aligned(__x.begin(), __x.end(), this->_M_impl._M_start); } vector(vector&&) = default; vector(vector&& __x, const allocator_type& __a) noexcept(_Bit_alloc_traits::_S_always_equal()) : _Base(__a) { if (__x.get_allocator() == __a) this->_M_move_data(std::move(__x)); else { _M_initialize(__x.size()); _M_copy_aligned(__x.begin(), __x.end(), begin()); __x.clear(); } } vector(const vector& __x, const allocator_type& __a) : _Base(__a) { _M_initialize(__x.size()); _M_copy_aligned(__x.begin(), __x.end(), this->_M_impl._M_start); } vector(initializer_list<bool> __l, const allocator_type& __a = allocator_type()) : _Base(__a) { _M_initialize_range(__l.begin(), __l.end(), random_access_iterator_tag()); } template<typename _InputIterator, typename = std::_RequireInputIter<_InputIterator>> vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a = allocator_type()) : _Base(__a) { _M_initialize_dispatch(__first, __last, __false_type()); } ~vector() noexcept { } vector& operator=(const vector& __x) { if (&__x == this) return *this; if (_Bit_alloc_traits::_S_propagate_on_copy_assign()) { if (this->_M_get_Bit_allocator() != __x._M_get_Bit_allocator()) { this->_M_deallocate(); std::__alloc_on_copy(_M_get_Bit_allocator(), __x._M_get_Bit_allocator()); _M_initialize(__x.size()); } else std::__alloc_on_copy(_M_get_Bit_allocator(), __x._M_get_Bit_allocator()); } if (__x.size() > capacity()) { this->_M_deallocate(); _M_initialize(__x.size()); } this->_M_impl._M_finish = _M_copy_aligned(__x.begin(), __x.end(), begin()); return *this; } vector& operator=(vector&& __x) noexcept(_Bit_alloc_traits::_S_nothrow_move()) { if (_Bit_alloc_traits::_S_propagate_on_move_assign() || this->_M_get_Bit_allocator() == __x._M_get_Bit_allocator()) { this->_M_deallocate(); this->_M_move_data(std::move(__x)); std::__alloc_on_move(_M_get_Bit_allocator(), __x._M_get_Bit_allocator()); } else { if (__x.size() > capacity()) { this->_M_deallocate(); _M_initialize(__x.size()); } this->_M_impl._M_finish = _M_copy_aligned(__x.begin(), __x.end(), begin()); __x.clear(); } return *this; } vector& operator=(initializer_list<bool> __l) { this->assign (__l.begin(), __l.end()); return *this; } void assign(size_type __n, const bool& __x) { _M_fill_assign(__n, __x); } template<typename _InputIterator, typename = std::_RequireInputIter<_InputIterator>> void assign(_InputIterator __first, _InputIterator __last) { _M_assign_aux(__first, __last, std::__iterator_category(__first)); } void assign(initializer_list<bool> __l) { _M_assign_aux(__l.begin(), __l.end(), random_access_iterator_tag()); } iterator begin() noexcept { return iterator(this->_M_impl._M_start._M_p, 0); } const_iterator begin() const noexcept { return const_iterator(this->_M_impl._M_start._M_p, 0); } iterator end() noexcept { return this->_M_impl._M_finish; } const_iterator end() const noexcept { return this->_M_impl._M_finish; } reverse_iterator rbegin() noexcept { return reverse_iterator(end()); } const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); } reverse_iterator rend() noexcept { return reverse_iterator(begin()); } const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); } const_iterator cbegin() const noexcept { return const_iterator(this->_M_impl._M_start._M_p, 0); } const_iterator cend() const noexcept { return this->_M_impl._M_finish; } const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(end()); } const_reverse_iterator crend() const noexcept { return const_reverse_iterator(begin()); } size_type size() const noexcept { return size_type(end() - begin()); } size_type max_size() const noexcept { const size_type __isize = __gnu_cxx::__numeric_traits<difference_type>::__max - int(_S_word_bit) + 1; const size_type __asize = _Bit_alloc_traits::max_size(_M_get_Bit_allocator()); return (__asize <= __isize / int(_S_word_bit) ? __asize * int(_S_word_bit) : __isize); } size_type capacity() const noexcept { return size_type(const_iterator(this->_M_impl._M_end_addr(), 0) - begin()); } bool empty() const noexcept { return begin() == end(); } reference operator[](size_type __n) { return *iterator(this->_M_impl._M_start._M_p + __n / int(_S_word_bit), __n % int(_S_word_bit)); } const_reference operator[](size_type __n) const { return *const_iterator(this->_M_impl._M_start._M_p + __n / int(_S_word_bit), __n % int(_S_word_bit)); } protected: void _M_range_check(size_type __n) const { if (__n >= this->size()) __throw_out_of_range_fmt(("vector<bool>::_M_range_check: __n " "(which is %zu) >= this->size() " "(which is %zu)") , __n, this->size()); } public: reference at(size_type __n) { _M_range_check(__n); return (*this)[__n]; } const_reference at(size_type __n) const { _M_range_check(__n); return (*this)[__n]; } void reserve(size_type __n) { if (__n > max_size()) __throw_length_error(("vector::reserve")); if (capacity() < __n) _M_reallocate(__n); } reference front() { return *begin(); } const_reference front() const { return *begin(); } reference back() { return *(end() - 1); } const_reference back() const { return *(end() - 1); } void data() noexcept { } void push_back(bool __x) { if (this->_M_impl._M_finish._M_p != this->_M_impl._M_end_addr()) *this->_M_impl._M_finish++ = __x; else _M_insert_aux(end(), __x); } void swap(vector& __x) noexcept { std::swap(this->_M_impl._M_start, __x._M_impl._M_start); std::swap(this->_M_impl._M_finish, __x._M_impl._M_finish); std::swap(this->_M_impl._M_end_of_storage, __x._M_impl._M_end_of_storage); _Bit_alloc_traits::_S_on_swap(_M_get_Bit_allocator(), __x._M_get_Bit_allocator()); } static void swap(reference __x, reference __y) noexcept { bool __tmp = __x; __x = __y; __y = __tmp; } iterator insert(const_iterator __position, const bool& __x = bool()) { const difference_type __n = __position - begin(); if (this->_M_impl._M_finish._M_p != this->_M_impl._M_end_addr() && __position == end()) *this->_M_impl._M_finish++ = __x; else _M_insert_aux(__position._M_const_cast(), __x); return begin() + __n; } template<typename _InputIterator, typename = std::_RequireInputIter<_InputIterator>> iterator insert(const_iterator __position, _InputIterator __first, _InputIterator __last) { difference_type __offset = __position - cbegin(); _M_insert_dispatch(__position._M_const_cast(), __first, __last, __false_type()); return begin() + __offset; } iterator insert(const_iterator __position, size_type __n, const bool& __x) { difference_type __offset = __position - cbegin(); _M_fill_insert(__position._M_const_cast(), __n, __x); return begin() + __offset; } iterator insert(const_iterator __p, initializer_list<bool> __l) { return this->insert(__p, __l.begin(), __l.end()); } void pop_back() { --this->_M_impl._M_finish; } iterator erase(const_iterator __position) { return _M_erase(__position._M_const_cast()); } iterator erase(const_iterator __first, const_iterator __last) { return _M_erase(__first._M_const_cast(), __last._M_const_cast()); } void resize(size_type __new_size, bool __x = bool()) { if (__new_size < size()) _M_erase_at_end(begin() + difference_type(__new_size)); else insert(end(), __new_size - size(), __x); } void shrink_to_fit() { _M_shrink_to_fit(); } void flip() noexcept { _Bit_type * const __end = this->_M_impl._M_end_addr(); for (_Bit_type * __p = this->_M_impl._M_start._M_p; __p != __end; ++__p) *__p = ~*__p; } void clear() noexcept { _M_erase_at_end(begin()); } template<typename... _Args> void emplace_back(_Args&&... __args) { push_back(bool(__args...)); } template<typename... _Args> iterator emplace(const_iterator __pos, _Args&&... __args) { return insert(__pos, bool(__args...)); } protected: iterator _M_copy_aligned(const_iterator __first, const_iterator __last, iterator __result) { _Bit_type* __q = std::copy(__first._M_p, __last._M_p, __result._M_p); return std::copy(const_iterator(__last._M_p, 0), __last, iterator(__q, 0)); } void _M_initialize(size_type __n) { if (__n) { _Bit_pointer __q = this->_M_allocate(__n); this->_M_impl._M_end_of_storage = __q + _S_nword(__n); this->_M_impl._M_start = iterator(std::__addressof(*__q), 0); } else { this->_M_impl._M_end_of_storage = _Bit_pointer(); this->_M_impl._M_start = iterator(0, 0); } this->_M_impl._M_finish = this->_M_impl._M_start + difference_type(__n); } void _M_initialize_value(bool __x) { if (_Bit_type* __p = this->_M_impl._M_start._M_p) __builtin_memset(__p, __x ? ~0 : 0, (this->_M_impl._M_end_addr() - __p) * sizeof(_Bit_type)); } void _M_reallocate(size_type __n); bool _M_shrink_to_fit(); template<typename _Integer> void _M_initialize_dispatch(_Integer __n, _Integer __x, __true_type) { _M_initialize(static_cast<size_type>(__n)); _M_initialize_value(__x); } template<typename _InputIterator> void _M_initialize_dispatch(_InputIterator __first, _InputIterator __last, __false_type) { _M_initialize_range(__first, __last, std::__iterator_category(__first)); } template<typename _InputIterator> void _M_initialize_range(_InputIterator __first, _InputIterator __last, std::input_iterator_tag) { for (; __first != __last; ++__first) push_back(*__first); } template<typename _ForwardIterator> void _M_initialize_range(_ForwardIterator __first, _ForwardIterator __last, std::forward_iterator_tag) { const size_type __n = std::distance(__first, __last); _M_initialize(__n); std::copy(__first, __last, this->_M_impl._M_start); } void _M_fill_assign(size_t __n, bool __x) { if (__n > size()) { _M_initialize_value(__x); insert(end(), __n - size(), __x); } else { _M_erase_at_end(begin() + __n); _M_initialize_value(__x); } } template<typename _InputIterator> void _M_assign_aux(_InputIterator __first, _InputIterator __last, std::input_iterator_tag) { iterator __cur = begin(); for (; __first != __last && __cur != end(); ++__cur, (void)++__first) *__cur = *__first; if (__first == __last) _M_erase_at_end(__cur); else insert(end(), __first, __last); } template<typename _ForwardIterator> void _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last, std::forward_iterator_tag) { const size_type __len = std::distance(__first, __last); if (__len < size()) _M_erase_at_end(std::copy(__first, __last, begin())); else { _ForwardIterator __mid = __first; std::advance(__mid, size()); std::copy(__first, __mid, begin()); insert(end(), __mid, __last); } } template<typename _Integer> void _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __x, __true_type) { _M_fill_insert(__pos, __n, __x); } template<typename _InputIterator> void _M_insert_dispatch(iterator __pos, _InputIterator __first, _InputIterator __last, __false_type) { _M_insert_range(__pos, __first, __last, std::__iterator_category(__first)); } void _M_fill_insert(iterator __position, size_type __n, bool __x); template<typename _InputIterator> void _M_insert_range(iterator __pos, _InputIterator __first, _InputIterator __last, std::input_iterator_tag) { for (; __first != __last; ++__first) { __pos = insert(__pos, *__first); ++__pos; } } template<typename _ForwardIterator> void _M_insert_range(iterator __position, _ForwardIterator __first, _ForwardIterator __last, std::forward_iterator_tag); void _M_insert_aux(iterator __position, bool __x); size_type _M_check_len(size_type __n, const char* __s) const { if (max_size() - size() < __n) __throw_length_error((__s)); const size_type __len = size() + std::max(size(), __n); return (__len < size() || __len > max_size()) ? max_size() : __len; } void _M_erase_at_end(iterator __pos) { this->_M_impl._M_finish = __pos; } iterator _M_erase(iterator __pos); iterator _M_erase(iterator __first, iterator __last); }; } namespace std __attribute__ ((__visibility__ ("default"))) { template<typename _Alloc> struct hash<std::vector<bool, _Alloc>> : public __hash_base<size_t, std::vector<bool, _Alloc>> { size_t operator()(const std::vector<bool, _Alloc>&) const noexcept; }; } namespace std __attribute__ ((__visibility__ ("default"))) { template<typename _Tp, typename _Alloc> void vector<_Tp, _Alloc>:: reserve(size_type __n) { if (__n > this->max_size()) __throw_length_error(("vector::reserve")); if (this->capacity() < __n) { const size_type __old_size = size(); pointer __tmp; if (_S_use_relocate()) { __tmp = this->_M_allocate(__n); _S_relocate(this->_M_impl._M_start, this->_M_impl._M_finish, __tmp, _M_get_Tp_allocator()); } else { __tmp = _M_allocate_and_copy(__n, std::__make_move_if_noexcept_iterator(this->_M_impl._M_start), std::__make_move_if_noexcept_iterator(this->_M_impl._M_finish)); std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish, _M_get_Tp_allocator()); } ; _M_deallocate(this->_M_impl._M_start, this->_M_impl._M_end_of_storage - this->_M_impl._M_start); this->_M_impl._M_start = __tmp; this->_M_impl._M_finish = __tmp + __old_size; this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n; } } template<typename _Tp, typename _Alloc> template<typename... _Args> void vector<_Tp, _Alloc>:: emplace_back(_Args&&... __args) { if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage) { ; _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish, std::forward<_Args>(__args)...); ++this->_M_impl._M_finish; ; } else _M_realloc_insert(end(), std::forward<_Args>(__args)...); } template<typename _Tp, typename _Alloc> typename vector<_Tp, _Alloc>::iterator vector<_Tp, _Alloc>:: insert(const_iterator __position, const value_type& __x) { const size_type __n = __position - begin(); if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage) if (__position == end()) { ; _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish, __x); ++this->_M_impl._M_finish; ; } else { const auto __pos = begin() + (__position - cbegin()); _Temporary_value __x_copy(this, __x); _M_insert_aux(__pos, std::move(__x_copy._M_val())); } else _M_realloc_insert(begin() + (__position - cbegin()), __x); return iterator(this->_M_impl._M_start + __n); } template<typename _Tp, typename _Alloc> typename vector<_Tp, _Alloc>::iterator vector<_Tp, _Alloc>:: _M_erase(iterator __position) { if (__position + 1 != end()) std::move(__position + 1, end(), __position); --this->_M_impl._M_finish; _Alloc_traits::destroy(this->_M_impl, this->_M_impl._M_finish); ; return __position; } template<typename _Tp, typename _Alloc> typename vector<_Tp, _Alloc>::iterator vector<_Tp, _Alloc>:: _M_erase(iterator __first, iterator __last) { if (__first != __last) { if (__last != end()) std::move(__last, end(), __first); _M_erase_at_end(__first.base() + (end() - __last)); } return __first; } template<typename _Tp, typename _Alloc> vector<_Tp, _Alloc>& vector<_Tp, _Alloc>:: operator=(const vector<_Tp, _Alloc>& __x) { if (&__x != this) { ; if (_Alloc_traits::_S_propagate_on_copy_assign()) { if (!_Alloc_traits::_S_always_equal() && _M_get_Tp_allocator() != __x._M_get_Tp_allocator()) { this->clear(); _M_deallocate(this->_M_impl._M_start, this->_M_impl._M_end_of_storage - this->_M_impl._M_start); this->_M_impl._M_start = nullptr; this->_M_impl._M_finish = nullptr; this->_M_impl._M_end_of_storage = nullptr; } std::__alloc_on_copy(_M_get_Tp_allocator(), __x._M_get_Tp_allocator()); } const size_type __xlen = __x.size(); if (__xlen > capacity()) { pointer __tmp = _M_allocate_and_copy(__xlen, __x.begin(), __x.end()); std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish, _M_get_Tp_allocator()); _M_deallocate(this->_M_impl._M_start, this->_M_impl._M_end_of_storage - this->_M_impl._M_start); this->_M_impl._M_start = __tmp; this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __xlen; } else if (size() >= __xlen) { std::_Destroy(std::copy(__x.begin(), __x.end(), begin()), end(), _M_get_Tp_allocator()); } else { std::copy(__x._M_impl._M_start, __x._M_impl._M_start + size(), this->_M_impl._M_start); std::__uninitialized_copy_a(__x._M_impl._M_start + size(), __x._M_impl._M_finish, this->_M_impl._M_finish, _M_get_Tp_allocator()); } this->_M_impl._M_finish = this->_M_impl._M_start + __xlen; } return *this; } template<typename _Tp, typename _Alloc> void vector<_Tp, _Alloc>:: _M_fill_assign(size_t __n, const value_type& __val) { if (__n > capacity()) { vector __tmp(__n, __val, _M_get_Tp_allocator()); __tmp._M_impl._M_swap_data(this->_M_impl); } else if (__n > size()) { std::fill(begin(), end(), __val); const size_type __add = __n - size(); ; this->_M_impl._M_finish = std::__uninitialized_fill_n_a(this->_M_impl._M_finish, __add, __val, _M_get_Tp_allocator()); ; } else _M_erase_at_end(std::fill_n(this->_M_impl._M_start, __n, __val)); } template<typename _Tp, typename _Alloc> template<typename _InputIterator> void vector<_Tp, _Alloc>:: _M_assign_aux(_InputIterator __first, _InputIterator __last, std::input_iterator_tag) { pointer __cur(this->_M_impl._M_start); for (; __first != __last && __cur != this->_M_impl._M_finish; ++__cur, (void)++__first) *__cur = *__first; if (__first == __last) _M_erase_at_end(__cur); else _M_range_insert(end(), __first, __last, std::__iterator_category(__first)); } template<typename _Tp, typename _Alloc> template<typename _ForwardIterator> void vector<_Tp, _Alloc>:: _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last, std::forward_iterator_tag) { const size_type __len = std::distance(__first, __last); if (__len > capacity()) { _S_check_init_len(__len, _M_get_Tp_allocator()); pointer __tmp(_M_allocate_and_copy(__len, __first, __last)); std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish, _M_get_Tp_allocator()); ; _M_deallocate(this->_M_impl._M_start, this->_M_impl._M_end_of_storage - this->_M_impl._M_start); this->_M_impl._M_start = __tmp; this->_M_impl._M_finish = this->_M_impl._M_start + __len; this->_M_impl._M_end_of_storage = this->_M_impl._M_finish; } else if (size() >= __len) _M_erase_at_end(std::copy(__first, __last, this->_M_impl._M_start)); else { _ForwardIterator __mid = __first; std::advance(__mid, size()); std::copy(__first, __mid, this->_M_impl._M_start); const size_type __attribute__((__unused__)) __n = __len - size(); ; this->_M_impl._M_finish = std::__uninitialized_copy_a(__mid, __last, this->_M_impl._M_finish, _M_get_Tp_allocator()); ; } } template<typename _Tp, typename _Alloc> auto vector<_Tp, _Alloc>:: _M_insert_rval(const_iterator __position, value_type&& __v) -> iterator { const auto __n = __position - cbegin(); if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage) if (__position == cend()) { ; _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish, std::move(__v)); ++this->_M_impl._M_finish; ; } else _M_insert_aux(begin() + __n, std::move(__v)); else _M_realloc_insert(begin() + __n, std::move(__v)); return iterator(this->_M_impl._M_start + __n); } template<typename _Tp, typename _Alloc> template<typename... _Args> auto vector<_Tp, _Alloc>:: _M_emplace_aux(const_iterator __position, _Args&&... __args) -> iterator { const auto __n = __position - cbegin(); if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage) if (__position == cend()) { ; _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish, std::forward<_Args>(__args)...); ++this->_M_impl._M_finish; ; } else { _Temporary_value __tmp(this, std::forward<_Args>(__args)...); _M_insert_aux(begin() + __n, std::move(__tmp._M_val())); } else _M_realloc_insert(begin() + __n, std::forward<_Args>(__args)...); return iterator(this->_M_impl._M_start + __n); } template<typename _Tp, typename _Alloc> template<typename _Arg> void vector<_Tp, _Alloc>:: _M_insert_aux(iterator __position, _Arg&& __arg) { ; _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish, std::move(*(this->_M_impl._M_finish - 1))); ++this->_M_impl._M_finish; ; std::move_backward(__position.base(), this->_M_impl._M_finish - 2, this->_M_impl._M_finish - 1) ; *__position = std::forward<_Arg>(__arg); } template<typename _Tp, typename _Alloc> template<typename... _Args> void vector<_Tp, _Alloc>:: _M_realloc_insert(iterator __position, _Args&&... __args) { const size_type __len = _M_check_len(size_type(1), "vector::_M_realloc_insert"); pointer __old_start = this->_M_impl._M_start; pointer __old_finish = this->_M_impl._M_finish; const size_type __elems_before = __position - begin(); pointer __new_start(this->_M_allocate(__len)); pointer __new_finish(__new_start); try { _Alloc_traits::construct(this->_M_impl, __new_start + __elems_before, std::forward<_Args>(__args)...); __new_finish = pointer(); if (_S_use_relocate()) { __new_finish = _S_relocate(__old_start, __position.base(), __new_start, _M_get_Tp_allocator()); ++__new_finish; __new_finish = _S_relocate(__position.base(), __old_finish, __new_finish, _M_get_Tp_allocator()); } else { __new_finish = std::__uninitialized_move_if_noexcept_a (__old_start, __position.base(), __new_start, _M_get_Tp_allocator()); ++__new_finish; __new_finish = std::__uninitialized_move_if_noexcept_a (__position.base(), __old_finish, __new_finish, _M_get_Tp_allocator()); } } catch(...) { if (!__new_finish) _Alloc_traits::destroy(this->_M_impl, __new_start + __elems_before); else std::_Destroy(__new_start, __new_finish, _M_get_Tp_allocator()); _M_deallocate(__new_start, __len); throw; } if (!_S_use_relocate()) std::_Destroy(__old_start, __old_finish, _M_get_Tp_allocator()); ; _M_deallocate(__old_start, this->_M_impl._M_end_of_storage - __old_start); this->_M_impl._M_start = __new_start; this->_M_impl._M_finish = __new_finish; this->_M_impl._M_end_of_storage = __new_start + __len; } template<typename _Tp, typename _Alloc> void vector<_Tp, _Alloc>:: _M_fill_insert(iterator __position, size_type __n, const value_type& __x) { if (__n != 0) { if (size_type(this->_M_impl._M_end_of_storage - this->_M_impl._M_finish) >= __n) { _Temporary_value __tmp(this, __x); value_type& __x_copy = __tmp._M_val(); const size_type __elems_after = end() - __position; pointer __old_finish(this->_M_impl._M_finish); if (__elems_after > __n) { ; std::__uninitialized_move_a(this->_M_impl._M_finish - __n, this->_M_impl._M_finish, this->_M_impl._M_finish, _M_get_Tp_allocator()); this->_M_impl._M_finish += __n; ; std::move_backward(__position.base(), __old_finish - __n, __old_finish) ; std::fill(__position.base(), __position.base() + __n, __x_copy); } else { ; this->_M_impl._M_finish = std::__uninitialized_fill_n_a(this->_M_impl._M_finish, __n - __elems_after, __x_copy, _M_get_Tp_allocator()); ; std::__uninitialized_move_a(__position.base(), __old_finish, this->_M_impl._M_finish, _M_get_Tp_allocator()); this->_M_impl._M_finish += __elems_after; ; std::fill(__position.base(), __old_finish, __x_copy); } } else { const size_type __len = _M_check_len(__n, "vector::_M_fill_insert"); const size_type __elems_before = __position - begin(); pointer __new_start(this->_M_allocate(__len)); pointer __new_finish(__new_start); try { std::__uninitialized_fill_n_a(__new_start + __elems_before, __n, __x, _M_get_Tp_allocator()); __new_finish = pointer(); __new_finish = std::__uninitialized_move_if_noexcept_a (this->_M_impl._M_start, __position.base(), __new_start, _M_get_Tp_allocator()); __new_finish += __n; __new_finish = std::__uninitialized_move_if_noexcept_a (__position.base(), this->_M_impl._M_finish, __new_finish, _M_get_Tp_allocator()); } catch(...) { if (!__new_finish) std::_Destroy(__new_start + __elems_before, __new_start + __elems_before + __n, _M_get_Tp_allocator()); else std::_Destroy(__new_start, __new_finish, _M_get_Tp_allocator()); _M_deallocate(__new_start, __len); throw; } std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish, _M_get_Tp_allocator()); ; _M_deallocate(this->_M_impl._M_start, this->_M_impl._M_end_of_storage - this->_M_impl._M_start); this->_M_impl._M_start = __new_start; this->_M_impl._M_finish = __new_finish; this->_M_impl._M_end_of_storage = __new_start + __len; } } } template<typename _Tp, typename _Alloc> void vector<_Tp, _Alloc>:: _M_default_append(size_type __n) { if (__n != 0) { const size_type __size = size(); size_type __navail = size_type(this->_M_impl._M_end_of_storage - this->_M_impl._M_finish); if (__size > max_size() || __navail > max_size() - __size) __builtin_unreachable(); if (__navail >= __n) { ; this->_M_impl._M_finish = std::__uninitialized_default_n_a(this->_M_impl._M_finish, __n, _M_get_Tp_allocator()); ; } else { const size_type __len = _M_check_len(__n, "vector::_M_default_append"); pointer __new_start(this->_M_allocate(__len)); if (_S_use_relocate()) { try { std::__uninitialized_default_n_a(__new_start + __size, __n, _M_get_Tp_allocator()); } catch(...) { _M_deallocate(__new_start, __len); throw; } _S_relocate(this->_M_impl._M_start, this->_M_impl._M_finish, __new_start, _M_get_Tp_allocator()); } else { pointer __destroy_from = pointer(); try { std::__uninitialized_default_n_a(__new_start + __size, __n, _M_get_Tp_allocator()); __destroy_from = __new_start + __size; std::__uninitialized_move_if_noexcept_a( this->_M_impl._M_start, this->_M_impl._M_finish, __new_start, _M_get_Tp_allocator()); } catch(...) { if (__destroy_from) std::_Destroy(__destroy_from, __destroy_from + __n, _M_get_Tp_allocator()); _M_deallocate(__new_start, __len); throw; } std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish, _M_get_Tp_allocator()); } ; _M_deallocate(this->_M_impl._M_start, this->_M_impl._M_end_of_storage - this->_M_impl._M_start); this->_M_impl._M_start = __new_start; this->_M_impl._M_finish = __new_start + __size + __n; this->_M_impl._M_end_of_storage = __new_start + __len; } } } template<typename _Tp, typename _Alloc> bool vector<_Tp, _Alloc>:: _M_shrink_to_fit() { if (capacity() == size()) return false; ; return std::__shrink_to_fit_aux<vector>::_S_do_it(*this); } template<typename _Tp, typename _Alloc> template<typename _InputIterator> void vector<_Tp, _Alloc>:: _M_range_insert(iterator __pos, _InputIterator __first, _InputIterator __last, std::input_iterator_tag) { if (__pos == end()) { for (; __first != __last; ++__first) insert(end(), *__first); } else if (__first != __last) { vector __tmp(__first, __last, _M_get_Tp_allocator()); insert(__pos, std::make_move_iterator(__tmp.begin()), std::make_move_iterator(__tmp.end())); } } template<typename _Tp, typename _Alloc> template<typename _ForwardIterator> void vector<_Tp, _Alloc>:: _M_range_insert(iterator __position, _ForwardIterator __first, _ForwardIterator __last, std::forward_iterator_tag) { if (__first != __last) { const size_type __n = std::distance(__first, __last); if (size_type(this->_M_impl._M_end_of_storage - this->_M_impl._M_finish) >= __n) { const size_type __elems_after = end() - __position; pointer __old_finish(this->_M_impl._M_finish); if (__elems_after > __n) { ; std::__uninitialized_move_a(this->_M_impl._M_finish - __n, this->_M_impl._M_finish, this->_M_impl._M_finish, _M_get_Tp_allocator()); this->_M_impl._M_finish += __n; ; std::move_backward(__position.base(), __old_finish - __n, __old_finish) ; std::copy(__first, __last, __position); } else { _ForwardIterator __mid = __first; std::advance(__mid, __elems_after); ; std::__uninitialized_copy_a(__mid, __last, this->_M_impl._M_finish, _M_get_Tp_allocator()); this->_M_impl._M_finish += __n - __elems_after; ; std::__uninitialized_move_a(__position.base(), __old_finish, this->_M_impl._M_finish, _M_get_Tp_allocator()); this->_M_impl._M_finish += __elems_after; ; std::copy(__first, __mid, __position); } } else { const size_type __len = _M_check_len(__n, "vector::_M_range_insert"); pointer __new_start(this->_M_allocate(__len)); pointer __new_finish(__new_start); try { __new_finish = std::__uninitialized_move_if_noexcept_a (this->_M_impl._M_start, __position.base(), __new_start, _M_get_Tp_allocator()); __new_finish = std::__uninitialized_copy_a(__first, __last, __new_finish, _M_get_Tp_allocator()); __new_finish = std::__uninitialized_move_if_noexcept_a (__position.base(), this->_M_impl._M_finish, __new_finish, _M_get_Tp_allocator()); } catch(...) { std::_Destroy(__new_start, __new_finish, _M_get_Tp_allocator()); _M_deallocate(__new_start, __len); throw; } std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish, _M_get_Tp_allocator()); ; _M_deallocate(this->_M_impl._M_start, this->_M_impl._M_end_of_storage - this->_M_impl._M_start); this->_M_impl._M_start = __new_start; this->_M_impl._M_finish = __new_finish; this->_M_impl._M_end_of_storage = __new_start + __len; } } } template<typename _Alloc> void vector<bool, _Alloc>:: _M_reallocate(size_type __n) { _Bit_pointer __q = this->_M_allocate(__n); iterator __start(std::__addressof(*__q), 0); iterator __finish(_M_copy_aligned(begin(), end(), __start)); this->_M_deallocate(); this->_M_impl._M_start = __start; this->_M_impl._M_finish = __finish; this->_M_impl._M_end_of_storage = __q + _S_nword(__n); } template<typename _Alloc> void vector<bool, _Alloc>:: _M_fill_insert(iterator __position, size_type __n, bool __x) { if (__n == 0) return; if (capacity() - size() >= __n) { std::copy_backward(__position, end(), this->_M_impl._M_finish + difference_type(__n)); std::fill(__position, __position + difference_type(__n), __x); this->_M_impl._M_finish += difference_type(__n); } else { const size_type __len = _M_check_len(__n, "vector<bool>::_M_fill_insert"); _Bit_pointer __q = this->_M_allocate(__len); iterator __start(std::__addressof(*__q), 0); iterator __i = _M_copy_aligned(begin(), __position, __start); std::fill(__i, __i + difference_type(__n), __x); iterator __finish = std::copy(__position, end(), __i + difference_type(__n)); this->_M_deallocate(); this->_M_impl._M_end_of_storage = __q + _S_nword(__len); this->_M_impl._M_start = __start; this->_M_impl._M_finish = __finish; } } template<typename _Alloc> template<typename _ForwardIterator> void vector<bool, _Alloc>:: _M_insert_range(iterator __position, _ForwardIterator __first, _ForwardIterator __last, std::forward_iterator_tag) { if (__first != __last) { size_type __n = std::distance(__first, __last); if (capacity() - size() >= __n) { std::copy_backward(__position, end(), this->_M_impl._M_finish + difference_type(__n)); std::copy(__first, __last, __position); this->_M_impl._M_finish += difference_type(__n); } else { const size_type __len = _M_check_len(__n, "vector<bool>::_M_insert_range"); _Bit_pointer __q = this->_M_allocate(__len); iterator __start(std::__addressof(*__q), 0); iterator __i = _M_copy_aligned(begin(), __position, __start); __i = std::copy(__first, __last, __i); iterator __finish = std::copy(__position, end(), __i); this->_M_deallocate(); this->_M_impl._M_end_of_storage = __q + _S_nword(__len); this->_M_impl._M_start = __start; this->_M_impl._M_finish = __finish; } } } template<typename _Alloc> void vector<bool, _Alloc>:: _M_insert_aux(iterator __position, bool __x) { if (this->_M_impl._M_finish._M_p != this->_M_impl._M_end_addr()) { std::copy_backward(__position, this->_M_impl._M_finish, this->_M_impl._M_finish + 1); *__position = __x; ++this->_M_impl._M_finish; } else { const size_type __len = _M_check_len(size_type(1), "vector<bool>::_M_insert_aux"); _Bit_pointer __q = this->_M_allocate(__len); iterator __start(std::__addressof(*__q), 0); iterator __i = _M_copy_aligned(begin(), __position, __start); *__i++ = __x; iterator __finish = std::copy(__position, end(), __i); this->_M_deallocate(); this->_M_impl._M_end_of_storage = __q + _S_nword(__len); this->_M_impl._M_start = __start; this->_M_impl._M_finish = __finish; } } template<typename _Alloc> typename vector<bool, _Alloc>::iterator vector<bool, _Alloc>:: _M_erase(iterator __position) { if (__position + 1 != end()) std::copy(__position + 1, end(), __position); --this->_M_impl._M_finish; return __position; } template<typename _Alloc> typename vector<bool, _Alloc>::iterator vector<bool, _Alloc>:: _M_erase(iterator __first, iterator __last) { if (__first != __last) _M_erase_at_end(std::copy(__last, end(), __first)); return __first; } template<typename _Alloc> bool vector<bool, _Alloc>:: _M_shrink_to_fit() { if (capacity() - size() < int(_S_word_bit)) return false; try { _M_reallocate(size()); return true; } catch(...) { return false; } } } namespace std __attribute__ ((__visibility__ ("default"))) { template<typename _Alloc> size_t hash<std::vector<bool, _Alloc>>:: operator()(const std::vector<bool, _Alloc>& __b) const noexcept { size_t __hash = 0; using std::_S_word_bit; using std::_Bit_type; const size_t __words = __b.size() / _S_word_bit; if (__words) { const size_t __clength = __words * sizeof(_Bit_type); __hash = std::_Hash_impl::hash(__b._M_impl._M_start._M_p, __clength); } const size_t __extrabits = __b.size() % _S_word_bit; if (__extrabits) { _Bit_type __hiword = *__b._M_impl._M_finish._M_p; __hiword &= ~((~static_cast<_Bit_type>(0)) << __extrabits); const size_t __clength = (__extrabits + 8 - 1) / 8; if (__words) __hash = std::_Hash_impl::hash(&__hiword, __clength, __hash); else __hash = std::_Hash_impl::hash(&__hiword, __clength); } return __hash; } } namespace std __attribute__ ((__visibility__ ("default"))) { constexpr inline size_t __deque_buf_size(size_t __size) { return (__size < 512 ? size_t(512 / __size) : size_t(1)); } template<typename _Tp, typename _Ref, typename _Ptr> struct _Deque_iterator { private: template<typename _CvTp> using __iter = _Deque_iterator<_Tp, _CvTp&, __ptr_rebind<_Ptr, _CvTp>>; public: typedef __iter<_Tp> iterator; typedef __iter<const _Tp> const_iterator; typedef __ptr_rebind<_Ptr, _Tp> _Elt_pointer; typedef __ptr_rebind<_Ptr, _Elt_pointer> _Map_pointer; static size_t _S_buffer_size() noexcept { return __deque_buf_size(sizeof(_Tp)); } typedef std::random_access_iterator_tag iterator_category; typedef _Tp value_type; typedef _Ptr pointer; typedef _Ref reference; typedef size_t size_type; typedef ptrdiff_t difference_type; typedef _Deque_iterator _Self; _Elt_pointer _M_cur; _Elt_pointer _M_first; _Elt_pointer _M_last; _Map_pointer _M_node; _Deque_iterator(_Elt_pointer __x, _Map_pointer __y) noexcept : _M_cur(__x), _M_first(*__y), _M_last(*__y + _S_buffer_size()), _M_node(__y) { } _Deque_iterator() noexcept : _M_cur(), _M_first(), _M_last(), _M_node() { } template<typename _Iter, typename = _Require<is_same<_Self, const_iterator>, is_same<_Iter, iterator>>> _Deque_iterator(const _Iter& __x) noexcept : _M_cur(__x._M_cur), _M_first(__x._M_first), _M_last(__x._M_last), _M_node(__x._M_node) { } _Deque_iterator(const _Deque_iterator& __x) noexcept : _M_cur(__x._M_cur), _M_first(__x._M_first), _M_last(__x._M_last), _M_node(__x._M_node) { } _Deque_iterator& operator=(const _Deque_iterator&) = default; iterator _M_const_cast() const noexcept { return iterator(_M_cur, _M_node); } reference operator*() const noexcept { return *_M_cur; } pointer operator->() const noexcept { return _M_cur; } _Self& operator++() noexcept { ++_M_cur; if (_M_cur == _M_last) { _M_set_node(_M_node + 1); _M_cur = _M_first; } return *this; } _Self operator++(int) noexcept { _Self __tmp = *this; ++*this; return __tmp; } _Self& operator--() noexcept { if (_M_cur == _M_first) { _M_set_node(_M_node - 1); _M_cur = _M_last; } --_M_cur; return *this; } _Self operator--(int) noexcept { _Self __tmp = *this; --*this; return __tmp; } _Self& operator+=(difference_type __n) noexcept { const difference_type __offset = __n + (_M_cur - _M_first); if (__offset >= 0 && __offset < difference_type(_S_buffer_size())) _M_cur += __n; else { const difference_type __node_offset = __offset > 0 ? __offset / difference_type(_S_buffer_size()) : -difference_type((-__offset - 1) / _S_buffer_size()) - 1; _M_set_node(_M_node + __node_offset); _M_cur = _M_first + (__offset - __node_offset * difference_type(_S_buffer_size())); } return *this; } _Self& operator-=(difference_type __n) noexcept { return *this += -__n; } reference operator[](difference_type __n) const noexcept { return *(*this + __n); } void _M_set_node(_Map_pointer __new_node) noexcept { _M_node = __new_node; _M_first = *__new_node; _M_last = _M_first + difference_type(_S_buffer_size()); } friend bool operator==(const _Self& __x, const _Self& __y) noexcept { return __x._M_cur == __y._M_cur; } template<typename _RefR, typename _PtrR> friend bool operator==(const _Self& __x, const _Deque_iterator<_Tp, _RefR, _PtrR>& __y) noexcept { return __x._M_cur == __y._M_cur; } friend bool operator!=(const _Self& __x, const _Self& __y) noexcept { return !(__x == __y); } template<typename _RefR, typename _PtrR> friend bool operator!=(const _Self& __x, const _Deque_iterator<_Tp, _RefR, _PtrR>& __y) noexcept { return !(__x == __y); } friend bool operator<(const _Self& __x, const _Self& __y) noexcept { return (__x._M_node == __y._M_node) ? (__x._M_cur < __y._M_cur) : (__x._M_node < __y._M_node); } template<typename _RefR, typename _PtrR> friend bool operator<(const _Self& __x, const _Deque_iterator<_Tp, _RefR, _PtrR>& __y) noexcept { return (__x._M_node == __y._M_node) ? (__x._M_cur < __y._M_cur) : (__x._M_node < __y._M_node); } friend bool operator>(const _Self& __x, const _Self& __y) noexcept { return __y < __x; } template<typename _RefR, typename _PtrR> friend bool operator>(const _Self& __x, const _Deque_iterator<_Tp, _RefR, _PtrR>& __y) noexcept { return __y < __x; } friend bool operator<=(const _Self& __x, const _Self& __y) noexcept { return !(__y < __x); } template<typename _RefR, typename _PtrR> friend bool operator<=(const _Self& __x, const _Deque_iterator<_Tp, _RefR, _PtrR>& __y) noexcept { return !(__y < __x); } friend bool operator>=(const _Self& __x, const _Self& __y) noexcept { return !(__x < __y); } template<typename _RefR, typename _PtrR> friend bool operator>=(const _Self& __x, const _Deque_iterator<_Tp, _RefR, _PtrR>& __y) noexcept { return !(__x < __y); } friend difference_type operator-(const _Self& __x, const _Self& __y) noexcept { return difference_type(_S_buffer_size()) * (__x._M_node - __y._M_node - 1) + (__x._M_cur - __x._M_first) + (__y._M_last - __y._M_cur); } template<typename _RefR, typename _PtrR> friend difference_type operator-(const _Self& __x, const _Deque_iterator<_Tp, _RefR, _PtrR>& __y) noexcept { return difference_type(_S_buffer_size()) * (__x._M_node - __y._M_node - 1) + (__x._M_cur - __x._M_first) + (__y._M_last - __y._M_cur); } friend _Self operator+(const _Self& __x, difference_type __n) noexcept { _Self __tmp = __x; __tmp += __n; return __tmp; } friend _Self operator-(const _Self& __x, difference_type __n) noexcept { _Self __tmp = __x; __tmp -= __n; return __tmp; } friend _Self operator+(difference_type __n, const _Self& __x) noexcept { return __x + __n; } }; template<typename _Tp, typename _Alloc> class _Deque_base { protected: typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template rebind<_Tp>::other _Tp_alloc_type; typedef __gnu_cxx::__alloc_traits<_Tp_alloc_type> _Alloc_traits; typedef typename _Alloc_traits::pointer _Ptr; typedef typename _Alloc_traits::const_pointer _Ptr_const; typedef typename _Alloc_traits::template rebind<_Ptr>::other _Map_alloc_type; typedef __gnu_cxx::__alloc_traits<_Map_alloc_type> _Map_alloc_traits; typedef _Alloc allocator_type; allocator_type get_allocator() const noexcept { return allocator_type(_M_get_Tp_allocator()); } typedef _Deque_iterator<_Tp, _Tp&, _Ptr> iterator; typedef _Deque_iterator<_Tp, const _Tp&, _Ptr_const> const_iterator; _Deque_base() : _M_impl() { _M_initialize_map(0); } _Deque_base(size_t __num_elements) : _M_impl() { _M_initialize_map(__num_elements); } _Deque_base(const allocator_type& __a, size_t __num_elements) : _M_impl(__a) { _M_initialize_map(__num_elements); } _Deque_base(const allocator_type& __a) : _M_impl(__a) { } _Deque_base(_Deque_base&& __x) : _M_impl(std::move(__x._M_get_Tp_allocator())) { _M_initialize_map(0); if (__x._M_impl._M_map) this->_M_impl._M_swap_data(__x._M_impl); } _Deque_base(_Deque_base&& __x, const allocator_type& __a) : _M_impl(std::move(__x._M_impl), _Tp_alloc_type(__a)) { __x._M_initialize_map(0); } _Deque_base(_Deque_base&& __x, const allocator_type& __a, size_t __n) : _M_impl(__a) { if (__x.get_allocator() == __a) { if (__x._M_impl._M_map) { _M_initialize_map(0); this->_M_impl._M_swap_data(__x._M_impl); } } else { _M_initialize_map(__n); } } ~_Deque_base() noexcept; typedef typename iterator::_Map_pointer _Map_pointer; struct _Deque_impl_data { _Map_pointer _M_map; size_t _M_map_size; iterator _M_start; iterator _M_finish; _Deque_impl_data() noexcept : _M_map(), _M_map_size(), _M_start(), _M_finish() { } _Deque_impl_data(const _Deque_impl_data&) = default; _Deque_impl_data& operator=(const _Deque_impl_data&) = default; _Deque_impl_data(_Deque_impl_data&& __x) noexcept : _Deque_impl_data(__x) { __x = _Deque_impl_data(); } void _M_swap_data(_Deque_impl_data& __x) noexcept { std::swap(*this, __x); } }; struct _Deque_impl : public _Tp_alloc_type, public _Deque_impl_data { _Deque_impl() noexcept(is_nothrow_default_constructible<_Tp_alloc_type>::value) : _Tp_alloc_type() { } _Deque_impl(const _Tp_alloc_type& __a) noexcept : _Tp_alloc_type(__a) { } _Deque_impl(_Deque_impl&&) = default; _Deque_impl(_Tp_alloc_type&& __a) noexcept : _Tp_alloc_type(std::move(__a)) { } _Deque_impl(_Deque_impl&& __d, _Tp_alloc_type&& __a) : _Tp_alloc_type(std::move(__a)), _Deque_impl_data(std::move(__d)) { } }; _Tp_alloc_type& _M_get_Tp_allocator() noexcept { return this->_M_impl; } const _Tp_alloc_type& _M_get_Tp_allocator() const noexcept { return this->_M_impl; } _Map_alloc_type _M_get_map_allocator() const noexcept { return _Map_alloc_type(_M_get_Tp_allocator()); } _Ptr _M_allocate_node() { typedef __gnu_cxx::__alloc_traits<_Tp_alloc_type> _Traits; return _Traits::allocate(_M_impl, __deque_buf_size(sizeof(_Tp))); } void _M_deallocate_node(_Ptr __p) noexcept { typedef __gnu_cxx::__alloc_traits<_Tp_alloc_type> _Traits; _Traits::deallocate(_M_impl, __p, __deque_buf_size(sizeof(_Tp))); } _Map_pointer _M_allocate_map(size_t __n) { _Map_alloc_type __map_alloc = _M_get_map_allocator(); return _Map_alloc_traits::allocate(__map_alloc, __n); } void _M_deallocate_map(_Map_pointer __p, size_t __n) noexcept { _Map_alloc_type __map_alloc = _M_get_map_allocator(); _Map_alloc_traits::deallocate(__map_alloc, __p, __n); } void _M_initialize_map(size_t); void _M_create_nodes(_Map_pointer __nstart, _Map_pointer __nfinish); void _M_destroy_nodes(_Map_pointer __nstart, _Map_pointer __nfinish) noexcept; enum { _S_initial_map_size = 8 }; _Deque_impl _M_impl; }; template<typename _Tp, typename _Alloc> _Deque_base<_Tp, _Alloc>:: ~_Deque_base() noexcept { if (this->_M_impl._M_map) { _M_destroy_nodes(this->_M_impl._M_start._M_node, this->_M_impl._M_finish._M_node + 1); _M_deallocate_map(this->_M_impl._M_map, this->_M_impl._M_map_size); } } template<typename _Tp, typename _Alloc> void _Deque_base<_Tp, _Alloc>:: _M_initialize_map(size_t __num_elements) { const size_t __num_nodes = (__num_elements / __deque_buf_size(sizeof(_Tp)) + 1); this->_M_impl._M_map_size = std::max((size_t) _S_initial_map_size, size_t(__num_nodes + 2)); this->_M_impl._M_map = _M_allocate_map(this->_M_impl._M_map_size); _Map_pointer __nstart = (this->_M_impl._M_map + (this->_M_impl._M_map_size - __num_nodes) / 2); _Map_pointer __nfinish = __nstart + __num_nodes; try { _M_create_nodes(__nstart, __nfinish); } catch(...) { _M_deallocate_map(this->_M_impl._M_map, this->_M_impl._M_map_size); this->_M_impl._M_map = _Map_pointer(); this->_M_impl._M_map_size = 0; throw; } this->_M_impl._M_start._M_set_node(__nstart); this->_M_impl._M_finish._M_set_node(__nfinish - 1); this->_M_impl._M_start._M_cur = _M_impl._M_start._M_first; this->_M_impl._M_finish._M_cur = (this->_M_impl._M_finish._M_first + __num_elements % __deque_buf_size(sizeof(_Tp))); } template<typename _Tp, typename _Alloc> void _Deque_base<_Tp, _Alloc>:: _M_create_nodes(_Map_pointer __nstart, _Map_pointer __nfinish) { _Map_pointer __cur; try { for (__cur = __nstart; __cur < __nfinish; ++__cur) *__cur = this->_M_allocate_node(); } catch(...) { _M_destroy_nodes(__nstart, __cur); throw; } } template<typename _Tp, typename _Alloc> void _Deque_base<_Tp, _Alloc>:: _M_destroy_nodes(_Map_pointer __nstart, _Map_pointer __nfinish) noexcept { for (_Map_pointer __n = __nstart; __n < __nfinish; ++__n) _M_deallocate_node(*__n); } template<typename _Tp, typename _Alloc = std::allocator<_Tp> > class deque : protected _Deque_base<_Tp, _Alloc> { static_assert(is_same<typename remove_cv<_Tp>::type, _Tp>::value, "std::deque must have a non-const, non-volatile value_type"); typedef _Deque_base<_Tp, _Alloc> _Base; typedef typename _Base::_Tp_alloc_type _Tp_alloc_type; typedef typename _Base::_Alloc_traits _Alloc_traits; typedef typename _Base::_Map_pointer _Map_pointer; public: typedef _Tp value_type; typedef typename _Alloc_traits::pointer pointer; typedef typename _Alloc_traits::const_pointer const_pointer; typedef typename _Alloc_traits::reference reference; typedef typename _Alloc_traits::const_reference const_reference; typedef typename _Base::iterator iterator; typedef typename _Base::const_iterator const_iterator; typedef std::reverse_iterator<const_iterator> const_reverse_iterator; typedef std::reverse_iterator<iterator> reverse_iterator; typedef size_t size_type; typedef ptrdiff_t difference_type; typedef _Alloc allocator_type; private: static size_t _S_buffer_size() noexcept { return __deque_buf_size(sizeof(_Tp)); } using _Base::_M_initialize_map; using _Base::_M_create_nodes; using _Base::_M_destroy_nodes; using _Base::_M_allocate_node; using _Base::_M_deallocate_node; using _Base::_M_allocate_map; using _Base::_M_deallocate_map; using _Base::_M_get_Tp_allocator; using _Base::_M_impl; public: deque() = default; explicit deque(const allocator_type& __a) : _Base(__a, 0) { } explicit deque(size_type __n, const allocator_type& __a = allocator_type()) : _Base(__a, _S_check_init_len(__n, __a)) { _M_default_initialize(); } deque(size_type __n, const value_type& __value, const allocator_type& __a = allocator_type()) : _Base(__a, _S_check_init_len(__n, __a)) { _M_fill_initialize(__value); } deque(const deque& __x) : _Base(_Alloc_traits::_S_select_on_copy(__x._M_get_Tp_allocator()), __x.size()) { std::__uninitialized_copy_a(__x.begin(), __x.end(), this->_M_impl._M_start, _M_get_Tp_allocator()); } deque(deque&&) = default; deque(const deque& __x, const allocator_type& __a) : _Base(__a, __x.size()) { std::__uninitialized_copy_a(__x.begin(), __x.end(), this->_M_impl._M_start, _M_get_Tp_allocator()); } deque(deque&& __x, const allocator_type& __a) : deque(std::move(__x), __a, typename _Alloc_traits::is_always_equal{}) { } private: deque(deque&& __x, const allocator_type& __a, true_type) : _Base(std::move(__x), __a) { } deque(deque&& __x, const allocator_type& __a, false_type) : _Base(std::move(__x), __a, __x.size()) { if (__x.get_allocator() != __a && !__x.empty()) { std::__uninitialized_move_a(__x.begin(), __x.end(), this->_M_impl._M_start, _M_get_Tp_allocator()); __x.clear(); } } public: deque(initializer_list<value_type> __l, const allocator_type& __a = allocator_type()) : _Base(__a) { _M_range_initialize(__l.begin(), __l.end(), random_access_iterator_tag()); } template<typename _InputIterator, typename = std::_RequireInputIter<_InputIterator>> deque(_InputIterator __first, _InputIterator __last, const allocator_type& __a = allocator_type()) : _Base(__a) { _M_range_initialize(__first, __last, std::__iterator_category(__first)); } ~deque() { _M_destroy_data(begin(), end(), _M_get_Tp_allocator()); } deque& operator=(const deque& __x); deque& operator=(deque&& __x) noexcept(_Alloc_traits::_S_always_equal()) { using __always_equal = typename _Alloc_traits::is_always_equal; _M_move_assign1(std::move(__x), __always_equal{}); return *this; } deque& operator=(initializer_list<value_type> __l) { _M_assign_aux(__l.begin(), __l.end(), random_access_iterator_tag()); return *this; } void assign(size_type __n, const value_type& __val) { _M_fill_assign(__n, __val); } template<typename _InputIterator, typename = std::_RequireInputIter<_InputIterator>> void assign(_InputIterator __first, _InputIterator __last) { _M_assign_aux(__first, __last, std::__iterator_category(__first)); } void assign(initializer_list<value_type> __l) { _M_assign_aux(__l.begin(), __l.end(), random_access_iterator_tag()); } allocator_type get_allocator() const noexcept { return _Base::get_allocator(); } iterator begin() noexcept { return this->_M_impl._M_start; } const_iterator begin() const noexcept { return this->_M_impl._M_start; } iterator end() noexcept { return this->_M_impl._M_finish; } const_iterator end() const noexcept { return this->_M_impl._M_finish; } reverse_iterator rbegin() noexcept { return reverse_iterator(this->_M_impl._M_finish); } const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(this->_M_impl._M_finish); } reverse_iterator rend() noexcept { return reverse_iterator(this->_M_impl._M_start); } const_reverse_iterator rend() const noexcept { return const_reverse_iterator(this->_M_impl._M_start); } const_iterator cbegin() const noexcept { return this->_M_impl._M_start; } const_iterator cend() const noexcept { return this->_M_impl._M_finish; } const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(this->_M_impl._M_finish); } const_reverse_iterator crend() const noexcept { return const_reverse_iterator(this->_M_impl._M_start); } size_type size() const noexcept { return this->_M_impl._M_finish - this->_M_impl._M_start; } size_type max_size() const noexcept { return _S_max_size(_M_get_Tp_allocator()); } void resize(size_type __new_size) { const size_type __len = size(); if (__new_size > __len) _M_default_append(__new_size - __len); else if (__new_size < __len) _M_erase_at_end(this->_M_impl._M_start + difference_type(__new_size)); } void resize(size_type __new_size, const value_type& __x) { const size_type __len = size(); if (__new_size > __len) _M_fill_insert(this->_M_impl._M_finish, __new_size - __len, __x); else if (__new_size < __len) _M_erase_at_end(this->_M_impl._M_start + difference_type(__new_size)); } void shrink_to_fit() noexcept { _M_shrink_to_fit(); } bool empty() const noexcept { return this->_M_impl._M_finish == this->_M_impl._M_start; } reference operator[](size_type __n) noexcept { ; return this->_M_impl._M_start[difference_type(__n)]; } const_reference operator[](size_type __n) const noexcept { ; return this->_M_impl._M_start[difference_type(__n)]; } protected: void _M_range_check(size_type __n) const { if (__n >= this->size()) __throw_out_of_range_fmt(("deque::_M_range_check: __n " "(which is %zu)>= this->size() " "(which is %zu)") , __n, this->size()); } public: reference at(size_type __n) { _M_range_check(__n); return (*this)[__n]; } const_reference at(size_type __n) const { _M_range_check(__n); return (*this)[__n]; } reference front() noexcept { ; return *begin(); } const_reference front() const noexcept { ; return *begin(); } reference back() noexcept { ; iterator __tmp = end(); --__tmp; return *__tmp; } const_reference back() const noexcept { ; const_iterator __tmp = end(); --__tmp; return *__tmp; } void push_front(const value_type& __x) { if (this->_M_impl._M_start._M_cur != this->_M_impl._M_start._M_first) { _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_start._M_cur - 1, __x); --this->_M_impl._M_start._M_cur; } else _M_push_front_aux(__x); } void push_front(value_type&& __x) { emplace_front(std::move(__x)); } template<typename... _Args> void emplace_front(_Args&&... __args); void push_back(const value_type& __x) { if (this->_M_impl._M_finish._M_cur != this->_M_impl._M_finish._M_last - 1) { _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish._M_cur, __x); ++this->_M_impl._M_finish._M_cur; } else _M_push_back_aux(__x); } void push_back(value_type&& __x) { emplace_back(std::move(__x)); } template<typename... _Args> void emplace_back(_Args&&... __args); void pop_front() noexcept { ; if (this->_M_impl._M_start._M_cur != this->_M_impl._M_start._M_last - 1) { _Alloc_traits::destroy(_M_get_Tp_allocator(), this->_M_impl._M_start._M_cur); ++this->_M_impl._M_start._M_cur; } else _M_pop_front_aux(); } void pop_back() noexcept { ; if (this->_M_impl._M_finish._M_cur != this->_M_impl._M_finish._M_first) { --this->_M_impl._M_finish._M_cur; _Alloc_traits::destroy(_M_get_Tp_allocator(), this->_M_impl._M_finish._M_cur); } else _M_pop_back_aux(); } template<typename... _Args> iterator emplace(const_iterator __position, _Args&&... __args); iterator insert(const_iterator __position, const value_type& __x); iterator insert(const_iterator __position, value_type&& __x) { return emplace(__position, std::move(__x)); } iterator insert(const_iterator __p, initializer_list<value_type> __l) { auto __offset = __p - cbegin(); _M_range_insert_aux(__p._M_const_cast(), __l.begin(), __l.end(), std::random_access_iterator_tag()); return begin() + __offset; } iterator insert(const_iterator __position, size_type __n, const value_type& __x) { difference_type __offset = __position - cbegin(); _M_fill_insert(__position._M_const_cast(), __n, __x); return begin() + __offset; } template<typename _InputIterator, typename = std::_RequireInputIter<_InputIterator>> iterator insert(const_iterator __position, _InputIterator __first, _InputIterator __last) { difference_type __offset = __position - cbegin(); _M_range_insert_aux(__position._M_const_cast(), __first, __last, std::__iterator_category(__first)); return begin() + __offset; } iterator erase(const_iterator __position) { return _M_erase(__position._M_const_cast()); } iterator erase(const_iterator __first, const_iterator __last) { return _M_erase(__first._M_const_cast(), __last._M_const_cast()); } void swap(deque& __x) noexcept { ; _M_impl._M_swap_data(__x._M_impl); _Alloc_traits::_S_on_swap(_M_get_Tp_allocator(), __x._M_get_Tp_allocator()); } void clear() noexcept { _M_erase_at_end(begin()); } protected: static size_t _S_check_init_len(size_t __n, const allocator_type& __a) { if (__n > _S_max_size(__a)) __throw_length_error( ("cannot create std::deque larger than max_size()")); return __n; } static size_type _S_max_size(const _Tp_alloc_type& __a) noexcept { const size_t __diffmax = __gnu_cxx::__numeric_traits<ptrdiff_t>::__max; const size_t __allocmax = _Alloc_traits::max_size(__a); return (std::min)(__diffmax, __allocmax); } template<typename _InputIterator> void _M_range_initialize(_InputIterator __first, _InputIterator __last, std::input_iterator_tag); template<typename _ForwardIterator> void _M_range_initialize(_ForwardIterator __first, _ForwardIterator __last, std::forward_iterator_tag); void _M_fill_initialize(const value_type& __value); void _M_default_initialize(); template<typename _InputIterator> void _M_assign_aux(_InputIterator __first, _InputIterator __last, std::input_iterator_tag); template<typename _ForwardIterator> void _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last, std::forward_iterator_tag) { const size_type __len = std::distance(__first, __last); if (__len > size()) { _ForwardIterator __mid = __first; std::advance(__mid, size()); std::copy(__first, __mid, begin()); _M_range_insert_aux(end(), __mid, __last, std::__iterator_category(__first)); } else _M_erase_at_end(std::copy(__first, __last, begin())); } void _M_fill_assign(size_type __n, const value_type& __val) { if (__n > size()) { std::fill(begin(), end(), __val); _M_fill_insert(end(), __n - size(), __val); } else { _M_erase_at_end(begin() + difference_type(__n)); std::fill(begin(), end(), __val); } } template<typename... _Args> void _M_push_back_aux(_Args&&... __args); template<typename... _Args> void _M_push_front_aux(_Args&&... __args); void _M_pop_back_aux(); void _M_pop_front_aux(); template<typename _InputIterator> void _M_range_insert_aux(iterator __pos, _InputIterator __first, _InputIterator __last, std::input_iterator_tag); template<typename _ForwardIterator> void _M_range_insert_aux(iterator __pos, _ForwardIterator __first, _ForwardIterator __last, std::forward_iterator_tag); void _M_fill_insert(iterator __pos, size_type __n, const value_type& __x); template<typename... _Args> iterator _M_insert_aux(iterator __pos, _Args&&... __args); void _M_insert_aux(iterator __pos, size_type __n, const value_type& __x); template<typename _ForwardIterator> void _M_insert_aux(iterator __pos, _ForwardIterator __first, _ForwardIterator __last, size_type __n); void _M_destroy_data_aux(iterator __first, iterator __last); template<typename _Alloc1> void _M_destroy_data(iterator __first, iterator __last, const _Alloc1&) { _M_destroy_data_aux(__first, __last); } void _M_destroy_data(iterator __first, iterator __last, const std::allocator<_Tp>&) { if (!__has_trivial_destructor(value_type)) _M_destroy_data_aux(__first, __last); } void _M_erase_at_begin(iterator __pos) { _M_destroy_data(begin(), __pos, _M_get_Tp_allocator()); _M_destroy_nodes(this->_M_impl._M_start._M_node, __pos._M_node); this->_M_impl._M_start = __pos; } void _M_erase_at_end(iterator __pos) { _M_destroy_data(__pos, end(), _M_get_Tp_allocator()); _M_destroy_nodes(__pos._M_node + 1, this->_M_impl._M_finish._M_node + 1); this->_M_impl._M_finish = __pos; } iterator _M_erase(iterator __pos); iterator _M_erase(iterator __first, iterator __last); void _M_default_append(size_type __n); bool _M_shrink_to_fit(); iterator _M_reserve_elements_at_front(size_type __n) { const size_type __vacancies = this->_M_impl._M_start._M_cur - this->_M_impl._M_start._M_first; if (__n > __vacancies) _M_new_elements_at_front(__n - __vacancies); return this->_M_impl._M_start - difference_type(__n); } iterator _M_reserve_elements_at_back(size_type __n) { const size_type __vacancies = (this->_M_impl._M_finish._M_last - this->_M_impl._M_finish._M_cur) - 1; if (__n > __vacancies) _M_new_elements_at_back(__n - __vacancies); return this->_M_impl._M_finish + difference_type(__n); } void _M_new_elements_at_front(size_type __new_elements); void _M_new_elements_at_back(size_type __new_elements); void _M_reserve_map_at_back(size_type __nodes_to_add = 1) { if (__nodes_to_add + 1 > this->_M_impl._M_map_size - (this->_M_impl._M_finish._M_node - this->_M_impl._M_map)) _M_reallocate_map(__nodes_to_add, false); } void _M_reserve_map_at_front(size_type __nodes_to_add = 1) { if (__nodes_to_add > size_type(this->_M_impl._M_start._M_node - this->_M_impl._M_map)) _M_reallocate_map(__nodes_to_add, true); } void _M_reallocate_map(size_type __nodes_to_add, bool __add_at_front); void _M_move_assign1(deque&& __x, true_type) noexcept { this->_M_impl._M_swap_data(__x._M_impl); __x.clear(); std::__alloc_on_move(_M_get_Tp_allocator(), __x._M_get_Tp_allocator()); } void _M_move_assign1(deque&& __x, false_type) { constexpr bool __move_storage = _Alloc_traits::_S_propagate_on_move_assign(); _M_move_assign2(std::move(__x), __bool_constant<__move_storage>()); } template<typename... _Args> void _M_replace_map(_Args&&... __args) { deque __newobj(std::forward<_Args>(__args)...); clear(); _M_deallocate_node(*begin()._M_node); _M_deallocate_map(this->_M_impl._M_map, this->_M_impl._M_map_size); this->_M_impl._M_map = nullptr; this->_M_impl._M_map_size = 0; this->_M_impl._M_swap_data(__newobj._M_impl); } void _M_move_assign2(deque&& __x, true_type) { auto __alloc = __x._M_get_Tp_allocator(); _M_replace_map(std::move(__x)); _M_get_Tp_allocator() = std::move(__alloc); } void _M_move_assign2(deque&& __x, false_type) { if (__x._M_get_Tp_allocator() == this->_M_get_Tp_allocator()) { _M_replace_map(std::move(__x), __x.get_allocator()); } else { _M_assign_aux(std::make_move_iterator(__x.begin()), std::make_move_iterator(__x.end()), std::random_access_iterator_tag()); __x.clear(); } } }; template<typename _Tp, typename _Alloc> inline bool operator==(const deque<_Tp, _Alloc>& __x, const deque<_Tp, _Alloc>& __y) { return __x.size() == __y.size() && std::equal(__x.begin(), __x.end(), __y.begin()); } template<typename _Tp, typename _Alloc> inline bool operator<(const deque<_Tp, _Alloc>& __x, const deque<_Tp, _Alloc>& __y) { return std::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end()); } template<typename _Tp, typename _Alloc> inline bool operator!=(const deque<_Tp, _Alloc>& __x, const deque<_Tp, _Alloc>& __y) { return !(__x == __y); } template<typename _Tp, typename _Alloc> inline bool operator>(const deque<_Tp, _Alloc>& __x, const deque<_Tp, _Alloc>& __y) { return __y < __x; } template<typename _Tp, typename _Alloc> inline bool operator<=(const deque<_Tp, _Alloc>& __x, const deque<_Tp, _Alloc>& __y) { return !(__y < __x); } template<typename _Tp, typename _Alloc> inline bool operator>=(const deque<_Tp, _Alloc>& __x, const deque<_Tp, _Alloc>& __y) { return !(__x < __y); } template<typename _Tp, typename _Alloc> inline void swap(deque<_Tp,_Alloc>& __x, deque<_Tp,_Alloc>& __y) noexcept(noexcept(__x.swap(__y))) { __x.swap(__y); } template<class _Tp> struct __is_bitwise_relocatable<std::deque<_Tp>> : true_type { }; } namespace std __attribute__ ((__visibility__ ("default"))) { template <typename _Tp, typename _Alloc> void deque<_Tp, _Alloc>:: _M_default_initialize() { _Map_pointer __cur; try { for (__cur = this->_M_impl._M_start._M_node; __cur < this->_M_impl._M_finish._M_node; ++__cur) std::__uninitialized_default_a(*__cur, *__cur + _S_buffer_size(), _M_get_Tp_allocator()); std::__uninitialized_default_a(this->_M_impl._M_finish._M_first, this->_M_impl._M_finish._M_cur, _M_get_Tp_allocator()); } catch(...) { std::_Destroy(this->_M_impl._M_start, iterator(*__cur, __cur), _M_get_Tp_allocator()); throw; } } template <typename _Tp, typename _Alloc> deque<_Tp, _Alloc>& deque<_Tp, _Alloc>:: operator=(const deque& __x) { if (&__x != this) { if (_Alloc_traits::_S_propagate_on_copy_assign()) { if (!_Alloc_traits::_S_always_equal() && _M_get_Tp_allocator() != __x._M_get_Tp_allocator()) { _M_replace_map(__x, __x.get_allocator()); std::__alloc_on_copy(_M_get_Tp_allocator(), __x._M_get_Tp_allocator()); return *this; } std::__alloc_on_copy(_M_get_Tp_allocator(), __x._M_get_Tp_allocator()); } const size_type __len = size(); if (__len >= __x.size()) _M_erase_at_end(std::copy(__x.begin(), __x.end(), this->_M_impl._M_start)); else { const_iterator __mid = __x.begin() + difference_type(__len); std::copy(__x.begin(), __mid, this->_M_impl._M_start); _M_range_insert_aux(this->_M_impl._M_finish, __mid, __x.end(), std::random_access_iterator_tag()); } } return *this; } template<typename _Tp, typename _Alloc> template<typename... _Args> void deque<_Tp, _Alloc>:: emplace_front(_Args&&... __args) { if (this->_M_impl._M_start._M_cur != this->_M_impl._M_start._M_first) { _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_start._M_cur - 1, std::forward<_Args>(__args)...); --this->_M_impl._M_start._M_cur; } else _M_push_front_aux(std::forward<_Args>(__args)...); } template<typename _Tp, typename _Alloc> template<typename... _Args> void deque<_Tp, _Alloc>:: emplace_back(_Args&&... __args) { if (this->_M_impl._M_finish._M_cur != this->_M_impl._M_finish._M_last - 1) { _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish._M_cur, std::forward<_Args>(__args)...); ++this->_M_impl._M_finish._M_cur; } else _M_push_back_aux(std::forward<_Args>(__args)...); } template<typename _Tp, typename _Alloc> template<typename... _Args> typename deque<_Tp, _Alloc>::iterator deque<_Tp, _Alloc>:: emplace(const_iterator __position, _Args&&... __args) { if (__position._M_cur == this->_M_impl._M_start._M_cur) { emplace_front(std::forward<_Args>(__args)...); return this->_M_impl._M_start; } else if (__position._M_cur == this->_M_impl._M_finish._M_cur) { emplace_back(std::forward<_Args>(__args)...); iterator __tmp = this->_M_impl._M_finish; --__tmp; return __tmp; } else return _M_insert_aux(__position._M_const_cast(), std::forward<_Args>(__args)...); } template <typename _Tp, typename _Alloc> typename deque<_Tp, _Alloc>::iterator deque<_Tp, _Alloc>:: insert(const_iterator __position, const value_type& __x) { if (__position._M_cur == this->_M_impl._M_start._M_cur) { push_front(__x); return this->_M_impl._M_start; } else if (__position._M_cur == this->_M_impl._M_finish._M_cur) { push_back(__x); iterator __tmp = this->_M_impl._M_finish; --__tmp; return __tmp; } else return _M_insert_aux(__position._M_const_cast(), __x); } template <typename _Tp, typename _Alloc> typename deque<_Tp, _Alloc>::iterator deque<_Tp, _Alloc>:: _M_erase(iterator __position) { iterator __next = __position; ++__next; const difference_type __index = __position - begin(); if (static_cast<size_type>(__index) < (size() >> 1)) { if (__position != begin()) std::move_backward(begin(), __position, __next); pop_front(); } else { if (__next != end()) std::move(__next, end(), __position); pop_back(); } return begin() + __index; } template <typename _Tp, typename _Alloc> typename deque<_Tp, _Alloc>::iterator deque<_Tp, _Alloc>:: _M_erase(iterator __first, iterator __last) { if (__first == __last) return __first; else if (__first == begin() && __last == end()) { clear(); return end(); } else { const difference_type __n = __last - __first; const difference_type __elems_before = __first - begin(); if (static_cast<size_type>(__elems_before) <= (size() - __n) / 2) { if (__first != begin()) std::move_backward(begin(), __first, __last); _M_erase_at_begin(begin() + __n); } else { if (__last != end()) std::move(__last, end(), __first); _M_erase_at_end(end() - __n); } return begin() + __elems_before; } } template <typename _Tp, class _Alloc> template <typename _InputIterator> void deque<_Tp, _Alloc>:: _M_assign_aux(_InputIterator __first, _InputIterator __last, std::input_iterator_tag) { iterator __cur = begin(); for (; __first != __last && __cur != end(); ++__cur, (void)++__first) *__cur = *__first; if (__first == __last) _M_erase_at_end(__cur); else _M_range_insert_aux(end(), __first, __last, std::__iterator_category(__first)); } template <typename _Tp, typename _Alloc> void deque<_Tp, _Alloc>:: _M_fill_insert(iterator __pos, size_type __n, const value_type& __x) { if (__pos._M_cur == this->_M_impl._M_start._M_cur) { iterator __new_start = _M_reserve_elements_at_front(__n); try { std::__uninitialized_fill_a(__new_start, this->_M_impl._M_start, __x, _M_get_Tp_allocator()); this->_M_impl._M_start = __new_start; } catch(...) { _M_destroy_nodes(__new_start._M_node, this->_M_impl._M_start._M_node); throw; } } else if (__pos._M_cur == this->_M_impl._M_finish._M_cur) { iterator __new_finish = _M_reserve_elements_at_back(__n); try { std::__uninitialized_fill_a(this->_M_impl._M_finish, __new_finish, __x, _M_get_Tp_allocator()); this->_M_impl._M_finish = __new_finish; } catch(...) { _M_destroy_nodes(this->_M_impl._M_finish._M_node + 1, __new_finish._M_node + 1); throw; } } else _M_insert_aux(__pos, __n, __x); } template <typename _Tp, typename _Alloc> void deque<_Tp, _Alloc>:: _M_default_append(size_type __n) { if (__n) { iterator __new_finish = _M_reserve_elements_at_back(__n); try { std::__uninitialized_default_a(this->_M_impl._M_finish, __new_finish, _M_get_Tp_allocator()); this->_M_impl._M_finish = __new_finish; } catch(...) { _M_destroy_nodes(this->_M_impl._M_finish._M_node + 1, __new_finish._M_node + 1); throw; } } } template <typename _Tp, typename _Alloc> bool deque<_Tp, _Alloc>:: _M_shrink_to_fit() { const difference_type __front_capacity = (this->_M_impl._M_start._M_cur - this->_M_impl._M_start._M_first); if (__front_capacity == 0) return false; const difference_type __back_capacity = (this->_M_impl._M_finish._M_last - this->_M_impl._M_finish._M_cur); if (__front_capacity + __back_capacity < _S_buffer_size()) return false; return std::__shrink_to_fit_aux<deque>::_S_do_it(*this); } template <typename _Tp, typename _Alloc> void deque<_Tp, _Alloc>:: _M_fill_initialize(const value_type& __value) { _Map_pointer __cur; try { for (__cur = this->_M_impl._M_start._M_node; __cur < this->_M_impl._M_finish._M_node; ++__cur) std::__uninitialized_fill_a(*__cur, *__cur + _S_buffer_size(), __value, _M_get_Tp_allocator()); std::__uninitialized_fill_a(this->_M_impl._M_finish._M_first, this->_M_impl._M_finish._M_cur, __value, _M_get_Tp_allocator()); } catch(...) { std::_Destroy(this->_M_impl._M_start, iterator(*__cur, __cur), _M_get_Tp_allocator()); throw; } } template <typename _Tp, typename _Alloc> template <typename _InputIterator> void deque<_Tp, _Alloc>:: _M_range_initialize(_InputIterator __first, _InputIterator __last, std::input_iterator_tag) { this->_M_initialize_map(0); try { for (; __first != __last; ++__first) emplace_back(*__first); } catch(...) { clear(); throw; } } template <typename _Tp, typename _Alloc> template <typename _ForwardIterator> void deque<_Tp, _Alloc>:: _M_range_initialize(_ForwardIterator __first, _ForwardIterator __last, std::forward_iterator_tag) { const size_type __n = std::distance(__first, __last); this->_M_initialize_map(_S_check_init_len(__n, _M_get_Tp_allocator())); _Map_pointer __cur_node; try { for (__cur_node = this->_M_impl._M_start._M_node; __cur_node < this->_M_impl._M_finish._M_node; ++__cur_node) { _ForwardIterator __mid = __first; std::advance(__mid, _S_buffer_size()); std::__uninitialized_copy_a(__first, __mid, *__cur_node, _M_get_Tp_allocator()); __first = __mid; } std::__uninitialized_copy_a(__first, __last, this->_M_impl._M_finish._M_first, _M_get_Tp_allocator()); } catch(...) { std::_Destroy(this->_M_impl._M_start, iterator(*__cur_node, __cur_node), _M_get_Tp_allocator()); throw; } } template<typename _Tp, typename _Alloc> template<typename... _Args> void deque<_Tp, _Alloc>:: _M_push_back_aux(_Args&&... __args) { if (size() == max_size()) __throw_length_error( ("cannot create std::deque larger than max_size()")); _M_reserve_map_at_back(); *(this->_M_impl._M_finish._M_node + 1) = this->_M_allocate_node(); try { _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish._M_cur, std::forward<_Args>(__args)...); this->_M_impl._M_finish._M_set_node(this->_M_impl._M_finish._M_node + 1); this->_M_impl._M_finish._M_cur = this->_M_impl._M_finish._M_first; } catch(...) { _M_deallocate_node(*(this->_M_impl._M_finish._M_node + 1)); throw; } } template<typename _Tp, typename _Alloc> template<typename... _Args> void deque<_Tp, _Alloc>:: _M_push_front_aux(_Args&&... __args) { if (size() == max_size()) __throw_length_error( ("cannot create std::deque larger than max_size()")); _M_reserve_map_at_front(); *(this->_M_impl._M_start._M_node - 1) = this->_M_allocate_node(); try { this->_M_impl._M_start._M_set_node(this->_M_impl._M_start._M_node - 1); this->_M_impl._M_start._M_cur = this->_M_impl._M_start._M_last - 1; _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_start._M_cur, std::forward<_Args>(__args)...); } catch(...) { ++this->_M_impl._M_start; _M_deallocate_node(*(this->_M_impl._M_start._M_node - 1)); throw; } } template <typename _Tp, typename _Alloc> void deque<_Tp, _Alloc>:: _M_pop_back_aux() { _M_deallocate_node(this->_M_impl._M_finish._M_first); this->_M_impl._M_finish._M_set_node(this->_M_impl._M_finish._M_node - 1); this->_M_impl._M_finish._M_cur = this->_M_impl._M_finish._M_last - 1; _Alloc_traits::destroy(_M_get_Tp_allocator(), this->_M_impl._M_finish._M_cur); } template <typename _Tp, typename _Alloc> void deque<_Tp, _Alloc>:: _M_pop_front_aux() { _Alloc_traits::destroy(_M_get_Tp_allocator(), this->_M_impl._M_start._M_cur); _M_deallocate_node(this->_M_impl._M_start._M_first); this->_M_impl._M_start._M_set_node(this->_M_impl._M_start._M_node + 1); this->_M_impl._M_start._M_cur = this->_M_impl._M_start._M_first; } template <typename _Tp, typename _Alloc> template <typename _InputIterator> void deque<_Tp, _Alloc>:: _M_range_insert_aux(iterator __pos, _InputIterator __first, _InputIterator __last, std::input_iterator_tag) { std::copy(__first, __last, std::inserter(*this, __pos)); } template <typename _Tp, typename _Alloc> template <typename _ForwardIterator> void deque<_Tp, _Alloc>:: _M_range_insert_aux(iterator __pos, _ForwardIterator __first, _ForwardIterator __last, std::forward_iterator_tag) { const size_type __n = std::distance(__first, __last); if (__pos._M_cur == this->_M_impl._M_start._M_cur) { iterator __new_start = _M_reserve_elements_at_front(__n); try { std::__uninitialized_copy_a(__first, __last, __new_start, _M_get_Tp_allocator()); this->_M_impl._M_start = __new_start; } catch(...) { _M_destroy_nodes(__new_start._M_node, this->_M_impl._M_start._M_node); throw; } } else if (__pos._M_cur == this->_M_impl._M_finish._M_cur) { iterator __new_finish = _M_reserve_elements_at_back(__n); try { std::__uninitialized_copy_a(__first, __last, this->_M_impl._M_finish, _M_get_Tp_allocator()); this->_M_impl._M_finish = __new_finish; } catch(...) { _M_destroy_nodes(this->_M_impl._M_finish._M_node + 1, __new_finish._M_node + 1); throw; } } else _M_insert_aux(__pos, __first, __last, __n); } template<typename _Tp, typename _Alloc> template<typename... _Args> typename deque<_Tp, _Alloc>::iterator deque<_Tp, _Alloc>:: _M_insert_aux(iterator __pos, _Args&&... __args) { value_type __x_copy(std::forward<_Args>(__args)...); difference_type __index = __pos - this->_M_impl._M_start; if (static_cast<size_type>(__index) < size() / 2) { push_front(std::move(front())); iterator __front1 = this->_M_impl._M_start; ++__front1; iterator __front2 = __front1; ++__front2; __pos = this->_M_impl._M_start + __index; iterator __pos1 = __pos; ++__pos1; std::move(__front2, __pos1, __front1); } else { push_back(std::move(back())); iterator __back1 = this->_M_impl._M_finish; --__back1; iterator __back2 = __back1; --__back2; __pos = this->_M_impl._M_start + __index; std::move_backward(__pos, __back2, __back1); } *__pos = std::move(__x_copy); return __pos; } template <typename _Tp, typename _Alloc> void deque<_Tp, _Alloc>:: _M_insert_aux(iterator __pos, size_type __n, const value_type& __x) { const difference_type __elems_before = __pos - this->_M_impl._M_start; const size_type __length = this->size(); value_type __x_copy = __x; if (__elems_before < difference_type(__length / 2)) { iterator __new_start = _M_reserve_elements_at_front(__n); iterator __old_start = this->_M_impl._M_start; __pos = this->_M_impl._M_start + __elems_before; try { if (__elems_before >= difference_type(__n)) { iterator __start_n = (this->_M_impl._M_start + difference_type(__n)); std::__uninitialized_move_a(this->_M_impl._M_start, __start_n, __new_start, _M_get_Tp_allocator()); this->_M_impl._M_start = __new_start; std::move(__start_n, __pos, __old_start); std::fill(__pos - difference_type(__n), __pos, __x_copy); } else { std::__uninitialized_move_fill(this->_M_impl._M_start, __pos, __new_start, this->_M_impl._M_start, __x_copy, _M_get_Tp_allocator()); this->_M_impl._M_start = __new_start; std::fill(__old_start, __pos, __x_copy); } } catch(...) { _M_destroy_nodes(__new_start._M_node, this->_M_impl._M_start._M_node); throw; } } else { iterator __new_finish = _M_reserve_elements_at_back(__n); iterator __old_finish = this->_M_impl._M_finish; const difference_type __elems_after = difference_type(__length) - __elems_before; __pos = this->_M_impl._M_finish - __elems_after; try { if (__elems_after > difference_type(__n)) { iterator __finish_n = (this->_M_impl._M_finish - difference_type(__n)); std::__uninitialized_move_a(__finish_n, this->_M_impl._M_finish, this->_M_impl._M_finish, _M_get_Tp_allocator()); this->_M_impl._M_finish = __new_finish; std::move_backward(__pos, __finish_n, __old_finish); std::fill(__pos, __pos + difference_type(__n), __x_copy); } else { std::__uninitialized_fill_move(this->_M_impl._M_finish, __pos + difference_type(__n), __x_copy, __pos, this->_M_impl._M_finish, _M_get_Tp_allocator()); this->_M_impl._M_finish = __new_finish; std::fill(__pos, __old_finish, __x_copy); } } catch(...) { _M_destroy_nodes(this->_M_impl._M_finish._M_node + 1, __new_finish._M_node + 1); throw; } } } template <typename _Tp, typename _Alloc> template <typename _ForwardIterator> void deque<_Tp, _Alloc>:: _M_insert_aux(iterator __pos, _ForwardIterator __first, _ForwardIterator __last, size_type __n) { const difference_type __elemsbefore = __pos - this->_M_impl._M_start; const size_type __length = size(); if (static_cast<size_type>(__elemsbefore) < __length / 2) { iterator __new_start = _M_reserve_elements_at_front(__n); iterator __old_start = this->_M_impl._M_start; __pos = this->_M_impl._M_start + __elemsbefore; try { if (__elemsbefore >= difference_type(__n)) { iterator __start_n = (this->_M_impl._M_start + difference_type(__n)); std::__uninitialized_move_a(this->_M_impl._M_start, __start_n, __new_start, _M_get_Tp_allocator()); this->_M_impl._M_start = __new_start; std::move(__start_n, __pos, __old_start); std::copy(__first, __last, __pos - difference_type(__n)); } else { _ForwardIterator __mid = __first; std::advance(__mid, difference_type(__n) - __elemsbefore); std::__uninitialized_move_copy(this->_M_impl._M_start, __pos, __first, __mid, __new_start, _M_get_Tp_allocator()); this->_M_impl._M_start = __new_start; std::copy(__mid, __last, __old_start); } } catch(...) { _M_destroy_nodes(__new_start._M_node, this->_M_impl._M_start._M_node); throw; } } else { iterator __new_finish = _M_reserve_elements_at_back(__n); iterator __old_finish = this->_M_impl._M_finish; const difference_type __elemsafter = difference_type(__length) - __elemsbefore; __pos = this->_M_impl._M_finish - __elemsafter; try { if (__elemsafter > difference_type(__n)) { iterator __finish_n = (this->_M_impl._M_finish - difference_type(__n)); std::__uninitialized_move_a(__finish_n, this->_M_impl._M_finish, this->_M_impl._M_finish, _M_get_Tp_allocator()); this->_M_impl._M_finish = __new_finish; std::move_backward(__pos, __finish_n, __old_finish); std::copy(__first, __last, __pos); } else { _ForwardIterator __mid = __first; std::advance(__mid, __elemsafter); std::__uninitialized_copy_move(__mid, __last, __pos, this->_M_impl._M_finish, this->_M_impl._M_finish, _M_get_Tp_allocator()); this->_M_impl._M_finish = __new_finish; std::copy(__first, __mid, __pos); } } catch(...) { _M_destroy_nodes(this->_M_impl._M_finish._M_node + 1, __new_finish._M_node + 1); throw; } } } template<typename _Tp, typename _Alloc> void deque<_Tp, _Alloc>:: _M_destroy_data_aux(iterator __first, iterator __last) { for (_Map_pointer __node = __first._M_node + 1; __node < __last._M_node; ++__node) std::_Destroy(*__node, *__node + _S_buffer_size(), _M_get_Tp_allocator()); if (__first._M_node != __last._M_node) { std::_Destroy(__first._M_cur, __first._M_last, _M_get_Tp_allocator()); std::_Destroy(__last._M_first, __last._M_cur, _M_get_Tp_allocator()); } else std::_Destroy(__first._M_cur, __last._M_cur, _M_get_Tp_allocator()); } template <typename _Tp, typename _Alloc> void deque<_Tp, _Alloc>:: _M_new_elements_at_front(size_type __new_elems) { if (this->max_size() - this->size() < __new_elems) __throw_length_error(("deque::_M_new_elements_at_front")); const size_type __new_nodes = ((__new_elems + _S_buffer_size() - 1) / _S_buffer_size()); _M_reserve_map_at_front(__new_nodes); size_type __i; try { for (__i = 1; __i <= __new_nodes; ++__i) *(this->_M_impl._M_start._M_node - __i) = this->_M_allocate_node(); } catch(...) { for (size_type __j = 1; __j < __i; ++__j) _M_deallocate_node(*(this->_M_impl._M_start._M_node - __j)); throw; } } template <typename _Tp, typename _Alloc> void deque<_Tp, _Alloc>:: _M_new_elements_at_back(size_type __new_elems) { if (this->max_size() - this->size() < __new_elems) __throw_length_error(("deque::_M_new_elements_at_back")); const size_type __new_nodes = ((__new_elems + _S_buffer_size() - 1) / _S_buffer_size()); _M_reserve_map_at_back(__new_nodes); size_type __i; try { for (__i = 1; __i <= __new_nodes; ++__i) *(this->_M_impl._M_finish._M_node + __i) = this->_M_allocate_node(); } catch(...) { for (size_type __j = 1; __j < __i; ++__j) _M_deallocate_node(*(this->_M_impl._M_finish._M_node + __j)); throw; } } template <typename _Tp, typename _Alloc> void deque<_Tp, _Alloc>:: _M_reallocate_map(size_type __nodes_to_add, bool __add_at_front) { const size_type __old_num_nodes = this->_M_impl._M_finish._M_node - this->_M_impl._M_start._M_node + 1; const size_type __new_num_nodes = __old_num_nodes + __nodes_to_add; _Map_pointer __new_nstart; if (this->_M_impl._M_map_size > 2 * __new_num_nodes) { __new_nstart = this->_M_impl._M_map + (this->_M_impl._M_map_size - __new_num_nodes) / 2 + (__add_at_front ? __nodes_to_add : 0); if (__new_nstart < this->_M_impl._M_start._M_node) std::copy(this->_M_impl._M_start._M_node, this->_M_impl._M_finish._M_node + 1, __new_nstart); else std::copy_backward(this->_M_impl._M_start._M_node, this->_M_impl._M_finish._M_node + 1, __new_nstart + __old_num_nodes); } else { size_type __new_map_size = this->_M_impl._M_map_size + std::max(this->_M_impl._M_map_size, __nodes_to_add) + 2; _Map_pointer __new_map = this->_M_allocate_map(__new_map_size); __new_nstart = __new_map + (__new_map_size - __new_num_nodes) / 2 + (__add_at_front ? __nodes_to_add : 0); std::copy(this->_M_impl._M_start._M_node, this->_M_impl._M_finish._M_node + 1, __new_nstart); _M_deallocate_map(this->_M_impl._M_map, this->_M_impl._M_map_size); this->_M_impl._M_map = __new_map; this->_M_impl._M_map_size = __new_map_size; } this->_M_impl._M_start._M_set_node(__new_nstart); this->_M_impl._M_finish._M_set_node(__new_nstart + __old_num_nodes - 1); } template<typename _Tp, typename _VTp> void __fill_a1(const std::_Deque_iterator<_Tp, _Tp&, _Tp*>& __first, const std::_Deque_iterator<_Tp, _Tp&, _Tp*>& __last, const _VTp& __value) { typedef std::_Deque_iterator<_Tp, _Tp&, _Tp*> _Iter; if (__first._M_node != __last._M_node) { std::__fill_a1(__first._M_cur, __first._M_last, __value); for (typename _Iter::_Map_pointer __node = __first._M_node + 1; __node < __last._M_node; ++__node) std::__fill_a1(*__node, *__node + _Iter::_S_buffer_size(), __value); std::__fill_a1(__last._M_first, __last._M_cur, __value); } else std::__fill_a1(__first._M_cur, __last._M_cur, __value); } template<bool _IsMove, typename _Tp, typename _Ref, typename _Ptr, typename _OI> _OI __copy_move_dit(std::_Deque_iterator<_Tp, _Ref, _Ptr> __first, std::_Deque_iterator<_Tp, _Ref, _Ptr> __last, _OI __result) { typedef std::_Deque_iterator<_Tp, _Ref, _Ptr> _Iter; if (__first._M_node != __last._M_node) { __result = std::__copy_move_a1<_IsMove>(__first._M_cur, __first._M_last, __result); for (typename _Iter::_Map_pointer __node = __first._M_node + 1; __node != __last._M_node; ++__node) __result = std::__copy_move_a1<_IsMove>(*__node, *__node + _Iter::_S_buffer_size(), __result); return std::__copy_move_a1<_IsMove>(__last._M_first, __last._M_cur, __result); } return std::__copy_move_a1<_IsMove>(__first._M_cur, __last._M_cur, __result); } template<bool _IsMove, typename _Tp, typename _Ref, typename _Ptr, typename _OI> _OI __copy_move_a1(std::_Deque_iterator<_Tp, _Ref, _Ptr> __first, std::_Deque_iterator<_Tp, _Ref, _Ptr> __last, _OI __result) { return __copy_move_dit<_IsMove>(__first, __last, __result); } template<bool _IsMove, typename _ITp, typename _IRef, typename _IPtr, typename _OTp> std::_Deque_iterator<_OTp, _OTp&, _OTp*> __copy_move_a1(std::_Deque_iterator<_ITp, _IRef, _IPtr> __first, std::_Deque_iterator<_ITp, _IRef, _IPtr> __last, std::_Deque_iterator<_OTp, _OTp&, _OTp*> __result) { return __copy_move_dit<_IsMove>(__first, __last, __result); } template<bool _IsMove, typename _II, typename _Tp> typename __gnu_cxx::__enable_if< __is_random_access_iter<_II>::__value, std::_Deque_iterator<_Tp, _Tp&, _Tp*> >::__type __copy_move_a1(_II __first, _II __last, std::_Deque_iterator<_Tp, _Tp&, _Tp*> __result) { typedef std::_Deque_iterator<_Tp, _Tp&, _Tp*> _Iter; typedef typename _Iter::difference_type difference_type; difference_type __len = __last - __first; while (__len > 0) { const difference_type __clen = std::min(__len, __result._M_last - __result._M_cur); std::__copy_move_a1<_IsMove>(__first, __first + __clen, __result._M_cur); __first += __clen; __result += __clen; __len -= __clen; } return __result; } template<bool _IsMove, typename _Tp, typename _Ref, typename _Ptr, typename _OI> _OI __copy_move_backward_dit( std::_Deque_iterator<_Tp, _Ref, _Ptr> __first, std::_Deque_iterator<_Tp, _Ref, _Ptr> __last, _OI __result) { typedef std::_Deque_iterator<_Tp, _Ref, _Ptr> _Iter; if (__first._M_node != __last._M_node) { __result = std::__copy_move_backward_a1<_IsMove>( __last._M_first, __last._M_cur, __result); for (typename _Iter::_Map_pointer __node = __last._M_node - 1; __node != __first._M_node; --__node) __result = std::__copy_move_backward_a1<_IsMove>( *__node, *__node + _Iter::_S_buffer_size(), __result); return std::__copy_move_backward_a1<_IsMove>( __first._M_cur, __first._M_last, __result); } return std::__copy_move_backward_a1<_IsMove>( __first._M_cur, __last._M_cur, __result); } template<bool _IsMove, typename _Tp, typename _Ref, typename _Ptr, typename _OI> _OI __copy_move_backward_a1( std::_Deque_iterator<_Tp, _Ref, _Ptr> __first, std::_Deque_iterator<_Tp, _Ref, _Ptr> __last, _OI __result) { return __copy_move_backward_dit<_IsMove>(__first, __last, __result); } template<bool _IsMove, typename _ITp, typename _IRef, typename _IPtr, typename _OTp> std::_Deque_iterator<_OTp, _OTp&, _OTp*> __copy_move_backward_a1( std::_Deque_iterator<_ITp, _IRef, _IPtr> __first, std::_Deque_iterator<_ITp, _IRef, _IPtr> __last, std::_Deque_iterator<_OTp, _OTp&, _OTp*> __result) { return __copy_move_backward_dit<_IsMove>(__first, __last, __result); } template<bool _IsMove, typename _II, typename _Tp> typename __gnu_cxx::__enable_if< __is_random_access_iter<_II>::__value, std::_Deque_iterator<_Tp, _Tp&, _Tp*> >::__type __copy_move_backward_a1(_II __first, _II __last, std::_Deque_iterator<_Tp, _Tp&, _Tp*> __result) { typedef std::_Deque_iterator<_Tp, _Tp&, _Tp*> _Iter; typedef typename _Iter::difference_type difference_type; difference_type __len = __last - __first; while (__len > 0) { difference_type __rlen = __result._M_cur - __result._M_first; _Tp* __rend = __result._M_cur; if (!__rlen) { __rlen = _Iter::_S_buffer_size(); __rend = *(__result._M_node - 1) + __rlen; } const difference_type __clen = std::min(__len, __rlen); std::__copy_move_backward_a1<_IsMove>(__last - __clen, __last, __rend); __last -= __clen; __result -= __clen; __len -= __clen; } return __result; } template<typename _Tp, typename _Ref, typename _Ptr, typename _II> bool __equal_dit( const std::_Deque_iterator<_Tp, _Ref, _Ptr>& __first1, const std::_Deque_iterator<_Tp, _Ref, _Ptr>& __last1, _II __first2) { typedef std::_Deque_iterator<_Tp, _Ref, _Ptr> _Iter; if (__first1._M_node != __last1._M_node) { if (!std::__equal_aux1(__first1._M_cur, __first1._M_last, __first2)) return false; __first2 += __first1._M_last - __first1._M_cur; for (typename _Iter::_Map_pointer __node = __first1._M_node + 1; __node != __last1._M_node; __first2 += _Iter::_S_buffer_size(), ++__node) if (!std::__equal_aux1(*__node, *__node + _Iter::_S_buffer_size(), __first2)) return false; return std::__equal_aux1(__last1._M_first, __last1._M_cur, __first2); } return std::__equal_aux1(__first1._M_cur, __last1._M_cur, __first2); } template<typename _Tp, typename _Ref, typename _Ptr, typename _II> typename __gnu_cxx::__enable_if< __is_random_access_iter<_II>::__value, bool>::__type __equal_aux1(std::_Deque_iterator<_Tp, _Ref, _Ptr> __first1, std::_Deque_iterator<_Tp, _Ref, _Ptr> __last1, _II __first2) { return std::__equal_dit(__first1, __last1, __first2); } template<typename _Tp1, typename _Ref1, typename _Ptr1, typename _Tp2, typename _Ref2, typename _Ptr2> bool __equal_aux1(std::_Deque_iterator<_Tp1, _Ref1, _Ptr1> __first1, std::_Deque_iterator<_Tp1, _Ref1, _Ptr1> __last1, std::_Deque_iterator<_Tp2, _Ref2, _Ptr2> __first2) { return std::__equal_dit(__first1, __last1, __first2); } template<typename _II, typename _Tp, typename _Ref, typename _Ptr> typename __gnu_cxx::__enable_if< __is_random_access_iter<_II>::__value, bool>::__type __equal_aux1(_II __first1, _II __last1, std::_Deque_iterator<_Tp, _Ref, _Ptr> __first2) { typedef std::_Deque_iterator<_Tp, _Ref, _Ptr> _Iter; typedef typename _Iter::difference_type difference_type; difference_type __len = __last1 - __first1; while (__len > 0) { const difference_type __clen = std::min(__len, __first2._M_last - __first2._M_cur); if (!std::__equal_aux1(__first1, __first1 + __clen, __first2._M_cur)) return false; __first1 += __clen; __len -= __clen; __first2 += __clen; } return true; } } namespace std __attribute__ ((__visibility__ ("default"))) { namespace __detail { struct _List_node_base { _List_node_base* _M_next; _List_node_base* _M_prev; static void swap(_List_node_base& __x, _List_node_base& __y) noexcept; void _M_transfer(_List_node_base* const __first, _List_node_base* const __last) noexcept; void _M_reverse() noexcept; void _M_hook(_List_node_base* const __position) noexcept; void _M_unhook() noexcept; }; struct _List_node_header : public _List_node_base { std::size_t _M_size; _List_node_header() noexcept { _M_init(); } _List_node_header(_List_node_header&& __x) noexcept : _List_node_base{ __x._M_next, __x._M_prev } , _M_size(__x._M_size) { if (__x._M_base()->_M_next == __x._M_base()) this->_M_next = this->_M_prev = this; else { this->_M_next->_M_prev = this->_M_prev->_M_next = this->_M_base(); __x._M_init(); } } void _M_move_nodes(_List_node_header&& __x) { _List_node_base* const __xnode = __x._M_base(); if (__xnode->_M_next == __xnode) _M_init(); else { _List_node_base* const __node = this->_M_base(); __node->_M_next = __xnode->_M_next; __node->_M_prev = __xnode->_M_prev; __node->_M_next->_M_prev = __node->_M_prev->_M_next = __node; _M_size = __x._M_size; __x._M_init(); } } void _M_init() noexcept { this->_M_next = this->_M_prev = this; this->_M_size = 0; } private: _List_node_base* _M_base() { return this; } }; } template<typename _Tp> struct _List_node : public __detail::_List_node_base { __gnu_cxx::__aligned_membuf<_Tp> _M_storage; _Tp* _M_valptr() { return _M_storage._M_ptr(); } _Tp const* _M_valptr() const { return _M_storage._M_ptr(); } }; template<typename _Tp> struct _List_iterator { typedef _List_iterator<_Tp> _Self; typedef _List_node<_Tp> _Node; typedef ptrdiff_t difference_type; typedef std::bidirectional_iterator_tag iterator_category; typedef _Tp value_type; typedef _Tp* pointer; typedef _Tp& reference; _List_iterator() noexcept : _M_node() { } explicit _List_iterator(__detail::_List_node_base* __x) noexcept : _M_node(__x) { } _Self _M_const_cast() const noexcept { return *this; } reference operator*() const noexcept { return *static_cast<_Node*>(_M_node)->_M_valptr(); } pointer operator->() const noexcept { return static_cast<_Node*>(_M_node)->_M_valptr(); } _Self& operator++() noexcept { _M_node = _M_node->_M_next; return *this; } _Self operator++(int) noexcept { _Self __tmp = *this; _M_node = _M_node->_M_next; return __tmp; } _Self& operator--() noexcept { _M_node = _M_node->_M_prev; return *this; } _Self operator--(int) noexcept { _Self __tmp = *this; _M_node = _M_node->_M_prev; return __tmp; } friend bool operator==(const _Self& __x, const _Self& __y) noexcept { return __x._M_node == __y._M_node; } friend bool operator!=(const _Self& __x, const _Self& __y) noexcept { return __x._M_node != __y._M_node; } __detail::_List_node_base* _M_node; }; template<typename _Tp> struct _List_const_iterator { typedef _List_const_iterator<_Tp> _Self; typedef const _List_node<_Tp> _Node; typedef _List_iterator<_Tp> iterator; typedef ptrdiff_t difference_type; typedef std::bidirectional_iterator_tag iterator_category; typedef _Tp value_type; typedef const _Tp* pointer; typedef const _Tp& reference; _List_const_iterator() noexcept : _M_node() { } explicit _List_const_iterator(const __detail::_List_node_base* __x) noexcept : _M_node(__x) { } _List_const_iterator(const iterator& __x) noexcept : _M_node(__x._M_node) { } iterator _M_const_cast() const noexcept { return iterator(const_cast<__detail::_List_node_base*>(_M_node)); } reference operator*() const noexcept { return *static_cast<_Node*>(_M_node)->_M_valptr(); } pointer operator->() const noexcept { return static_cast<_Node*>(_M_node)->_M_valptr(); } _Self& operator++() noexcept { _M_node = _M_node->_M_next; return *this; } _Self operator++(int) noexcept { _Self __tmp = *this; _M_node = _M_node->_M_next; return __tmp; } _Self& operator--() noexcept { _M_node = _M_node->_M_prev; return *this; } _Self operator--(int) noexcept { _Self __tmp = *this; _M_node = _M_node->_M_prev; return __tmp; } friend bool operator==(const _Self& __x, const _Self& __y) noexcept { return __x._M_node == __y._M_node; } friend bool operator!=(const _Self& __x, const _Self& __y) noexcept { return __x._M_node != __y._M_node; } const __detail::_List_node_base* _M_node; }; namespace __cxx11 { template<typename _Tp, typename _Alloc> class _List_base { protected: typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template rebind<_Tp>::other _Tp_alloc_type; typedef __gnu_cxx::__alloc_traits<_Tp_alloc_type> _Tp_alloc_traits; typedef typename _Tp_alloc_traits::template rebind<_List_node<_Tp> >::other _Node_alloc_type; typedef __gnu_cxx::__alloc_traits<_Node_alloc_type> _Node_alloc_traits; static size_t _S_distance(const __detail::_List_node_base* __first, const __detail::_List_node_base* __last) { size_t __n = 0; while (__first != __last) { __first = __first->_M_next; ++__n; } return __n; } struct _List_impl : public _Node_alloc_type { __detail::_List_node_header _M_node; _List_impl() noexcept(is_nothrow_default_constructible<_Node_alloc_type>::value) : _Node_alloc_type() { } _List_impl(const _Node_alloc_type& __a) noexcept : _Node_alloc_type(__a) { } _List_impl(_List_impl&&) = default; _List_impl(_Node_alloc_type&& __a, _List_impl&& __x) : _Node_alloc_type(std::move(__a)), _M_node(std::move(__x._M_node)) { } _List_impl(_Node_alloc_type&& __a) noexcept : _Node_alloc_type(std::move(__a)) { } }; _List_impl _M_impl; size_t _M_get_size() const { return _M_impl._M_node._M_size; } void _M_set_size(size_t __n) { _M_impl._M_node._M_size = __n; } void _M_inc_size(size_t __n) { _M_impl._M_node._M_size += __n; } void _M_dec_size(size_t __n) { _M_impl._M_node._M_size -= __n; } size_t _M_distance(const __detail::_List_node_base* __first, const __detail::_List_node_base* __last) const { return _S_distance(__first, __last); } size_t _M_node_count() const { return _M_get_size(); } typename _Node_alloc_traits::pointer _M_get_node() { return _Node_alloc_traits::allocate(_M_impl, 1); } void _M_put_node(typename _Node_alloc_traits::pointer __p) noexcept { _Node_alloc_traits::deallocate(_M_impl, __p, 1); } public: typedef _Alloc allocator_type; _Node_alloc_type& _M_get_Node_allocator() noexcept { return _M_impl; } const _Node_alloc_type& _M_get_Node_allocator() const noexcept { return _M_impl; } _List_base() = default; _List_base(const _Node_alloc_type& __a) noexcept : _M_impl(__a) { } _List_base(_List_base&&) = default; _List_base(_List_base&& __x, _Node_alloc_type&& __a) : _M_impl(std::move(__a)) { if (__x._M_get_Node_allocator() == _M_get_Node_allocator()) _M_move_nodes(std::move(__x)); } _List_base(_Node_alloc_type&& __a, _List_base&& __x) : _M_impl(std::move(__a), std::move(__x._M_impl)) { } _List_base(_Node_alloc_type&& __a) : _M_impl(std::move(__a)) { } void _M_move_nodes(_List_base&& __x) { _M_impl._M_node._M_move_nodes(std::move(__x._M_impl._M_node)); } ~_List_base() noexcept { _M_clear(); } void _M_clear() noexcept; void _M_init() noexcept { this->_M_impl._M_node._M_init(); } }; template<typename _Tp, typename _Alloc = std::allocator<_Tp> > class list : protected _List_base<_Tp, _Alloc> { static_assert(is_same<typename remove_cv<_Tp>::type, _Tp>::value, "std::list must have a non-const, non-volatile value_type"); typedef _List_base<_Tp, _Alloc> _Base; typedef typename _Base::_Tp_alloc_type _Tp_alloc_type; typedef typename _Base::_Tp_alloc_traits _Tp_alloc_traits; typedef typename _Base::_Node_alloc_type _Node_alloc_type; typedef typename _Base::_Node_alloc_traits _Node_alloc_traits; public: typedef _Tp value_type; typedef typename _Tp_alloc_traits::pointer pointer; typedef typename _Tp_alloc_traits::const_pointer const_pointer; typedef typename _Tp_alloc_traits::reference reference; typedef typename _Tp_alloc_traits::const_reference const_reference; typedef _List_iterator<_Tp> iterator; typedef _List_const_iterator<_Tp> const_iterator; typedef std::reverse_iterator<const_iterator> const_reverse_iterator; typedef std::reverse_iterator<iterator> reverse_iterator; typedef size_t size_type; typedef ptrdiff_t difference_type; typedef _Alloc allocator_type; protected: typedef _List_node<_Tp> _Node; using _Base::_M_impl; using _Base::_M_put_node; using _Base::_M_get_node; using _Base::_M_get_Node_allocator; template<typename... _Args> _Node* _M_create_node(_Args&&... __args) { auto __p = this->_M_get_node(); auto& __alloc = _M_get_Node_allocator(); __allocated_ptr<_Node_alloc_type> __guard{__alloc, __p}; _Node_alloc_traits::construct(__alloc, __p->_M_valptr(), std::forward<_Args>(__args)...); __guard = nullptr; return __p; } static size_t _S_distance(const_iterator __first, const_iterator __last) { return std::distance(__first, __last); } size_t _M_node_count() const { return this->_M_get_size(); } public: list() = default; explicit list(const allocator_type& __a) noexcept : _Base(_Node_alloc_type(__a)) { } explicit list(size_type __n, const allocator_type& __a = allocator_type()) : _Base(_Node_alloc_type(__a)) { _M_default_initialize(__n); } list(size_type __n, const value_type& __value, const allocator_type& __a = allocator_type()) : _Base(_Node_alloc_type(__a)) { _M_fill_initialize(__n, __value); } list(const list& __x) : _Base(_Node_alloc_traits:: _S_select_on_copy(__x._M_get_Node_allocator())) { _M_initialize_dispatch(__x.begin(), __x.end(), __false_type()); } list(list&&) = default; list(initializer_list<value_type> __l, const allocator_type& __a = allocator_type()) : _Base(_Node_alloc_type(__a)) { _M_initialize_dispatch(__l.begin(), __l.end(), __false_type()); } list(const list& __x, const allocator_type& __a) : _Base(_Node_alloc_type(__a)) { _M_initialize_dispatch(__x.begin(), __x.end(), __false_type()); } private: list(list&& __x, const allocator_type& __a, true_type) noexcept : _Base(_Node_alloc_type(__a), std::move(__x)) { } list(list&& __x, const allocator_type& __a, false_type) : _Base(_Node_alloc_type(__a)) { if (__x._M_get_Node_allocator() == this->_M_get_Node_allocator()) this->_M_move_nodes(std::move(__x)); else insert(begin(), std::__make_move_if_noexcept_iterator(__x.begin()), std::__make_move_if_noexcept_iterator(__x.end())); } public: list(list&& __x, const allocator_type& __a) noexcept(_Node_alloc_traits::_S_always_equal()) : list(std::move(__x), __a, typename _Node_alloc_traits::is_always_equal{}) { } template<typename _InputIterator, typename = std::_RequireInputIter<_InputIterator>> list(_InputIterator __first, _InputIterator __last, const allocator_type& __a = allocator_type()) : _Base(_Node_alloc_type(__a)) { _M_initialize_dispatch(__first, __last, __false_type()); } ~list() = default; list& operator=(const list& __x); list& operator=(list&& __x) noexcept(_Node_alloc_traits::_S_nothrow_move()) { constexpr bool __move_storage = _Node_alloc_traits::_S_propagate_on_move_assign() || _Node_alloc_traits::_S_always_equal(); _M_move_assign(std::move(__x), __bool_constant<__move_storage>()); return *this; } list& operator=(initializer_list<value_type> __l) { this->assign(__l.begin(), __l.end()); return *this; } void assign(size_type __n, const value_type& __val) { _M_fill_assign(__n, __val); } template<typename _InputIterator, typename = std::_RequireInputIter<_InputIterator>> void assign(_InputIterator __first, _InputIterator __last) { _M_assign_dispatch(__first, __last, __false_type()); } void assign(initializer_list<value_type> __l) { this->_M_assign_dispatch(__l.begin(), __l.end(), __false_type()); } allocator_type get_allocator() const noexcept { return allocator_type(_Base::_M_get_Node_allocator()); } iterator begin() noexcept { return iterator(this->_M_impl._M_node._M_next); } const_iterator begin() const noexcept { return const_iterator(this->_M_impl._M_node._M_next); } iterator end() noexcept { return iterator(&this->_M_impl._M_node); } const_iterator end() const noexcept { return const_iterator(&this->_M_impl._M_node); } reverse_iterator rbegin() noexcept { return reverse_iterator(end()); } const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); } reverse_iterator rend() noexcept { return reverse_iterator(begin()); } const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); } const_iterator cbegin() const noexcept { return const_iterator(this->_M_impl._M_node._M_next); } const_iterator cend() const noexcept { return const_iterator(&this->_M_impl._M_node); } const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(end()); } const_reverse_iterator crend() const noexcept { return const_reverse_iterator(begin()); } bool empty() const noexcept { return this->_M_impl._M_node._M_next == &this->_M_impl._M_node; } size_type size() const noexcept { return _M_node_count(); } size_type max_size() const noexcept { return _Node_alloc_traits::max_size(_M_get_Node_allocator()); } void resize(size_type __new_size); void resize(size_type __new_size, const value_type& __x); reference front() noexcept { return *begin(); } const_reference front() const noexcept { return *begin(); } reference back() noexcept { iterator __tmp = end(); --__tmp; return *__tmp; } const_reference back() const noexcept { const_iterator __tmp = end(); --__tmp; return *__tmp; } void push_front(const value_type& __x) { this->_M_insert(begin(), __x); } void push_front(value_type&& __x) { this->_M_insert(begin(), std::move(__x)); } template<typename... _Args> void emplace_front(_Args&&... __args) { this->_M_insert(begin(), std::forward<_Args>(__args)...); } void pop_front() noexcept { this->_M_erase(begin()); } void push_back(const value_type& __x) { this->_M_insert(end(), __x); } void push_back(value_type&& __x) { this->_M_insert(end(), std::move(__x)); } template<typename... _Args> void emplace_back(_Args&&... __args) { this->_M_insert(end(), std::forward<_Args>(__args)...); } void pop_back() noexcept { this->_M_erase(iterator(this->_M_impl._M_node._M_prev)); } template<typename... _Args> iterator emplace(const_iterator __position, _Args&&... __args); iterator insert(const_iterator __position, const value_type& __x); iterator insert(const_iterator __position, value_type&& __x) { return emplace(__position, std::move(__x)); } iterator insert(const_iterator __p, initializer_list<value_type> __l) { return this->insert(__p, __l.begin(), __l.end()); } iterator insert(const_iterator __position, size_type __n, const value_type& __x); template<typename _InputIterator, typename = std::_RequireInputIter<_InputIterator>> iterator insert(const_iterator __position, _InputIterator __first, _InputIterator __last); iterator erase(const_iterator __position) noexcept; iterator erase(const_iterator __first, const_iterator __last) noexcept { while (__first != __last) __first = erase(__first); return __last._M_const_cast(); } void swap(list& __x) noexcept { __detail::_List_node_base::swap(this->_M_impl._M_node, __x._M_impl._M_node); size_t __xsize = __x._M_get_size(); __x._M_set_size(this->_M_get_size()); this->_M_set_size(__xsize); _Node_alloc_traits::_S_on_swap(this->_M_get_Node_allocator(), __x._M_get_Node_allocator()); } void clear() noexcept { _Base::_M_clear(); _Base::_M_init(); } void splice(const_iterator __position, list&& __x) noexcept { if (!__x.empty()) { _M_check_equal_allocators(__x); this->_M_transfer(__position._M_const_cast(), __x.begin(), __x.end()); this->_M_inc_size(__x._M_get_size()); __x._M_set_size(0); } } void splice(const_iterator __position, list& __x) noexcept { splice(__position, std::move(__x)); } void splice(const_iterator __position, list&& __x, const_iterator __i) noexcept { iterator __j = __i._M_const_cast(); ++__j; if (__position == __i || __position == __j) return; if (this != std::__addressof(__x)) _M_check_equal_allocators(__x); this->_M_transfer(__position._M_const_cast(), __i._M_const_cast(), __j); this->_M_inc_size(1); __x._M_dec_size(1); } void splice(const_iterator __position, list& __x, const_iterator __i) noexcept { splice(__position, std::move(__x), __i); } void splice(const_iterator __position, list&& __x, const_iterator __first, const_iterator __last) noexcept { if (__first != __last) { if (this != std::__addressof(__x)) _M_check_equal_allocators(__x); size_t __n = _S_distance(__first, __last); this->_M_inc_size(__n); __x._M_dec_size(__n); this->_M_transfer(__position._M_const_cast(), __first._M_const_cast(), __last._M_const_cast()); } } void splice(const_iterator __position, list& __x, const_iterator __first, const_iterator __last) noexcept { splice(__position, std::move(__x), __first, __last); } private: typedef void __remove_return_type; public: __remove_return_type remove(const _Tp& __value); template<typename _Predicate> __remove_return_type remove_if(_Predicate); __remove_return_type unique(); template<typename _BinaryPredicate> __remove_return_type unique(_BinaryPredicate); void merge(list&& __x); void merge(list& __x) { merge(std::move(__x)); } template<typename _StrictWeakOrdering> void merge(list&& __x, _StrictWeakOrdering __comp); template<typename _StrictWeakOrdering> void merge(list& __x, _StrictWeakOrdering __comp) { merge(std::move(__x), __comp); } void reverse() noexcept { this->_M_impl._M_node._M_reverse(); } void sort(); template<typename _StrictWeakOrdering> void sort(_StrictWeakOrdering); protected: template<typename _Integer> void _M_initialize_dispatch(_Integer __n, _Integer __x, __true_type) { _M_fill_initialize(static_cast<size_type>(__n), __x); } template<typename _InputIterator> void _M_initialize_dispatch(_InputIterator __first, _InputIterator __last, __false_type) { for (; __first != __last; ++__first) emplace_back(*__first); } void _M_fill_initialize(size_type __n, const value_type& __x) { for (; __n; --__n) push_back(__x); } void _M_default_initialize(size_type __n) { for (; __n; --__n) emplace_back(); } void _M_default_append(size_type __n); template<typename _Integer> void _M_assign_dispatch(_Integer __n, _Integer __val, __true_type) { _M_fill_assign(__n, __val); } template<typename _InputIterator> void _M_assign_dispatch(_InputIterator __first, _InputIterator __last, __false_type); void _M_fill_assign(size_type __n, const value_type& __val); void _M_transfer(iterator __position, iterator __first, iterator __last) { __position._M_node->_M_transfer(__first._M_node, __last._M_node); } template<typename... _Args> void _M_insert(iterator __position, _Args&&... __args) { _Node* __tmp = _M_create_node(std::forward<_Args>(__args)...); __tmp->_M_hook(__position._M_node); this->_M_inc_size(1); } void _M_erase(iterator __position) noexcept { this->_M_dec_size(1); __position._M_node->_M_unhook(); _Node* __n = static_cast<_Node*>(__position._M_node); _Node_alloc_traits::destroy(_M_get_Node_allocator(), __n->_M_valptr()); _M_put_node(__n); } void _M_check_equal_allocators(list& __x) noexcept { if (std::__alloc_neq<typename _Base::_Node_alloc_type>:: _S_do_it(_M_get_Node_allocator(), __x._M_get_Node_allocator())) __builtin_abort(); } const_iterator _M_resize_pos(size_type& __new_size) const; void _M_move_assign(list&& __x, true_type) noexcept { this->_M_clear(); this->_M_move_nodes(std::move(__x)); std::__alloc_on_move(this->_M_get_Node_allocator(), __x._M_get_Node_allocator()); } void _M_move_assign(list&& __x, false_type) { if (__x._M_get_Node_allocator() == this->_M_get_Node_allocator()) _M_move_assign(std::move(__x), true_type{}); else _M_assign_dispatch(std::make_move_iterator(__x.begin()), std::make_move_iterator(__x.end()), __false_type{}); } }; } template<typename _Tp, typename _Alloc> inline bool operator==(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) { if (__x.size() != __y.size()) return false; typedef typename list<_Tp, _Alloc>::const_iterator const_iterator; const_iterator __end1 = __x.end(); const_iterator __end2 = __y.end(); const_iterator __i1 = __x.begin(); const_iterator __i2 = __y.begin(); while (__i1 != __end1 && __i2 != __end2 && *__i1 == *__i2) { ++__i1; ++__i2; } return __i1 == __end1 && __i2 == __end2; } template<typename _Tp, typename _Alloc> inline bool operator<(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) { return std::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end()); } template<typename _Tp, typename _Alloc> inline bool operator!=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) { return !(__x == __y); } template<typename _Tp, typename _Alloc> inline bool operator>(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) { return __y < __x; } template<typename _Tp, typename _Alloc> inline bool operator<=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) { return !(__y < __x); } template<typename _Tp, typename _Alloc> inline bool operator>=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) { return !(__x < __y); } template<typename _Tp, typename _Alloc> inline void swap(list<_Tp, _Alloc>& __x, list<_Tp, _Alloc>& __y) noexcept(noexcept(__x.swap(__y))) { __x.swap(__y); } template<typename _Tp> inline ptrdiff_t __distance(std::_List_iterator<_Tp> __first, std::_List_iterator<_Tp> __last, input_iterator_tag __tag) { typedef std::_List_const_iterator<_Tp> _CIter; return std::__distance(_CIter(__first), _CIter(__last), __tag); } template<typename _Tp> inline ptrdiff_t __distance(std::_List_const_iterator<_Tp> __first, std::_List_const_iterator<_Tp> __last, input_iterator_tag) { typedef __detail::_List_node_header _Sentinel; std::_List_const_iterator<_Tp> __beyond = __last; ++__beyond; const bool __whole = __first == __beyond; if (__builtin_constant_p (__whole) && __whole) return static_cast<const _Sentinel*>(__last._M_node)->_M_size; ptrdiff_t __n = 0; while (__first != __last) { ++__first; ++__n; } return __n; } } namespace std __attribute__ ((__visibility__ ("default"))) { template<typename _Tp, typename _Alloc> void _List_base<_Tp, _Alloc>:: _M_clear() noexcept { typedef _List_node<_Tp> _Node; __detail::_List_node_base* __cur = _M_impl._M_node._M_next; while (__cur != &_M_impl._M_node) { _Node* __tmp = static_cast<_Node*>(__cur); __cur = __tmp->_M_next; _Tp* __val = __tmp->_M_valptr(); _Node_alloc_traits::destroy(_M_get_Node_allocator(), __val); _M_put_node(__tmp); } } template<typename _Tp, typename _Alloc> template<typename... _Args> typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>:: emplace(const_iterator __position, _Args&&... __args) { _Node* __tmp = _M_create_node(std::forward<_Args>(__args)...); __tmp->_M_hook(__position._M_const_cast()._M_node); this->_M_inc_size(1); return iterator(__tmp); } template<typename _Tp, typename _Alloc> typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>:: insert(const_iterator __position, const value_type& __x) { _Node* __tmp = _M_create_node(__x); __tmp->_M_hook(__position._M_const_cast()._M_node); this->_M_inc_size(1); return iterator(__tmp); } template<typename _Tp, typename _Alloc> typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>:: insert(const_iterator __position, size_type __n, const value_type& __x) { if (__n) { list __tmp(__n, __x, get_allocator()); iterator __it = __tmp.begin(); splice(__position, __tmp); return __it; } return __position._M_const_cast(); } template<typename _Tp, typename _Alloc> template<typename _InputIterator, typename> typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>:: insert(const_iterator __position, _InputIterator __first, _InputIterator __last) { list __tmp(__first, __last, get_allocator()); if (!__tmp.empty()) { iterator __it = __tmp.begin(); splice(__position, __tmp); return __it; } return __position._M_const_cast(); } template<typename _Tp, typename _Alloc> typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>:: erase(const_iterator __position) noexcept { iterator __ret = iterator(__position._M_node->_M_next); _M_erase(__position._M_const_cast()); return __ret; } template<typename _Tp, typename _Alloc> typename list<_Tp, _Alloc>::const_iterator list<_Tp, _Alloc>:: _M_resize_pos(size_type& __new_size) const { const_iterator __i; const size_type __len = size(); if (__new_size < __len) { if (__new_size <= __len / 2) { __i = begin(); std::advance(__i, __new_size); } else { __i = end(); ptrdiff_t __num_erase = __len - __new_size; std::advance(__i, -__num_erase); } __new_size = 0; return __i; } else __i = end(); __new_size -= __len; return __i; } template<typename _Tp, typename _Alloc> void list<_Tp, _Alloc>:: _M_default_append(size_type __n) { size_type __i = 0; try { for (; __i < __n; ++__i) emplace_back(); } catch(...) { for (; __i; --__i) pop_back(); throw; } } template<typename _Tp, typename _Alloc> void list<_Tp, _Alloc>:: resize(size_type __new_size) { const_iterator __i = _M_resize_pos(__new_size); if (__new_size) _M_default_append(__new_size); else erase(__i, end()); } template<typename _Tp, typename _Alloc> void list<_Tp, _Alloc>:: resize(size_type __new_size, const value_type& __x) { const_iterator __i = _M_resize_pos(__new_size); if (__new_size) insert(end(), __new_size, __x); else erase(__i, end()); } template<typename _Tp, typename _Alloc> list<_Tp, _Alloc>& list<_Tp, _Alloc>:: operator=(const list& __x) { if (this != std::__addressof(__x)) { if (_Node_alloc_traits::_S_propagate_on_copy_assign()) { auto& __this_alloc = this->_M_get_Node_allocator(); auto& __that_alloc = __x._M_get_Node_allocator(); if (!_Node_alloc_traits::_S_always_equal() && __this_alloc != __that_alloc) { clear(); } std::__alloc_on_copy(__this_alloc, __that_alloc); } _M_assign_dispatch(__x.begin(), __x.end(), __false_type()); } return *this; } template<typename _Tp, typename _Alloc> void list<_Tp, _Alloc>:: _M_fill_assign(size_type __n, const value_type& __val) { iterator __i = begin(); for (; __i != end() && __n > 0; ++__i, --__n) *__i = __val; if (__n > 0) insert(end(), __n, __val); else erase(__i, end()); } template<typename _Tp, typename _Alloc> template <typename _InputIterator> void list<_Tp, _Alloc>:: _M_assign_dispatch(_InputIterator __first2, _InputIterator __last2, __false_type) { iterator __first1 = begin(); iterator __last1 = end(); for (; __first1 != __last1 && __first2 != __last2; ++__first1, (void)++__first2) *__first1 = *__first2; if (__first2 == __last2) erase(__first1, __last1); else insert(__last1, __first2, __last2); } template<typename _Tp, typename _Alloc> typename list<_Tp, _Alloc>::__remove_return_type list<_Tp, _Alloc>:: remove(const value_type& __value) { size_type __removed __attribute__((__unused__)) = 0; iterator __first = begin(); iterator __last = end(); iterator __extra = __last; while (__first != __last) { iterator __next = __first; ++__next; if (*__first == __value) { if (std::__addressof(*__first) != std::__addressof(__value)) { _M_erase(__first); ; } else __extra = __first; } __first = __next; } if (__extra != __last) { _M_erase(__extra); ; } return ; } template<typename _Tp, typename _Alloc> typename list<_Tp, _Alloc>::__remove_return_type list<_Tp, _Alloc>:: unique() { iterator __first = begin(); iterator __last = end(); if (__first == __last) return ; size_type __removed __attribute__((__unused__)) = 0; iterator __next = __first; while (++__next != __last) { if (*__first == *__next) { _M_erase(__next); ; } else __first = __next; __next = __first; } return ; } template<typename _Tp, typename _Alloc> void list<_Tp, _Alloc>:: merge(list&& __x) { if (this != std::__addressof(__x)) { _M_check_equal_allocators(__x); iterator __first1 = begin(); iterator __last1 = end(); iterator __first2 = __x.begin(); iterator __last2 = __x.end(); const size_t __orig_size = __x.size(); try { while (__first1 != __last1 && __first2 != __last2) if (*__first2 < *__first1) { iterator __next = __first2; _M_transfer(__first1, __first2, ++__next); __first2 = __next; } else ++__first1; if (__first2 != __last2) _M_transfer(__last1, __first2, __last2); this->_M_inc_size(__x._M_get_size()); __x._M_set_size(0); } catch(...) { const size_t __dist = std::distance(__first2, __last2); this->_M_inc_size(__orig_size - __dist); __x._M_set_size(__dist); throw; } } } template<typename _Tp, typename _Alloc> template <typename _StrictWeakOrdering> void list<_Tp, _Alloc>:: merge(list&& __x, _StrictWeakOrdering __comp) { if (this != std::__addressof(__x)) { _M_check_equal_allocators(__x); iterator __first1 = begin(); iterator __last1 = end(); iterator __first2 = __x.begin(); iterator __last2 = __x.end(); const size_t __orig_size = __x.size(); try { while (__first1 != __last1 && __first2 != __last2) if (__comp(*__first2, *__first1)) { iterator __next = __first2; _M_transfer(__first1, __first2, ++__next); __first2 = __next; } else ++__first1; if (__first2 != __last2) _M_transfer(__last1, __first2, __last2); this->_M_inc_size(__x._M_get_size()); __x._M_set_size(0); } catch(...) { const size_t __dist = std::distance(__first2, __last2); this->_M_inc_size(__orig_size - __dist); __x._M_set_size(__dist); throw; } } } template<typename _Tp, typename _Alloc> void list<_Tp, _Alloc>:: sort() { if (this->_M_impl._M_node._M_next != &this->_M_impl._M_node && this->_M_impl._M_node._M_next->_M_next != &this->_M_impl._M_node) { list __carry; list __tmp[64]; list * __fill = __tmp; list * __counter; try { do { __carry.splice(__carry.begin(), *this, begin()); for(__counter = __tmp; __counter != __fill && !__counter->empty(); ++__counter) { __counter->merge(__carry); __carry.swap(*__counter); } __carry.swap(*__counter); if (__counter == __fill) ++__fill; } while ( !empty() ); for (__counter = __tmp + 1; __counter != __fill; ++__counter) __counter->merge(*(__counter - 1)); swap( *(__fill - 1) ); } catch(...) { this->splice(this->end(), __carry); for (int __i = 0; __i < sizeof(__tmp)/sizeof(__tmp[0]); ++__i) this->splice(this->end(), __tmp[__i]); throw; } } } template<typename _Tp, typename _Alloc> template <typename _Predicate> typename list<_Tp, _Alloc>::__remove_return_type list<_Tp, _Alloc>:: remove_if(_Predicate __pred) { size_type __removed __attribute__((__unused__)) = 0; iterator __first = begin(); iterator __last = end(); while (__first != __last) { iterator __next = __first; ++__next; if (__pred(*__first)) { _M_erase(__first); ; } __first = __next; } return ; } template<typename _Tp, typename _Alloc> template <typename _BinaryPredicate> typename list<_Tp, _Alloc>::__remove_return_type list<_Tp, _Alloc>:: unique(_BinaryPredicate __binary_pred) { iterator __first = begin(); iterator __last = end(); if (__first == __last) return ; size_type __removed __attribute__((__unused__)) = 0; iterator __next = __first; while (++__next != __last) { if (__binary_pred(*__first, *__next)) { _M_erase(__next); ; } else __first = __next; __next = __first; } return ; } template<typename _Tp, typename _Alloc> template <typename _StrictWeakOrdering> void list<_Tp, _Alloc>:: sort(_StrictWeakOrdering __comp) { if (this->_M_impl._M_node._M_next != &this->_M_impl._M_node && this->_M_impl._M_node._M_next->_M_next != &this->_M_impl._M_node) { list __carry; list __tmp[64]; list * __fill = __tmp; list * __counter; try { do { __carry.splice(__carry.begin(), *this, begin()); for(__counter = __tmp; __counter != __fill && !__counter->empty(); ++__counter) { __counter->merge(__carry, __comp); __carry.swap(*__counter); } __carry.swap(*__counter); if (__counter == __fill) ++__fill; } while ( !empty() ); for (__counter = __tmp + 1; __counter != __fill; ++__counter) __counter->merge(*(__counter - 1), __comp); swap(*(__fill - 1)); } catch(...) { this->splice(this->end(), __carry); for (int __i = 0; __i < sizeof(__tmp)/sizeof(__tmp[0]); ++__i) this->splice(this->end(), __tmp[__i]); throw; } } } } namespace std __attribute__ ((__visibility__ ("default"))) { enum _Rb_tree_color { _S_red = false, _S_black = true }; struct _Rb_tree_node_base { typedef _Rb_tree_node_base* _Base_ptr; typedef const _Rb_tree_node_base* _Const_Base_ptr; _Rb_tree_color _M_color; _Base_ptr _M_parent; _Base_ptr _M_left; _Base_ptr _M_right; static _Base_ptr _S_minimum(_Base_ptr __x) noexcept { while (__x->_M_left != 0) __x = __x->_M_left; return __x; } static _Const_Base_ptr _S_minimum(_Const_Base_ptr __x) noexcept { while (__x->_M_left != 0) __x = __x->_M_left; return __x; } static _Base_ptr _S_maximum(_Base_ptr __x) noexcept { while (__x->_M_right != 0) __x = __x->_M_right; return __x; } static _Const_Base_ptr _S_maximum(_Const_Base_ptr __x) noexcept { while (__x->_M_right != 0) __x = __x->_M_right; return __x; } }; template<typename _Key_compare> struct _Rb_tree_key_compare { _Key_compare _M_key_compare; _Rb_tree_key_compare() noexcept(is_nothrow_default_constructible<_Key_compare>::value) : _M_key_compare() { } _Rb_tree_key_compare(const _Key_compare& __comp) : _M_key_compare(__comp) { } _Rb_tree_key_compare(const _Rb_tree_key_compare&) = default; _Rb_tree_key_compare(_Rb_tree_key_compare&& __x) noexcept(is_nothrow_copy_constructible<_Key_compare>::value) : _M_key_compare(__x._M_key_compare) { } }; struct _Rb_tree_header { _Rb_tree_node_base _M_header; size_t _M_node_count; _Rb_tree_header() noexcept { _M_header._M_color = _S_red; _M_reset(); } _Rb_tree_header(_Rb_tree_header&& __x) noexcept { if (__x._M_header._M_parent != nullptr) _M_move_data(__x); else { _M_header._M_color = _S_red; _M_reset(); } } void _M_move_data(_Rb_tree_header& __from) { _M_header._M_color = __from._M_header._M_color; _M_header._M_parent = __from._M_header._M_parent; _M_header._M_left = __from._M_header._M_left; _M_header._M_right = __from._M_header._M_right; _M_header._M_parent->_M_parent = &_M_header; _M_node_count = __from._M_node_count; __from._M_reset(); } void _M_reset() { _M_header._M_parent = 0; _M_header._M_left = &_M_header; _M_header._M_right = &_M_header; _M_node_count = 0; } }; template<typename _Val> struct _Rb_tree_node : public _Rb_tree_node_base { typedef _Rb_tree_node<_Val>* _Link_type; __gnu_cxx::__aligned_membuf<_Val> _M_storage; _Val* _M_valptr() { return _M_storage._M_ptr(); } const _Val* _M_valptr() const { return _M_storage._M_ptr(); } }; __attribute__ ((__pure__)) _Rb_tree_node_base* _Rb_tree_increment(_Rb_tree_node_base* __x) throw (); __attribute__ ((__pure__)) const _Rb_tree_node_base* _Rb_tree_increment(const _Rb_tree_node_base* __x) throw (); __attribute__ ((__pure__)) _Rb_tree_node_base* _Rb_tree_decrement(_Rb_tree_node_base* __x) throw (); __attribute__ ((__pure__)) const _Rb_tree_node_base* _Rb_tree_decrement(const _Rb_tree_node_base* __x) throw (); template<typename _Tp> struct _Rb_tree_iterator { typedef _Tp value_type; typedef _Tp& reference; typedef _Tp* pointer; typedef bidirectional_iterator_tag iterator_category; typedef ptrdiff_t difference_type; typedef _Rb_tree_iterator<_Tp> _Self; typedef _Rb_tree_node_base::_Base_ptr _Base_ptr; typedef _Rb_tree_node<_Tp>* _Link_type; _Rb_tree_iterator() noexcept : _M_node() { } explicit _Rb_tree_iterator(_Base_ptr __x) noexcept : _M_node(__x) { } reference operator*() const noexcept { return *static_cast<_Link_type>(_M_node)->_M_valptr(); } pointer operator->() const noexcept { return static_cast<_Link_type> (_M_node)->_M_valptr(); } _Self& operator++() noexcept { _M_node = _Rb_tree_increment(_M_node); return *this; } _Self operator++(int) noexcept { _Self __tmp = *this; _M_node = _Rb_tree_increment(_M_node); return __tmp; } _Self& operator--() noexcept { _M_node = _Rb_tree_decrement(_M_node); return *this; } _Self operator--(int) noexcept { _Self __tmp = *this; _M_node = _Rb_tree_decrement(_M_node); return __tmp; } friend bool operator==(const _Self& __x, const _Self& __y) noexcept { return __x._M_node == __y._M_node; } friend bool operator!=(const _Self& __x, const _Self& __y) noexcept { return __x._M_node != __y._M_node; } _Base_ptr _M_node; }; template<typename _Tp> struct _Rb_tree_const_iterator { typedef _Tp value_type; typedef const _Tp& reference; typedef const _Tp* pointer; typedef _Rb_tree_iterator<_Tp> iterator; typedef bidirectional_iterator_tag iterator_category; typedef ptrdiff_t difference_type; typedef _Rb_tree_const_iterator<_Tp> _Self; typedef _Rb_tree_node_base::_Const_Base_ptr _Base_ptr; typedef const _Rb_tree_node<_Tp>* _Link_type; _Rb_tree_const_iterator() noexcept : _M_node() { } explicit _Rb_tree_const_iterator(_Base_ptr __x) noexcept : _M_node(__x) { } _Rb_tree_const_iterator(const iterator& __it) noexcept : _M_node(__it._M_node) { } iterator _M_const_cast() const noexcept { return iterator(const_cast<typename iterator::_Base_ptr>(_M_node)); } reference operator*() const noexcept { return *static_cast<_Link_type>(_M_node)->_M_valptr(); } pointer operator->() const noexcept { return static_cast<_Link_type>(_M_node)->_M_valptr(); } _Self& operator++() noexcept { _M_node = _Rb_tree_increment(_M_node); return *this; } _Self operator++(int) noexcept { _Self __tmp = *this; _M_node = _Rb_tree_increment(_M_node); return __tmp; } _Self& operator--() noexcept { _M_node = _Rb_tree_decrement(_M_node); return *this; } _Self operator--(int) noexcept { _Self __tmp = *this; _M_node = _Rb_tree_decrement(_M_node); return __tmp; } friend bool operator==(const _Self& __x, const _Self& __y) noexcept { return __x._M_node == __y._M_node; } friend bool operator!=(const _Self& __x, const _Self& __y) noexcept { return __x._M_node != __y._M_node; } _Base_ptr _M_node; }; void _Rb_tree_insert_and_rebalance(const bool __insert_left, _Rb_tree_node_base* __x, _Rb_tree_node_base* __p, _Rb_tree_node_base& __header) throw (); _Rb_tree_node_base* _Rb_tree_rebalance_for_erase(_Rb_tree_node_base* const __z, _Rb_tree_node_base& __header) throw (); template<typename _Cmp, typename _SfinaeType, typename = __void_t<>> struct __has_is_transparent { }; template<typename _Cmp, typename _SfinaeType> struct __has_is_transparent<_Cmp, _SfinaeType, __void_t<typename _Cmp::is_transparent>> { typedef void type; }; template<typename _Cmp, typename _SfinaeType> using __has_is_transparent_t = typename __has_is_transparent<_Cmp, _SfinaeType>::type; template<typename _Key, typename _Val, typename _KeyOfValue, typename _Compare, typename _Alloc = allocator<_Val> > class _Rb_tree { typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template rebind<_Rb_tree_node<_Val> >::other _Node_allocator; typedef __gnu_cxx::__alloc_traits<_Node_allocator> _Alloc_traits; protected: typedef _Rb_tree_node_base* _Base_ptr; typedef const _Rb_tree_node_base* _Const_Base_ptr; typedef _Rb_tree_node<_Val>* _Link_type; typedef const _Rb_tree_node<_Val>* _Const_Link_type; private: struct _Reuse_or_alloc_node { _Reuse_or_alloc_node(_Rb_tree& __t) : _M_root(__t._M_root()), _M_nodes(__t._M_rightmost()), _M_t(__t) { if (_M_root) { _M_root->_M_parent = 0; if (_M_nodes->_M_left) _M_nodes = _M_nodes->_M_left; } else _M_nodes = 0; } _Reuse_or_alloc_node(const _Reuse_or_alloc_node&) = delete; ~_Reuse_or_alloc_node() { _M_t._M_erase(static_cast<_Link_type>(_M_root)); } template<typename _Arg> _Link_type operator()(_Arg&& __arg) { _Link_type __node = static_cast<_Link_type>(_M_extract()); if (__node) { _M_t._M_destroy_node(__node); _M_t._M_construct_node(__node, std::forward<_Arg>(__arg)); return __node; } return _M_t._M_create_node(std::forward<_Arg>(__arg)); } private: _Base_ptr _M_extract() { if (!_M_nodes) return _M_nodes; _Base_ptr __node = _M_nodes; _M_nodes = _M_nodes->_M_parent; if (_M_nodes) { if (_M_nodes->_M_right == __node) { _M_nodes->_M_right = 0; if (_M_nodes->_M_left) { _M_nodes = _M_nodes->_M_left; while (_M_nodes->_M_right) _M_nodes = _M_nodes->_M_right; if (_M_nodes->_M_left) _M_nodes = _M_nodes->_M_left; } } else _M_nodes->_M_left = 0; } else _M_root = 0; return __node; } _Base_ptr _M_root; _Base_ptr _M_nodes; _Rb_tree& _M_t; }; struct _Alloc_node { _Alloc_node(_Rb_tree& __t) : _M_t(__t) { } template<typename _Arg> _Link_type operator()(_Arg&& __arg) const { return _M_t._M_create_node(std::forward<_Arg>(__arg)); } private: _Rb_tree& _M_t; }; public: typedef _Key key_type; typedef _Val value_type; typedef value_type* pointer; typedef const value_type* const_pointer; typedef value_type& reference; typedef const value_type& const_reference; typedef size_t size_type; typedef ptrdiff_t difference_type; typedef _Alloc allocator_type; _Node_allocator& _M_get_Node_allocator() noexcept { return this->_M_impl; } const _Node_allocator& _M_get_Node_allocator() const noexcept { return this->_M_impl; } allocator_type get_allocator() const noexcept { return allocator_type(_M_get_Node_allocator()); } protected: _Link_type _M_get_node() { return _Alloc_traits::allocate(_M_get_Node_allocator(), 1); } void _M_put_node(_Link_type __p) noexcept { _Alloc_traits::deallocate(_M_get_Node_allocator(), __p, 1); } template<typename... _Args> void _M_construct_node(_Link_type __node, _Args&&... __args) { try { ::new(__node) _Rb_tree_node<_Val>; _Alloc_traits::construct(_M_get_Node_allocator(), __node->_M_valptr(), std::forward<_Args>(__args)...); } catch(...) { __node->~_Rb_tree_node<_Val>(); _M_put_node(__node); throw; } } template<typename... _Args> _Link_type _M_create_node(_Args&&... __args) { _Link_type __tmp = _M_get_node(); _M_construct_node(__tmp, std::forward<_Args>(__args)...); return __tmp; } void _M_destroy_node(_Link_type __p) noexcept { _Alloc_traits::destroy(_M_get_Node_allocator(), __p->_M_valptr()); __p->~_Rb_tree_node<_Val>(); } void _M_drop_node(_Link_type __p) noexcept { _M_destroy_node(__p); _M_put_node(__p); } template<typename _NodeGen> _Link_type _M_clone_node(_Const_Link_type __x, _NodeGen& __node_gen) { _Link_type __tmp = __node_gen(*__x->_M_valptr()); __tmp->_M_color = __x->_M_color; __tmp->_M_left = 0; __tmp->_M_right = 0; return __tmp; } protected: template<typename _Key_compare, bool = __is_pod(_Key_compare)> struct _Rb_tree_impl : public _Node_allocator , public _Rb_tree_key_compare<_Key_compare> , public _Rb_tree_header { typedef _Rb_tree_key_compare<_Key_compare> _Base_key_compare; _Rb_tree_impl() noexcept(is_nothrow_default_constructible<_Node_allocator>::value && is_nothrow_default_constructible<_Base_key_compare>::value) : _Node_allocator() { } _Rb_tree_impl(const _Rb_tree_impl& __x) : _Node_allocator(_Alloc_traits::_S_select_on_copy(__x)) , _Base_key_compare(__x._M_key_compare) { } _Rb_tree_impl(_Rb_tree_impl&&) = default; explicit _Rb_tree_impl(_Node_allocator&& __a) : _Node_allocator(std::move(__a)) { } _Rb_tree_impl(_Rb_tree_impl&& __x, _Node_allocator&& __a) : _Node_allocator(std::move(__a)), _Base_key_compare(std::move(__x)), _Rb_tree_header(std::move(__x)) { } _Rb_tree_impl(const _Key_compare& __comp, _Node_allocator&& __a) : _Node_allocator(std::move(__a)), _Base_key_compare(__comp) { } }; _Rb_tree_impl<_Compare> _M_impl; protected: _Base_ptr& _M_root() noexcept { return this->_M_impl._M_header._M_parent; } _Const_Base_ptr _M_root() const noexcept { return this->_M_impl._M_header._M_parent; } _Base_ptr& _M_leftmost() noexcept { return this->_M_impl._M_header._M_left; } _Const_Base_ptr _M_leftmost() const noexcept { return this->_M_impl._M_header._M_left; } _Base_ptr& _M_rightmost() noexcept { return this->_M_impl._M_header._M_right; } _Const_Base_ptr _M_rightmost() const noexcept { return this->_M_impl._M_header._M_right; } _Link_type _M_begin() noexcept { return static_cast<_Link_type>(this->_M_impl._M_header._M_parent); } _Const_Link_type _M_begin() const noexcept { return static_cast<_Const_Link_type> (this->_M_impl._M_header._M_parent); } _Base_ptr _M_end() noexcept { return &this->_M_impl._M_header; } _Const_Base_ptr _M_end() const noexcept { return &this->_M_impl._M_header; } static const _Key& _S_key(_Const_Link_type __x) { static_assert(__is_invocable<_Compare&, const _Key&, const _Key&>{}, "comparison object must be invocable " "with two arguments of key type"); return _KeyOfValue()(*__x->_M_valptr()); } static _Link_type _S_left(_Base_ptr __x) noexcept { return static_cast<_Link_type>(__x->_M_left); } static _Const_Link_type _S_left(_Const_Base_ptr __x) noexcept { return static_cast<_Const_Link_type>(__x->_M_left); } static _Link_type _S_right(_Base_ptr __x) noexcept { return static_cast<_Link_type>(__x->_M_right); } static _Const_Link_type _S_right(_Const_Base_ptr __x) noexcept { return static_cast<_Const_Link_type>(__x->_M_right); } static const _Key& _S_key(_Const_Base_ptr __x) { return _S_key(static_cast<_Const_Link_type>(__x)); } static _Base_ptr _S_minimum(_Base_ptr __x) noexcept { return _Rb_tree_node_base::_S_minimum(__x); } static _Const_Base_ptr _S_minimum(_Const_Base_ptr __x) noexcept { return _Rb_tree_node_base::_S_minimum(__x); } static _Base_ptr _S_maximum(_Base_ptr __x) noexcept { return _Rb_tree_node_base::_S_maximum(__x); } static _Const_Base_ptr _S_maximum(_Const_Base_ptr __x) noexcept { return _Rb_tree_node_base::_S_maximum(__x); } public: typedef _Rb_tree_iterator<value_type> iterator; typedef _Rb_tree_const_iterator<value_type> const_iterator; typedef std::reverse_iterator<iterator> reverse_iterator; typedef std::reverse_iterator<const_iterator> const_reverse_iterator; pair<_Base_ptr, _Base_ptr> _M_get_insert_unique_pos(const key_type& __k); pair<_Base_ptr, _Base_ptr> _M_get_insert_equal_pos(const key_type& __k); pair<_Base_ptr, _Base_ptr> _M_get_insert_hint_unique_pos(const_iterator __pos, const key_type& __k); pair<_Base_ptr, _Base_ptr> _M_get_insert_hint_equal_pos(const_iterator __pos, const key_type& __k); private: template<typename _Arg, typename _NodeGen> iterator _M_insert_(_Base_ptr __x, _Base_ptr __y, _Arg&& __v, _NodeGen&); iterator _M_insert_node(_Base_ptr __x, _Base_ptr __y, _Link_type __z); template<typename _Arg> iterator _M_insert_lower(_Base_ptr __y, _Arg&& __v); template<typename _Arg> iterator _M_insert_equal_lower(_Arg&& __x); iterator _M_insert_lower_node(_Base_ptr __p, _Link_type __z); iterator _M_insert_equal_lower_node(_Link_type __z); template<typename _NodeGen> _Link_type _M_copy(_Const_Link_type __x, _Base_ptr __p, _NodeGen&); template<typename _NodeGen> _Link_type _M_copy(const _Rb_tree& __x, _NodeGen& __gen) { _Link_type __root = _M_copy(__x._M_begin(), _M_end(), __gen); _M_leftmost() = _S_minimum(__root); _M_rightmost() = _S_maximum(__root); _M_impl._M_node_count = __x._M_impl._M_node_count; return __root; } _Link_type _M_copy(const _Rb_tree& __x) { _Alloc_node __an(*this); return _M_copy(__x, __an); } void _M_erase(_Link_type __x); iterator _M_lower_bound(_Link_type __x, _Base_ptr __y, const _Key& __k); const_iterator _M_lower_bound(_Const_Link_type __x, _Const_Base_ptr __y, const _Key& __k) const; iterator _M_upper_bound(_Link_type __x, _Base_ptr __y, const _Key& __k); const_iterator _M_upper_bound(_Const_Link_type __x, _Const_Base_ptr __y, const _Key& __k) const; public: _Rb_tree() = default; _Rb_tree(const _Compare& __comp, const allocator_type& __a = allocator_type()) : _M_impl(__comp, _Node_allocator(__a)) { } _Rb_tree(const _Rb_tree& __x) : _M_impl(__x._M_impl) { if (__x._M_root() != 0) _M_root() = _M_copy(__x); } _Rb_tree(const allocator_type& __a) : _M_impl(_Node_allocator(__a)) { } _Rb_tree(const _Rb_tree& __x, const allocator_type& __a) : _M_impl(__x._M_impl._M_key_compare, _Node_allocator(__a)) { if (__x._M_root() != nullptr) _M_root() = _M_copy(__x); } _Rb_tree(_Rb_tree&&) = default; _Rb_tree(_Rb_tree&& __x, const allocator_type& __a) : _Rb_tree(std::move(__x), _Node_allocator(__a)) { } private: _Rb_tree(_Rb_tree&& __x, _Node_allocator&& __a, true_type) noexcept(is_nothrow_default_constructible<_Compare>::value) : _M_impl(std::move(__x._M_impl), std::move(__a)) { } _Rb_tree(_Rb_tree&& __x, _Node_allocator&& __a, false_type) : _M_impl(__x._M_impl._M_key_compare, std::move(__a)) { if (__x._M_root() != nullptr) _M_move_data(__x, false_type{}); } public: _Rb_tree(_Rb_tree&& __x, _Node_allocator&& __a) noexcept( noexcept( _Rb_tree(std::declval<_Rb_tree&&>(), std::declval<_Node_allocator&&>(), std::declval<typename _Alloc_traits::is_always_equal>())) ) : _Rb_tree(std::move(__x), std::move(__a), typename _Alloc_traits::is_always_equal{}) { } ~_Rb_tree() noexcept { _M_erase(_M_begin()); } _Rb_tree& operator=(const _Rb_tree& __x); _Compare key_comp() const { return _M_impl._M_key_compare; } iterator begin() noexcept { return iterator(this->_M_impl._M_header._M_left); } const_iterator begin() const noexcept { return const_iterator(this->_M_impl._M_header._M_left); } iterator end() noexcept { return iterator(&this->_M_impl._M_header); } const_iterator end() const noexcept { return const_iterator(&this->_M_impl._M_header); } reverse_iterator rbegin() noexcept { return reverse_iterator(end()); } const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); } reverse_iterator rend() noexcept { return reverse_iterator(begin()); } const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); } bool empty() const noexcept { return _M_impl._M_node_count == 0; } size_type size() const noexcept { return _M_impl._M_node_count; } size_type max_size() const noexcept { return _Alloc_traits::max_size(_M_get_Node_allocator()); } void swap(_Rb_tree& __t) noexcept(__is_nothrow_swappable<_Compare>::value); template<typename _Arg> pair<iterator, bool> _M_insert_unique(_Arg&& __x); template<typename _Arg> iterator _M_insert_equal(_Arg&& __x); template<typename _Arg, typename _NodeGen> iterator _M_insert_unique_(const_iterator __pos, _Arg&& __x, _NodeGen&); template<typename _Arg> iterator _M_insert_unique_(const_iterator __pos, _Arg&& __x) { _Alloc_node __an(*this); return _M_insert_unique_(__pos, std::forward<_Arg>(__x), __an); } template<typename _Arg, typename _NodeGen> iterator _M_insert_equal_(const_iterator __pos, _Arg&& __x, _NodeGen&); template<typename _Arg> iterator _M_insert_equal_(const_iterator __pos, _Arg&& __x) { _Alloc_node __an(*this); return _M_insert_equal_(__pos, std::forward<_Arg>(__x), __an); } template<typename... _Args> pair<iterator, bool> _M_emplace_unique(_Args&&... __args); template<typename... _Args> iterator _M_emplace_equal(_Args&&... __args); template<typename... _Args> iterator _M_emplace_hint_unique(const_iterator __pos, _Args&&... __args); template<typename... _Args> iterator _M_emplace_hint_equal(const_iterator __pos, _Args&&... __args); template<typename _Iter> using __same_value_type = is_same<value_type, typename iterator_traits<_Iter>::value_type>; template<typename _InputIterator> __enable_if_t<__same_value_type<_InputIterator>::value> _M_insert_range_unique(_InputIterator __first, _InputIterator __last) { _Alloc_node __an(*this); for (; __first != __last; ++__first) _M_insert_unique_(end(), *__first, __an); } template<typename _InputIterator> __enable_if_t<!__same_value_type<_InputIterator>::value> _M_insert_range_unique(_InputIterator __first, _InputIterator __last) { for (; __first != __last; ++__first) _M_emplace_unique(*__first); } template<typename _InputIterator> __enable_if_t<__same_value_type<_InputIterator>::value> _M_insert_range_equal(_InputIterator __first, _InputIterator __last) { _Alloc_node __an(*this); for (; __first != __last; ++__first) _M_insert_equal_(end(), *__first, __an); } template<typename _InputIterator> __enable_if_t<!__same_value_type<_InputIterator>::value> _M_insert_range_equal(_InputIterator __first, _InputIterator __last) { _Alloc_node __an(*this); for (; __first != __last; ++__first) _M_emplace_equal(*__first); } private: void _M_erase_aux(const_iterator __position); void _M_erase_aux(const_iterator __first, const_iterator __last); public: __attribute ((__abi_tag__ ("cxx11"))) iterator erase(const_iterator __position) { ; const_iterator __result = __position; ++__result; _M_erase_aux(__position); return __result._M_const_cast(); } __attribute ((__abi_tag__ ("cxx11"))) iterator erase(iterator __position) { ; iterator __result = __position; ++__result; _M_erase_aux(__position); return __result; } size_type erase(const key_type& __x); __attribute ((__abi_tag__ ("cxx11"))) iterator erase(const_iterator __first, const_iterator __last) { _M_erase_aux(__first, __last); return __last._M_const_cast(); } void clear() noexcept { _M_erase(_M_begin()); _M_impl._M_reset(); } iterator find(const key_type& __k); const_iterator find(const key_type& __k) const; size_type count(const key_type& __k) const; iterator lower_bound(const key_type& __k) { return _M_lower_bound(_M_begin(), _M_end(), __k); } const_iterator lower_bound(const key_type& __k) const { return _M_lower_bound(_M_begin(), _M_end(), __k); } iterator upper_bound(const key_type& __k) { return _M_upper_bound(_M_begin(), _M_end(), __k); } const_iterator upper_bound(const key_type& __k) const { return _M_upper_bound(_M_begin(), _M_end(), __k); } pair<iterator, iterator> equal_range(const key_type& __k); pair<const_iterator, const_iterator> equal_range(const key_type& __k) const; template<typename _Kt, typename _Req = __has_is_transparent_t<_Compare, _Kt>> iterator _M_find_tr(const _Kt& __k) { const _Rb_tree* __const_this = this; return __const_this->_M_find_tr(__k)._M_const_cast(); } template<typename _Kt, typename _Req = __has_is_transparent_t<_Compare, _Kt>> const_iterator _M_find_tr(const _Kt& __k) const { auto __j = _M_lower_bound_tr(__k); if (__j != end() && _M_impl._M_key_compare(__k, _S_key(__j._M_node))) __j = end(); return __j; } template<typename _Kt, typename _Req = __has_is_transparent_t<_Compare, _Kt>> size_type _M_count_tr(const _Kt& __k) const { auto __p = _M_equal_range_tr(__k); return std::distance(__p.first, __p.second); } template<typename _Kt, typename _Req = __has_is_transparent_t<_Compare, _Kt>> iterator _M_lower_bound_tr(const _Kt& __k) { const _Rb_tree* __const_this = this; return __const_this->_M_lower_bound_tr(__k)._M_const_cast(); } template<typename _Kt, typename _Req = __has_is_transparent_t<_Compare, _Kt>> const_iterator _M_lower_bound_tr(const _Kt& __k) const { auto __x = _M_begin(); auto __y = _M_end(); while (__x != 0) if (!_M_impl._M_key_compare(_S_key(__x), __k)) { __y = __x; __x = _S_left(__x); } else __x = _S_right(__x); return const_iterator(__y); } template<typename _Kt, typename _Req = __has_is_transparent_t<_Compare, _Kt>> iterator _M_upper_bound_tr(const _Kt& __k) { const _Rb_tree* __const_this = this; return __const_this->_M_upper_bound_tr(__k)._M_const_cast(); } template<typename _Kt, typename _Req = __has_is_transparent_t<_Compare, _Kt>> const_iterator _M_upper_bound_tr(const _Kt& __k) const { auto __x = _M_begin(); auto __y = _M_end(); while (__x != 0) if (_M_impl._M_key_compare(__k, _S_key(__x))) { __y = __x; __x = _S_left(__x); } else __x = _S_right(__x); return const_iterator(__y); } template<typename _Kt, typename _Req = __has_is_transparent_t<_Compare, _Kt>> pair<iterator, iterator> _M_equal_range_tr(const _Kt& __k) { const _Rb_tree* __const_this = this; auto __ret = __const_this->_M_equal_range_tr(__k); return { __ret.first._M_const_cast(), __ret.second._M_const_cast() }; } template<typename _Kt, typename _Req = __has_is_transparent_t<_Compare, _Kt>> pair<const_iterator, const_iterator> _M_equal_range_tr(const _Kt& __k) const { auto __low = _M_lower_bound_tr(__k); auto __high = __low; auto& __cmp = _M_impl._M_key_compare; while (__high != end() && !__cmp(__k, _S_key(__high._M_node))) ++__high; return { __low, __high }; } bool __rb_verify() const; _Rb_tree& operator=(_Rb_tree&&) noexcept(_Alloc_traits::_S_nothrow_move() && is_nothrow_move_assignable<_Compare>::value); template<typename _Iterator> void _M_assign_unique(_Iterator, _Iterator); template<typename _Iterator> void _M_assign_equal(_Iterator, _Iterator); private: void _M_move_data(_Rb_tree& __x, true_type) { _M_impl._M_move_data(__x._M_impl); } void _M_move_data(_Rb_tree&, false_type); void _M_move_assign(_Rb_tree&, true_type); void _M_move_assign(_Rb_tree&, false_type); friend bool operator==(const _Rb_tree& __x, const _Rb_tree& __y) { return __x.size() == __y.size() && std::equal(__x.begin(), __x.end(), __y.begin()); } friend bool operator<(const _Rb_tree& __x, const _Rb_tree& __y) { return std::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end()); } friend bool __attribute__ ((__deprecated__)) operator!=(const _Rb_tree& __x, const _Rb_tree& __y) { return !(__x == __y); } friend bool __attribute__ ((__deprecated__)) operator>(const _Rb_tree& __x, const _Rb_tree& __y) { return __y < __x; } friend bool __attribute__ ((__deprecated__)) operator<=(const _Rb_tree& __x, const _Rb_tree& __y) { return !(__y < __x); } friend bool __attribute__ ((__deprecated__)) operator>=(const _Rb_tree& __x, const _Rb_tree& __y) { return !(__x < __y); } }; template<typename _Key, typename _Val, typename _KeyOfValue, typename _Compare, typename _Alloc> inline void swap(_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __x, _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __y) { __x.swap(__y); } template<typename _Key, typename _Val, typename _KeyOfValue, typename _Compare, typename _Alloc> void _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: _M_move_data(_Rb_tree& __x, false_type) { if (_M_get_Node_allocator() == __x._M_get_Node_allocator()) _M_move_data(__x, true_type()); else { _Alloc_node __an(*this); auto __lbd = [&__an](const value_type& __cval) { auto& __val = const_cast<value_type&>(__cval); return __an(std::move_if_noexcept(__val)); }; _M_root() = _M_copy(__x, __lbd); } } template<typename _Key, typename _Val, typename _KeyOfValue, typename _Compare, typename _Alloc> inline void _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: _M_move_assign(_Rb_tree& __x, true_type) { clear(); if (__x._M_root() != nullptr) _M_move_data(__x, true_type()); std::__alloc_on_move(_M_get_Node_allocator(), __x._M_get_Node_allocator()); } template<typename _Key, typename _Val, typename _KeyOfValue, typename _Compare, typename _Alloc> void _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: _M_move_assign(_Rb_tree& __x, false_type) { if (_M_get_Node_allocator() == __x._M_get_Node_allocator()) return _M_move_assign(__x, true_type{}); _Reuse_or_alloc_node __roan(*this); _M_impl._M_reset(); if (__x._M_root() != nullptr) { auto __lbd = [&__roan](const value_type& __cval) { auto& __val = const_cast<value_type&>(__cval); return __roan(std::move(__val)); }; _M_root() = _M_copy(__x, __lbd); __x.clear(); } } template<typename _Key, typename _Val, typename _KeyOfValue, typename _Compare, typename _Alloc> inline _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: operator=(_Rb_tree&& __x) noexcept(_Alloc_traits::_S_nothrow_move() && is_nothrow_move_assignable<_Compare>::value) { _M_impl._M_key_compare = std::move(__x._M_impl._M_key_compare); _M_move_assign(__x, __bool_constant<_Alloc_traits::_S_nothrow_move()>()); return *this; } template<typename _Key, typename _Val, typename _KeyOfValue, typename _Compare, typename _Alloc> template<typename _Iterator> void _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: _M_assign_unique(_Iterator __first, _Iterator __last) { _Reuse_or_alloc_node __roan(*this); _M_impl._M_reset(); for (; __first != __last; ++__first) _M_insert_unique_(end(), *__first, __roan); } template<typename _Key, typename _Val, typename _KeyOfValue, typename _Compare, typename _Alloc> template<typename _Iterator> void _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: _M_assign_equal(_Iterator __first, _Iterator __last) { _Reuse_or_alloc_node __roan(*this); _M_impl._M_reset(); for (; __first != __last; ++__first) _M_insert_equal_(end(), *__first, __roan); } template<typename _Key, typename _Val, typename _KeyOfValue, typename _Compare, typename _Alloc> _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: operator=(const _Rb_tree& __x) { if (this != &__x) { if (_Alloc_traits::_S_propagate_on_copy_assign()) { auto& __this_alloc = this->_M_get_Node_allocator(); auto& __that_alloc = __x._M_get_Node_allocator(); if (!_Alloc_traits::_S_always_equal() && __this_alloc != __that_alloc) { clear(); std::__alloc_on_copy(__this_alloc, __that_alloc); } } _Reuse_or_alloc_node __roan(*this); _M_impl._M_reset(); _M_impl._M_key_compare = __x._M_impl._M_key_compare; if (__x._M_root() != 0) _M_root() = _M_copy(__x, __roan); } return *this; } template<typename _Key, typename _Val, typename _KeyOfValue, typename _Compare, typename _Alloc> template<typename _Arg, typename _NodeGen> typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: _M_insert_(_Base_ptr __x, _Base_ptr __p, _Arg&& __v, _NodeGen& __node_gen) { bool __insert_left = (__x != 0 || __p == _M_end() || _M_impl._M_key_compare(_KeyOfValue()(__v), _S_key(__p))); _Link_type __z = __node_gen(std::forward<_Arg>(__v)); _Rb_tree_insert_and_rebalance(__insert_left, __z, __p, this->_M_impl._M_header); ++_M_impl._M_node_count; return iterator(__z); } template<typename _Key, typename _Val, typename _KeyOfValue, typename _Compare, typename _Alloc> template<typename _Arg> typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: _M_insert_lower(_Base_ptr __p, _Arg&& __v) { bool __insert_left = (__p == _M_end() || !_M_impl._M_key_compare(_S_key(__p), _KeyOfValue()(__v))); _Link_type __z = _M_create_node(std::forward<_Arg>(__v)); _Rb_tree_insert_and_rebalance(__insert_left, __z, __p, this->_M_impl._M_header); ++_M_impl._M_node_count; return iterator(__z); } template<typename _Key, typename _Val, typename _KeyOfValue, typename _Compare, typename _Alloc> template<typename _Arg> typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: _M_insert_equal_lower(_Arg&& __v) { _Link_type __x = _M_begin(); _Base_ptr __y = _M_end(); while (__x != 0) { __y = __x; __x = !_M_impl._M_key_compare(_S_key(__x), _KeyOfValue()(__v)) ? _S_left(__x) : _S_right(__x); } return _M_insert_lower(__y, std::forward<_Arg>(__v)); } template<typename _Key, typename _Val, typename _KoV, typename _Compare, typename _Alloc> template<typename _NodeGen> typename _Rb_tree<_Key, _Val, _KoV, _Compare, _Alloc>::_Link_type _Rb_tree<_Key, _Val, _KoV, _Compare, _Alloc>:: _M_copy(_Const_Link_type __x, _Base_ptr __p, _NodeGen& __node_gen) { _Link_type __top = _M_clone_node(__x, __node_gen); __top->_M_parent = __p; try { if (__x->_M_right) __top->_M_right = _M_copy(_S_right(__x), __top, __node_gen); __p = __top; __x = _S_left(__x); while (__x != 0) { _Link_type __y = _M_clone_node(__x, __node_gen); __p->_M_left = __y; __y->_M_parent = __p; if (__x->_M_right) __y->_M_right = _M_copy(_S_right(__x), __y, __node_gen); __p = __y; __x = _S_left(__x); } } catch(...) { _M_erase(__top); throw; } return __top; } template<typename _Key, typename _Val, typename _KeyOfValue, typename _Compare, typename _Alloc> void _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: _M_erase(_Link_type __x) { while (__x != 0) { _M_erase(_S_right(__x)); _Link_type __y = _S_left(__x); _M_drop_node(__x); __x = __y; } } template<typename _Key, typename _Val, typename _KeyOfValue, typename _Compare, typename _Alloc> typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: _M_lower_bound(_Link_type __x, _Base_ptr __y, const _Key& __k) { while (__x != 0) if (!_M_impl._M_key_compare(_S_key(__x), __k)) __y = __x, __x = _S_left(__x); else __x = _S_right(__x); return iterator(__y); } template<typename _Key, typename _Val, typename _KeyOfValue, typename _Compare, typename _Alloc> typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: _M_lower_bound(_Const_Link_type __x, _Const_Base_ptr __y, const _Key& __k) const { while (__x != 0) if (!_M_impl._M_key_compare(_S_key(__x), __k)) __y = __x, __x = _S_left(__x); else __x = _S_right(__x); return const_iterator(__y); } template<typename _Key, typename _Val, typename _KeyOfValue, typename _Compare, typename _Alloc> typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: _M_upper_bound(_Link_type __x, _Base_ptr __y, const _Key& __k) { while (__x != 0) if (_M_impl._M_key_compare(__k, _S_key(__x))) __y = __x, __x = _S_left(__x); else __x = _S_right(__x); return iterator(__y); } template<typename _Key, typename _Val, typename _KeyOfValue, typename _Compare, typename _Alloc> typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: _M_upper_bound(_Const_Link_type __x, _Const_Base_ptr __y, const _Key& __k) const { while (__x != 0) if (_M_impl._M_key_compare(__k, _S_key(__x))) __y = __x, __x = _S_left(__x); else __x = _S_right(__x); return const_iterator(__y); } template<typename _Key, typename _Val, typename _KeyOfValue, typename _Compare, typename _Alloc> pair<typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator, typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator> _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: equal_range(const _Key& __k) { _Link_type __x = _M_begin(); _Base_ptr __y = _M_end(); while (__x != 0) { if (_M_impl._M_key_compare(_S_key(__x), __k)) __x = _S_right(__x); else if (_M_impl._M_key_compare(__k, _S_key(__x))) __y = __x, __x = _S_left(__x); else { _Link_type __xu(__x); _Base_ptr __yu(__y); __y = __x, __x = _S_left(__x); __xu = _S_right(__xu); return pair<iterator, iterator>(_M_lower_bound(__x, __y, __k), _M_upper_bound(__xu, __yu, __k)); } } return pair<iterator, iterator>(iterator(__y), iterator(__y)); } template<typename _Key, typename _Val, typename _KeyOfValue, typename _Compare, typename _Alloc> pair<typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator, typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator> _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: equal_range(const _Key& __k) const { _Const_Link_type __x = _M_begin(); _Const_Base_ptr __y = _M_end(); while (__x != 0) { if (_M_impl._M_key_compare(_S_key(__x), __k)) __x = _S_right(__x); else if (_M_impl._M_key_compare(__k, _S_key(__x))) __y = __x, __x = _S_left(__x); else { _Const_Link_type __xu(__x); _Const_Base_ptr __yu(__y); __y = __x, __x = _S_left(__x); __xu = _S_right(__xu); return pair<const_iterator, const_iterator>(_M_lower_bound(__x, __y, __k), _M_upper_bound(__xu, __yu, __k)); } } return pair<const_iterator, const_iterator>(const_iterator(__y), const_iterator(__y)); } template<typename _Key, typename _Val, typename _KeyOfValue, typename _Compare, typename _Alloc> void _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: swap(_Rb_tree& __t) noexcept(__is_nothrow_swappable<_Compare>::value) { if (_M_root() == 0) { if (__t._M_root() != 0) _M_impl._M_move_data(__t._M_impl); } else if (__t._M_root() == 0) __t._M_impl._M_move_data(_M_impl); else { std::swap(_M_root(),__t._M_root()); std::swap(_M_leftmost(),__t._M_leftmost()); std::swap(_M_rightmost(),__t._M_rightmost()); _M_root()->_M_parent = _M_end(); __t._M_root()->_M_parent = __t._M_end(); std::swap(this->_M_impl._M_node_count, __t._M_impl._M_node_count); } std::swap(this->_M_impl._M_key_compare, __t._M_impl._M_key_compare); _Alloc_traits::_S_on_swap(_M_get_Node_allocator(), __t._M_get_Node_allocator()); } template<typename _Key, typename _Val, typename _KeyOfValue, typename _Compare, typename _Alloc> pair<typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Base_ptr, typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Base_ptr> _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: _M_get_insert_unique_pos(const key_type& __k) { typedef pair<_Base_ptr, _Base_ptr> _Res; _Link_type __x = _M_begin(); _Base_ptr __y = _M_end(); bool __comp = true; while (__x != 0) { __y = __x; __comp = _M_impl._M_key_compare(__k, _S_key(__x)); __x = __comp ? _S_left(__x) : _S_right(__x); } iterator __j = iterator(__y); if (__comp) { if (__j == begin()) return _Res(__x, __y); else --__j; } if (_M_impl._M_key_compare(_S_key(__j._M_node), __k)) return _Res(__x, __y); return _Res(__j._M_node, 0); } template<typename _Key, typename _Val, typename _KeyOfValue, typename _Compare, typename _Alloc> pair<typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Base_ptr, typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Base_ptr> _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: _M_get_insert_equal_pos(const key_type& __k) { typedef pair<_Base_ptr, _Base_ptr> _Res; _Link_type __x = _M_begin(); _Base_ptr __y = _M_end(); while (__x != 0) { __y = __x; __x = _M_impl._M_key_compare(__k, _S_key(__x)) ? _S_left(__x) : _S_right(__x); } return _Res(__x, __y); } template<typename _Key, typename _Val, typename _KeyOfValue, typename _Compare, typename _Alloc> template<typename _Arg> pair<typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator, bool> _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: _M_insert_unique(_Arg&& __v) { typedef pair<iterator, bool> _Res; pair<_Base_ptr, _Base_ptr> __res = _M_get_insert_unique_pos(_KeyOfValue()(__v)); if (__res.second) { _Alloc_node __an(*this); return _Res(_M_insert_(__res.first, __res.second, std::forward<_Arg>(__v), __an), true); } return _Res(iterator(__res.first), false); } template<typename _Key, typename _Val, typename _KeyOfValue, typename _Compare, typename _Alloc> template<typename _Arg> typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: _M_insert_equal(_Arg&& __v) { pair<_Base_ptr, _Base_ptr> __res = _M_get_insert_equal_pos(_KeyOfValue()(__v)); _Alloc_node __an(*this); return _M_insert_(__res.first, __res.second, std::forward<_Arg>(__v), __an); } template<typename _Key, typename _Val, typename _KeyOfValue, typename _Compare, typename _Alloc> pair<typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Base_ptr, typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Base_ptr> _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: _M_get_insert_hint_unique_pos(const_iterator __position, const key_type& __k) { iterator __pos = __position._M_const_cast(); typedef pair<_Base_ptr, _Base_ptr> _Res; if (__pos._M_node == _M_end()) { if (size() > 0 && _M_impl._M_key_compare(_S_key(_M_rightmost()), __k)) return _Res(0, _M_rightmost()); else return _M_get_insert_unique_pos(__k); } else if (_M_impl._M_key_compare(__k, _S_key(__pos._M_node))) { iterator __before = __pos; if (__pos._M_node == _M_leftmost()) return _Res(_M_leftmost(), _M_leftmost()); else if (_M_impl._M_key_compare(_S_key((--__before)._M_node), __k)) { if (_S_right(__before._M_node) == 0) return _Res(0, __before._M_node); else return _Res(__pos._M_node, __pos._M_node); } else return _M_get_insert_unique_pos(__k); } else if (_M_impl._M_key_compare(_S_key(__pos._M_node), __k)) { iterator __after = __pos; if (__pos._M_node == _M_rightmost()) return _Res(0, _M_rightmost()); else if (_M_impl._M_key_compare(__k, _S_key((++__after)._M_node))) { if (_S_right(__pos._M_node) == 0) return _Res(0, __pos._M_node); else return _Res(__after._M_node, __after._M_node); } else return _M_get_insert_unique_pos(__k); } else return _Res(__pos._M_node, 0); } template<typename _Key, typename _Val, typename _KeyOfValue, typename _Compare, typename _Alloc> template<typename _Arg, typename _NodeGen> typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: _M_insert_unique_(const_iterator __position, _Arg&& __v, _NodeGen& __node_gen) { pair<_Base_ptr, _Base_ptr> __res = _M_get_insert_hint_unique_pos(__position, _KeyOfValue()(__v)); if (__res.second) return _M_insert_(__res.first, __res.second, std::forward<_Arg>(__v), __node_gen); return iterator(__res.first); } template<typename _Key, typename _Val, typename _KeyOfValue, typename _Compare, typename _Alloc> pair<typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Base_ptr, typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Base_ptr> _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: _M_get_insert_hint_equal_pos(const_iterator __position, const key_type& __k) { iterator __pos = __position._M_const_cast(); typedef pair<_Base_ptr, _Base_ptr> _Res; if (__pos._M_node == _M_end()) { if (size() > 0 && !_M_impl._M_key_compare(__k, _S_key(_M_rightmost()))) return _Res(0, _M_rightmost()); else return _M_get_insert_equal_pos(__k); } else if (!_M_impl._M_key_compare(_S_key(__pos._M_node), __k)) { iterator __before = __pos; if (__pos._M_node == _M_leftmost()) return _Res(_M_leftmost(), _M_leftmost()); else if (!_M_impl._M_key_compare(__k, _S_key((--__before)._M_node))) { if (_S_right(__before._M_node) == 0) return _Res(0, __before._M_node); else return _Res(__pos._M_node, __pos._M_node); } else return _M_get_insert_equal_pos(__k); } else { iterator __after = __pos; if (__pos._M_node == _M_rightmost()) return _Res(0, _M_rightmost()); else if (!_M_impl._M_key_compare(_S_key((++__after)._M_node), __k)) { if (_S_right(__pos._M_node) == 0) return _Res(0, __pos._M_node); else return _Res(__after._M_node, __after._M_node); } else return _Res(0, 0); } } template<typename _Key, typename _Val, typename _KeyOfValue, typename _Compare, typename _Alloc> template<typename _Arg, typename _NodeGen> typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: _M_insert_equal_(const_iterator __position, _Arg&& __v, _NodeGen& __node_gen) { pair<_Base_ptr, _Base_ptr> __res = _M_get_insert_hint_equal_pos(__position, _KeyOfValue()(__v)); if (__res.second) return _M_insert_(__res.first, __res.second, std::forward<_Arg>(__v), __node_gen); return _M_insert_equal_lower(std::forward<_Arg>(__v)); } template<typename _Key, typename _Val, typename _KeyOfValue, typename _Compare, typename _Alloc> typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: _M_insert_node(_Base_ptr __x, _Base_ptr __p, _Link_type __z) { bool __insert_left = (__x != 0 || __p == _M_end() || _M_impl._M_key_compare(_S_key(__z), _S_key(__p))); _Rb_tree_insert_and_rebalance(__insert_left, __z, __p, this->_M_impl._M_header); ++_M_impl._M_node_count; return iterator(__z); } template<typename _Key, typename _Val, typename _KeyOfValue, typename _Compare, typename _Alloc> typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: _M_insert_lower_node(_Base_ptr __p, _Link_type __z) { bool __insert_left = (__p == _M_end() || !_M_impl._M_key_compare(_S_key(__p), _S_key(__z))); _Rb_tree_insert_and_rebalance(__insert_left, __z, __p, this->_M_impl._M_header); ++_M_impl._M_node_count; return iterator(__z); } template<typename _Key, typename _Val, typename _KeyOfValue, typename _Compare, typename _Alloc> typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: _M_insert_equal_lower_node(_Link_type __z) { _Link_type __x = _M_begin(); _Base_ptr __y = _M_end(); while (__x != 0) { __y = __x; __x = !_M_impl._M_key_compare(_S_key(__x), _S_key(__z)) ? _S_left(__x) : _S_right(__x); } return _M_insert_lower_node(__y, __z); } template<typename _Key, typename _Val, typename _KeyOfValue, typename _Compare, typename _Alloc> template<typename... _Args> pair<typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator, bool> _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: _M_emplace_unique(_Args&&... __args) { _Link_type __z = _M_create_node(std::forward<_Args>(__args)...); try { typedef pair<iterator, bool> _Res; auto __res = _M_get_insert_unique_pos(_S_key(__z)); if (__res.second) return _Res(_M_insert_node(__res.first, __res.second, __z), true); _M_drop_node(__z); return _Res(iterator(__res.first), false); } catch(...) { _M_drop_node(__z); throw; } } template<typename _Key, typename _Val, typename _KeyOfValue, typename _Compare, typename _Alloc> template<typename... _Args> typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: _M_emplace_equal(_Args&&... __args) { _Link_type __z = _M_create_node(std::forward<_Args>(__args)...); try { auto __res = _M_get_insert_equal_pos(_S_key(__z)); return _M_insert_node(__res.first, __res.second, __z); } catch(...) { _M_drop_node(__z); throw; } } template<typename _Key, typename _Val, typename _KeyOfValue, typename _Compare, typename _Alloc> template<typename... _Args> typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: _M_emplace_hint_unique(const_iterator __pos, _Args&&... __args) { _Link_type __z = _M_create_node(std::forward<_Args>(__args)...); try { auto __res = _M_get_insert_hint_unique_pos(__pos, _S_key(__z)); if (__res.second) return _M_insert_node(__res.first, __res.second, __z); _M_drop_node(__z); return iterator(__res.first); } catch(...) { _M_drop_node(__z); throw; } } template<typename _Key, typename _Val, typename _KeyOfValue, typename _Compare, typename _Alloc> template<typename... _Args> typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: _M_emplace_hint_equal(const_iterator __pos, _Args&&... __args) { _Link_type __z = _M_create_node(std::forward<_Args>(__args)...); try { auto __res = _M_get_insert_hint_equal_pos(__pos, _S_key(__z)); if (__res.second) return _M_insert_node(__res.first, __res.second, __z); return _M_insert_equal_lower_node(__z); } catch(...) { _M_drop_node(__z); throw; } } template<typename _Key, typename _Val, typename _KeyOfValue, typename _Compare, typename _Alloc> void _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: _M_erase_aux(const_iterator __position) { _Link_type __y = static_cast<_Link_type>(_Rb_tree_rebalance_for_erase (const_cast<_Base_ptr>(__position._M_node), this->_M_impl._M_header)); _M_drop_node(__y); --_M_impl._M_node_count; } template<typename _Key, typename _Val, typename _KeyOfValue, typename _Compare, typename _Alloc> void _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: _M_erase_aux(const_iterator __first, const_iterator __last) { if (__first == begin() && __last == end()) clear(); else while (__first != __last) _M_erase_aux(__first++); } template<typename _Key, typename _Val, typename _KeyOfValue, typename _Compare, typename _Alloc> typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::size_type _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: erase(const _Key& __x) { pair<iterator, iterator> __p = equal_range(__x); const size_type __old_size = size(); _M_erase_aux(__p.first, __p.second); return __old_size - size(); } template<typename _Key, typename _Val, typename _KeyOfValue, typename _Compare, typename _Alloc> typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: find(const _Key& __k) { iterator __j = _M_lower_bound(_M_begin(), _M_end(), __k); return (__j == end() || _M_impl._M_key_compare(__k, _S_key(__j._M_node))) ? end() : __j; } template<typename _Key, typename _Val, typename _KeyOfValue, typename _Compare, typename _Alloc> typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: find(const _Key& __k) const { const_iterator __j = _M_lower_bound(_M_begin(), _M_end(), __k); return (__j == end() || _M_impl._M_key_compare(__k, _S_key(__j._M_node))) ? end() : __j; } template<typename _Key, typename _Val, typename _KeyOfValue, typename _Compare, typename _Alloc> typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::size_type _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: count(const _Key& __k) const { pair<const_iterator, const_iterator> __p = equal_range(__k); const size_type __n = std::distance(__p.first, __p.second); return __n; } __attribute__ ((__pure__)) unsigned int _Rb_tree_black_count(const _Rb_tree_node_base* __node, const _Rb_tree_node_base* __root) throw (); template<typename _Key, typename _Val, typename _KeyOfValue, typename _Compare, typename _Alloc> bool _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>::__rb_verify() const { if (_M_impl._M_node_count == 0 || begin() == end()) return _M_impl._M_node_count == 0 && begin() == end() && this->_M_impl._M_header._M_left == _M_end() && this->_M_impl._M_header._M_right == _M_end(); unsigned int __len = _Rb_tree_black_count(_M_leftmost(), _M_root()); for (const_iterator __it = begin(); __it != end(); ++__it) { _Const_Link_type __x = static_cast<_Const_Link_type>(__it._M_node); _Const_Link_type __L = _S_left(__x); _Const_Link_type __R = _S_right(__x); if (__x->_M_color == _S_red) if ((__L && __L->_M_color == _S_red) || (__R && __R->_M_color == _S_red)) return false; if (__L && _M_impl._M_key_compare(_S_key(__x), _S_key(__L))) return false; if (__R && _M_impl._M_key_compare(_S_key(__R), _S_key(__x))) return false; if (!__L && !__R && _Rb_tree_black_count(__x, _M_root()) != __len) return false; } if (_M_leftmost() != _Rb_tree_node_base::_S_minimum(_M_root())) return false; if (_M_rightmost() != _Rb_tree_node_base::_S_maximum(_M_root())) return false; return true; } } namespace std __attribute__ ((__visibility__ ("default"))) { template <typename _Key, typename _Tp, typename _Compare, typename _Alloc> class multimap; template <typename _Key, typename _Tp, typename _Compare = std::less<_Key>, typename _Alloc = std::allocator<std::pair<const _Key, _Tp> > > class map { public: typedef _Key key_type; typedef _Tp mapped_type; typedef std::pair<const _Key, _Tp> value_type; typedef _Compare key_compare; typedef _Alloc allocator_type; private: public: class value_compare : public std::binary_function<value_type, value_type, bool> { friend class map<_Key, _Tp, _Compare, _Alloc>; protected: _Compare comp; value_compare(_Compare __c) : comp(__c) { } public: bool operator()(const value_type& __x, const value_type& __y) const { return comp(__x.first, __y.first); } }; private: typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template rebind<value_type>::other _Pair_alloc_type; typedef _Rb_tree<key_type, value_type, _Select1st<value_type>, key_compare, _Pair_alloc_type> _Rep_type; _Rep_type _M_t; typedef __gnu_cxx::__alloc_traits<_Pair_alloc_type> _Alloc_traits; public: typedef typename _Alloc_traits::pointer pointer; typedef typename _Alloc_traits::const_pointer const_pointer; typedef typename _Alloc_traits::reference reference; typedef typename _Alloc_traits::const_reference const_reference; typedef typename _Rep_type::iterator iterator; typedef typename _Rep_type::const_iterator const_iterator; typedef typename _Rep_type::size_type size_type; typedef typename _Rep_type::difference_type difference_type; typedef typename _Rep_type::reverse_iterator reverse_iterator; typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator; map() = default; explicit map(const _Compare& __comp, const allocator_type& __a = allocator_type()) : _M_t(__comp, _Pair_alloc_type(__a)) { } map(const map&) = default; map(map&&) = default; map(initializer_list<value_type> __l, const _Compare& __comp = _Compare(), const allocator_type& __a = allocator_type()) : _M_t(__comp, _Pair_alloc_type(__a)) { _M_t._M_insert_range_unique(__l.begin(), __l.end()); } explicit map(const allocator_type& __a) : _M_t(_Pair_alloc_type(__a)) { } map(const map& __m, const allocator_type& __a) : _M_t(__m._M_t, _Pair_alloc_type(__a)) { } map(map&& __m, const allocator_type& __a) noexcept(is_nothrow_copy_constructible<_Compare>::value && _Alloc_traits::_S_always_equal()) : _M_t(std::move(__m._M_t), _Pair_alloc_type(__a)) { } map(initializer_list<value_type> __l, const allocator_type& __a) : _M_t(_Pair_alloc_type(__a)) { _M_t._M_insert_range_unique(__l.begin(), __l.end()); } template<typename _InputIterator> map(_InputIterator __first, _InputIterator __last, const allocator_type& __a) : _M_t(_Pair_alloc_type(__a)) { _M_t._M_insert_range_unique(__first, __last); } template<typename _InputIterator> map(_InputIterator __first, _InputIterator __last) : _M_t() { _M_t._M_insert_range_unique(__first, __last); } template<typename _InputIterator> map(_InputIterator __first, _InputIterator __last, const _Compare& __comp, const allocator_type& __a = allocator_type()) : _M_t(__comp, _Pair_alloc_type(__a)) { _M_t._M_insert_range_unique(__first, __last); } ~map() = default; map& operator=(const map&) = default; map& operator=(map&&) = default; map& operator=(initializer_list<value_type> __l) { _M_t._M_assign_unique(__l.begin(), __l.end()); return *this; } allocator_type get_allocator() const noexcept { return allocator_type(_M_t.get_allocator()); } iterator begin() noexcept { return _M_t.begin(); } const_iterator begin() const noexcept { return _M_t.begin(); } iterator end() noexcept { return _M_t.end(); } const_iterator end() const noexcept { return _M_t.end(); } reverse_iterator rbegin() noexcept { return _M_t.rbegin(); } const_reverse_iterator rbegin() const noexcept { return _M_t.rbegin(); } reverse_iterator rend() noexcept { return _M_t.rend(); } const_reverse_iterator rend() const noexcept { return _M_t.rend(); } const_iterator cbegin() const noexcept { return _M_t.begin(); } const_iterator cend() const noexcept { return _M_t.end(); } const_reverse_iterator crbegin() const noexcept { return _M_t.rbegin(); } const_reverse_iterator crend() const noexcept { return _M_t.rend(); } bool empty() const noexcept { return _M_t.empty(); } size_type size() const noexcept { return _M_t.size(); } size_type max_size() const noexcept { return _M_t.max_size(); } mapped_type& operator[](const key_type& __k) { iterator __i = lower_bound(__k); if (__i == end() || key_comp()(__k, (*__i).first)) __i = _M_t._M_emplace_hint_unique(__i, std::piecewise_construct, std::tuple<const key_type&>(__k), std::tuple<>()); return (*__i).second; } mapped_type& operator[](key_type&& __k) { iterator __i = lower_bound(__k); if (__i == end() || key_comp()(__k, (*__i).first)) __i = _M_t._M_emplace_hint_unique(__i, std::piecewise_construct, std::forward_as_tuple(std::move(__k)), std::tuple<>()); return (*__i).second; } mapped_type& at(const key_type& __k) { iterator __i = lower_bound(__k); if (__i == end() || key_comp()(__k, (*__i).first)) __throw_out_of_range(("map::at")); return (*__i).second; } const mapped_type& at(const key_type& __k) const { const_iterator __i = lower_bound(__k); if (__i == end() || key_comp()(__k, (*__i).first)) __throw_out_of_range(("map::at")); return (*__i).second; } template<typename... _Args> std::pair<iterator, bool> emplace(_Args&&... __args) { return _M_t._M_emplace_unique(std::forward<_Args>(__args)...); } template<typename... _Args> iterator emplace_hint(const_iterator __pos, _Args&&... __args) { return _M_t._M_emplace_hint_unique(__pos, std::forward<_Args>(__args)...); } std::pair<iterator, bool> insert(const value_type& __x) { return _M_t._M_insert_unique(__x); } std::pair<iterator, bool> insert(value_type&& __x) { return _M_t._M_insert_unique(std::move(__x)); } template<typename _Pair> __enable_if_t<is_constructible<value_type, _Pair>::value, pair<iterator, bool>> insert(_Pair&& __x) { return _M_t._M_emplace_unique(std::forward<_Pair>(__x)); } void insert(std::initializer_list<value_type> __list) { insert(__list.begin(), __list.end()); } iterator insert(const_iterator __position, const value_type& __x) { return _M_t._M_insert_unique_(__position, __x); } iterator insert(const_iterator __position, value_type&& __x) { return _M_t._M_insert_unique_(__position, std::move(__x)); } template<typename _Pair> __enable_if_t<is_constructible<value_type, _Pair>::value, iterator> insert(const_iterator __position, _Pair&& __x) { return _M_t._M_emplace_hint_unique(__position, std::forward<_Pair>(__x)); } template<typename _InputIterator> void insert(_InputIterator __first, _InputIterator __last) { _M_t._M_insert_range_unique(__first, __last); } iterator erase(const_iterator __position) { return _M_t.erase(__position); } __attribute ((__abi_tag__ ("cxx11"))) iterator erase(iterator __position) { return _M_t.erase(__position); } size_type erase(const key_type& __x) { return _M_t.erase(__x); } iterator erase(const_iterator __first, const_iterator __last) { return _M_t.erase(__first, __last); } void swap(map& __x) noexcept(__is_nothrow_swappable<_Compare>::value) { _M_t.swap(__x._M_t); } void clear() noexcept { _M_t.clear(); } key_compare key_comp() const { return _M_t.key_comp(); } value_compare value_comp() const { return value_compare(_M_t.key_comp()); } iterator find(const key_type& __x) { return _M_t.find(__x); } template<typename _Kt> auto find(const _Kt& __x) -> decltype(_M_t._M_find_tr(__x)) { return _M_t._M_find_tr(__x); } const_iterator find(const key_type& __x) const { return _M_t.find(__x); } template<typename _Kt> auto find(const _Kt& __x) const -> decltype(_M_t._M_find_tr(__x)) { return _M_t._M_find_tr(__x); } size_type count(const key_type& __x) const { return _M_t.find(__x) == _M_t.end() ? 0 : 1; } template<typename _Kt> auto count(const _Kt& __x) const -> decltype(_M_t._M_count_tr(__x)) { return _M_t._M_count_tr(__x); } iterator lower_bound(const key_type& __x) { return _M_t.lower_bound(__x); } template<typename _Kt> auto lower_bound(const _Kt& __x) -> decltype(iterator(_M_t._M_lower_bound_tr(__x))) { return iterator(_M_t._M_lower_bound_tr(__x)); } const_iterator lower_bound(const key_type& __x) const { return _M_t.lower_bound(__x); } template<typename _Kt> auto lower_bound(const _Kt& __x) const -> decltype(const_iterator(_M_t._M_lower_bound_tr(__x))) { return const_iterator(_M_t._M_lower_bound_tr(__x)); } iterator upper_bound(const key_type& __x) { return _M_t.upper_bound(__x); } template<typename _Kt> auto upper_bound(const _Kt& __x) -> decltype(iterator(_M_t._M_upper_bound_tr(__x))) { return iterator(_M_t._M_upper_bound_tr(__x)); } const_iterator upper_bound(const key_type& __x) const { return _M_t.upper_bound(__x); } template<typename _Kt> auto upper_bound(const _Kt& __x) const -> decltype(const_iterator(_M_t._M_upper_bound_tr(__x))) { return const_iterator(_M_t._M_upper_bound_tr(__x)); } std::pair<iterator, iterator> equal_range(const key_type& __x) { return _M_t.equal_range(__x); } template<typename _Kt> auto equal_range(const _Kt& __x) -> decltype(pair<iterator, iterator>(_M_t._M_equal_range_tr(__x))) { return pair<iterator, iterator>(_M_t._M_equal_range_tr(__x)); } std::pair<const_iterator, const_iterator> equal_range(const key_type& __x) const { return _M_t.equal_range(__x); } template<typename _Kt> auto equal_range(const _Kt& __x) const -> decltype(pair<const_iterator, const_iterator>( _M_t._M_equal_range_tr(__x))) { return pair<const_iterator, const_iterator>( _M_t._M_equal_range_tr(__x)); } template<typename _K1, typename _T1, typename _C1, typename _A1> friend bool operator==(const map<_K1, _T1, _C1, _A1>&, const map<_K1, _T1, _C1, _A1>&); template<typename _K1, typename _T1, typename _C1, typename _A1> friend bool operator<(const map<_K1, _T1, _C1, _A1>&, const map<_K1, _T1, _C1, _A1>&); }; template<typename _Key, typename _Tp, typename _Compare, typename _Alloc> inline bool operator==(const map<_Key, _Tp, _Compare, _Alloc>& __x, const map<_Key, _Tp, _Compare, _Alloc>& __y) { return __x._M_t == __y._M_t; } template<typename _Key, typename _Tp, typename _Compare, typename _Alloc> inline bool operator<(const map<_Key, _Tp, _Compare, _Alloc>& __x, const map<_Key, _Tp, _Compare, _Alloc>& __y) { return __x._M_t < __y._M_t; } template<typename _Key, typename _Tp, typename _Compare, typename _Alloc> inline bool operator!=(const map<_Key, _Tp, _Compare, _Alloc>& __x, const map<_Key, _Tp, _Compare, _Alloc>& __y) { return !(__x == __y); } template<typename _Key, typename _Tp, typename _Compare, typename _Alloc> inline bool operator>(const map<_Key, _Tp, _Compare, _Alloc>& __x, const map<_Key, _Tp, _Compare, _Alloc>& __y) { return __y < __x; } template<typename _Key, typename _Tp, typename _Compare, typename _Alloc> inline bool operator<=(const map<_Key, _Tp, _Compare, _Alloc>& __x, const map<_Key, _Tp, _Compare, _Alloc>& __y) { return !(__y < __x); } template<typename _Key, typename _Tp, typename _Compare, typename _Alloc> inline bool operator>=(const map<_Key, _Tp, _Compare, _Alloc>& __x, const map<_Key, _Tp, _Compare, _Alloc>& __y) { return !(__x < __y); } template<typename _Key, typename _Tp, typename _Compare, typename _Alloc> inline void swap(map<_Key, _Tp, _Compare, _Alloc>& __x, map<_Key, _Tp, _Compare, _Alloc>& __y) noexcept(noexcept(__x.swap(__y))) { __x.swap(__y); } } namespace std __attribute__ ((__visibility__ ("default"))) { template <typename _Key, typename _Tp, typename _Compare, typename _Alloc> class map; template <typename _Key, typename _Tp, typename _Compare = std::less<_Key>, typename _Alloc = std::allocator<std::pair<const _Key, _Tp> > > class multimap { public: typedef _Key key_type; typedef _Tp mapped_type; typedef std::pair<const _Key, _Tp> value_type; typedef _Compare key_compare; typedef _Alloc allocator_type; private: public: class value_compare : public std::binary_function<value_type, value_type, bool> { friend class multimap<_Key, _Tp, _Compare, _Alloc>; protected: _Compare comp; value_compare(_Compare __c) : comp(__c) { } public: bool operator()(const value_type& __x, const value_type& __y) const { return comp(__x.first, __y.first); } }; private: typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template rebind<value_type>::other _Pair_alloc_type; typedef _Rb_tree<key_type, value_type, _Select1st<value_type>, key_compare, _Pair_alloc_type> _Rep_type; _Rep_type _M_t; typedef __gnu_cxx::__alloc_traits<_Pair_alloc_type> _Alloc_traits; public: typedef typename _Alloc_traits::pointer pointer; typedef typename _Alloc_traits::const_pointer const_pointer; typedef typename _Alloc_traits::reference reference; typedef typename _Alloc_traits::const_reference const_reference; typedef typename _Rep_type::iterator iterator; typedef typename _Rep_type::const_iterator const_iterator; typedef typename _Rep_type::size_type size_type; typedef typename _Rep_type::difference_type difference_type; typedef typename _Rep_type::reverse_iterator reverse_iterator; typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator; multimap() = default; explicit multimap(const _Compare& __comp, const allocator_type& __a = allocator_type()) : _M_t(__comp, _Pair_alloc_type(__a)) { } multimap(const multimap&) = default; multimap(multimap&&) = default; multimap(initializer_list<value_type> __l, const _Compare& __comp = _Compare(), const allocator_type& __a = allocator_type()) : _M_t(__comp, _Pair_alloc_type(__a)) { _M_t._M_insert_range_equal(__l.begin(), __l.end()); } explicit multimap(const allocator_type& __a) : _M_t(_Pair_alloc_type(__a)) { } multimap(const multimap& __m, const allocator_type& __a) : _M_t(__m._M_t, _Pair_alloc_type(__a)) { } multimap(multimap&& __m, const allocator_type& __a) noexcept(is_nothrow_copy_constructible<_Compare>::value && _Alloc_traits::_S_always_equal()) : _M_t(std::move(__m._M_t), _Pair_alloc_type(__a)) { } multimap(initializer_list<value_type> __l, const allocator_type& __a) : _M_t(_Pair_alloc_type(__a)) { _M_t._M_insert_range_equal(__l.begin(), __l.end()); } template<typename _InputIterator> multimap(_InputIterator __first, _InputIterator __last, const allocator_type& __a) : _M_t(_Pair_alloc_type(__a)) { _M_t._M_insert_range_equal(__first, __last); } template<typename _InputIterator> multimap(_InputIterator __first, _InputIterator __last) : _M_t() { _M_t._M_insert_range_equal(__first, __last); } template<typename _InputIterator> multimap(_InputIterator __first, _InputIterator __last, const _Compare& __comp, const allocator_type& __a = allocator_type()) : _M_t(__comp, _Pair_alloc_type(__a)) { _M_t._M_insert_range_equal(__first, __last); } ~multimap() = default; multimap& operator=(const multimap&) = default; multimap& operator=(multimap&&) = default; multimap& operator=(initializer_list<value_type> __l) { _M_t._M_assign_equal(__l.begin(), __l.end()); return *this; } allocator_type get_allocator() const noexcept { return allocator_type(_M_t.get_allocator()); } iterator begin() noexcept { return _M_t.begin(); } const_iterator begin() const noexcept { return _M_t.begin(); } iterator end() noexcept { return _M_t.end(); } const_iterator end() const noexcept { return _M_t.end(); } reverse_iterator rbegin() noexcept { return _M_t.rbegin(); } const_reverse_iterator rbegin() const noexcept { return _M_t.rbegin(); } reverse_iterator rend() noexcept { return _M_t.rend(); } const_reverse_iterator rend() const noexcept { return _M_t.rend(); } const_iterator cbegin() const noexcept { return _M_t.begin(); } const_iterator cend() const noexcept { return _M_t.end(); } const_reverse_iterator crbegin() const noexcept { return _M_t.rbegin(); } const_reverse_iterator crend() const noexcept { return _M_t.rend(); } bool empty() const noexcept { return _M_t.empty(); } size_type size() const noexcept { return _M_t.size(); } size_type max_size() const noexcept { return _M_t.max_size(); } template<typename... _Args> iterator emplace(_Args&&... __args) { return _M_t._M_emplace_equal(std::forward<_Args>(__args)...); } template<typename... _Args> iterator emplace_hint(const_iterator __pos, _Args&&... __args) { return _M_t._M_emplace_hint_equal(__pos, std::forward<_Args>(__args)...); } iterator insert(const value_type& __x) { return _M_t._M_insert_equal(__x); } iterator insert(value_type&& __x) { return _M_t._M_insert_equal(std::move(__x)); } template<typename _Pair> __enable_if_t<is_constructible<value_type, _Pair>::value, iterator> insert(_Pair&& __x) { return _M_t._M_emplace_equal(std::forward<_Pair>(__x)); } iterator insert(const_iterator __position, const value_type& __x) { return _M_t._M_insert_equal_(__position, __x); } iterator insert(const_iterator __position, value_type&& __x) { return _M_t._M_insert_equal_(__position, std::move(__x)); } template<typename _Pair> __enable_if_t<is_constructible<value_type, _Pair&&>::value, iterator> insert(const_iterator __position, _Pair&& __x) { return _M_t._M_emplace_hint_equal(__position, std::forward<_Pair>(__x)); } template<typename _InputIterator> void insert(_InputIterator __first, _InputIterator __last) { _M_t._M_insert_range_equal(__first, __last); } void insert(initializer_list<value_type> __l) { this->insert(__l.begin(), __l.end()); } iterator erase(const_iterator __position) { return _M_t.erase(__position); } __attribute ((__abi_tag__ ("cxx11"))) iterator erase(iterator __position) { return _M_t.erase(__position); } size_type erase(const key_type& __x) { return _M_t.erase(__x); } iterator erase(const_iterator __first, const_iterator __last) { return _M_t.erase(__first, __last); } void swap(multimap& __x) noexcept(__is_nothrow_swappable<_Compare>::value) { _M_t.swap(__x._M_t); } void clear() noexcept { _M_t.clear(); } key_compare key_comp() const { return _M_t.key_comp(); } value_compare value_comp() const { return value_compare(_M_t.key_comp()); } iterator find(const key_type& __x) { return _M_t.find(__x); } template<typename _Kt> auto find(const _Kt& __x) -> decltype(_M_t._M_find_tr(__x)) { return _M_t._M_find_tr(__x); } const_iterator find(const key_type& __x) const { return _M_t.find(__x); } template<typename _Kt> auto find(const _Kt& __x) const -> decltype(_M_t._M_find_tr(__x)) { return _M_t._M_find_tr(__x); } size_type count(const key_type& __x) const { return _M_t.count(__x); } template<typename _Kt> auto count(const _Kt& __x) const -> decltype(_M_t._M_count_tr(__x)) { return _M_t._M_count_tr(__x); } iterator lower_bound(const key_type& __x) { return _M_t.lower_bound(__x); } template<typename _Kt> auto lower_bound(const _Kt& __x) -> decltype(iterator(_M_t._M_lower_bound_tr(__x))) { return iterator(_M_t._M_lower_bound_tr(__x)); } const_iterator lower_bound(const key_type& __x) const { return _M_t.lower_bound(__x); } template<typename _Kt> auto lower_bound(const _Kt& __x) const -> decltype(const_iterator(_M_t._M_lower_bound_tr(__x))) { return const_iterator(_M_t._M_lower_bound_tr(__x)); } iterator upper_bound(const key_type& __x) { return _M_t.upper_bound(__x); } template<typename _Kt> auto upper_bound(const _Kt& __x) -> decltype(iterator(_M_t._M_upper_bound_tr(__x))) { return iterator(_M_t._M_upper_bound_tr(__x)); } const_iterator upper_bound(const key_type& __x) const { return _M_t.upper_bound(__x); } template<typename _Kt> auto upper_bound(const _Kt& __x) const -> decltype(const_iterator(_M_t._M_upper_bound_tr(__x))) { return const_iterator(_M_t._M_upper_bound_tr(__x)); } std::pair<iterator, iterator> equal_range(const key_type& __x) { return _M_t.equal_range(__x); } template<typename _Kt> auto equal_range(const _Kt& __x) -> decltype(pair<iterator, iterator>(_M_t._M_equal_range_tr(__x))) { return pair<iterator, iterator>(_M_t._M_equal_range_tr(__x)); } std::pair<const_iterator, const_iterator> equal_range(const key_type& __x) const { return _M_t.equal_range(__x); } template<typename _Kt> auto equal_range(const _Kt& __x) const -> decltype(pair<const_iterator, const_iterator>( _M_t._M_equal_range_tr(__x))) { return pair<const_iterator, const_iterator>( _M_t._M_equal_range_tr(__x)); } template<typename _K1, typename _T1, typename _C1, typename _A1> friend bool operator==(const multimap<_K1, _T1, _C1, _A1>&, const multimap<_K1, _T1, _C1, _A1>&); template<typename _K1, typename _T1, typename _C1, typename _A1> friend bool operator<(const multimap<_K1, _T1, _C1, _A1>&, const multimap<_K1, _T1, _C1, _A1>&); }; template<typename _Key, typename _Tp, typename _Compare, typename _Alloc> inline bool operator==(const multimap<_Key, _Tp, _Compare, _Alloc>& __x, const multimap<_Key, _Tp, _Compare, _Alloc>& __y) { return __x._M_t == __y._M_t; } template<typename _Key, typename _Tp, typename _Compare, typename _Alloc> inline bool operator<(const multimap<_Key, _Tp, _Compare, _Alloc>& __x, const multimap<_Key, _Tp, _Compare, _Alloc>& __y) { return __x._M_t < __y._M_t; } template<typename _Key, typename _Tp, typename _Compare, typename _Alloc> inline bool operator!=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x, const multimap<_Key, _Tp, _Compare, _Alloc>& __y) { return !(__x == __y); } template<typename _Key, typename _Tp, typename _Compare, typename _Alloc> inline bool operator>(const multimap<_Key, _Tp, _Compare, _Alloc>& __x, const multimap<_Key, _Tp, _Compare, _Alloc>& __y) { return __y < __x; } template<typename _Key, typename _Tp, typename _Compare, typename _Alloc> inline bool operator<=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x, const multimap<_Key, _Tp, _Compare, _Alloc>& __y) { return !(__y < __x); } template<typename _Key, typename _Tp, typename _Compare, typename _Alloc> inline bool operator>=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x, const multimap<_Key, _Tp, _Compare, _Alloc>& __y) { return !(__x < __y); } template<typename _Key, typename _Tp, typename _Compare, typename _Alloc> inline void swap(multimap<_Key, _Tp, _Compare, _Alloc>& __x, multimap<_Key, _Tp, _Compare, _Alloc>& __y) noexcept(noexcept(__x.swap(__y))) { __x.swap(__y); } } namespace std { namespace __detail { template<typename _Container, typename _Predicate> typename _Container::size_type __erase_nodes_if(_Container& __cont, _Predicate __pred) { typename _Container::size_type __num = 0; for (auto __iter = __cont.begin(), __last = __cont.end(); __iter != __last;) { if (__pred(*__iter)) { __iter = __cont.erase(__iter); ++__num; } else ++__iter; } return __num; } } } namespace std __attribute__ ((__visibility__ ("default"))) { template<typename _Tp> struct atomic; template<> struct atomic<bool> { using value_type = bool; private: __atomic_base<bool> _M_base; public: atomic() noexcept = default; ~atomic() noexcept = default; atomic(const atomic&) = delete; atomic& operator=(const atomic&) = delete; atomic& operator=(const atomic&) volatile = delete; constexpr atomic(bool __i) noexcept : _M_base(__i) { } bool operator=(bool __i) noexcept { return _M_base.operator=(__i); } bool operator=(bool __i) volatile noexcept { return _M_base.operator=(__i); } operator bool() const noexcept { return _M_base.load(); } operator bool() const volatile noexcept { return _M_base.load(); } bool is_lock_free() const noexcept { return _M_base.is_lock_free(); } bool is_lock_free() const volatile noexcept { return _M_base.is_lock_free(); } void store(bool __i, memory_order __m = memory_order_seq_cst) noexcept { _M_base.store(__i, __m); } void store(bool __i, memory_order __m = memory_order_seq_cst) volatile noexcept { _M_base.store(__i, __m); } bool load(memory_order __m = memory_order_seq_cst) const noexcept { return _M_base.load(__m); } bool load(memory_order __m = memory_order_seq_cst) const volatile noexcept { return _M_base.load(__m); } bool exchange(bool __i, memory_order __m = memory_order_seq_cst) noexcept { return _M_base.exchange(__i, __m); } bool exchange(bool __i, memory_order __m = memory_order_seq_cst) volatile noexcept { return _M_base.exchange(__i, __m); } bool compare_exchange_weak(bool& __i1, bool __i2, memory_order __m1, memory_order __m2) noexcept { return _M_base.compare_exchange_weak(__i1, __i2, __m1, __m2); } bool compare_exchange_weak(bool& __i1, bool __i2, memory_order __m1, memory_order __m2) volatile noexcept { return _M_base.compare_exchange_weak(__i1, __i2, __m1, __m2); } bool compare_exchange_weak(bool& __i1, bool __i2, memory_order __m = memory_order_seq_cst) noexcept { return _M_base.compare_exchange_weak(__i1, __i2, __m); } bool compare_exchange_weak(bool& __i1, bool __i2, memory_order __m = memory_order_seq_cst) volatile noexcept { return _M_base.compare_exchange_weak(__i1, __i2, __m); } bool compare_exchange_strong(bool& __i1, bool __i2, memory_order __m1, memory_order __m2) noexcept { return _M_base.compare_exchange_strong(__i1, __i2, __m1, __m2); } bool compare_exchange_strong(bool& __i1, bool __i2, memory_order __m1, memory_order __m2) volatile noexcept { return _M_base.compare_exchange_strong(__i1, __i2, __m1, __m2); } bool compare_exchange_strong(bool& __i1, bool __i2, memory_order __m = memory_order_seq_cst) noexcept { return _M_base.compare_exchange_strong(__i1, __i2, __m); } bool compare_exchange_strong(bool& __i1, bool __i2, memory_order __m = memory_order_seq_cst) volatile noexcept { return _M_base.compare_exchange_strong(__i1, __i2, __m); } }; template<typename _Tp> struct atomic { using value_type = _Tp; private: static constexpr int _S_min_alignment = (sizeof(_Tp) & (sizeof(_Tp) - 1)) || sizeof(_Tp) > 16 ? 0 : sizeof(_Tp); static constexpr int _S_alignment = _S_min_alignment > alignof(_Tp) ? _S_min_alignment : alignof(_Tp); alignas(_S_alignment) _Tp _M_i ; static_assert(__is_trivially_copyable(_Tp), "std::atomic requires a trivially copyable type"); static_assert(sizeof(_Tp) > 0, "Incomplete or zero-sized types are not supported"); public: atomic() = default; ~atomic() noexcept = default; atomic(const atomic&) = delete; atomic& operator=(const atomic&) = delete; atomic& operator=(const atomic&) volatile = delete; constexpr atomic(_Tp __i) noexcept : _M_i(__i) { } operator _Tp() const noexcept { return load(); } operator _Tp() const volatile noexcept { return load(); } _Tp operator=(_Tp __i) noexcept { store(__i); return __i; } _Tp operator=(_Tp __i) volatile noexcept { store(__i); return __i; } bool is_lock_free() const noexcept { return __atomic_is_lock_free(sizeof(_M_i), reinterpret_cast<void *>(-_S_alignment)); } bool is_lock_free() const volatile noexcept { return __atomic_is_lock_free(sizeof(_M_i), reinterpret_cast<void *>(-_S_alignment)); } void store(_Tp __i, memory_order __m = memory_order_seq_cst) noexcept { __atomic_store(std::__addressof(_M_i), std::__addressof(__i), int(__m)); } void store(_Tp __i, memory_order __m = memory_order_seq_cst) volatile noexcept { __atomic_store(std::__addressof(_M_i), std::__addressof(__i), int(__m)); } _Tp load(memory_order __m = memory_order_seq_cst) const noexcept { alignas(_Tp) unsigned char __buf[sizeof(_Tp)]; _Tp* __ptr = reinterpret_cast<_Tp*>(__buf); __atomic_load(std::__addressof(_M_i), __ptr, int(__m)); return *__ptr; } _Tp load(memory_order __m = memory_order_seq_cst) const volatile noexcept { alignas(_Tp) unsigned char __buf[sizeof(_Tp)]; _Tp* __ptr = reinterpret_cast<_Tp*>(__buf); __atomic_load(std::__addressof(_M_i), __ptr, int(__m)); return *__ptr; } _Tp exchange(_Tp __i, memory_order __m = memory_order_seq_cst) noexcept { alignas(_Tp) unsigned char __buf[sizeof(_Tp)]; _Tp* __ptr = reinterpret_cast<_Tp*>(__buf); __atomic_exchange(std::__addressof(_M_i), std::__addressof(__i), __ptr, int(__m)); return *__ptr; } _Tp exchange(_Tp __i, memory_order __m = memory_order_seq_cst) volatile noexcept { alignas(_Tp) unsigned char __buf[sizeof(_Tp)]; _Tp* __ptr = reinterpret_cast<_Tp*>(__buf); __atomic_exchange(std::__addressof(_M_i), std::__addressof(__i), __ptr, int(__m)); return *__ptr; } bool compare_exchange_weak(_Tp& __e, _Tp __i, memory_order __s, memory_order __f) noexcept { return __atomic_compare_exchange(std::__addressof(_M_i), std::__addressof(__e), std::__addressof(__i), true, int(__s), int(__f)); } bool compare_exchange_weak(_Tp& __e, _Tp __i, memory_order __s, memory_order __f) volatile noexcept { return __atomic_compare_exchange(std::__addressof(_M_i), std::__addressof(__e), std::__addressof(__i), true, int(__s), int(__f)); } bool compare_exchange_weak(_Tp& __e, _Tp __i, memory_order __m = memory_order_seq_cst) noexcept { return compare_exchange_weak(__e, __i, __m, __cmpexch_failure_order(__m)); } bool compare_exchange_weak(_Tp& __e, _Tp __i, memory_order __m = memory_order_seq_cst) volatile noexcept { return compare_exchange_weak(__e, __i, __m, __cmpexch_failure_order(__m)); } bool compare_exchange_strong(_Tp& __e, _Tp __i, memory_order __s, memory_order __f) noexcept { return __atomic_compare_exchange(std::__addressof(_M_i), std::__addressof(__e), std::__addressof(__i), false, int(__s), int(__f)); } bool compare_exchange_strong(_Tp& __e, _Tp __i, memory_order __s, memory_order __f) volatile noexcept { return __atomic_compare_exchange(std::__addressof(_M_i), std::__addressof(__e), std::__addressof(__i), false, int(__s), int(__f)); } bool compare_exchange_strong(_Tp& __e, _Tp __i, memory_order __m = memory_order_seq_cst) noexcept { return compare_exchange_strong(__e, __i, __m, __cmpexch_failure_order(__m)); } bool compare_exchange_strong(_Tp& __e, _Tp __i, memory_order __m = memory_order_seq_cst) volatile noexcept { return compare_exchange_strong(__e, __i, __m, __cmpexch_failure_order(__m)); } }; template<typename _Tp> struct atomic<_Tp*> { using value_type = _Tp*; using difference_type = ptrdiff_t; typedef _Tp* __pointer_type; typedef __atomic_base<_Tp*> __base_type; __base_type _M_b; atomic() noexcept = default; ~atomic() noexcept = default; atomic(const atomic&) = delete; atomic& operator=(const atomic&) = delete; atomic& operator=(const atomic&) volatile = delete; constexpr atomic(__pointer_type __p) noexcept : _M_b(__p) { } operator __pointer_type() const noexcept { return __pointer_type(_M_b); } operator __pointer_type() const volatile noexcept { return __pointer_type(_M_b); } __pointer_type operator=(__pointer_type __p) noexcept { return _M_b.operator=(__p); } __pointer_type operator=(__pointer_type __p) volatile noexcept { return _M_b.operator=(__p); } __pointer_type operator++(int) noexcept { return _M_b++; } __pointer_type operator++(int) volatile noexcept { return _M_b++; } __pointer_type operator--(int) noexcept { return _M_b--; } __pointer_type operator--(int) volatile noexcept { return _M_b--; } __pointer_type operator++() noexcept { return ++_M_b; } __pointer_type operator++() volatile noexcept { return ++_M_b; } __pointer_type operator--() noexcept { return --_M_b; } __pointer_type operator--() volatile noexcept { return --_M_b; } __pointer_type operator+=(ptrdiff_t __d) noexcept { return _M_b.operator+=(__d); } __pointer_type operator+=(ptrdiff_t __d) volatile noexcept { return _M_b.operator+=(__d); } __pointer_type operator-=(ptrdiff_t __d) noexcept { return _M_b.operator-=(__d); } __pointer_type operator-=(ptrdiff_t __d) volatile noexcept { return _M_b.operator-=(__d); } bool is_lock_free() const noexcept { return _M_b.is_lock_free(); } bool is_lock_free() const volatile noexcept { return _M_b.is_lock_free(); } void store(__pointer_type __p, memory_order __m = memory_order_seq_cst) noexcept { return _M_b.store(__p, __m); } void store(__pointer_type __p, memory_order __m = memory_order_seq_cst) volatile noexcept { return _M_b.store(__p, __m); } __pointer_type load(memory_order __m = memory_order_seq_cst) const noexcept { return _M_b.load(__m); } __pointer_type load(memory_order __m = memory_order_seq_cst) const volatile noexcept { return _M_b.load(__m); } __pointer_type exchange(__pointer_type __p, memory_order __m = memory_order_seq_cst) noexcept { return _M_b.exchange(__p, __m); } __pointer_type exchange(__pointer_type __p, memory_order __m = memory_order_seq_cst) volatile noexcept { return _M_b.exchange(__p, __m); } bool compare_exchange_weak(__pointer_type& __p1, __pointer_type __p2, memory_order __m1, memory_order __m2) noexcept { return _M_b.compare_exchange_strong(__p1, __p2, __m1, __m2); } bool compare_exchange_weak(__pointer_type& __p1, __pointer_type __p2, memory_order __m1, memory_order __m2) volatile noexcept { return _M_b.compare_exchange_strong(__p1, __p2, __m1, __m2); } bool compare_exchange_weak(__pointer_type& __p1, __pointer_type __p2, memory_order __m = memory_order_seq_cst) noexcept { return compare_exchange_weak(__p1, __p2, __m, __cmpexch_failure_order(__m)); } bool compare_exchange_weak(__pointer_type& __p1, __pointer_type __p2, memory_order __m = memory_order_seq_cst) volatile noexcept { return compare_exchange_weak(__p1, __p2, __m, __cmpexch_failure_order(__m)); } bool compare_exchange_strong(__pointer_type& __p1, __pointer_type __p2, memory_order __m1, memory_order __m2) noexcept { return _M_b.compare_exchange_strong(__p1, __p2, __m1, __m2); } bool compare_exchange_strong(__pointer_type& __p1, __pointer_type __p2, memory_order __m1, memory_order __m2) volatile noexcept { return _M_b.compare_exchange_strong(__p1, __p2, __m1, __m2); } bool compare_exchange_strong(__pointer_type& __p1, __pointer_type __p2, memory_order __m = memory_order_seq_cst) noexcept { return _M_b.compare_exchange_strong(__p1, __p2, __m, __cmpexch_failure_order(__m)); } bool compare_exchange_strong(__pointer_type& __p1, __pointer_type __p2, memory_order __m = memory_order_seq_cst) volatile noexcept { return _M_b.compare_exchange_strong(__p1, __p2, __m, __cmpexch_failure_order(__m)); } __pointer_type fetch_add(ptrdiff_t __d, memory_order __m = memory_order_seq_cst) noexcept { return _M_b.fetch_add(__d, __m); } __pointer_type fetch_add(ptrdiff_t __d, memory_order __m = memory_order_seq_cst) volatile noexcept { return _M_b.fetch_add(__d, __m); } __pointer_type fetch_sub(ptrdiff_t __d, memory_order __m = memory_order_seq_cst) noexcept { return _M_b.fetch_sub(__d, __m); } __pointer_type fetch_sub(ptrdiff_t __d, memory_order __m = memory_order_seq_cst) volatile noexcept { return _M_b.fetch_sub(__d, __m); } }; template<> struct atomic<char> : __atomic_base<char> { typedef char __integral_type; typedef __atomic_base<char> __base_type; atomic() noexcept = default; ~atomic() noexcept = default; atomic(const atomic&) = delete; atomic& operator=(const atomic&) = delete; atomic& operator=(const atomic&) volatile = delete; constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { } using __base_type::operator __integral_type; using __base_type::operator=; }; template<> struct atomic<signed char> : __atomic_base<signed char> { typedef signed char __integral_type; typedef __atomic_base<signed char> __base_type; atomic() noexcept= default; ~atomic() noexcept = default; atomic(const atomic&) = delete; atomic& operator=(const atomic&) = delete; atomic& operator=(const atomic&) volatile = delete; constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { } using __base_type::operator __integral_type; using __base_type::operator=; }; template<> struct atomic<unsigned char> : __atomic_base<unsigned char> { typedef unsigned char __integral_type; typedef __atomic_base<unsigned char> __base_type; atomic() noexcept= default; ~atomic() noexcept = default; atomic(const atomic&) = delete; atomic& operator=(const atomic&) = delete; atomic& operator=(const atomic&) volatile = delete; constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { } using __base_type::operator __integral_type; using __base_type::operator=; }; template<> struct atomic<short> : __atomic_base<short> { typedef short __integral_type; typedef __atomic_base<short> __base_type; atomic() noexcept = default; ~atomic() noexcept = default; atomic(const atomic&) = delete; atomic& operator=(const atomic&) = delete; atomic& operator=(const atomic&) volatile = delete; constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { } using __base_type::operator __integral_type; using __base_type::operator=; }; template<> struct atomic<unsigned short> : __atomic_base<unsigned short> { typedef unsigned short __integral_type; typedef __atomic_base<unsigned short> __base_type; atomic() noexcept = default; ~atomic() noexcept = default; atomic(const atomic&) = delete; atomic& operator=(const atomic&) = delete; atomic& operator=(const atomic&) volatile = delete; constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { } using __base_type::operator __integral_type; using __base_type::operator=; }; template<> struct atomic<int> : __atomic_base<int> { typedef int __integral_type; typedef __atomic_base<int> __base_type; atomic() noexcept = default; ~atomic() noexcept = default; atomic(const atomic&) = delete; atomic& operator=(const atomic&) = delete; atomic& operator=(const atomic&) volatile = delete; constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { } using __base_type::operator __integral_type; using __base_type::operator=; }; template<> struct atomic<unsigned int> : __atomic_base<unsigned int> { typedef unsigned int __integral_type; typedef __atomic_base<unsigned int> __base_type; atomic() noexcept = default; ~atomic() noexcept = default; atomic(const atomic&) = delete; atomic& operator=(const atomic&) = delete; atomic& operator=(const atomic&) volatile = delete; constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { } using __base_type::operator __integral_type; using __base_type::operator=; }; template<> struct atomic<long> : __atomic_base<long> { typedef long __integral_type; typedef __atomic_base<long> __base_type; atomic() noexcept = default; ~atomic() noexcept = default; atomic(const atomic&) = delete; atomic& operator=(const atomic&) = delete; atomic& operator=(const atomic&) volatile = delete; constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { } using __base_type::operator __integral_type; using __base_type::operator=; }; template<> struct atomic<unsigned long> : __atomic_base<unsigned long> { typedef unsigned long __integral_type; typedef __atomic_base<unsigned long> __base_type; atomic() noexcept = default; ~atomic() noexcept = default; atomic(const atomic&) = delete; atomic& operator=(const atomic&) = delete; atomic& operator=(const atomic&) volatile = delete; constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { } using __base_type::operator __integral_type; using __base_type::operator=; }; template<> struct atomic<long long> : __atomic_base<long long> { typedef long long __integral_type; typedef __atomic_base<long long> __base_type; atomic() noexcept = default; ~atomic() noexcept = default; atomic(const atomic&) = delete; atomic& operator=(const atomic&) = delete; atomic& operator=(const atomic&) volatile = delete; constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { } using __base_type::operator __integral_type; using __base_type::operator=; }; template<> struct atomic<unsigned long long> : __atomic_base<unsigned long long> { typedef unsigned long long __integral_type; typedef __atomic_base<unsigned long long> __base_type; atomic() noexcept = default; ~atomic() noexcept = default; atomic(const atomic&) = delete; atomic& operator=(const atomic&) = delete; atomic& operator=(const atomic&) volatile = delete; constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { } using __base_type::operator __integral_type; using __base_type::operator=; }; template<> struct atomic<wchar_t> : __atomic_base<wchar_t> { typedef wchar_t __integral_type; typedef __atomic_base<wchar_t> __base_type; atomic() noexcept = default; ~atomic() noexcept = default; atomic(const atomic&) = delete; atomic& operator=(const atomic&) = delete; atomic& operator=(const atomic&) volatile = delete; constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { } using __base_type::operator __integral_type; using __base_type::operator=; }; template<> struct atomic<char16_t> : __atomic_base<char16_t> { typedef char16_t __integral_type; typedef __atomic_base<char16_t> __base_type; atomic() noexcept = default; ~atomic() noexcept = default; atomic(const atomic&) = delete; atomic& operator=(const atomic&) = delete; atomic& operator=(const atomic&) volatile = delete; constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { } using __base_type::operator __integral_type; using __base_type::operator=; }; template<> struct atomic<char32_t> : __atomic_base<char32_t> { typedef char32_t __integral_type; typedef __atomic_base<char32_t> __base_type; atomic() noexcept = default; ~atomic() noexcept = default; atomic(const atomic&) = delete; atomic& operator=(const atomic&) = delete; atomic& operator=(const atomic&) volatile = delete; constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { } using __base_type::operator __integral_type; using __base_type::operator=; }; typedef atomic<bool> atomic_bool; typedef atomic<char> atomic_char; typedef atomic<signed char> atomic_schar; typedef atomic<unsigned char> atomic_uchar; typedef atomic<short> atomic_short; typedef atomic<unsigned short> atomic_ushort; typedef atomic<int> atomic_int; typedef atomic<unsigned int> atomic_uint; typedef atomic<long> atomic_long; typedef atomic<unsigned long> atomic_ulong; typedef atomic<long long> atomic_llong; typedef atomic<unsigned long long> atomic_ullong; typedef atomic<wchar_t> atomic_wchar_t; typedef atomic<char16_t> atomic_char16_t; typedef atomic<char32_t> atomic_char32_t; typedef atomic<int8_t> atomic_int8_t; typedef atomic<uint8_t> atomic_uint8_t; typedef atomic<int16_t> atomic_int16_t; typedef atomic<uint16_t> atomic_uint16_t; typedef atomic<int32_t> atomic_int32_t; typedef atomic<uint32_t> atomic_uint32_t; typedef atomic<int64_t> atomic_int64_t; typedef atomic<uint64_t> atomic_uint64_t; typedef atomic<int_least8_t> atomic_int_least8_t; typedef atomic<uint_least8_t> atomic_uint_least8_t; typedef atomic<int_least16_t> atomic_int_least16_t; typedef atomic<uint_least16_t> atomic_uint_least16_t; typedef atomic<int_least32_t> atomic_int_least32_t; typedef atomic<uint_least32_t> atomic_uint_least32_t; typedef atomic<int_least64_t> atomic_int_least64_t; typedef atomic<uint_least64_t> atomic_uint_least64_t; typedef atomic<int_fast8_t> atomic_int_fast8_t; typedef atomic<uint_fast8_t> atomic_uint_fast8_t; typedef atomic<int_fast16_t> atomic_int_fast16_t; typedef atomic<uint_fast16_t> atomic_uint_fast16_t; typedef atomic<int_fast32_t> atomic_int_fast32_t; typedef atomic<uint_fast32_t> atomic_uint_fast32_t; typedef atomic<int_fast64_t> atomic_int_fast64_t; typedef atomic<uint_fast64_t> atomic_uint_fast64_t; typedef atomic<intptr_t> atomic_intptr_t; typedef atomic<uintptr_t> atomic_uintptr_t; typedef atomic<size_t> atomic_size_t; typedef atomic<ptrdiff_t> atomic_ptrdiff_t; typedef atomic<intmax_t> atomic_intmax_t; typedef atomic<uintmax_t> atomic_uintmax_t; inline bool atomic_flag_test_and_set_explicit(atomic_flag* __a, memory_order __m) noexcept { return __a->test_and_set(__m); } inline bool atomic_flag_test_and_set_explicit(volatile atomic_flag* __a, memory_order __m) noexcept { return __a->test_and_set(__m); } inline void atomic_flag_clear_explicit(atomic_flag* __a, memory_order __m) noexcept { __a->clear(__m); } inline void atomic_flag_clear_explicit(volatile atomic_flag* __a, memory_order __m) noexcept { __a->clear(__m); } inline bool atomic_flag_test_and_set(atomic_flag* __a) noexcept { return atomic_flag_test_and_set_explicit(__a, memory_order_seq_cst); } inline bool atomic_flag_test_and_set(volatile atomic_flag* __a) noexcept { return atomic_flag_test_and_set_explicit(__a, memory_order_seq_cst); } inline void atomic_flag_clear(atomic_flag* __a) noexcept { atomic_flag_clear_explicit(__a, memory_order_seq_cst); } inline void atomic_flag_clear(volatile atomic_flag* __a) noexcept { atomic_flag_clear_explicit(__a, memory_order_seq_cst); } template<typename _Tp> using __atomic_val_t = typename atomic<_Tp>::value_type; template<typename _Tp> using __atomic_diff_t = typename atomic<_Tp>::difference_type; template<typename _ITp> inline bool atomic_is_lock_free(const atomic<_ITp>* __a) noexcept { return __a->is_lock_free(); } template<typename _ITp> inline bool atomic_is_lock_free(const volatile atomic<_ITp>* __a) noexcept { return __a->is_lock_free(); } template<typename _ITp> inline void atomic_init(atomic<_ITp>* __a, __atomic_val_t<_ITp> __i) noexcept { __a->store(__i, memory_order_relaxed); } template<typename _ITp> inline void atomic_init(volatile atomic<_ITp>* __a, __atomic_val_t<_ITp> __i) noexcept { __a->store(__i, memory_order_relaxed); } template<typename _ITp> inline void atomic_store_explicit(atomic<_ITp>* __a, __atomic_val_t<_ITp> __i, memory_order __m) noexcept { __a->store(__i, __m); } template<typename _ITp> inline void atomic_store_explicit(volatile atomic<_ITp>* __a, __atomic_val_t<_ITp> __i, memory_order __m) noexcept { __a->store(__i, __m); } template<typename _ITp> inline _ITp atomic_load_explicit(const atomic<_ITp>* __a, memory_order __m) noexcept { return __a->load(__m); } template<typename _ITp> inline _ITp atomic_load_explicit(const volatile atomic<_ITp>* __a, memory_order __m) noexcept { return __a->load(__m); } template<typename _ITp> inline _ITp atomic_exchange_explicit(atomic<_ITp>* __a, __atomic_val_t<_ITp> __i, memory_order __m) noexcept { return __a->exchange(__i, __m); } template<typename _ITp> inline _ITp atomic_exchange_explicit(volatile atomic<_ITp>* __a, __atomic_val_t<_ITp> __i, memory_order __m) noexcept { return __a->exchange(__i, __m); } template<typename _ITp> inline bool atomic_compare_exchange_weak_explicit(atomic<_ITp>* __a, __atomic_val_t<_ITp>* __i1, __atomic_val_t<_ITp> __i2, memory_order __m1, memory_order __m2) noexcept { return __a->compare_exchange_weak(*__i1, __i2, __m1, __m2); } template<typename _ITp> inline bool atomic_compare_exchange_weak_explicit(volatile atomic<_ITp>* __a, __atomic_val_t<_ITp>* __i1, __atomic_val_t<_ITp> __i2, memory_order __m1, memory_order __m2) noexcept { return __a->compare_exchange_weak(*__i1, __i2, __m1, __m2); } template<typename _ITp> inline bool atomic_compare_exchange_strong_explicit(atomic<_ITp>* __a, __atomic_val_t<_ITp>* __i1, __atomic_val_t<_ITp> __i2, memory_order __m1, memory_order __m2) noexcept { return __a->compare_exchange_strong(*__i1, __i2, __m1, __m2); } template<typename _ITp> inline bool atomic_compare_exchange_strong_explicit(volatile atomic<_ITp>* __a, __atomic_val_t<_ITp>* __i1, __atomic_val_t<_ITp> __i2, memory_order __m1, memory_order __m2) noexcept { return __a->compare_exchange_strong(*__i1, __i2, __m1, __m2); } template<typename _ITp> inline void atomic_store(atomic<_ITp>* __a, __atomic_val_t<_ITp> __i) noexcept { atomic_store_explicit(__a, __i, memory_order_seq_cst); } template<typename _ITp> inline void atomic_store(volatile atomic<_ITp>* __a, __atomic_val_t<_ITp> __i) noexcept { atomic_store_explicit(__a, __i, memory_order_seq_cst); } template<typename _ITp> inline _ITp atomic_load(const atomic<_ITp>* __a) noexcept { return atomic_load_explicit(__a, memory_order_seq_cst); } template<typename _ITp> inline _ITp atomic_load(const volatile atomic<_ITp>* __a) noexcept { return atomic_load_explicit(__a, memory_order_seq_cst); } template<typename _ITp> inline _ITp atomic_exchange(atomic<_ITp>* __a, __atomic_val_t<_ITp> __i) noexcept { return atomic_exchange_explicit(__a, __i, memory_order_seq_cst); } template<typename _ITp> inline _ITp atomic_exchange(volatile atomic<_ITp>* __a, __atomic_val_t<_ITp> __i) noexcept { return atomic_exchange_explicit(__a, __i, memory_order_seq_cst); } template<typename _ITp> inline bool atomic_compare_exchange_weak(atomic<_ITp>* __a, __atomic_val_t<_ITp>* __i1, __atomic_val_t<_ITp> __i2) noexcept { return atomic_compare_exchange_weak_explicit(__a, __i1, __i2, memory_order_seq_cst, memory_order_seq_cst); } template<typename _ITp> inline bool atomic_compare_exchange_weak(volatile atomic<_ITp>* __a, __atomic_val_t<_ITp>* __i1, __atomic_val_t<_ITp> __i2) noexcept { return atomic_compare_exchange_weak_explicit(__a, __i1, __i2, memory_order_seq_cst, memory_order_seq_cst); } template<typename _ITp> inline bool atomic_compare_exchange_strong(atomic<_ITp>* __a, __atomic_val_t<_ITp>* __i1, __atomic_val_t<_ITp> __i2) noexcept { return atomic_compare_exchange_strong_explicit(__a, __i1, __i2, memory_order_seq_cst, memory_order_seq_cst); } template<typename _ITp> inline bool atomic_compare_exchange_strong(volatile atomic<_ITp>* __a, __atomic_val_t<_ITp>* __i1, __atomic_val_t<_ITp> __i2) noexcept { return atomic_compare_exchange_strong_explicit(__a, __i1, __i2, memory_order_seq_cst, memory_order_seq_cst); } template<typename _ITp> inline _ITp atomic_fetch_add_explicit(atomic<_ITp>* __a, __atomic_diff_t<_ITp> __i, memory_order __m) noexcept { return __a->fetch_add(__i, __m); } template<typename _ITp> inline _ITp atomic_fetch_add_explicit(volatile atomic<_ITp>* __a, __atomic_diff_t<_ITp> __i, memory_order __m) noexcept { return __a->fetch_add(__i, __m); } template<typename _ITp> inline _ITp atomic_fetch_sub_explicit(atomic<_ITp>* __a, __atomic_diff_t<_ITp> __i, memory_order __m) noexcept { return __a->fetch_sub(__i, __m); } template<typename _ITp> inline _ITp atomic_fetch_sub_explicit(volatile atomic<_ITp>* __a, __atomic_diff_t<_ITp> __i, memory_order __m) noexcept { return __a->fetch_sub(__i, __m); } template<typename _ITp> inline _ITp atomic_fetch_and_explicit(__atomic_base<_ITp>* __a, __atomic_val_t<_ITp> __i, memory_order __m) noexcept { return __a->fetch_and(__i, __m); } template<typename _ITp> inline _ITp atomic_fetch_and_explicit(volatile __atomic_base<_ITp>* __a, __atomic_val_t<_ITp> __i, memory_order __m) noexcept { return __a->fetch_and(__i, __m); } template<typename _ITp> inline _ITp atomic_fetch_or_explicit(__atomic_base<_ITp>* __a, __atomic_val_t<_ITp> __i, memory_order __m) noexcept { return __a->fetch_or(__i, __m); } template<typename _ITp> inline _ITp atomic_fetch_or_explicit(volatile __atomic_base<_ITp>* __a, __atomic_val_t<_ITp> __i, memory_order __m) noexcept { return __a->fetch_or(__i, __m); } template<typename _ITp> inline _ITp atomic_fetch_xor_explicit(__atomic_base<_ITp>* __a, __atomic_val_t<_ITp> __i, memory_order __m) noexcept { return __a->fetch_xor(__i, __m); } template<typename _ITp> inline _ITp atomic_fetch_xor_explicit(volatile __atomic_base<_ITp>* __a, __atomic_val_t<_ITp> __i, memory_order __m) noexcept { return __a->fetch_xor(__i, __m); } template<typename _ITp> inline _ITp atomic_fetch_add(atomic<_ITp>* __a, __atomic_diff_t<_ITp> __i) noexcept { return atomic_fetch_add_explicit(__a, __i, memory_order_seq_cst); } template<typename _ITp> inline _ITp atomic_fetch_add(volatile atomic<_ITp>* __a, __atomic_diff_t<_ITp> __i) noexcept { return atomic_fetch_add_explicit(__a, __i, memory_order_seq_cst); } template<typename _ITp> inline _ITp atomic_fetch_sub(atomic<_ITp>* __a, __atomic_diff_t<_ITp> __i) noexcept { return atomic_fetch_sub_explicit(__a, __i, memory_order_seq_cst); } template<typename _ITp> inline _ITp atomic_fetch_sub(volatile atomic<_ITp>* __a, __atomic_diff_t<_ITp> __i) noexcept { return atomic_fetch_sub_explicit(__a, __i, memory_order_seq_cst); } template<typename _ITp> inline _ITp atomic_fetch_and(__atomic_base<_ITp>* __a, __atomic_val_t<_ITp> __i) noexcept { return atomic_fetch_and_explicit(__a, __i, memory_order_seq_cst); } template<typename _ITp> inline _ITp atomic_fetch_and(volatile __atomic_base<_ITp>* __a, __atomic_val_t<_ITp> __i) noexcept { return atomic_fetch_and_explicit(__a, __i, memory_order_seq_cst); } template<typename _ITp> inline _ITp atomic_fetch_or(__atomic_base<_ITp>* __a, __atomic_val_t<_ITp> __i) noexcept { return atomic_fetch_or_explicit(__a, __i, memory_order_seq_cst); } template<typename _ITp> inline _ITp atomic_fetch_or(volatile __atomic_base<_ITp>* __a, __atomic_val_t<_ITp> __i) noexcept { return atomic_fetch_or_explicit(__a, __i, memory_order_seq_cst); } template<typename _ITp> inline _ITp atomic_fetch_xor(__atomic_base<_ITp>* __a, __atomic_val_t<_ITp> __i) noexcept { return atomic_fetch_xor_explicit(__a, __i, memory_order_seq_cst); } template<typename _ITp> inline _ITp atomic_fetch_xor(volatile __atomic_base<_ITp>* __a, __atomic_val_t<_ITp> __i) noexcept { return atomic_fetch_xor_explicit(__a, __i, memory_order_seq_cst); } } namespace std __attribute__ ((__visibility__ ("default"))) { template<intmax_t _Pn> struct __static_sign : integral_constant<intmax_t, (_Pn < 0) ? -1 : 1> { }; template<intmax_t _Pn> struct __static_abs : integral_constant<intmax_t, _Pn * __static_sign<_Pn>::value> { }; template<intmax_t _Pn, intmax_t _Qn> struct __static_gcd : __static_gcd<_Qn, (_Pn % _Qn)> { }; template<intmax_t _Pn> struct __static_gcd<_Pn, 0> : integral_constant<intmax_t, __static_abs<_Pn>::value> { }; template<intmax_t _Qn> struct __static_gcd<0, _Qn> : integral_constant<intmax_t, __static_abs<_Qn>::value> { }; template<intmax_t _Pn, intmax_t _Qn> struct __safe_multiply { private: static const uintmax_t __c = uintmax_t(1) << (sizeof(intmax_t) * 4); static const uintmax_t __a0 = __static_abs<_Pn>::value % __c; static const uintmax_t __a1 = __static_abs<_Pn>::value / __c; static const uintmax_t __b0 = __static_abs<_Qn>::value % __c; static const uintmax_t __b1 = __static_abs<_Qn>::value / __c; static_assert(__a1 == 0 || __b1 == 0, "overflow in multiplication"); static_assert(__a0 * __b1 + __b0 * __a1 < (__c >> 1), "overflow in multiplication"); static_assert(__b0 * __a0 <= 0x7fffffffffffffffL, "overflow in multiplication"); static_assert((__a0 * __b1 + __b0 * __a1) * __c <= 0x7fffffffffffffffL - __b0 * __a0, "overflow in multiplication"); public: static const intmax_t value = _Pn * _Qn; }; template<uintmax_t __hi1, uintmax_t __lo1, uintmax_t __hi2, uintmax_t __lo2> struct __big_less : integral_constant<bool, (__hi1 < __hi2 || (__hi1 == __hi2 && __lo1 < __lo2))> { }; template<uintmax_t __hi1, uintmax_t __lo1, uintmax_t __hi2, uintmax_t __lo2> struct __big_add { static constexpr uintmax_t __lo = __lo1 + __lo2; static constexpr uintmax_t __hi = (__hi1 + __hi2 + (__lo1 + __lo2 < __lo1)); }; template<uintmax_t __hi1, uintmax_t __lo1, uintmax_t __hi2, uintmax_t __lo2> struct __big_sub { static_assert(!__big_less<__hi1, __lo1, __hi2, __lo2>::value, "Internal library error"); static constexpr uintmax_t __lo = __lo1 - __lo2; static constexpr uintmax_t __hi = (__hi1 - __hi2 - (__lo1 < __lo2)); }; template<uintmax_t __x, uintmax_t __y> struct __big_mul { private: static constexpr uintmax_t __c = uintmax_t(1) << (sizeof(intmax_t) * 4); static constexpr uintmax_t __x0 = __x % __c; static constexpr uintmax_t __x1 = __x / __c; static constexpr uintmax_t __y0 = __y % __c; static constexpr uintmax_t __y1 = __y / __c; static constexpr uintmax_t __x0y0 = __x0 * __y0; static constexpr uintmax_t __x0y1 = __x0 * __y1; static constexpr uintmax_t __x1y0 = __x1 * __y0; static constexpr uintmax_t __x1y1 = __x1 * __y1; static constexpr uintmax_t __mix = __x0y1 + __x1y0; static constexpr uintmax_t __mix_lo = __mix * __c; static constexpr uintmax_t __mix_hi = __mix / __c + ((__mix < __x0y1) ? __c : 0); typedef __big_add<__mix_hi, __mix_lo, __x1y1, __x0y0> _Res; public: static constexpr uintmax_t __hi = _Res::__hi; static constexpr uintmax_t __lo = _Res::__lo; }; template<uintmax_t __n1, uintmax_t __n0, uintmax_t __d> struct __big_div_impl { private: static_assert(__d >= (uintmax_t(1) << (sizeof(intmax_t) * 8 - 1)), "Internal library error"); static_assert(__n1 < __d, "Internal library error"); static constexpr uintmax_t __c = uintmax_t(1) << (sizeof(intmax_t) * 4); static constexpr uintmax_t __d1 = __d / __c; static constexpr uintmax_t __d0 = __d % __c; static constexpr uintmax_t __q1x = __n1 / __d1; static constexpr uintmax_t __r1x = __n1 % __d1; static constexpr uintmax_t __m = __q1x * __d0; static constexpr uintmax_t __r1y = __r1x * __c + __n0 / __c; static constexpr uintmax_t __r1z = __r1y + __d; static constexpr uintmax_t __r1 = ((__r1y < __m) ? ((__r1z >= __d) && (__r1z < __m)) ? (__r1z + __d) : __r1z : __r1y) - __m; static constexpr uintmax_t __q1 = __q1x - ((__r1y < __m) ? ((__r1z >= __d) && (__r1z < __m)) ? 2 : 1 : 0); static constexpr uintmax_t __q0x = __r1 / __d1; static constexpr uintmax_t __r0x = __r1 % __d1; static constexpr uintmax_t __n = __q0x * __d0; static constexpr uintmax_t __r0y = __r0x * __c + __n0 % __c; static constexpr uintmax_t __r0z = __r0y + __d; static constexpr uintmax_t __r0 = ((__r0y < __n) ? ((__r0z >= __d) && (__r0z < __n)) ? (__r0z + __d) : __r0z : __r0y) - __n; static constexpr uintmax_t __q0 = __q0x - ((__r0y < __n) ? ((__r0z >= __d) && (__r0z < __n)) ? 2 : 1 : 0); public: static constexpr uintmax_t __quot = __q1 * __c + __q0; static constexpr uintmax_t __rem = __r0; private: typedef __big_mul<__quot, __d> _Prod; typedef __big_add<_Prod::__hi, _Prod::__lo, 0, __rem> _Sum; static_assert(_Sum::__hi == __n1 && _Sum::__lo == __n0, "Internal library error"); }; template<uintmax_t __n1, uintmax_t __n0, uintmax_t __d> struct __big_div { private: static_assert(__d != 0, "Internal library error"); static_assert(sizeof (uintmax_t) == sizeof (unsigned long long), "This library calls __builtin_clzll on uintmax_t, which " "is unsafe on your platform. Please complain to " "http://gcc.gnu.org/bugzilla/"); static constexpr int __shift = __builtin_clzll(__d); static constexpr int __coshift_ = sizeof(uintmax_t) * 8 - __shift; static constexpr int __coshift = (__shift != 0) ? __coshift_ : 0; static constexpr uintmax_t __c1 = uintmax_t(1) << __shift; static constexpr uintmax_t __c2 = uintmax_t(1) << __coshift; static constexpr uintmax_t __new_d = __d * __c1; static constexpr uintmax_t __new_n0 = __n0 * __c1; static constexpr uintmax_t __n1_shifted = (__n1 % __d) * __c1; static constexpr uintmax_t __n0_top = (__shift != 0) ? (__n0 / __c2) : 0; static constexpr uintmax_t __new_n1 = __n1_shifted + __n0_top; typedef __big_div_impl<__new_n1, __new_n0, __new_d> _Res; public: static constexpr uintmax_t __quot_hi = __n1 / __d; static constexpr uintmax_t __quot_lo = _Res::__quot; static constexpr uintmax_t __rem = _Res::__rem / __c1; private: typedef __big_mul<__quot_lo, __d> _P0; typedef __big_mul<__quot_hi, __d> _P1; typedef __big_add<_P0::__hi, _P0::__lo, _P1::__lo, __rem> _Sum; static_assert(_P1::__hi == 0, "Internal library error"); static_assert(_Sum::__hi >= _P0::__hi, "Internal library error"); static_assert(_Sum::__hi == __n1 && _Sum::__lo == __n0, "Internal library error"); static_assert(__rem < __d, "Internal library error"); }; template<intmax_t _Num, intmax_t _Den = 1> struct ratio { static_assert(_Den != 0, "denominator cannot be zero"); static_assert(_Num >= -0x7fffffffffffffffL && _Den >= -0x7fffffffffffffffL, "out of range"); static constexpr intmax_t num = _Num * __static_sign<_Den>::value / __static_gcd<_Num, _Den>::value; static constexpr intmax_t den = __static_abs<_Den>::value / __static_gcd<_Num, _Den>::value; typedef ratio<num, den> type; }; template<intmax_t _Num, intmax_t _Den> constexpr intmax_t ratio<_Num, _Den>::num; template<intmax_t _Num, intmax_t _Den> constexpr intmax_t ratio<_Num, _Den>::den; template<typename _R1, typename _R2> struct __ratio_multiply { private: static const intmax_t __gcd1 = __static_gcd<_R1::num, _R2::den>::value; static const intmax_t __gcd2 = __static_gcd<_R2::num, _R1::den>::value; public: typedef ratio< __safe_multiply<(_R1::num / __gcd1), (_R2::num / __gcd2)>::value, __safe_multiply<(_R1::den / __gcd2), (_R2::den / __gcd1)>::value> type; static constexpr intmax_t num = type::num; static constexpr intmax_t den = type::den; }; template<typename _R1, typename _R2> constexpr intmax_t __ratio_multiply<_R1, _R2>::num; template<typename _R1, typename _R2> constexpr intmax_t __ratio_multiply<_R1, _R2>::den; template<typename _R1, typename _R2> using ratio_multiply = typename __ratio_multiply<_R1, _R2>::type; template<typename _R1, typename _R2> struct __ratio_divide { static_assert(_R2::num != 0, "division by 0"); typedef typename __ratio_multiply< _R1, ratio<_R2::den, _R2::num>>::type type; static constexpr intmax_t num = type::num; static constexpr intmax_t den = type::den; }; template<typename _R1, typename _R2> constexpr intmax_t __ratio_divide<_R1, _R2>::num; template<typename _R1, typename _R2> constexpr intmax_t __ratio_divide<_R1, _R2>::den; template<typename _R1, typename _R2> using ratio_divide = typename __ratio_divide<_R1, _R2>::type; template<typename _R1, typename _R2> struct ratio_equal : integral_constant<bool, _R1::num == _R2::num && _R1::den == _R2::den> { }; template<typename _R1, typename _R2> struct ratio_not_equal : integral_constant<bool, !ratio_equal<_R1, _R2>::value> { }; template<typename _R1, typename _R2, typename _Left = __big_mul<_R1::num,_R2::den>, typename _Right = __big_mul<_R2::num,_R1::den> > struct __ratio_less_impl_1 : integral_constant<bool, __big_less<_Left::__hi, _Left::__lo, _Right::__hi, _Right::__lo>::value> { }; template<typename _R1, typename _R2, bool = (_R1::num == 0 || _R2::num == 0 || (__static_sign<_R1::num>::value != __static_sign<_R2::num>::value)), bool = (__static_sign<_R1::num>::value == -1 && __static_sign<_R2::num>::value == -1)> struct __ratio_less_impl : __ratio_less_impl_1<_R1, _R2>::type { }; template<typename _R1, typename _R2> struct __ratio_less_impl<_R1, _R2, true, false> : integral_constant<bool, _R1::num < _R2::num> { }; template<typename _R1, typename _R2> struct __ratio_less_impl<_R1, _R2, false, true> : __ratio_less_impl_1<ratio<-_R2::num, _R2::den>, ratio<-_R1::num, _R1::den> >::type { }; template<typename _R1, typename _R2> struct ratio_less : __ratio_less_impl<_R1, _R2>::type { }; template<typename _R1, typename _R2> struct ratio_less_equal : integral_constant<bool, !ratio_less<_R2, _R1>::value> { }; template<typename _R1, typename _R2> struct ratio_greater : integral_constant<bool, ratio_less<_R2, _R1>::value> { }; template<typename _R1, typename _R2> struct ratio_greater_equal : integral_constant<bool, !ratio_less<_R1, _R2>::value> { }; template<typename _R1, typename _R2, bool = (_R1::num >= 0), bool = (_R2::num >= 0), bool = ratio_less<ratio<__static_abs<_R1::num>::value, _R1::den>, ratio<__static_abs<_R2::num>::value, _R2::den> >::value> struct __ratio_add_impl { private: typedef typename __ratio_add_impl< ratio<-_R1::num, _R1::den>, ratio<-_R2::num, _R2::den> >::type __t; public: typedef ratio<-__t::num, __t::den> type; }; template<typename _R1, typename _R2, bool __b> struct __ratio_add_impl<_R1, _R2, true, true, __b> { private: static constexpr uintmax_t __g = __static_gcd<_R1::den, _R2::den>::value; static constexpr uintmax_t __d2 = _R2::den / __g; typedef __big_mul<_R1::den, __d2> __d; typedef __big_mul<_R1::num, _R2::den / __g> __x; typedef __big_mul<_R2::num, _R1::den / __g> __y; typedef __big_add<__x::__hi, __x::__lo, __y::__hi, __y::__lo> __n; static_assert(__n::__hi >= __x::__hi, "Internal library error"); typedef __big_div<__n::__hi, __n::__lo, __g> __ng; static constexpr uintmax_t __g2 = __static_gcd<__ng::__rem, __g>::value; typedef __big_div<__n::__hi, __n::__lo, __g2> __n_final; static_assert(__n_final::__rem == 0, "Internal library error"); static_assert(__n_final::__quot_hi == 0 && __n_final::__quot_lo <= 0x7fffffffffffffffL, "overflow in addition"); typedef __big_mul<_R1::den / __g2, __d2> __d_final; static_assert(__d_final::__hi == 0 && __d_final::__lo <= 0x7fffffffffffffffL, "overflow in addition"); public: typedef ratio<__n_final::__quot_lo, __d_final::__lo> type; }; template<typename _R1, typename _R2> struct __ratio_add_impl<_R1, _R2, false, true, true> : __ratio_add_impl<_R2, _R1> { }; template<typename _R1, typename _R2> struct __ratio_add_impl<_R1, _R2, true, false, false> { private: static constexpr uintmax_t __g = __static_gcd<_R1::den, _R2::den>::value; static constexpr uintmax_t __d2 = _R2::den / __g; typedef __big_mul<_R1::den, __d2> __d; typedef __big_mul<_R1::num, _R2::den / __g> __x; typedef __big_mul<-_R2::num, _R1::den / __g> __y; typedef __big_sub<__x::__hi, __x::__lo, __y::__hi, __y::__lo> __n; typedef __big_div<__n::__hi, __n::__lo, __g> __ng; static constexpr uintmax_t __g2 = __static_gcd<__ng::__rem, __g>::value; typedef __big_div<__n::__hi, __n::__lo, __g2> __n_final; static_assert(__n_final::__rem == 0, "Internal library error"); static_assert(__n_final::__quot_hi == 0 && __n_final::__quot_lo <= 0x7fffffffffffffffL, "overflow in addition"); typedef __big_mul<_R1::den / __g2, __d2> __d_final; static_assert(__d_final::__hi == 0 && __d_final::__lo <= 0x7fffffffffffffffL, "overflow in addition"); public: typedef ratio<__n_final::__quot_lo, __d_final::__lo> type; }; template<typename _R1, typename _R2> struct __ratio_add { typedef typename __ratio_add_impl<_R1, _R2>::type type; static constexpr intmax_t num = type::num; static constexpr intmax_t den = type::den; }; template<typename _R1, typename _R2> constexpr intmax_t __ratio_add<_R1, _R2>::num; template<typename _R1, typename _R2> constexpr intmax_t __ratio_add<_R1, _R2>::den; template<typename _R1, typename _R2> using ratio_add = typename __ratio_add<_R1, _R2>::type; template<typename _R1, typename _R2> struct __ratio_subtract { typedef typename __ratio_add< _R1, ratio<-_R2::num, _R2::den>>::type type; static constexpr intmax_t num = type::num; static constexpr intmax_t den = type::den; }; template<typename _R1, typename _R2> constexpr intmax_t __ratio_subtract<_R1, _R2>::num; template<typename _R1, typename _R2> constexpr intmax_t __ratio_subtract<_R1, _R2>::den; template<typename _R1, typename _R2> using ratio_subtract = typename __ratio_subtract<_R1, _R2>::type; typedef ratio<1, 1000000000000000000> atto; typedef ratio<1, 1000000000000000> femto; typedef ratio<1, 1000000000000> pico; typedef ratio<1, 1000000000> nano; typedef ratio<1, 1000000> micro; typedef ratio<1, 1000> milli; typedef ratio<1, 100> centi; typedef ratio<1, 10> deci; typedef ratio< 10, 1> deca; typedef ratio< 100, 1> hecto; typedef ratio< 1000, 1> kilo; typedef ratio< 1000000, 1> mega; typedef ratio< 1000000000, 1> giga; typedef ratio< 1000000000000, 1> tera; typedef ratio< 1000000000000000, 1> peta; typedef ratio< 1000000000000000000, 1> exa; } namespace std { using ::clock_t; using ::time_t; using ::tm; using ::clock; using ::difftime; using ::mktime; using ::time; using ::asctime; using ::ctime; using ::gmtime; using ::localtime; using ::strftime; } namespace std __attribute__ ((__visibility__ ("default"))) { namespace __parse_int { template<unsigned _Base, char _Dig> struct _Digit; template<unsigned _Base> struct _Digit<_Base, '0'> : integral_constant<unsigned, 0> { using __valid = true_type; }; template<unsigned _Base> struct _Digit<_Base, '1'> : integral_constant<unsigned, 1> { using __valid = true_type; }; template<unsigned _Base, unsigned _Val> struct _Digit_impl : integral_constant<unsigned, _Val> { static_assert(_Base > _Val, "invalid digit"); using __valid = true_type; }; template<unsigned _Base> struct _Digit<_Base, '2'> : _Digit_impl<_Base, 2> { }; template<unsigned _Base> struct _Digit<_Base, '3'> : _Digit_impl<_Base, 3> { }; template<unsigned _Base> struct _Digit<_Base, '4'> : _Digit_impl<_Base, 4> { }; template<unsigned _Base> struct _Digit<_Base, '5'> : _Digit_impl<_Base, 5> { }; template<unsigned _Base> struct _Digit<_Base, '6'> : _Digit_impl<_Base, 6> { }; template<unsigned _Base> struct _Digit<_Base, '7'> : _Digit_impl<_Base, 7> { }; template<unsigned _Base> struct _Digit<_Base, '8'> : _Digit_impl<_Base, 8> { }; template<unsigned _Base> struct _Digit<_Base, '9'> : _Digit_impl<_Base, 9> { }; template<unsigned _Base> struct _Digit<_Base, 'a'> : _Digit_impl<_Base, 0xa> { }; template<unsigned _Base> struct _Digit<_Base, 'A'> : _Digit_impl<_Base, 0xa> { }; template<unsigned _Base> struct _Digit<_Base, 'b'> : _Digit_impl<_Base, 0xb> { }; template<unsigned _Base> struct _Digit<_Base, 'B'> : _Digit_impl<_Base, 0xb> { }; template<unsigned _Base> struct _Digit<_Base, 'c'> : _Digit_impl<_Base, 0xc> { }; template<unsigned _Base> struct _Digit<_Base, 'C'> : _Digit_impl<_Base, 0xc> { }; template<unsigned _Base> struct _Digit<_Base, 'd'> : _Digit_impl<_Base, 0xd> { }; template<unsigned _Base> struct _Digit<_Base, 'D'> : _Digit_impl<_Base, 0xd> { }; template<unsigned _Base> struct _Digit<_Base, 'e'> : _Digit_impl<_Base, 0xe> { }; template<unsigned _Base> struct _Digit<_Base, 'E'> : _Digit_impl<_Base, 0xe> { }; template<unsigned _Base> struct _Digit<_Base, 'f'> : _Digit_impl<_Base, 0xf> { }; template<unsigned _Base> struct _Digit<_Base, 'F'> : _Digit_impl<_Base, 0xf> { }; template<unsigned _Base> struct _Digit<_Base, '\''> : integral_constant<unsigned, 0> { using __valid = false_type; }; template<unsigned long long _Val> using __ull_constant = integral_constant<unsigned long long, _Val>; template<unsigned _Base, char _Dig, char... _Digs> struct _Power_help { using __next = typename _Power_help<_Base, _Digs...>::type; using __valid_digit = typename _Digit<_Base, _Dig>::__valid; using type = __ull_constant<__next::value * (__valid_digit{} ? _Base : 1ULL)>; }; template<unsigned _Base, char _Dig> struct _Power_help<_Base, _Dig> { using __valid_digit = typename _Digit<_Base, _Dig>::__valid; using type = __ull_constant<__valid_digit::value>; }; template<unsigned _Base, char... _Digs> struct _Power : _Power_help<_Base, _Digs...>::type { }; template<unsigned _Base> struct _Power<_Base> : __ull_constant<0> { }; template<unsigned _Base, unsigned long long _Pow, char _Dig, char... _Digs> struct _Number_help { using __digit = _Digit<_Base, _Dig>; using __valid_digit = typename __digit::__valid; using __next = _Number_help<_Base, __valid_digit::value ? _Pow / _Base : _Pow, _Digs...>; using type = __ull_constant<_Pow * __digit::value + __next::type::value>; static_assert((type::value / _Pow) == __digit::value, "integer literal does not fit in unsigned long long"); }; template<unsigned _Base, unsigned long long _Pow, char _Dig, char..._Digs> struct _Number_help<_Base, _Pow, '\'', _Dig, _Digs...> : _Number_help<_Base, _Pow, _Dig, _Digs...> { }; template<unsigned _Base, char _Dig> struct _Number_help<_Base, 1ULL, _Dig> { using type = __ull_constant<_Digit<_Base, _Dig>::value>; }; template<unsigned _Base, char... _Digs> struct _Number : _Number_help<_Base, _Power<_Base, _Digs...>::value, _Digs...>::type { }; template<unsigned _Base> struct _Number<_Base> : __ull_constant<0> { }; template<char... _Digs> struct _Parse_int; template<char... _Digs> struct _Parse_int<'0', 'b', _Digs...> : _Number<2U, _Digs...>::type { }; template<char... _Digs> struct _Parse_int<'0', 'B', _Digs...> : _Number<2U, _Digs...>::type { }; template<char... _Digs> struct _Parse_int<'0', 'x', _Digs...> : _Number<16U, _Digs...>::type { }; template<char... _Digs> struct _Parse_int<'0', 'X', _Digs...> : _Number<16U, _Digs...>::type { }; template<char... _Digs> struct _Parse_int<'0', _Digs...> : _Number<8U, _Digs...>::type { }; template<char... _Digs> struct _Parse_int : _Number<10U, _Digs...>::type { }; } namespace __select_int { template<unsigned long long _Val, typename... _Ints> struct _Select_int_base; template<unsigned long long _Val, typename _IntType, typename... _Ints> struct _Select_int_base<_Val, _IntType, _Ints...> : conditional_t<(_Val <= __detail::__int_limits<_IntType>::max()), integral_constant<_IntType, _Val>, _Select_int_base<_Val, _Ints...>> { }; template<unsigned long long _Val> struct _Select_int_base<_Val> { }; template<char... _Digs> using _Select_int = typename _Select_int_base< __parse_int::_Parse_int<_Digs...>::value, unsigned char, unsigned short, unsigned int, unsigned long, unsigned long long >::type; } } namespace std __attribute__ ((__visibility__ ("default"))) { namespace chrono { template<typename _Rep, typename _Period = ratio<1>> struct duration; template<typename _Clock, typename _Dur = typename _Clock::duration> struct time_point; } template<typename _CT, typename _Period1, typename _Period2, typename = void> struct __duration_common_type { }; template<typename _CT, typename _Period1, typename _Period2> struct __duration_common_type<_CT, _Period1, _Period2, __void_t<typename _CT::type>> { private: using __gcd_num = __static_gcd<_Period1::num, _Period2::num>; using __gcd_den = __static_gcd<_Period1::den, _Period2::den>; using __cr = typename _CT::type; using __r = ratio<__gcd_num::value, (_Period1::den / __gcd_den::value) * _Period2::den>; public: using type = chrono::duration<__cr, __r>; }; template<typename _Period1, typename _Period2> struct __duration_common_type<__failure_type, _Period1, _Period2> { typedef __failure_type type; }; template<typename _Rep1, typename _Period1, typename _Rep2, typename _Period2> struct common_type<chrono::duration<_Rep1, _Period1>, chrono::duration<_Rep2, _Period2>> : __duration_common_type<common_type<_Rep1, _Rep2>, _Period1, _Period2> { }; template<typename _CT, typename _Clock, typename = void> struct __timepoint_common_type { }; template<typename _CT, typename _Clock> struct __timepoint_common_type<_CT, _Clock, __void_t<typename _CT::type>> { using type = chrono::time_point<_Clock, typename _CT::type>; }; template<typename _Clock, typename _Duration1, typename _Duration2> struct common_type<chrono::time_point<_Clock, _Duration1>, chrono::time_point<_Clock, _Duration2>> : __timepoint_common_type<common_type<_Duration1, _Duration2>, _Clock> { }; namespace chrono { template<typename _ToDur, typename _CF, typename _CR, bool _NumIsOne = false, bool _DenIsOne = false> struct __duration_cast_impl { template<typename _Rep, typename _Period> static constexpr _ToDur __cast(const duration<_Rep, _Period>& __d) { typedef typename _ToDur::rep __to_rep; return _ToDur(static_cast<__to_rep>(static_cast<_CR>(__d.count()) * static_cast<_CR>(_CF::num) / static_cast<_CR>(_CF::den))); } }; template<typename _ToDur, typename _CF, typename _CR> struct __duration_cast_impl<_ToDur, _CF, _CR, true, true> { template<typename _Rep, typename _Period> static constexpr _ToDur __cast(const duration<_Rep, _Period>& __d) { typedef typename _ToDur::rep __to_rep; return _ToDur(static_cast<__to_rep>(__d.count())); } }; template<typename _ToDur, typename _CF, typename _CR> struct __duration_cast_impl<_ToDur, _CF, _CR, true, false> { template<typename _Rep, typename _Period> static constexpr _ToDur __cast(const duration<_Rep, _Period>& __d) { typedef typename _ToDur::rep __to_rep; return _ToDur(static_cast<__to_rep>( static_cast<_CR>(__d.count()) / static_cast<_CR>(_CF::den))); } }; template<typename _ToDur, typename _CF, typename _CR> struct __duration_cast_impl<_ToDur, _CF, _CR, false, true> { template<typename _Rep, typename _Period> static constexpr _ToDur __cast(const duration<_Rep, _Period>& __d) { typedef typename _ToDur::rep __to_rep; return _ToDur(static_cast<__to_rep>( static_cast<_CR>(__d.count()) * static_cast<_CR>(_CF::num))); } }; template<typename _Tp> struct __is_duration : std::false_type { }; template<typename _Rep, typename _Period> struct __is_duration<duration<_Rep, _Period>> : std::true_type { }; template<typename _Tp> using __enable_if_is_duration = typename enable_if<__is_duration<_Tp>::value, _Tp>::type; template<typename _Tp> using __disable_if_is_duration = typename enable_if<!__is_duration<_Tp>::value, _Tp>::type; template<typename _ToDur, typename _Rep, typename _Period> constexpr __enable_if_is_duration<_ToDur> duration_cast(const duration<_Rep, _Period>& __d) { typedef typename _ToDur::period __to_period; typedef typename _ToDur::rep __to_rep; typedef ratio_divide<_Period, __to_period> __cf; typedef typename common_type<__to_rep, _Rep, intmax_t>::type __cr; typedef __duration_cast_impl<_ToDur, __cf, __cr, __cf::num == 1, __cf::den == 1> __dc; return __dc::__cast(__d); } template<typename _Rep> struct treat_as_floating_point : is_floating_point<_Rep> { }; template<typename _Rep> struct duration_values { static constexpr _Rep zero() noexcept { return _Rep(0); } static constexpr _Rep max() noexcept { return numeric_limits<_Rep>::max(); } static constexpr _Rep min() noexcept { return numeric_limits<_Rep>::lowest(); } }; template<typename _Tp> struct __is_ratio : std::false_type { }; template<intmax_t _Num, intmax_t _Den> struct __is_ratio<ratio<_Num, _Den>> : std::true_type { }; template<typename _Rep, typename _Period> struct duration { private: template<typename _Rep2> using __is_float = treat_as_floating_point<_Rep2>; template<typename _Period2> using __is_harmonic = __bool_constant<ratio_divide<_Period2, _Period>::den == 1>; public: typedef _Rep rep; typedef _Period period; static_assert(!__is_duration<_Rep>::value, "rep cannot be a duration"); static_assert(__is_ratio<_Period>::value, "period must be a specialization of ratio"); static_assert(_Period::num > 0, "period must be positive"); constexpr duration() = default; duration(const duration&) = default; template<typename _Rep2, typename = _Require< is_convertible<const _Rep2&, rep>, __or_<__is_float<rep>, __not_<__is_float<_Rep2>>>>> constexpr explicit duration(const _Rep2& __rep) : __r(static_cast<rep>(__rep)) { } template<typename _Rep2, typename _Period2, typename = _Require< __or_<__is_float<rep>, __and_<__is_harmonic<_Period2>, __not_<__is_float<_Rep2>>>>>> constexpr duration(const duration<_Rep2, _Period2>& __d) : __r(duration_cast<duration>(__d).count()) { } ~duration() = default; duration& operator=(const duration&) = default; constexpr rep count() const { return __r; } constexpr duration operator+() const { return *this; } constexpr duration operator-() const { return duration(-__r); } duration& operator++() { ++__r; return *this; } duration operator++(int) { return duration(__r++); } duration& operator--() { --__r; return *this; } duration operator--(int) { return duration(__r--); } duration& operator+=(const duration& __d) { __r += __d.count(); return *this; } duration& operator-=(const duration& __d) { __r -= __d.count(); return *this; } duration& operator*=(const rep& __rhs) { __r *= __rhs; return *this; } duration& operator/=(const rep& __rhs) { __r /= __rhs; return *this; } template<typename _Rep2 = rep> typename enable_if<!treat_as_floating_point<_Rep2>::value, duration&>::type operator%=(const rep& __rhs) { __r %= __rhs; return *this; } template<typename _Rep2 = rep> typename enable_if<!treat_as_floating_point<_Rep2>::value, duration&>::type operator%=(const duration& __d) { __r %= __d.count(); return *this; } static constexpr duration zero() noexcept { return duration(duration_values<rep>::zero()); } static constexpr duration min() noexcept { return duration(duration_values<rep>::min()); } static constexpr duration max() noexcept { return duration(duration_values<rep>::max()); } private: rep __r; }; template<typename _Rep1, typename _Period1, typename _Rep2, typename _Period2> constexpr typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2>>::type operator+(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) { typedef duration<_Rep1, _Period1> __dur1; typedef duration<_Rep2, _Period2> __dur2; typedef typename common_type<__dur1,__dur2>::type __cd; return __cd(__cd(__lhs).count() + __cd(__rhs).count()); } template<typename _Rep1, typename _Period1, typename _Rep2, typename _Period2> constexpr typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2>>::type operator-(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) { typedef duration<_Rep1, _Period1> __dur1; typedef duration<_Rep2, _Period2> __dur2; typedef typename common_type<__dur1,__dur2>::type __cd; return __cd(__cd(__lhs).count() - __cd(__rhs).count()); } template<typename _Rep1, typename _Rep2, typename _CRep = typename common_type<_Rep1, _Rep2>::type> using __common_rep_t = typename enable_if<is_convertible<const _Rep2&, _CRep>::value, _CRep>::type; template<typename _Rep1, typename _Period, typename _Rep2> constexpr duration<__common_rep_t<_Rep1, _Rep2>, _Period> operator*(const duration<_Rep1, _Period>& __d, const _Rep2& __s) { typedef duration<typename common_type<_Rep1, _Rep2>::type, _Period> __cd; return __cd(__cd(__d).count() * __s); } template<typename _Rep1, typename _Rep2, typename _Period> constexpr duration<__common_rep_t<_Rep2, _Rep1>, _Period> operator*(const _Rep1& __s, const duration<_Rep2, _Period>& __d) { return __d * __s; } template<typename _Rep1, typename _Period, typename _Rep2> constexpr duration<__common_rep_t<_Rep1, __disable_if_is_duration<_Rep2>>, _Period> operator/(const duration<_Rep1, _Period>& __d, const _Rep2& __s) { typedef duration<typename common_type<_Rep1, _Rep2>::type, _Period> __cd; return __cd(__cd(__d).count() / __s); } template<typename _Rep1, typename _Period1, typename _Rep2, typename _Period2> constexpr typename common_type<_Rep1, _Rep2>::type operator/(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) { typedef duration<_Rep1, _Period1> __dur1; typedef duration<_Rep2, _Period2> __dur2; typedef typename common_type<__dur1,__dur2>::type __cd; return __cd(__lhs).count() / __cd(__rhs).count(); } template<typename _Rep1, typename _Period, typename _Rep2> constexpr duration<__common_rep_t<_Rep1, __disable_if_is_duration<_Rep2>>, _Period> operator%(const duration<_Rep1, _Period>& __d, const _Rep2& __s) { typedef duration<typename common_type<_Rep1, _Rep2>::type, _Period> __cd; return __cd(__cd(__d).count() % __s); } template<typename _Rep1, typename _Period1, typename _Rep2, typename _Period2> constexpr typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2>>::type operator%(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) { typedef duration<_Rep1, _Period1> __dur1; typedef duration<_Rep2, _Period2> __dur2; typedef typename common_type<__dur1,__dur2>::type __cd; return __cd(__cd(__lhs).count() % __cd(__rhs).count()); } template<typename _Rep1, typename _Period1, typename _Rep2, typename _Period2> constexpr bool operator==(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) { typedef duration<_Rep1, _Period1> __dur1; typedef duration<_Rep2, _Period2> __dur2; typedef typename common_type<__dur1,__dur2>::type __ct; return __ct(__lhs).count() == __ct(__rhs).count(); } template<typename _Rep1, typename _Period1, typename _Rep2, typename _Period2> constexpr bool operator<(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) { typedef duration<_Rep1, _Period1> __dur1; typedef duration<_Rep2, _Period2> __dur2; typedef typename common_type<__dur1,__dur2>::type __ct; return __ct(__lhs).count() < __ct(__rhs).count(); } template<typename _Rep1, typename _Period1, typename _Rep2, typename _Period2> constexpr bool operator!=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) { return !(__lhs == __rhs); } template<typename _Rep1, typename _Period1, typename _Rep2, typename _Period2> constexpr bool operator<=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) { return !(__rhs < __lhs); } template<typename _Rep1, typename _Period1, typename _Rep2, typename _Period2> constexpr bool operator>(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) { return __rhs < __lhs; } template<typename _Rep1, typename _Period1, typename _Rep2, typename _Period2> constexpr bool operator>=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) { return !(__lhs < __rhs); } using nanoseconds = duration<int64_t, nano>; using microseconds = duration<int64_t, micro>; using milliseconds = duration<int64_t, milli>; using seconds = duration<int64_t>; using minutes = duration<int64_t, ratio< 60>>; using hours = duration<int64_t, ratio<3600>>; template<typename _Clock, typename _Dur> struct time_point { static_assert(__is_duration<_Dur>::value, "duration must be a specialization of std::chrono::duration"); typedef _Clock clock; typedef _Dur duration; typedef typename duration::rep rep; typedef typename duration::period period; constexpr time_point() : __d(duration::zero()) { } constexpr explicit time_point(const duration& __dur) : __d(__dur) { } template<typename _Dur2, typename = _Require<is_convertible<_Dur2, _Dur>>> constexpr time_point(const time_point<clock, _Dur2>& __t) : __d(__t.time_since_epoch()) { } constexpr duration time_since_epoch() const { return __d; } time_point& operator+=(const duration& __dur) { __d += __dur; return *this; } time_point& operator-=(const duration& __dur) { __d -= __dur; return *this; } static constexpr time_point min() noexcept { return time_point(duration::min()); } static constexpr time_point max() noexcept { return time_point(duration::max()); } private: duration __d; }; template<typename _ToDur, typename _Clock, typename _Dur> constexpr typename enable_if<__is_duration<_ToDur>::value, time_point<_Clock, _ToDur>>::type time_point_cast(const time_point<_Clock, _Dur>& __t) { typedef time_point<_Clock, _ToDur> __time_point; return __time_point(duration_cast<_ToDur>(__t.time_since_epoch())); } template<typename _Clock, typename _Dur1, typename _Rep2, typename _Period2> constexpr time_point<_Clock, typename common_type<_Dur1, duration<_Rep2, _Period2>>::type> operator+(const time_point<_Clock, _Dur1>& __lhs, const duration<_Rep2, _Period2>& __rhs) { typedef duration<_Rep2, _Period2> __dur2; typedef typename common_type<_Dur1,__dur2>::type __ct; typedef time_point<_Clock, __ct> __time_point; return __time_point(__lhs.time_since_epoch() + __rhs); } template<typename _Rep1, typename _Period1, typename _Clock, typename _Dur2> constexpr time_point<_Clock, typename common_type<duration<_Rep1, _Period1>, _Dur2>::type> operator+(const duration<_Rep1, _Period1>& __lhs, const time_point<_Clock, _Dur2>& __rhs) { typedef duration<_Rep1, _Period1> __dur1; typedef typename common_type<__dur1,_Dur2>::type __ct; typedef time_point<_Clock, __ct> __time_point; return __time_point(__rhs.time_since_epoch() + __lhs); } template<typename _Clock, typename _Dur1, typename _Rep2, typename _Period2> constexpr time_point<_Clock, typename common_type<_Dur1, duration<_Rep2, _Period2>>::type> operator-(const time_point<_Clock, _Dur1>& __lhs, const duration<_Rep2, _Period2>& __rhs) { typedef duration<_Rep2, _Period2> __dur2; typedef typename common_type<_Dur1,__dur2>::type __ct; typedef time_point<_Clock, __ct> __time_point; return __time_point(__lhs.time_since_epoch() -__rhs); } template<typename _Clock, typename _Dur1, typename _Dur2> constexpr typename common_type<_Dur1, _Dur2>::type operator-(const time_point<_Clock, _Dur1>& __lhs, const time_point<_Clock, _Dur2>& __rhs) { return __lhs.time_since_epoch() - __rhs.time_since_epoch(); } template<typename _Clock, typename _Dur1, typename _Dur2> constexpr bool operator==(const time_point<_Clock, _Dur1>& __lhs, const time_point<_Clock, _Dur2>& __rhs) { return __lhs.time_since_epoch() == __rhs.time_since_epoch(); } template<typename _Clock, typename _Dur1, typename _Dur2> constexpr bool operator!=(const time_point<_Clock, _Dur1>& __lhs, const time_point<_Clock, _Dur2>& __rhs) { return !(__lhs == __rhs); } template<typename _Clock, typename _Dur1, typename _Dur2> constexpr bool operator<(const time_point<_Clock, _Dur1>& __lhs, const time_point<_Clock, _Dur2>& __rhs) { return __lhs.time_since_epoch() < __rhs.time_since_epoch(); } template<typename _Clock, typename _Dur1, typename _Dur2> constexpr bool operator<=(const time_point<_Clock, _Dur1>& __lhs, const time_point<_Clock, _Dur2>& __rhs) { return !(__rhs < __lhs); } template<typename _Clock, typename _Dur1, typename _Dur2> constexpr bool operator>(const time_point<_Clock, _Dur1>& __lhs, const time_point<_Clock, _Dur2>& __rhs) { return __rhs < __lhs; } template<typename _Clock, typename _Dur1, typename _Dur2> constexpr bool operator>=(const time_point<_Clock, _Dur1>& __lhs, const time_point<_Clock, _Dur2>& __rhs) { return !(__lhs < __rhs); } inline namespace _V2 { struct system_clock { typedef chrono::nanoseconds duration; typedef duration::rep rep; typedef duration::period period; typedef chrono::time_point<system_clock, duration> time_point; static_assert(system_clock::duration::min() < system_clock::duration::zero(), "a clock's minimum duration cannot be less than its epoch"); static constexpr bool is_steady = false; static time_point now() noexcept; static std::time_t to_time_t(const time_point& __t) noexcept { return std::time_t(duration_cast<chrono::seconds> (__t.time_since_epoch()).count()); } static time_point from_time_t(std::time_t __t) noexcept { typedef chrono::time_point<system_clock, seconds> __from; return time_point_cast<system_clock::duration> (__from(chrono::seconds(__t))); } }; struct steady_clock { typedef chrono::nanoseconds duration; typedef duration::rep rep; typedef duration::period period; typedef chrono::time_point<steady_clock, duration> time_point; static constexpr bool is_steady = true; static time_point now() noexcept; }; using high_resolution_clock = system_clock; } } inline namespace literals { inline namespace chrono_literals { template<typename _Dur, char... _Digits> constexpr _Dur __check_overflow() { using _Val = __parse_int::_Parse_int<_Digits...>; constexpr typename _Dur::rep __repval = _Val::value; static_assert(__repval >= 0 && __repval == _Val::value, "literal value cannot be represented by duration type"); return _Dur(__repval); } constexpr chrono::duration<long double, ratio<3600,1>> operator""h(long double __hours) { return chrono::duration<long double, ratio<3600,1>>{__hours}; } template <char... _Digits> constexpr chrono::hours operator""h() { return __check_overflow<chrono::hours, _Digits...>(); } constexpr chrono::duration<long double, ratio<60,1>> operator""min(long double __mins) { return chrono::duration<long double, ratio<60,1>>{__mins}; } template <char... _Digits> constexpr chrono::minutes operator""min() { return __check_overflow<chrono::minutes, _Digits...>(); } constexpr chrono::duration<long double> operator""s(long double __secs) { return chrono::duration<long double>{__secs}; } template <char... _Digits> constexpr chrono::seconds operator""s() { return __check_overflow<chrono::seconds, _Digits...>(); } constexpr chrono::duration<long double, milli> operator""ms(long double __msecs) { return chrono::duration<long double, milli>{__msecs}; } template <char... _Digits> constexpr chrono::milliseconds operator""ms() { return __check_overflow<chrono::milliseconds, _Digits...>(); } constexpr chrono::duration<long double, micro> operator""us(long double __usecs) { return chrono::duration<long double, micro>{__usecs}; } template <char... _Digits> constexpr chrono::microseconds operator""us() { return __check_overflow<chrono::microseconds, _Digits...>(); } constexpr chrono::duration<long double, nano> operator""ns(long double __nsecs) { return chrono::duration<long double, nano>{__nsecs}; } template <char... _Digits> constexpr chrono::nanoseconds operator""ns() { return __check_overflow<chrono::nanoseconds, _Digits...>(); } } } namespace chrono { using namespace literals::chrono_literals; } } namespace std __attribute__ ((__visibility__ ("default"))) { enum class errc { address_family_not_supported = 97, address_in_use = 98, address_not_available = 99, already_connected = 106, argument_list_too_long = 7, argument_out_of_domain = 33, bad_address = 14, bad_file_descriptor = 9, bad_message = 74, broken_pipe = 32, connection_aborted = 103, connection_already_in_progress = 114, connection_refused = 111, connection_reset = 104, cross_device_link = 18, destination_address_required = 89, device_or_resource_busy = 16, directory_not_empty = 39, executable_format_error = 8, file_exists = 17, file_too_large = 27, filename_too_long = 36, function_not_supported = 38, host_unreachable = 113, identifier_removed = 43, illegal_byte_sequence = 84, inappropriate_io_control_operation = 25, interrupted = 4, invalid_argument = 22, invalid_seek = 29, io_error = 5, is_a_directory = 21, message_size = 90, network_down = 100, network_reset = 102, network_unreachable = 101, no_buffer_space = 105, no_child_process = 10, no_link = 67, no_lock_available = 37, no_message_available = 61, no_message = 42, no_protocol_option = 92, no_space_on_device = 28, no_stream_resources = 63, no_such_device_or_address = 6, no_such_device = 19, no_such_file_or_directory = 2, no_such_process = 3, not_a_directory = 20, not_a_socket = 88, not_a_stream = 60, not_connected = 107, not_enough_memory = 12, not_supported = 95, operation_canceled = 125, operation_in_progress = 115, operation_not_permitted = 1, operation_not_supported = 95, operation_would_block = 11, owner_dead = 130, permission_denied = 13, protocol_error = 71, protocol_not_supported = 93, read_only_file_system = 30, resource_deadlock_would_occur = 35, resource_unavailable_try_again = 11, result_out_of_range = 34, state_not_recoverable = 131, stream_timeout = 62, text_file_busy = 26, timed_out = 110, too_many_files_open_in_system = 23, too_many_files_open = 24, too_many_links = 31, too_many_symbolic_link_levels = 40, value_too_large = 75, wrong_protocol_type = 91 }; } namespace std __attribute__ ((__visibility__ ("default"))) { struct __cow_string { union { const char* _M_p; char _M_bytes[sizeof(const char*)]; }; __cow_string(); __cow_string(const std::string&); __cow_string(const char*, size_t); __cow_string(const __cow_string&) noexcept; __cow_string& operator=(const __cow_string&) noexcept; ~__cow_string(); __cow_string(__cow_string&&) noexcept; __cow_string& operator=(__cow_string&&) noexcept; }; typedef basic_string<char> __sso_string; class logic_error : public exception { __cow_string _M_msg; public: explicit logic_error(const string& __arg) ; explicit logic_error(const char*) ; logic_error(logic_error&&) noexcept; logic_error& operator=(logic_error&&) noexcept; logic_error(const logic_error&) noexcept; logic_error& operator=(const logic_error&) noexcept; virtual ~logic_error() noexcept; virtual const char* what() const noexcept; }; class domain_error : public logic_error { public: explicit domain_error(const string& __arg) ; explicit domain_error(const char*) ; domain_error(const domain_error&) = default; domain_error& operator=(const domain_error&) = default; domain_error(domain_error&&) = default; domain_error& operator=(domain_error&&) = default; virtual ~domain_error() noexcept; }; class invalid_argument : public logic_error { public: explicit invalid_argument(const string& __arg) ; explicit invalid_argument(const char*) ; invalid_argument(const invalid_argument&) = default; invalid_argument& operator=(const invalid_argument&) = default; invalid_argument(invalid_argument&&) = default; invalid_argument& operator=(invalid_argument&&) = default; virtual ~invalid_argument() noexcept; }; class length_error : public logic_error { public: explicit length_error(const string& __arg) ; explicit length_error(const char*) ; length_error(const length_error&) = default; length_error& operator=(const length_error&) = default; length_error(length_error&&) = default; length_error& operator=(length_error&&) = default; virtual ~length_error() noexcept; }; class out_of_range : public logic_error { public: explicit out_of_range(const string& __arg) ; explicit out_of_range(const char*) ; out_of_range(const out_of_range&) = default; out_of_range& operator=(const out_of_range&) = default; out_of_range(out_of_range&&) = default; out_of_range& operator=(out_of_range&&) = default; virtual ~out_of_range() noexcept; }; class runtime_error : public exception { __cow_string _M_msg; public: explicit runtime_error(const string& __arg) ; explicit runtime_error(const char*) ; runtime_error(runtime_error&&) noexcept; runtime_error& operator=(runtime_error&&) noexcept; runtime_error(const runtime_error&) noexcept; runtime_error& operator=(const runtime_error&) noexcept; virtual ~runtime_error() noexcept; virtual const char* what() const noexcept; }; class range_error : public runtime_error { public: explicit range_error(const string& __arg) ; explicit range_error(const char*) ; range_error(const range_error&) = default; range_error& operator=(const range_error&) = default; range_error(range_error&&) = default; range_error& operator=(range_error&&) = default; virtual ~range_error() noexcept; }; class overflow_error : public runtime_error { public: explicit overflow_error(const string& __arg) ; explicit overflow_error(const char*) ; overflow_error(const overflow_error&) = default; overflow_error& operator=(const overflow_error&) = default; overflow_error(overflow_error&&) = default; overflow_error& operator=(overflow_error&&) = default; virtual ~overflow_error() noexcept; }; class underflow_error : public runtime_error { public: explicit underflow_error(const string& __arg) ; explicit underflow_error(const char*) ; underflow_error(const underflow_error&) = default; underflow_error& operator=(const underflow_error&) = default; underflow_error(underflow_error&&) = default; underflow_error& operator=(underflow_error&&) = default; virtual ~underflow_error() noexcept; }; } namespace std __attribute__ ((__visibility__ ("default"))) { class error_code; class error_condition; class system_error; template<typename _Tp> struct is_error_code_enum : public false_type { }; template<typename _Tp> struct is_error_condition_enum : public false_type { }; template<> struct is_error_condition_enum<errc> : public true_type { }; inline namespace _V2 { class error_category { public: constexpr error_category() noexcept = default; virtual ~error_category(); error_category(const error_category&) = delete; error_category& operator=(const error_category&) = delete; virtual const char* name() const noexcept = 0; private: __attribute ((__abi_tag__ ("cxx11"))) virtual __cow_string _M_message(int) const; public: __attribute ((__abi_tag__ ("cxx11"))) virtual string message(int) const = 0; public: virtual error_condition default_error_condition(int __i) const noexcept; virtual bool equivalent(int __i, const error_condition& __cond) const noexcept; virtual bool equivalent(const error_code& __code, int __i) const noexcept; bool operator==(const error_category& __other) const noexcept { return this == &__other; } bool operator!=(const error_category& __other) const noexcept { return this != &__other; } bool operator<(const error_category& __other) const noexcept { return less<const error_category*>()(this, &__other); } }; __attribute__ ((__const__)) const error_category& generic_category() noexcept; __attribute__ ((__const__)) const error_category& system_category() noexcept; } error_code make_error_code(errc) noexcept; struct error_code { error_code() noexcept : _M_value(0), _M_cat(&system_category()) { } error_code(int __v, const error_category& __cat) noexcept : _M_value(__v), _M_cat(&__cat) { } template<typename _ErrorCodeEnum, typename = typename enable_if<is_error_code_enum<_ErrorCodeEnum>::value>::type> error_code(_ErrorCodeEnum __e) noexcept { *this = make_error_code(__e); } void assign(int __v, const error_category& __cat) noexcept { _M_value = __v; _M_cat = &__cat; } void clear() noexcept { assign(0, system_category()); } template<typename _ErrorCodeEnum> typename enable_if<is_error_code_enum<_ErrorCodeEnum>::value, error_code&>::type operator=(_ErrorCodeEnum __e) noexcept { return *this = make_error_code(__e); } int value() const noexcept { return _M_value; } const error_category& category() const noexcept { return *_M_cat; } error_condition default_error_condition() const noexcept; __attribute ((__abi_tag__ ("cxx11"))) string message() const { return category().message(value()); } explicit operator bool() const noexcept { return _M_value != 0; } private: int _M_value; const error_category* _M_cat; }; inline error_code make_error_code(errc __e) noexcept { return error_code(static_cast<int>(__e), generic_category()); } inline bool operator<(const error_code& __lhs, const error_code& __rhs) noexcept { return (__lhs.category() < __rhs.category() || (__lhs.category() == __rhs.category() && __lhs.value() < __rhs.value())); } template<typename _CharT, typename _Traits> basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const error_code& __e) { return (__os << __e.category().name() << ':' << __e.value()); } error_condition make_error_condition(errc) noexcept; struct error_condition { error_condition() noexcept : _M_value(0), _M_cat(&generic_category()) { } error_condition(int __v, const error_category& __cat) noexcept : _M_value(__v), _M_cat(&__cat) { } template<typename _ErrorConditionEnum, typename = typename enable_if<is_error_condition_enum<_ErrorConditionEnum>::value>::type> error_condition(_ErrorConditionEnum __e) noexcept { *this = make_error_condition(__e); } void assign(int __v, const error_category& __cat) noexcept { _M_value = __v; _M_cat = &__cat; } template<typename _ErrorConditionEnum> typename enable_if<is_error_condition_enum <_ErrorConditionEnum>::value, error_condition&>::type operator=(_ErrorConditionEnum __e) noexcept { return *this = make_error_condition(__e); } void clear() noexcept { assign(0, generic_category()); } int value() const noexcept { return _M_value; } const error_category& category() const noexcept { return *_M_cat; } __attribute ((__abi_tag__ ("cxx11"))) string message() const { return category().message(value()); } explicit operator bool() const noexcept { return _M_value != 0; } private: int _M_value; const error_category* _M_cat; }; inline error_condition make_error_condition(errc __e) noexcept { return error_condition(static_cast<int>(__e), generic_category()); } inline bool operator==(const error_code& __lhs, const error_code& __rhs) noexcept { return (__lhs.category() == __rhs.category() && __lhs.value() == __rhs.value()); } inline bool operator==(const error_code& __lhs, const error_condition& __rhs) noexcept { return (__lhs.category().equivalent(__lhs.value(), __rhs) || __rhs.category().equivalent(__lhs, __rhs.value())); } inline bool operator==(const error_condition& __lhs, const error_condition& __rhs) noexcept { return (__lhs.category() == __rhs.category() && __lhs.value() == __rhs.value()); } inline bool operator<(const error_condition& __lhs, const error_condition& __rhs) noexcept { return (__lhs.category() < __rhs.category() || (__lhs.category() == __rhs.category() && __lhs.value() < __rhs.value())); } inline bool operator==(const error_condition& __lhs, const error_code& __rhs) noexcept { return (__rhs.category().equivalent(__rhs.value(), __lhs) || __lhs.category().equivalent(__rhs, __lhs.value())); } inline bool operator!=(const error_code& __lhs, const error_code& __rhs) noexcept { return !(__lhs == __rhs); } inline bool operator!=(const error_code& __lhs, const error_condition& __rhs) noexcept { return !(__lhs == __rhs); } inline bool operator!=(const error_condition& __lhs, const error_code& __rhs) noexcept { return !(__lhs == __rhs); } inline bool operator!=(const error_condition& __lhs, const error_condition& __rhs) noexcept { return !(__lhs == __rhs); } class system_error : public std::runtime_error { private: error_code _M_code; public: system_error(error_code __ec = error_code()) : runtime_error(__ec.message()), _M_code(__ec) { } system_error(error_code __ec, const string& __what) : runtime_error(__what + ": " + __ec.message()), _M_code(__ec) { } system_error(error_code __ec, const char* __what) : runtime_error(__what + (": " + __ec.message())), _M_code(__ec) { } system_error(int __v, const error_category& __ecat, const char* __what) : system_error(error_code(__v, __ecat), __what) { } system_error(int __v, const error_category& __ecat) : runtime_error(error_code(__v, __ecat).message()), _M_code(__v, __ecat) { } system_error(int __v, const error_category& __ecat, const string& __what) : runtime_error(__what + ": " + error_code(__v, __ecat).message()), _M_code(__v, __ecat) { } system_error (const system_error &) = default; system_error &operator= (const system_error &) = default; virtual ~system_error() noexcept; const error_code& code() const noexcept { return _M_code; } }; } namespace std __attribute__ ((__visibility__ ("default"))) { template<> struct hash<error_code> : public __hash_base<size_t, error_code> { size_t operator()(const error_code& __e) const noexcept { const size_t __tmp = std::_Hash_impl::hash(__e.value()); return std::_Hash_impl::__hash_combine(&__e.category(), __tmp); } }; } namespace std __attribute__ ((__visibility__ ("default"))) { class __mutex_base { protected: typedef __gthread_mutex_t __native_type; __native_type _M_mutex = { { 0, 0, 0, 0, PTHREAD_MUTEX_TIMED_NP, 0, 0, { 0, 0 } } }; constexpr __mutex_base() noexcept = default; __mutex_base(const __mutex_base&) = delete; __mutex_base& operator=(const __mutex_base&) = delete; }; class mutex : private __mutex_base { public: typedef __native_type* native_handle_type; constexpr mutex() noexcept = default; ~mutex() = default; mutex(const mutex&) = delete; mutex& operator=(const mutex&) = delete; void lock() { int __e = __gthread_mutex_lock(&_M_mutex); if (__e) __throw_system_error(__e); } bool try_lock() noexcept { return !__gthread_mutex_trylock(&_M_mutex); } void unlock() { __gthread_mutex_unlock(&_M_mutex); } native_handle_type native_handle() noexcept { return &_M_mutex; } }; struct defer_lock_t { explicit defer_lock_t() = default; }; struct try_to_lock_t { explicit try_to_lock_t() = default; }; struct adopt_lock_t { explicit adopt_lock_t() = default; }; constexpr defer_lock_t defer_lock { }; constexpr try_to_lock_t try_to_lock { }; constexpr adopt_lock_t adopt_lock { }; template<typename _Mutex> class lock_guard { public: typedef _Mutex mutex_type; explicit lock_guard(mutex_type& __m) : _M_device(__m) { _M_device.lock(); } lock_guard(mutex_type& __m, adopt_lock_t) noexcept : _M_device(__m) { } ~lock_guard() { _M_device.unlock(); } lock_guard(const lock_guard&) = delete; lock_guard& operator=(const lock_guard&) = delete; private: mutex_type& _M_device; }; } namespace std __attribute__ ((__visibility__ ("default"))) { template<typename _Mutex> class unique_lock { public: typedef _Mutex mutex_type; unique_lock() noexcept : _M_device(0), _M_owns(false) { } explicit unique_lock(mutex_type& __m) : _M_device(std::__addressof(__m)), _M_owns(false) { lock(); _M_owns = true; } unique_lock(mutex_type& __m, defer_lock_t) noexcept : _M_device(std::__addressof(__m)), _M_owns(false) { } unique_lock(mutex_type& __m, try_to_lock_t) : _M_device(std::__addressof(__m)), _M_owns(_M_device->try_lock()) { } unique_lock(mutex_type& __m, adopt_lock_t) noexcept : _M_device(std::__addressof(__m)), _M_owns(true) { } template<typename _Clock, typename _Duration> unique_lock(mutex_type& __m, const chrono::time_point<_Clock, _Duration>& __atime) : _M_device(std::__addressof(__m)), _M_owns(_M_device->try_lock_until(__atime)) { } template<typename _Rep, typename _Period> unique_lock(mutex_type& __m, const chrono::duration<_Rep, _Period>& __rtime) : _M_device(std::__addressof(__m)), _M_owns(_M_device->try_lock_for(__rtime)) { } ~unique_lock() { if (_M_owns) unlock(); } unique_lock(const unique_lock&) = delete; unique_lock& operator=(const unique_lock&) = delete; unique_lock(unique_lock&& __u) noexcept : _M_device(__u._M_device), _M_owns(__u._M_owns) { __u._M_device = 0; __u._M_owns = false; } unique_lock& operator=(unique_lock&& __u) noexcept { if(_M_owns) unlock(); unique_lock(std::move(__u)).swap(*this); __u._M_device = 0; __u._M_owns = false; return *this; } void lock() { if (!_M_device) __throw_system_error(int(errc::operation_not_permitted)); else if (_M_owns) __throw_system_error(int(errc::resource_deadlock_would_occur)); else { _M_device->lock(); _M_owns = true; } } bool try_lock() { if (!_M_device) __throw_system_error(int(errc::operation_not_permitted)); else if (_M_owns) __throw_system_error(int(errc::resource_deadlock_would_occur)); else { _M_owns = _M_device->try_lock(); return _M_owns; } } template<typename _Clock, typename _Duration> bool try_lock_until(const chrono::time_point<_Clock, _Duration>& __atime) { if (!_M_device) __throw_system_error(int(errc::operation_not_permitted)); else if (_M_owns) __throw_system_error(int(errc::resource_deadlock_would_occur)); else { _M_owns = _M_device->try_lock_until(__atime); return _M_owns; } } template<typename _Rep, typename _Period> bool try_lock_for(const chrono::duration<_Rep, _Period>& __rtime) { if (!_M_device) __throw_system_error(int(errc::operation_not_permitted)); else if (_M_owns) __throw_system_error(int(errc::resource_deadlock_would_occur)); else { _M_owns = _M_device->try_lock_for(__rtime); return _M_owns; } } void unlock() { if (!_M_owns) __throw_system_error(int(errc::operation_not_permitted)); else if (_M_device) { _M_device->unlock(); _M_owns = false; } } void swap(unique_lock& __u) noexcept { std::swap(_M_device, __u._M_device); std::swap(_M_owns, __u._M_owns); } mutex_type* release() noexcept { mutex_type* __ret = _M_device; _M_device = 0; _M_owns = false; return __ret; } bool owns_lock() const noexcept { return _M_owns; } explicit operator bool() const noexcept { return owns_lock(); } mutex_type* mutex() const noexcept { return _M_device; } private: mutex_type* _M_device; bool _M_owns; }; template<typename _Mutex> inline void swap(unique_lock<_Mutex>& __x, unique_lock<_Mutex>& __y) noexcept { __x.swap(__y); } } namespace std __attribute__ ((__visibility__ ("default"))) { class __recursive_mutex_base { protected: typedef __gthread_recursive_mutex_t __native_type; __recursive_mutex_base(const __recursive_mutex_base&) = delete; __recursive_mutex_base& operator=(const __recursive_mutex_base&) = delete; __native_type _M_mutex = { { 0, 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP, 0, 0, { 0, 0 } } }; __recursive_mutex_base() = default; }; class recursive_mutex : private __recursive_mutex_base { public: typedef __native_type* native_handle_type; recursive_mutex() = default; ~recursive_mutex() = default; recursive_mutex(const recursive_mutex&) = delete; recursive_mutex& operator=(const recursive_mutex&) = delete; void lock() { int __e = __gthread_recursive_mutex_lock(&_M_mutex); if (__e) __throw_system_error(__e); } bool try_lock() noexcept { return !__gthread_recursive_mutex_trylock(&_M_mutex); } void unlock() { __gthread_recursive_mutex_unlock(&_M_mutex); } native_handle_type native_handle() noexcept { return &_M_mutex; } }; template<typename _Derived> class __timed_mutex_impl { protected: template<typename _Rep, typename _Period> bool _M_try_lock_for(const chrono::duration<_Rep, _Period>& __rtime) { using __clock = chrono::steady_clock; auto __rt = chrono::duration_cast<__clock::duration>(__rtime); if (ratio_greater<__clock::period, _Period>()) ++__rt; return _M_try_lock_until(__clock::now() + __rt); } template<typename _Duration> bool _M_try_lock_until(const chrono::time_point<chrono::system_clock, _Duration>& __atime) { auto __s = chrono::time_point_cast<chrono::seconds>(__atime); auto __ns = chrono::duration_cast<chrono::nanoseconds>(__atime - __s); __gthread_time_t __ts = { static_cast<std::time_t>(__s.time_since_epoch().count()), static_cast<long>(__ns.count()) }; return static_cast<_Derived*>(this)->_M_timedlock(__ts); } template<typename _Duration> bool _M_try_lock_until(const chrono::time_point<chrono::steady_clock, _Duration>& __atime) { auto __s = chrono::time_point_cast<chrono::seconds>(__atime); auto __ns = chrono::duration_cast<chrono::nanoseconds>(__atime - __s); __gthread_time_t __ts = { static_cast<std::time_t>(__s.time_since_epoch().count()), static_cast<long>(__ns.count()) }; return static_cast<_Derived*>(this)->_M_clocklock(1, __ts); } template<typename _Clock, typename _Duration> bool _M_try_lock_until(const chrono::time_point<_Clock, _Duration>& __atime) { auto __now = _Clock::now(); do { auto __rtime = __atime - __now; if (_M_try_lock_for(__rtime)) return true; __now = _Clock::now(); } while (__atime > __now); return false; } }; class timed_mutex : private __mutex_base, public __timed_mutex_impl<timed_mutex> { public: typedef __native_type* native_handle_type; timed_mutex() = default; ~timed_mutex() = default; timed_mutex(const timed_mutex&) = delete; timed_mutex& operator=(const timed_mutex&) = delete; void lock() { int __e = __gthread_mutex_lock(&_M_mutex); if (__e) __throw_system_error(__e); } bool try_lock() noexcept { return !__gthread_mutex_trylock(&_M_mutex); } template <class _Rep, class _Period> bool try_lock_for(const chrono::duration<_Rep, _Period>& __rtime) { return _M_try_lock_for(__rtime); } template <class _Clock, class _Duration> bool try_lock_until(const chrono::time_point<_Clock, _Duration>& __atime) { return _M_try_lock_until(__atime); } void unlock() { __gthread_mutex_unlock(&_M_mutex); } native_handle_type native_handle() noexcept { return &_M_mutex; } private: friend class __timed_mutex_impl<timed_mutex>; bool _M_timedlock(const __gthread_time_t& __ts) { return !__gthread_mutex_timedlock(&_M_mutex, &__ts); } bool _M_clocklock(clockid_t clockid, const __gthread_time_t& __ts) { return !pthread_mutex_clocklock(&_M_mutex, clockid, &__ts); } }; class recursive_timed_mutex : private __recursive_mutex_base, public __timed_mutex_impl<recursive_timed_mutex> { public: typedef __native_type* native_handle_type; recursive_timed_mutex() = default; ~recursive_timed_mutex() = default; recursive_timed_mutex(const recursive_timed_mutex&) = delete; recursive_timed_mutex& operator=(const recursive_timed_mutex&) = delete; void lock() { int __e = __gthread_recursive_mutex_lock(&_M_mutex); if (__e) __throw_system_error(__e); } bool try_lock() noexcept { return !__gthread_recursive_mutex_trylock(&_M_mutex); } template <class _Rep, class _Period> bool try_lock_for(const chrono::duration<_Rep, _Period>& __rtime) { return _M_try_lock_for(__rtime); } template <class _Clock, class _Duration> bool try_lock_until(const chrono::time_point<_Clock, _Duration>& __atime) { return _M_try_lock_until(__atime); } void unlock() { __gthread_recursive_mutex_unlock(&_M_mutex); } native_handle_type native_handle() noexcept { return &_M_mutex; } private: friend class __timed_mutex_impl<recursive_timed_mutex>; bool _M_timedlock(const __gthread_time_t& __ts) { return !__gthread_recursive_mutex_timedlock(&_M_mutex, &__ts); } bool _M_clocklock(clockid_t clockid, const __gthread_time_t& __ts) { return !pthread_mutex_clocklock(&_M_mutex, clockid, &__ts); } }; template<typename _Lock> inline unique_lock<_Lock> __try_to_lock(_Lock& __l) { return unique_lock<_Lock>{__l, try_to_lock}; } template<int _Idx, bool _Continue = true> struct __try_lock_impl { template<typename... _Lock> static void __do_try_lock(tuple<_Lock&...>& __locks, int& __idx) { __idx = _Idx; auto __lock = std::__try_to_lock(std::get<_Idx>(__locks)); if (__lock.owns_lock()) { constexpr bool __cont = _Idx + 2 < sizeof...(_Lock); using __try_locker = __try_lock_impl<_Idx + 1, __cont>; __try_locker::__do_try_lock(__locks, __idx); if (__idx == -1) __lock.release(); } } }; template<int _Idx> struct __try_lock_impl<_Idx, false> { template<typename... _Lock> static void __do_try_lock(tuple<_Lock&...>& __locks, int& __idx) { __idx = _Idx; auto __lock = std::__try_to_lock(std::get<_Idx>(__locks)); if (__lock.owns_lock()) { __idx = -1; __lock.release(); } } }; template<typename _Lock1, typename _Lock2, typename... _Lock3> int try_lock(_Lock1& __l1, _Lock2& __l2, _Lock3&... __l3) { int __idx; auto __locks = std::tie(__l1, __l2, __l3...); __try_lock_impl<0>::__do_try_lock(__locks, __idx); return __idx; } template<typename _L1, typename _L2, typename... _L3> void lock(_L1& __l1, _L2& __l2, _L3&... __l3) { while (true) { using __try_locker = __try_lock_impl<0, sizeof...(_L3) != 0>; unique_lock<_L1> __first(__l1); int __idx; auto __locks = std::tie(__l2, __l3...); __try_locker::__do_try_lock(__locks, __idx); if (__idx == -1) { __first.release(); return; } } } struct once_flag { private: typedef __gthread_once_t __native_type; __native_type _M_once = 0; public: constexpr once_flag() noexcept = default; once_flag(const once_flag&) = delete; once_flag& operator=(const once_flag&) = delete; template<typename _Callable, typename... _Args> friend void call_once(once_flag& __once, _Callable&& __f, _Args&&... __args); }; extern __thread void* __once_callable; extern __thread void (*__once_call)(); extern "C" void __once_proxy(void); template<typename _Callable, typename... _Args> void call_once(once_flag& __once, _Callable&& __f, _Args&&... __args) { auto __callable = [&] { std::__invoke(std::forward<_Callable>(__f), std::forward<_Args>(__args)...); }; __once_callable = std::__addressof(__callable); __once_call = []{ (*(decltype(__callable)*)__once_callable)(); }; int __e = __gthread_once(&__once._M_once, &__once_proxy); if (__e) __throw_system_error(__e); } } extern "C" { extern void *memcpy (void *__restrict __dest, const void *__restrict __src, size_t __n) throw () __attribute__ ((__nonnull__ (1, 2))); extern void *memmove (void *__dest, const void *__src, size_t __n) throw () __attribute__ ((__nonnull__ (1, 2))); extern void *memccpy (void *__restrict __dest, const void *__restrict __src, int __c, size_t __n) throw () __attribute__ ((__nonnull__ (1, 2))); extern void *memset (void *__s, int __c, size_t __n) throw () __attribute__ ((__nonnull__ (1))); extern int memcmp (const void *__s1, const void *__s2, size_t __n) throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); extern "C++" { extern void *memchr (void *__s, int __c, size_t __n) throw () __asm ("memchr") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))); extern const void *memchr (const void *__s, int __c, size_t __n) throw () __asm ("memchr") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))); extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) void * memchr (void *__s, int __c, size_t __n) throw () { return __builtin_memchr (__s, __c, __n); } extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) const void * memchr (const void *__s, int __c, size_t __n) throw () { return __builtin_memchr (__s, __c, __n); } } extern "C++" void *rawmemchr (void *__s, int __c) throw () __asm ("rawmemchr") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))); extern "C++" const void *rawmemchr (const void *__s, int __c) throw () __asm ("rawmemchr") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))); extern "C++" void *memrchr (void *__s, int __c, size_t __n) throw () __asm ("memrchr") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))); extern "C++" const void *memrchr (const void *__s, int __c, size_t __n) throw () __asm ("memrchr") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))); extern char *strcpy (char *__restrict __dest, const char *__restrict __src) throw () __attribute__ ((__nonnull__ (1, 2))); extern char *strncpy (char *__restrict __dest, const char *__restrict __src, size_t __n) throw () __attribute__ ((__nonnull__ (1, 2))); extern char *strcat (char *__restrict __dest, const char *__restrict __src) throw () __attribute__ ((__nonnull__ (1, 2))); extern char *strncat (char *__restrict __dest, const char *__restrict __src, size_t __n) throw () __attribute__ ((__nonnull__ (1, 2))); extern int strcmp (const char *__s1, const char *__s2) throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); extern int strncmp (const char *__s1, const char *__s2, size_t __n) throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); extern int strcoll (const char *__s1, const char *__s2) throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); extern size_t strxfrm (char *__restrict __dest, const char *__restrict __src, size_t __n) throw () __attribute__ ((__nonnull__ (2))); extern int strcoll_l (const char *__s1, const char *__s2, locale_t __l) throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2, 3))); extern size_t strxfrm_l (char *__dest, const char *__src, size_t __n, locale_t __l) throw () __attribute__ ((__nonnull__ (2, 4))); extern char *strdup (const char *__s) throw () __attribute__ ((__malloc__)) __attribute__ ((__nonnull__ (1))); extern char *strndup (const char *__string, size_t __n) throw () __attribute__ ((__malloc__)) __attribute__ ((__nonnull__ (1))); extern "C++" { extern char *strchr (char *__s, int __c) throw () __asm ("strchr") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))); extern const char *strchr (const char *__s, int __c) throw () __asm ("strchr") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))); extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) char * strchr (char *__s, int __c) throw () { return __builtin_strchr (__s, __c); } extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) const char * strchr (const char *__s, int __c) throw () { return __builtin_strchr (__s, __c); } } extern "C++" { extern char *strrchr (char *__s, int __c) throw () __asm ("strrchr") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))); extern const char *strrchr (const char *__s, int __c) throw () __asm ("strrchr") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))); extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) char * strrchr (char *__s, int __c) throw () { return __builtin_strrchr (__s, __c); } extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) const char * strrchr (const char *__s, int __c) throw () { return __builtin_strrchr (__s, __c); } } extern "C++" char *strchrnul (char *__s, int __c) throw () __asm ("strchrnul") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))); extern "C++" const char *strchrnul (const char *__s, int __c) throw () __asm ("strchrnul") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))); extern size_t strcspn (const char *__s, const char *__reject) throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); extern size_t strspn (const char *__s, const char *__accept) throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); extern "C++" { extern char *strpbrk (char *__s, const char *__accept) throw () __asm ("strpbrk") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); extern const char *strpbrk (const char *__s, const char *__accept) throw () __asm ("strpbrk") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) char * strpbrk (char *__s, const char *__accept) throw () { return __builtin_strpbrk (__s, __accept); } extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) const char * strpbrk (const char *__s, const char *__accept) throw () { return __builtin_strpbrk (__s, __accept); } } extern "C++" { extern char *strstr (char *__haystack, const char *__needle) throw () __asm ("strstr") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); extern const char *strstr (const char *__haystack, const char *__needle) throw () __asm ("strstr") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) char * strstr (char *__haystack, const char *__needle) throw () { return __builtin_strstr (__haystack, __needle); } extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) const char * strstr (const char *__haystack, const char *__needle) throw () { return __builtin_strstr (__haystack, __needle); } } extern char *strtok (char *__restrict __s, const char *__restrict __delim) throw () __attribute__ ((__nonnull__ (2))); extern char *__strtok_r (char *__restrict __s, const char *__restrict __delim, char **__restrict __save_ptr) throw () __attribute__ ((__nonnull__ (2, 3))); extern char *strtok_r (char *__restrict __s, const char *__restrict __delim, char **__restrict __save_ptr) throw () __attribute__ ((__nonnull__ (2, 3))); extern "C++" char *strcasestr (char *__haystack, const char *__needle) throw () __asm ("strcasestr") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); extern "C++" const char *strcasestr (const char *__haystack, const char *__needle) throw () __asm ("strcasestr") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); extern void *memmem (const void *__haystack, size_t __haystacklen, const void *__needle, size_t __needlelen) throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 3))); extern void *__mempcpy (void *__restrict __dest, const void *__restrict __src, size_t __n) throw () __attribute__ ((__nonnull__ (1, 2))); extern void *mempcpy (void *__restrict __dest, const void *__restrict __src, size_t __n) throw () __attribute__ ((__nonnull__ (1, 2))); extern size_t strlen (const char *__s) throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))); extern size_t strnlen (const char *__string, size_t __maxlen) throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))); extern char *strerror (int __errnum) throw (); extern char *strerror_r (int __errnum, char *__buf, size_t __buflen) throw () __attribute__ ((__nonnull__ (2))) ; extern char *strerror_l (int __errnum, locale_t __l) throw (); extern "C" { extern int bcmp (const void *__s1, const void *__s2, size_t __n) throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); extern void bcopy (const void *__src, void *__dest, size_t __n) throw () __attribute__ ((__nonnull__ (1, 2))); extern void bzero (void *__s, size_t __n) throw () __attribute__ ((__nonnull__ (1))); extern "C++" { extern char *index (char *__s, int __c) throw () __asm ("index") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))); extern const char *index (const char *__s, int __c) throw () __asm ("index") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))); extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) char * index (char *__s, int __c) throw () { return __builtin_index (__s, __c); } extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) const char * index (const char *__s, int __c) throw () { return __builtin_index (__s, __c); } } extern "C++" { extern char *rindex (char *__s, int __c) throw () __asm ("rindex") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))); extern const char *rindex (const char *__s, int __c) throw () __asm ("rindex") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))); extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) char * rindex (char *__s, int __c) throw () { return __builtin_rindex (__s, __c); } extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) const char * rindex (const char *__s, int __c) throw () { return __builtin_rindex (__s, __c); } } extern int ffs (int __i) throw () __attribute__ ((__const__)); extern int ffsl (long int __l) throw () __attribute__ ((__const__)); __extension__ extern int ffsll (long long int __ll) throw () __attribute__ ((__const__)); extern int strcasecmp (const char *__s1, const char *__s2) throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); extern int strncasecmp (const char *__s1, const char *__s2, size_t __n) throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); extern int strcasecmp_l (const char *__s1, const char *__s2, locale_t __loc) throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2, 3))); extern int strncasecmp_l (const char *__s1, const char *__s2, size_t __n, locale_t __loc) throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2, 4))); } extern void explicit_bzero (void *__s, size_t __n) throw () __attribute__ ((__nonnull__ (1))); extern char *strsep (char **__restrict __stringp, const char *__restrict __delim) throw () __attribute__ ((__nonnull__ (1, 2))); extern char *strsignal (int __sig) throw (); extern char *__stpcpy (char *__restrict __dest, const char *__restrict __src) throw () __attribute__ ((__nonnull__ (1, 2))); extern char *stpcpy (char *__restrict __dest, const char *__restrict __src) throw () __attribute__ ((__nonnull__ (1, 2))); extern char *__stpncpy (char *__restrict __dest, const char *__restrict __src, size_t __n) throw () __attribute__ ((__nonnull__ (1, 2))); extern char *stpncpy (char *__restrict __dest, const char *__restrict __src, size_t __n) throw () __attribute__ ((__nonnull__ (1, 2))); extern int strverscmp (const char *__s1, const char *__s2) throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); extern char *strfry (char *__string) throw () __attribute__ ((__nonnull__ (1))); extern void *memfrob (void *__s, size_t __n) throw () __attribute__ ((__nonnull__ (1))); extern "C++" char *basename (char *__filename) throw () __asm ("basename") __attribute__ ((__nonnull__ (1))); extern "C++" const char *basename (const char *__filename) throw () __asm ("basename") __attribute__ ((__nonnull__ (1))); } extern "C++" { namespace std __attribute__ ((__visibility__ ("default"))) { using ::memchr; using ::memcmp; using ::memcpy; using ::memmove; using ::memset; using ::strcat; using ::strcmp; using ::strcoll; using ::strcpy; using ::strcspn; using ::strerror; using ::strlen; using ::strncat; using ::strncmp; using ::strncpy; using ::strspn; using ::strtok; using ::strxfrm; using ::strchr; using ::strpbrk; using ::strrchr; using ::strstr; } } extern "C" { typedef float float_t; typedef double double_t; enum { FP_INT_UPWARD = 0, FP_INT_DOWNWARD = 1, FP_INT_TOWARDZERO = 2, FP_INT_TONEARESTFROMZERO = 3, FP_INT_TONEAREST = 4, }; extern int __fpclassify (double __value) throw () __attribute__ ((__const__)); extern int __signbit (double __value) throw () __attribute__ ((__const__)); extern int __isinf (double __value) throw () __attribute__ ((__const__)); extern int __finite (double __value) throw () __attribute__ ((__const__)); extern int __isnan (double __value) throw () __attribute__ ((__const__)); extern int __iseqsig (double __x, double __y) throw (); extern int __issignaling (double __value) throw () __attribute__ ((__const__)); extern double acos (double __x) throw (); extern double __acos (double __x) throw (); extern double asin (double __x) throw (); extern double __asin (double __x) throw (); extern double atan (double __x) throw (); extern double __atan (double __x) throw (); extern double atan2 (double __y, double __x) throw (); extern double __atan2 (double __y, double __x) throw (); extern double cos (double __x) throw (); extern double __cos (double __x) throw (); extern double sin (double __x) throw (); extern double __sin (double __x) throw (); extern double tan (double __x) throw (); extern double __tan (double __x) throw (); extern double cosh (double __x) throw (); extern double __cosh (double __x) throw (); extern double sinh (double __x) throw (); extern double __sinh (double __x) throw (); extern double tanh (double __x) throw (); extern double __tanh (double __x) throw (); extern void sincos (double __x, double *__sinx, double *__cosx) throw (); extern void __sincos (double __x, double *__sinx, double *__cosx) throw () ; extern double acosh (double __x) throw (); extern double __acosh (double __x) throw (); extern double asinh (double __x) throw (); extern double __asinh (double __x) throw (); extern double atanh (double __x) throw (); extern double __atanh (double __x) throw (); extern double exp (double __x) throw (); extern double __exp (double __x) throw (); extern double frexp (double __x, int *__exponent) throw (); extern double __frexp (double __x, int *__exponent) throw (); extern double ldexp (double __x, int __exponent) throw (); extern double __ldexp (double __x, int __exponent) throw (); extern double log (double __x) throw (); extern double __log (double __x) throw (); extern double log10 (double __x) throw (); extern double __log10 (double __x) throw (); extern double modf (double __x, double *__iptr) throw (); extern double __modf (double __x, double *__iptr) throw () __attribute__ ((__nonnull__ (2))); extern double exp10 (double __x) throw (); extern double __exp10 (double __x) throw (); extern double expm1 (double __x) throw (); extern double __expm1 (double __x) throw (); extern double log1p (double __x) throw (); extern double __log1p (double __x) throw (); extern double logb (double __x) throw (); extern double __logb (double __x) throw (); extern double exp2 (double __x) throw (); extern double __exp2 (double __x) throw (); extern double log2 (double __x) throw (); extern double __log2 (double __x) throw (); extern double pow (double __x, double __y) throw (); extern double __pow (double __x, double __y) throw (); extern double sqrt (double __x) throw (); extern double __sqrt (double __x) throw (); extern double hypot (double __x, double __y) throw (); extern double __hypot (double __x, double __y) throw (); extern double cbrt (double __x) throw (); extern double __cbrt (double __x) throw (); extern double ceil (double __x) throw () __attribute__ ((__const__)); extern double __ceil (double __x) throw () __attribute__ ((__const__)); extern double fabs (double __x) throw () __attribute__ ((__const__)); extern double __fabs (double __x) throw () __attribute__ ((__const__)); extern double floor (double __x) throw () __attribute__ ((__const__)); extern double __floor (double __x) throw () __attribute__ ((__const__)); extern double fmod (double __x, double __y) throw (); extern double __fmod (double __x, double __y) throw (); extern int finite (double __value) throw () __attribute__ ((__const__)); extern double drem (double __x, double __y) throw (); extern double __drem (double __x, double __y) throw (); extern double significand (double __x) throw (); extern double __significand (double __x) throw (); extern double copysign (double __x, double __y) throw () __attribute__ ((__const__)); extern double __copysign (double __x, double __y) throw () __attribute__ ((__const__)); extern double nan (const char *__tagb) throw (); extern double __nan (const char *__tagb) throw (); extern double j0 (double) throw (); extern double __j0 (double) throw (); extern double j1 (double) throw (); extern double __j1 (double) throw (); extern double jn (int, double) throw (); extern double __jn (int, double) throw (); extern double y0 (double) throw (); extern double __y0 (double) throw (); extern double y1 (double) throw (); extern double __y1 (double) throw (); extern double yn (int, double) throw (); extern double __yn (int, double) throw (); extern double erf (double) throw (); extern double __erf (double) throw (); extern double erfc (double) throw (); extern double __erfc (double) throw (); extern double lgamma (double) throw (); extern double __lgamma (double) throw (); extern double tgamma (double) throw (); extern double __tgamma (double) throw (); extern double gamma (double) throw (); extern double __gamma (double) throw (); extern double lgamma_r (double, int *__signgamp) throw (); extern double __lgamma_r (double, int *__signgamp) throw (); extern double rint (double __x) throw (); extern double __rint (double __x) throw (); extern double nextafter (double __x, double __y) throw (); extern double __nextafter (double __x, double __y) throw (); extern double nexttoward (double __x, long double __y) throw (); extern double __nexttoward (double __x, long double __y) throw (); extern double nextdown (double __x) throw (); extern double __nextdown (double __x) throw (); extern double nextup (double __x) throw (); extern double __nextup (double __x) throw (); extern double remainder (double __x, double __y) throw (); extern double __remainder (double __x, double __y) throw (); extern double scalbn (double __x, int __n) throw (); extern double __scalbn (double __x, int __n) throw (); extern int ilogb (double __x) throw (); extern int __ilogb (double __x) throw (); extern long int llogb (double __x) throw (); extern long int __llogb (double __x) throw (); extern double scalbln (double __x, long int __n) throw (); extern double __scalbln (double __x, long int __n) throw (); extern double nearbyint (double __x) throw (); extern double __nearbyint (double __x) throw (); extern double round (double __x) throw () __attribute__ ((__const__)); extern double __round (double __x) throw () __attribute__ ((__const__)); extern double trunc (double __x) throw () __attribute__ ((__const__)); extern double __trunc (double __x) throw () __attribute__ ((__const__)); extern double remquo (double __x, double __y, int *__quo) throw (); extern double __remquo (double __x, double __y, int *__quo) throw (); extern long int lrint (double __x) throw (); extern long int __lrint (double __x) throw (); __extension__ extern long long int llrint (double __x) throw (); extern long long int __llrint (double __x) throw (); extern long int lround (double __x) throw (); extern long int __lround (double __x) throw (); __extension__ extern long long int llround (double __x) throw (); extern long long int __llround (double __x) throw (); extern double fdim (double __x, double __y) throw (); extern double __fdim (double __x, double __y) throw (); extern double fmax (double __x, double __y) throw () __attribute__ ((__const__)); extern double __fmax (double __x, double __y) throw () __attribute__ ((__const__)); extern double fmin (double __x, double __y) throw () __attribute__ ((__const__)); extern double __fmin (double __x, double __y) throw () __attribute__ ((__const__)); extern double fma (double __x, double __y, double __z) throw (); extern double __fma (double __x, double __y, double __z) throw (); extern double roundeven (double __x) throw () __attribute__ ((__const__)); extern double __roundeven (double __x) throw () __attribute__ ((__const__)); extern __intmax_t fromfp (double __x, int __round, unsigned int __width) throw (); extern __intmax_t __fromfp (double __x, int __round, unsigned int __width) throw () ; extern __uintmax_t ufromfp (double __x, int __round, unsigned int __width) throw (); extern __uintmax_t __ufromfp (double __x, int __round, unsigned int __width) throw () ; extern __intmax_t fromfpx (double __x, int __round, unsigned int __width) throw (); extern __intmax_t __fromfpx (double __x, int __round, unsigned int __width) throw () ; extern __uintmax_t ufromfpx (double __x, int __round, unsigned int __width) throw (); extern __uintmax_t __ufromfpx (double __x, int __round, unsigned int __width) throw () ; extern double fmaxmag (double __x, double __y) throw () __attribute__ ((__const__)); extern double __fmaxmag (double __x, double __y) throw () __attribute__ ((__const__)); extern double fminmag (double __x, double __y) throw () __attribute__ ((__const__)); extern double __fminmag (double __x, double __y) throw () __attribute__ ((__const__)); extern int canonicalize (double *__cx, const double *__x) throw (); extern int totalorder (const double *__x, const double *__y) throw () __attribute__ ((__pure__)); extern int totalordermag (const double *__x, const double *__y) throw () __attribute__ ((__pure__)); extern double getpayload (const double *__x) throw (); extern double __getpayload (const double *__x) throw (); extern int setpayload (double *__x, double __payload) throw (); extern int setpayloadsig (double *__x, double __payload) throw (); extern double scalb (double __x, double __n) throw (); extern double __scalb (double __x, double __n) throw (); extern int __fpclassifyf (float __value) throw () __attribute__ ((__const__)); extern int __signbitf (float __value) throw () __attribute__ ((__const__)); extern int __isinff (float __value) throw () __attribute__ ((__const__)); extern int __finitef (float __value) throw () __attribute__ ((__const__)); extern int __isnanf (float __value) throw () __attribute__ ((__const__)); extern int __iseqsigf (float __x, float __y) throw (); extern int __issignalingf (float __value) throw () __attribute__ ((__const__)); extern float acosf (float __x) throw (); extern float __acosf (float __x) throw (); extern float asinf (float __x) throw (); extern float __asinf (float __x) throw (); extern float atanf (float __x) throw (); extern float __atanf (float __x) throw (); extern float atan2f (float __y, float __x) throw (); extern float __atan2f (float __y, float __x) throw (); extern float cosf (float __x) throw (); extern float __cosf (float __x) throw (); extern float sinf (float __x) throw (); extern float __sinf (float __x) throw (); extern float tanf (float __x) throw (); extern float __tanf (float __x) throw (); extern float coshf (float __x) throw (); extern float __coshf (float __x) throw (); extern float sinhf (float __x) throw (); extern float __sinhf (float __x) throw (); extern float tanhf (float __x) throw (); extern float __tanhf (float __x) throw (); extern void sincosf (float __x, float *__sinx, float *__cosx) throw (); extern void __sincosf (float __x, float *__sinx, float *__cosx) throw () ; extern float acoshf (float __x) throw (); extern float __acoshf (float __x) throw (); extern float asinhf (float __x) throw (); extern float __asinhf (float __x) throw (); extern float atanhf (float __x) throw (); extern float __atanhf (float __x) throw (); extern float expf (float __x) throw (); extern float __expf (float __x) throw (); extern float frexpf (float __x, int *__exponent) throw (); extern float __frexpf (float __x, int *__exponent) throw (); extern float ldexpf (float __x, int __exponent) throw (); extern float __ldexpf (float __x, int __exponent) throw (); extern float logf (float __x) throw (); extern float __logf (float __x) throw (); extern float log10f (float __x) throw (); extern float __log10f (float __x) throw (); extern float modff (float __x, float *__iptr) throw (); extern float __modff (float __x, float *__iptr) throw () __attribute__ ((__nonnull__ (2))); extern float exp10f (float __x) throw (); extern float __exp10f (float __x) throw (); extern float expm1f (float __x) throw (); extern float __expm1f (float __x) throw (); extern float log1pf (float __x) throw (); extern float __log1pf (float __x) throw (); extern float logbf (float __x) throw (); extern float __logbf (float __x) throw (); extern float exp2f (float __x) throw (); extern float __exp2f (float __x) throw (); extern float log2f (float __x) throw (); extern float __log2f (float __x) throw (); extern float powf (float __x, float __y) throw (); extern float __powf (float __x, float __y) throw (); extern float sqrtf (float __x) throw (); extern float __sqrtf (float __x) throw (); extern float hypotf (float __x, float __y) throw (); extern float __hypotf (float __x, float __y) throw (); extern float cbrtf (float __x) throw (); extern float __cbrtf (float __x) throw (); extern float ceilf (float __x) throw () __attribute__ ((__const__)); extern float __ceilf (float __x) throw () __attribute__ ((__const__)); extern float fabsf (float __x) throw () __attribute__ ((__const__)); extern float __fabsf (float __x) throw () __attribute__ ((__const__)); extern float floorf (float __x) throw () __attribute__ ((__const__)); extern float __floorf (float __x) throw () __attribute__ ((__const__)); extern float fmodf (float __x, float __y) throw (); extern float __fmodf (float __x, float __y) throw (); extern int isinff (float __value) throw () __attribute__ ((__const__)); extern int finitef (float __value) throw () __attribute__ ((__const__)); extern float dremf (float __x, float __y) throw (); extern float __dremf (float __x, float __y) throw (); extern float significandf (float __x) throw (); extern float __significandf (float __x) throw (); extern float copysignf (float __x, float __y) throw () __attribute__ ((__const__)); extern float __copysignf (float __x, float __y) throw () __attribute__ ((__const__)); extern float nanf (const char *__tagb) throw (); extern float __nanf (const char *__tagb) throw (); extern int isnanf (float __value) throw () __attribute__ ((__const__)); extern float j0f (float) throw (); extern float __j0f (float) throw (); extern float j1f (float) throw (); extern float __j1f (float) throw (); extern float jnf (int, float) throw (); extern float __jnf (int, float) throw (); extern float y0f (float) throw (); extern float __y0f (float) throw (); extern float y1f (float) throw (); extern float __y1f (float) throw (); extern float ynf (int, float) throw (); extern float __ynf (int, float) throw (); extern float erff (float) throw (); extern float __erff (float) throw (); extern float erfcf (float) throw (); extern float __erfcf (float) throw (); extern float lgammaf (float) throw (); extern float __lgammaf (float) throw (); extern float tgammaf (float) throw (); extern float __tgammaf (float) throw (); extern float gammaf (float) throw (); extern float __gammaf (float) throw (); extern float lgammaf_r (float, int *__signgamp) throw (); extern float __lgammaf_r (float, int *__signgamp) throw (); extern float rintf (float __x) throw (); extern float __rintf (float __x) throw (); extern float nextafterf (float __x, float __y) throw (); extern float __nextafterf (float __x, float __y) throw (); extern float nexttowardf (float __x, long double __y) throw (); extern float __nexttowardf (float __x, long double __y) throw (); extern float nextdownf (float __x) throw (); extern float __nextdownf (float __x) throw (); extern float nextupf (float __x) throw (); extern float __nextupf (float __x) throw (); extern float remainderf (float __x, float __y) throw (); extern float __remainderf (float __x, float __y) throw (); extern float scalbnf (float __x, int __n) throw (); extern float __scalbnf (float __x, int __n) throw (); extern int ilogbf (float __x) throw (); extern int __ilogbf (float __x) throw (); extern long int llogbf (float __x) throw (); extern long int __llogbf (float __x) throw (); extern float scalblnf (float __x, long int __n) throw (); extern float __scalblnf (float __x, long int __n) throw (); extern float nearbyintf (float __x) throw (); extern float __nearbyintf (float __x) throw (); extern float roundf (float __x) throw () __attribute__ ((__const__)); extern float __roundf (float __x) throw () __attribute__ ((__const__)); extern float truncf (float __x) throw () __attribute__ ((__const__)); extern float __truncf (float __x) throw () __attribute__ ((__const__)); extern float remquof (float __x, float __y, int *__quo) throw (); extern float __remquof (float __x, float __y, int *__quo) throw (); extern long int lrintf (float __x) throw (); extern long int __lrintf (float __x) throw (); __extension__ extern long long int llrintf (float __x) throw (); extern long long int __llrintf (float __x) throw (); extern long int lroundf (float __x) throw (); extern long int __lroundf (float __x) throw (); __extension__ extern long long int llroundf (float __x) throw (); extern long long int __llroundf (float __x) throw (); extern float fdimf (float __x, float __y) throw (); extern float __fdimf (float __x, float __y) throw (); extern float fmaxf (float __x, float __y) throw () __attribute__ ((__const__)); extern float __fmaxf (float __x, float __y) throw () __attribute__ ((__const__)); extern float fminf (float __x, float __y) throw () __attribute__ ((__const__)); extern float __fminf (float __x, float __y) throw () __attribute__ ((__const__)); extern float fmaf (float __x, float __y, float __z) throw (); extern float __fmaf (float __x, float __y, float __z) throw (); extern float roundevenf (float __x) throw () __attribute__ ((__const__)); extern float __roundevenf (float __x) throw () __attribute__ ((__const__)); extern __intmax_t fromfpf (float __x, int __round, unsigned int __width) throw (); extern __intmax_t __fromfpf (float __x, int __round, unsigned int __width) throw () ; extern __uintmax_t ufromfpf (float __x, int __round, unsigned int __width) throw (); extern __uintmax_t __ufromfpf (float __x, int __round, unsigned int __width) throw () ; extern __intmax_t fromfpxf (float __x, int __round, unsigned int __width) throw (); extern __intmax_t __fromfpxf (float __x, int __round, unsigned int __width) throw () ; extern __uintmax_t ufromfpxf (float __x, int __round, unsigned int __width) throw (); extern __uintmax_t __ufromfpxf (float __x, int __round, unsigned int __width) throw () ; extern float fmaxmagf (float __x, float __y) throw () __attribute__ ((__const__)); extern float __fmaxmagf (float __x, float __y) throw () __attribute__ ((__const__)); extern float fminmagf (float __x, float __y) throw () __attribute__ ((__const__)); extern float __fminmagf (float __x, float __y) throw () __attribute__ ((__const__)); extern int canonicalizef (float *__cx, const float *__x) throw (); extern int totalorderf (const float *__x, const float *__y) throw () __attribute__ ((__pure__)); extern int totalordermagf (const float *__x, const float *__y) throw () __attribute__ ((__pure__)); extern float getpayloadf (const float *__x) throw (); extern float __getpayloadf (const float *__x) throw (); extern int setpayloadf (float *__x, float __payload) throw (); extern int setpayloadsigf (float *__x, float __payload) throw (); extern float scalbf (float __x, float __n) throw (); extern float __scalbf (float __x, float __n) throw (); extern int __fpclassifyl (long double __value) throw () __attribute__ ((__const__)); extern int __signbitl (long double __value) throw () __attribute__ ((__const__)); extern int __isinfl (long double __value) throw () __attribute__ ((__const__)); extern int __finitel (long double __value) throw () __attribute__ ((__const__)); extern int __isnanl (long double __value) throw () __attribute__ ((__const__)); extern int __iseqsigl (long double __x, long double __y) throw (); extern int __issignalingl (long double __value) throw () __attribute__ ((__const__)); extern long double acosl (long double __x) throw (); extern long double __acosl (long double __x) throw (); extern long double asinl (long double __x) throw (); extern long double __asinl (long double __x) throw (); extern long double atanl (long double __x) throw (); extern long double __atanl (long double __x) throw (); extern long double atan2l (long double __y, long double __x) throw (); extern long double __atan2l (long double __y, long double __x) throw (); extern long double cosl (long double __x) throw (); extern long double __cosl (long double __x) throw (); extern long double sinl (long double __x) throw (); extern long double __sinl (long double __x) throw (); extern long double tanl (long double __x) throw (); extern long double __tanl (long double __x) throw (); extern long double coshl (long double __x) throw (); extern long double __coshl (long double __x) throw (); extern long double sinhl (long double __x) throw (); extern long double __sinhl (long double __x) throw (); extern long double tanhl (long double __x) throw (); extern long double __tanhl (long double __x) throw (); extern void sincosl (long double __x, long double *__sinx, long double *__cosx) throw (); extern void __sincosl (long double __x, long double *__sinx, long double *__cosx) throw () ; extern long double acoshl (long double __x) throw (); extern long double __acoshl (long double __x) throw (); extern long double asinhl (long double __x) throw (); extern long double __asinhl (long double __x) throw (); extern long double atanhl (long double __x) throw (); extern long double __atanhl (long double __x) throw (); extern long double expl (long double __x) throw (); extern long double __expl (long double __x) throw (); extern long double frexpl (long double __x, int *__exponent) throw (); extern long double __frexpl (long double __x, int *__exponent) throw (); extern long double ldexpl (long double __x, int __exponent) throw (); extern long double __ldexpl (long double __x, int __exponent) throw (); extern long double logl (long double __x) throw (); extern long double __logl (long double __x) throw (); extern long double log10l (long double __x) throw (); extern long double __log10l (long double __x) throw (); extern long double modfl (long double __x, long double *__iptr) throw (); extern long double __modfl (long double __x, long double *__iptr) throw () __attribute__ ((__nonnull__ (2))); extern long double exp10l (long double __x) throw (); extern long double __exp10l (long double __x) throw (); extern long double expm1l (long double __x) throw (); extern long double __expm1l (long double __x) throw (); extern long double log1pl (long double __x) throw (); extern long double __log1pl (long double __x) throw (); extern long double logbl (long double __x) throw (); extern long double __logbl (long double __x) throw (); extern long double exp2l (long double __x) throw (); extern long double __exp2l (long double __x) throw (); extern long double log2l (long double __x) throw (); extern long double __log2l (long double __x) throw (); extern long double powl (long double __x, long double __y) throw (); extern long double __powl (long double __x, long double __y) throw (); extern long double sqrtl (long double __x) throw (); extern long double __sqrtl (long double __x) throw (); extern long double hypotl (long double __x, long double __y) throw (); extern long double __hypotl (long double __x, long double __y) throw (); extern long double cbrtl (long double __x) throw (); extern long double __cbrtl (long double __x) throw (); extern long double ceill (long double __x) throw () __attribute__ ((__const__)); extern long double __ceill (long double __x) throw () __attribute__ ((__const__)); extern long double fabsl (long double __x) throw () __attribute__ ((__const__)); extern long double __fabsl (long double __x) throw () __attribute__ ((__const__)); extern long double floorl (long double __x) throw () __attribute__ ((__const__)); extern long double __floorl (long double __x) throw () __attribute__ ((__const__)); extern long double fmodl (long double __x, long double __y) throw (); extern long double __fmodl (long double __x, long double __y) throw (); extern int isinfl (long double __value) throw () __attribute__ ((__const__)); extern int finitel (long double __value) throw () __attribute__ ((__const__)); extern long double dreml (long double __x, long double __y) throw (); extern long double __dreml (long double __x, long double __y) throw (); extern long double significandl (long double __x) throw (); extern long double __significandl (long double __x) throw (); extern long double copysignl (long double __x, long double __y) throw () __attribute__ ((__const__)); extern long double __copysignl (long double __x, long double __y) throw () __attribute__ ((__const__)); extern long double nanl (const char *__tagb) throw (); extern long double __nanl (const char *__tagb) throw (); extern int isnanl (long double __value) throw () __attribute__ ((__const__)); extern long double j0l (long double) throw (); extern long double __j0l (long double) throw (); extern long double j1l (long double) throw (); extern long double __j1l (long double) throw (); extern long double jnl (int, long double) throw (); extern long double __jnl (int, long double) throw (); extern long double y0l (long double) throw (); extern long double __y0l (long double) throw (); extern long double y1l (long double) throw (); extern long double __y1l (long double) throw (); extern long double ynl (int, long double) throw (); extern long double __ynl (int, long double) throw (); extern long double erfl (long double) throw (); extern long double __erfl (long double) throw (); extern long double erfcl (long double) throw (); extern long double __erfcl (long double) throw (); extern long double lgammal (long double) throw (); extern long double __lgammal (long double) throw (); extern long double tgammal (long double) throw (); extern long double __tgammal (long double) throw (); extern long double gammal (long double) throw (); extern long double __gammal (long double) throw (); extern long double lgammal_r (long double, int *__signgamp) throw (); extern long double __lgammal_r (long double, int *__signgamp) throw (); extern long double rintl (long double __x) throw (); extern long double __rintl (long double __x) throw (); extern long double nextafterl (long double __x, long double __y) throw (); extern long double __nextafterl (long double __x, long double __y) throw (); extern long double nexttowardl (long double __x, long double __y) throw (); extern long double __nexttowardl (long double __x, long double __y) throw (); extern long double nextdownl (long double __x) throw (); extern long double __nextdownl (long double __x) throw (); extern long double nextupl (long double __x) throw (); extern long double __nextupl (long double __x) throw (); extern long double remainderl (long double __x, long double __y) throw (); extern long double __remainderl (long double __x, long double __y) throw (); extern long double scalbnl (long double __x, int __n) throw (); extern long double __scalbnl (long double __x, int __n) throw (); extern int ilogbl (long double __x) throw (); extern int __ilogbl (long double __x) throw (); extern long int llogbl (long double __x) throw (); extern long int __llogbl (long double __x) throw (); extern long double scalblnl (long double __x, long int __n) throw (); extern long double __scalblnl (long double __x, long int __n) throw (); extern long double nearbyintl (long double __x) throw (); extern long double __nearbyintl (long double __x) throw (); extern long double roundl (long double __x) throw () __attribute__ ((__const__)); extern long double __roundl (long double __x) throw () __attribute__ ((__const__)); extern long double truncl (long double __x) throw () __attribute__ ((__const__)); extern long double __truncl (long double __x) throw () __attribute__ ((__const__)); extern long double remquol (long double __x, long double __y, int *__quo) throw (); extern long double __remquol (long double __x, long double __y, int *__quo) throw (); extern long int lrintl (long double __x) throw (); extern long int __lrintl (long double __x) throw (); __extension__ extern long long int llrintl (long double __x) throw (); extern long long int __llrintl (long double __x) throw (); extern long int lroundl (long double __x) throw (); extern long int __lroundl (long double __x) throw (); __extension__ extern long long int llroundl (long double __x) throw (); extern long long int __llroundl (long double __x) throw (); extern long double fdiml (long double __x, long double __y) throw (); extern long double __fdiml (long double __x, long double __y) throw (); extern long double fmaxl (long double __x, long double __y) throw () __attribute__ ((__const__)); extern long double __fmaxl (long double __x, long double __y) throw () __attribute__ ((__const__)); extern long double fminl (long double __x, long double __y) throw () __attribute__ ((__const__)); extern long double __fminl (long double __x, long double __y) throw () __attribute__ ((__const__)); extern long double fmal (long double __x, long double __y, long double __z) throw (); extern long double __fmal (long double __x, long double __y, long double __z) throw (); extern long double roundevenl (long double __x) throw () __attribute__ ((__const__)); extern long double __roundevenl (long double __x) throw () __attribute__ ((__const__)); extern __intmax_t fromfpl (long double __x, int __round, unsigned int __width) throw (); extern __intmax_t __fromfpl (long double __x, int __round, unsigned int __width) throw () ; extern __uintmax_t ufromfpl (long double __x, int __round, unsigned int __width) throw (); extern __uintmax_t __ufromfpl (long double __x, int __round, unsigned int __width) throw () ; extern __intmax_t fromfpxl (long double __x, int __round, unsigned int __width) throw (); extern __intmax_t __fromfpxl (long double __x, int __round, unsigned int __width) throw () ; extern __uintmax_t ufromfpxl (long double __x, int __round, unsigned int __width) throw (); extern __uintmax_t __ufromfpxl (long double __x, int __round, unsigned int __width) throw () ; extern long double fmaxmagl (long double __x, long double __y) throw () __attribute__ ((__const__)); extern long double __fmaxmagl (long double __x, long double __y) throw () __attribute__ ((__const__)); extern long double fminmagl (long double __x, long double __y) throw () __attribute__ ((__const__)); extern long double __fminmagl (long double __x, long double __y) throw () __attribute__ ((__const__)); extern int canonicalizel (long double *__cx, const long double *__x) throw (); extern int totalorderl (const long double *__x, const long double *__y) throw () __attribute__ ((__pure__)); extern int totalordermagl (const long double *__x, const long double *__y) throw () __attribute__ ((__pure__)); extern long double getpayloadl (const long double *__x) throw (); extern long double __getpayloadl (const long double *__x) throw (); extern int setpayloadl (long double *__x, long double __payload) throw (); extern int setpayloadsigl (long double *__x, long double __payload) throw (); extern long double scalbl (long double __x, long double __n) throw (); extern long double __scalbl (long double __x, long double __n) throw (); extern _Float32 acosf32 (_Float32 __x) throw (); extern _Float32 __acosf32 (_Float32 __x) throw (); extern _Float32 asinf32 (_Float32 __x) throw (); extern _Float32 __asinf32 (_Float32 __x) throw (); extern _Float32 atanf32 (_Float32 __x) throw (); extern _Float32 __atanf32 (_Float32 __x) throw (); extern _Float32 atan2f32 (_Float32 __y, _Float32 __x) throw (); extern _Float32 __atan2f32 (_Float32 __y, _Float32 __x) throw (); extern _Float32 cosf32 (_Float32 __x) throw (); extern _Float32 __cosf32 (_Float32 __x) throw (); extern _Float32 sinf32 (_Float32 __x) throw (); extern _Float32 __sinf32 (_Float32 __x) throw (); extern _Float32 tanf32 (_Float32 __x) throw (); extern _Float32 __tanf32 (_Float32 __x) throw (); extern _Float32 coshf32 (_Float32 __x) throw (); extern _Float32 __coshf32 (_Float32 __x) throw (); extern _Float32 sinhf32 (_Float32 __x) throw (); extern _Float32 __sinhf32 (_Float32 __x) throw (); extern _Float32 tanhf32 (_Float32 __x) throw (); extern _Float32 __tanhf32 (_Float32 __x) throw (); extern void sincosf32 (_Float32 __x, _Float32 *__sinx, _Float32 *__cosx) throw (); extern void __sincosf32 (_Float32 __x, _Float32 *__sinx, _Float32 *__cosx) throw () ; extern _Float32 acoshf32 (_Float32 __x) throw (); extern _Float32 __acoshf32 (_Float32 __x) throw (); extern _Float32 asinhf32 (_Float32 __x) throw (); extern _Float32 __asinhf32 (_Float32 __x) throw (); extern _Float32 atanhf32 (_Float32 __x) throw (); extern _Float32 __atanhf32 (_Float32 __x) throw (); extern _Float32 expf32 (_Float32 __x) throw (); extern _Float32 __expf32 (_Float32 __x) throw (); extern _Float32 frexpf32 (_Float32 __x, int *__exponent) throw (); extern _Float32 __frexpf32 (_Float32 __x, int *__exponent) throw (); extern _Float32 ldexpf32 (_Float32 __x, int __exponent) throw (); extern _Float32 __ldexpf32 (_Float32 __x, int __exponent) throw (); extern _Float32 logf32 (_Float32 __x) throw (); extern _Float32 __logf32 (_Float32 __x) throw (); extern _Float32 log10f32 (_Float32 __x) throw (); extern _Float32 __log10f32 (_Float32 __x) throw (); extern _Float32 modff32 (_Float32 __x, _Float32 *__iptr) throw (); extern _Float32 __modff32 (_Float32 __x, _Float32 *__iptr) throw () __attribute__ ((__nonnull__ (2))); extern _Float32 exp10f32 (_Float32 __x) throw (); extern _Float32 __exp10f32 (_Float32 __x) throw (); extern _Float32 expm1f32 (_Float32 __x) throw (); extern _Float32 __expm1f32 (_Float32 __x) throw (); extern _Float32 log1pf32 (_Float32 __x) throw (); extern _Float32 __log1pf32 (_Float32 __x) throw (); extern _Float32 logbf32 (_Float32 __x) throw (); extern _Float32 __logbf32 (_Float32 __x) throw (); extern _Float32 exp2f32 (_Float32 __x) throw (); extern _Float32 __exp2f32 (_Float32 __x) throw (); extern _Float32 log2f32 (_Float32 __x) throw (); extern _Float32 __log2f32 (_Float32 __x) throw (); extern _Float32 powf32 (_Float32 __x, _Float32 __y) throw (); extern _Float32 __powf32 (_Float32 __x, _Float32 __y) throw (); extern _Float32 sqrtf32 (_Float32 __x) throw (); extern _Float32 __sqrtf32 (_Float32 __x) throw (); extern _Float32 hypotf32 (_Float32 __x, _Float32 __y) throw (); extern _Float32 __hypotf32 (_Float32 __x, _Float32 __y) throw (); extern _Float32 cbrtf32 (_Float32 __x) throw (); extern _Float32 __cbrtf32 (_Float32 __x) throw (); extern _Float32 ceilf32 (_Float32 __x) throw () __attribute__ ((__const__)); extern _Float32 __ceilf32 (_Float32 __x) throw () __attribute__ ((__const__)); extern _Float32 fabsf32 (_Float32 __x) throw () __attribute__ ((__const__)); extern _Float32 __fabsf32 (_Float32 __x) throw () __attribute__ ((__const__)); extern _Float32 floorf32 (_Float32 __x) throw () __attribute__ ((__const__)); extern _Float32 __floorf32 (_Float32 __x) throw () __attribute__ ((__const__)); extern _Float32 fmodf32 (_Float32 __x, _Float32 __y) throw (); extern _Float32 __fmodf32 (_Float32 __x, _Float32 __y) throw (); extern _Float32 copysignf32 (_Float32 __x, _Float32 __y) throw () __attribute__ ((__const__)); extern _Float32 __copysignf32 (_Float32 __x, _Float32 __y) throw () __attribute__ ((__const__)); extern _Float32 nanf32 (const char *__tagb) throw (); extern _Float32 __nanf32 (const char *__tagb) throw (); extern _Float32 j0f32 (_Float32) throw (); extern _Float32 __j0f32 (_Float32) throw (); extern _Float32 j1f32 (_Float32) throw (); extern _Float32 __j1f32 (_Float32) throw (); extern _Float32 jnf32 (int, _Float32) throw (); extern _Float32 __jnf32 (int, _Float32) throw (); extern _Float32 y0f32 (_Float32) throw (); extern _Float32 __y0f32 (_Float32) throw (); extern _Float32 y1f32 (_Float32) throw (); extern _Float32 __y1f32 (_Float32) throw (); extern _Float32 ynf32 (int, _Float32) throw (); extern _Float32 __ynf32 (int, _Float32) throw (); extern _Float32 erff32 (_Float32) throw (); extern _Float32 __erff32 (_Float32) throw (); extern _Float32 erfcf32 (_Float32) throw (); extern _Float32 __erfcf32 (_Float32) throw (); extern _Float32 lgammaf32 (_Float32) throw (); extern _Float32 __lgammaf32 (_Float32) throw (); extern _Float32 tgammaf32 (_Float32) throw (); extern _Float32 __tgammaf32 (_Float32) throw (); extern _Float32 lgammaf32_r (_Float32, int *__signgamp) throw (); extern _Float32 __lgammaf32_r (_Float32, int *__signgamp) throw (); extern _Float32 rintf32 (_Float32 __x) throw (); extern _Float32 __rintf32 (_Float32 __x) throw (); extern _Float32 nextafterf32 (_Float32 __x, _Float32 __y) throw (); extern _Float32 __nextafterf32 (_Float32 __x, _Float32 __y) throw (); extern _Float32 nextdownf32 (_Float32 __x) throw (); extern _Float32 __nextdownf32 (_Float32 __x) throw (); extern _Float32 nextupf32 (_Float32 __x) throw (); extern _Float32 __nextupf32 (_Float32 __x) throw (); extern _Float32 remainderf32 (_Float32 __x, _Float32 __y) throw (); extern _Float32 __remainderf32 (_Float32 __x, _Float32 __y) throw (); extern _Float32 scalbnf32 (_Float32 __x, int __n) throw (); extern _Float32 __scalbnf32 (_Float32 __x, int __n) throw (); extern int ilogbf32 (_Float32 __x) throw (); extern int __ilogbf32 (_Float32 __x) throw (); extern long int llogbf32 (_Float32 __x) throw (); extern long int __llogbf32 (_Float32 __x) throw (); extern _Float32 scalblnf32 (_Float32 __x, long int __n) throw (); extern _Float32 __scalblnf32 (_Float32 __x, long int __n) throw (); extern _Float32 nearbyintf32 (_Float32 __x) throw (); extern _Float32 __nearbyintf32 (_Float32 __x) throw (); extern _Float32 roundf32 (_Float32 __x) throw () __attribute__ ((__const__)); extern _Float32 __roundf32 (_Float32 __x) throw () __attribute__ ((__const__)); extern _Float32 truncf32 (_Float32 __x) throw () __attribute__ ((__const__)); extern _Float32 __truncf32 (_Float32 __x) throw () __attribute__ ((__const__)); extern _Float32 remquof32 (_Float32 __x, _Float32 __y, int *__quo) throw (); extern _Float32 __remquof32 (_Float32 __x, _Float32 __y, int *__quo) throw (); extern long int lrintf32 (_Float32 __x) throw (); extern long int __lrintf32 (_Float32 __x) throw (); __extension__ extern long long int llrintf32 (_Float32 __x) throw (); extern long long int __llrintf32 (_Float32 __x) throw (); extern long int lroundf32 (_Float32 __x) throw (); extern long int __lroundf32 (_Float32 __x) throw (); __extension__ extern long long int llroundf32 (_Float32 __x) throw (); extern long long int __llroundf32 (_Float32 __x) throw (); extern _Float32 fdimf32 (_Float32 __x, _Float32 __y) throw (); extern _Float32 __fdimf32 (_Float32 __x, _Float32 __y) throw (); extern _Float32 fmaxf32 (_Float32 __x, _Float32 __y) throw () __attribute__ ((__const__)); extern _Float32 __fmaxf32 (_Float32 __x, _Float32 __y) throw () __attribute__ ((__const__)); extern _Float32 fminf32 (_Float32 __x, _Float32 __y) throw () __attribute__ ((__const__)); extern _Float32 __fminf32 (_Float32 __x, _Float32 __y) throw () __attribute__ ((__const__)); extern _Float32 fmaf32 (_Float32 __x, _Float32 __y, _Float32 __z) throw (); extern _Float32 __fmaf32 (_Float32 __x, _Float32 __y, _Float32 __z) throw (); extern _Float32 roundevenf32 (_Float32 __x) throw () __attribute__ ((__const__)); extern _Float32 __roundevenf32 (_Float32 __x) throw () __attribute__ ((__const__)); extern __intmax_t fromfpf32 (_Float32 __x, int __round, unsigned int __width) throw (); extern __intmax_t __fromfpf32 (_Float32 __x, int __round, unsigned int __width) throw () ; extern __uintmax_t ufromfpf32 (_Float32 __x, int __round, unsigned int __width) throw (); extern __uintmax_t __ufromfpf32 (_Float32 __x, int __round, unsigned int __width) throw () ; extern __intmax_t fromfpxf32 (_Float32 __x, int __round, unsigned int __width) throw (); extern __intmax_t __fromfpxf32 (_Float32 __x, int __round, unsigned int __width) throw () ; extern __uintmax_t ufromfpxf32 (_Float32 __x, int __round, unsigned int __width) throw (); extern __uintmax_t __ufromfpxf32 (_Float32 __x, int __round, unsigned int __width) throw () ; extern _Float32 fmaxmagf32 (_Float32 __x, _Float32 __y) throw () __attribute__ ((__const__)); extern _Float32 __fmaxmagf32 (_Float32 __x, _Float32 __y) throw () __attribute__ ((__const__)); extern _Float32 fminmagf32 (_Float32 __x, _Float32 __y) throw () __attribute__ ((__const__)); extern _Float32 __fminmagf32 (_Float32 __x, _Float32 __y) throw () __attribute__ ((__const__)); extern int canonicalizef32 (_Float32 *__cx, const _Float32 *__x) throw (); extern int totalorderf32 (const _Float32 *__x, const _Float32 *__y) throw () __attribute__ ((__pure__)); extern int totalordermagf32 (const _Float32 *__x, const _Float32 *__y) throw () __attribute__ ((__pure__)); extern _Float32 getpayloadf32 (const _Float32 *__x) throw (); extern _Float32 __getpayloadf32 (const _Float32 *__x) throw (); extern int setpayloadf32 (_Float32 *__x, _Float32 __payload) throw (); extern int setpayloadsigf32 (_Float32 *__x, _Float32 __payload) throw (); extern _Float64 acosf64 (_Float64 __x) throw (); extern _Float64 __acosf64 (_Float64 __x) throw (); extern _Float64 asinf64 (_Float64 __x) throw (); extern _Float64 __asinf64 (_Float64 __x) throw (); extern _Float64 atanf64 (_Float64 __x) throw (); extern _Float64 __atanf64 (_Float64 __x) throw (); extern _Float64 atan2f64 (_Float64 __y, _Float64 __x) throw (); extern _Float64 __atan2f64 (_Float64 __y, _Float64 __x) throw (); extern _Float64 cosf64 (_Float64 __x) throw (); extern _Float64 __cosf64 (_Float64 __x) throw (); extern _Float64 sinf64 (_Float64 __x) throw (); extern _Float64 __sinf64 (_Float64 __x) throw (); extern _Float64 tanf64 (_Float64 __x) throw (); extern _Float64 __tanf64 (_Float64 __x) throw (); extern _Float64 coshf64 (_Float64 __x) throw (); extern _Float64 __coshf64 (_Float64 __x) throw (); extern _Float64 sinhf64 (_Float64 __x) throw (); extern _Float64 __sinhf64 (_Float64 __x) throw (); extern _Float64 tanhf64 (_Float64 __x) throw (); extern _Float64 __tanhf64 (_Float64 __x) throw (); extern void sincosf64 (_Float64 __x, _Float64 *__sinx, _Float64 *__cosx) throw (); extern void __sincosf64 (_Float64 __x, _Float64 *__sinx, _Float64 *__cosx) throw () ; extern _Float64 acoshf64 (_Float64 __x) throw (); extern _Float64 __acoshf64 (_Float64 __x) throw (); extern _Float64 asinhf64 (_Float64 __x) throw (); extern _Float64 __asinhf64 (_Float64 __x) throw (); extern _Float64 atanhf64 (_Float64 __x) throw (); extern _Float64 __atanhf64 (_Float64 __x) throw (); extern _Float64 expf64 (_Float64 __x) throw (); extern _Float64 __expf64 (_Float64 __x) throw (); extern _Float64 frexpf64 (_Float64 __x, int *__exponent) throw (); extern _Float64 __frexpf64 (_Float64 __x, int *__exponent) throw (); extern _Float64 ldexpf64 (_Float64 __x, int __exponent) throw (); extern _Float64 __ldexpf64 (_Float64 __x, int __exponent) throw (); extern _Float64 logf64 (_Float64 __x) throw (); extern _Float64 __logf64 (_Float64 __x) throw (); extern _Float64 log10f64 (_Float64 __x) throw (); extern _Float64 __log10f64 (_Float64 __x) throw (); extern _Float64 modff64 (_Float64 __x, _Float64 *__iptr) throw (); extern _Float64 __modff64 (_Float64 __x, _Float64 *__iptr) throw () __attribute__ ((__nonnull__ (2))); extern _Float64 exp10f64 (_Float64 __x) throw (); extern _Float64 __exp10f64 (_Float64 __x) throw (); extern _Float64 expm1f64 (_Float64 __x) throw (); extern _Float64 __expm1f64 (_Float64 __x) throw (); extern _Float64 log1pf64 (_Float64 __x) throw (); extern _Float64 __log1pf64 (_Float64 __x) throw (); extern _Float64 logbf64 (_Float64 __x) throw (); extern _Float64 __logbf64 (_Float64 __x) throw (); extern _Float64 exp2f64 (_Float64 __x) throw (); extern _Float64 __exp2f64 (_Float64 __x) throw (); extern _Float64 log2f64 (_Float64 __x) throw (); extern _Float64 __log2f64 (_Float64 __x) throw (); extern _Float64 powf64 (_Float64 __x, _Float64 __y) throw (); extern _Float64 __powf64 (_Float64 __x, _Float64 __y) throw (); extern _Float64 sqrtf64 (_Float64 __x) throw (); extern _Float64 __sqrtf64 (_Float64 __x) throw (); extern _Float64 hypotf64 (_Float64 __x, _Float64 __y) throw (); extern _Float64 __hypotf64 (_Float64 __x, _Float64 __y) throw (); extern _Float64 cbrtf64 (_Float64 __x) throw (); extern _Float64 __cbrtf64 (_Float64 __x) throw (); extern _Float64 ceilf64 (_Float64 __x) throw () __attribute__ ((__const__)); extern _Float64 __ceilf64 (_Float64 __x) throw () __attribute__ ((__const__)); extern _Float64 fabsf64 (_Float64 __x) throw () __attribute__ ((__const__)); extern _Float64 __fabsf64 (_Float64 __x) throw () __attribute__ ((__const__)); extern _Float64 floorf64 (_Float64 __x) throw () __attribute__ ((__const__)); extern _Float64 __floorf64 (_Float64 __x) throw () __attribute__ ((__const__)); extern _Float64 fmodf64 (_Float64 __x, _Float64 __y) throw (); extern _Float64 __fmodf64 (_Float64 __x, _Float64 __y) throw (); extern _Float64 copysignf64 (_Float64 __x, _Float64 __y) throw () __attribute__ ((__const__)); extern _Float64 __copysignf64 (_Float64 __x, _Float64 __y) throw () __attribute__ ((__const__)); extern _Float64 nanf64 (const char *__tagb) throw (); extern _Float64 __nanf64 (const char *__tagb) throw (); extern _Float64 j0f64 (_Float64) throw (); extern _Float64 __j0f64 (_Float64) throw (); extern _Float64 j1f64 (_Float64) throw (); extern _Float64 __j1f64 (_Float64) throw (); extern _Float64 jnf64 (int, _Float64) throw (); extern _Float64 __jnf64 (int, _Float64) throw (); extern _Float64 y0f64 (_Float64) throw (); extern _Float64 __y0f64 (_Float64) throw (); extern _Float64 y1f64 (_Float64) throw (); extern _Float64 __y1f64 (_Float64) throw (); extern _Float64 ynf64 (int, _Float64) throw (); extern _Float64 __ynf64 (int, _Float64) throw (); extern _Float64 erff64 (_Float64) throw (); extern _Float64 __erff64 (_Float64) throw (); extern _Float64 erfcf64 (_Float64) throw (); extern _Float64 __erfcf64 (_Float64) throw (); extern _Float64 lgammaf64 (_Float64) throw (); extern _Float64 __lgammaf64 (_Float64) throw (); extern _Float64 tgammaf64 (_Float64) throw (); extern _Float64 __tgammaf64 (_Float64) throw (); extern _Float64 lgammaf64_r (_Float64, int *__signgamp) throw (); extern _Float64 __lgammaf64_r (_Float64, int *__signgamp) throw (); extern _Float64 rintf64 (_Float64 __x) throw (); extern _Float64 __rintf64 (_Float64 __x) throw (); extern _Float64 nextafterf64 (_Float64 __x, _Float64 __y) throw (); extern _Float64 __nextafterf64 (_Float64 __x, _Float64 __y) throw (); extern _Float64 nextdownf64 (_Float64 __x) throw (); extern _Float64 __nextdownf64 (_Float64 __x) throw (); extern _Float64 nextupf64 (_Float64 __x) throw (); extern _Float64 __nextupf64 (_Float64 __x) throw (); extern _Float64 remainderf64 (_Float64 __x, _Float64 __y) throw (); extern _Float64 __remainderf64 (_Float64 __x, _Float64 __y) throw (); extern _Float64 scalbnf64 (_Float64 __x, int __n) throw (); extern _Float64 __scalbnf64 (_Float64 __x, int __n) throw (); extern int ilogbf64 (_Float64 __x) throw (); extern int __ilogbf64 (_Float64 __x) throw (); extern long int llogbf64 (_Float64 __x) throw (); extern long int __llogbf64 (_Float64 __x) throw (); extern _Float64 scalblnf64 (_Float64 __x, long int __n) throw (); extern _Float64 __scalblnf64 (_Float64 __x, long int __n) throw (); extern _Float64 nearbyintf64 (_Float64 __x) throw (); extern _Float64 __nearbyintf64 (_Float64 __x) throw (); extern _Float64 roundf64 (_Float64 __x) throw () __attribute__ ((__const__)); extern _Float64 __roundf64 (_Float64 __x) throw () __attribute__ ((__const__)); extern _Float64 truncf64 (_Float64 __x) throw () __attribute__ ((__const__)); extern _Float64 __truncf64 (_Float64 __x) throw () __attribute__ ((__const__)); extern _Float64 remquof64 (_Float64 __x, _Float64 __y, int *__quo) throw (); extern _Float64 __remquof64 (_Float64 __x, _Float64 __y, int *__quo) throw (); extern long int lrintf64 (_Float64 __x) throw (); extern long int __lrintf64 (_Float64 __x) throw (); __extension__ extern long long int llrintf64 (_Float64 __x) throw (); extern long long int __llrintf64 (_Float64 __x) throw (); extern long int lroundf64 (_Float64 __x) throw (); extern long int __lroundf64 (_Float64 __x) throw (); __extension__ extern long long int llroundf64 (_Float64 __x) throw (); extern long long int __llroundf64 (_Float64 __x) throw (); extern _Float64 fdimf64 (_Float64 __x, _Float64 __y) throw (); extern _Float64 __fdimf64 (_Float64 __x, _Float64 __y) throw (); extern _Float64 fmaxf64 (_Float64 __x, _Float64 __y) throw () __attribute__ ((__const__)); extern _Float64 __fmaxf64 (_Float64 __x, _Float64 __y) throw () __attribute__ ((__const__)); extern _Float64 fminf64 (_Float64 __x, _Float64 __y) throw () __attribute__ ((__const__)); extern _Float64 __fminf64 (_Float64 __x, _Float64 __y) throw () __attribute__ ((__const__)); extern _Float64 fmaf64 (_Float64 __x, _Float64 __y, _Float64 __z) throw (); extern _Float64 __fmaf64 (_Float64 __x, _Float64 __y, _Float64 __z) throw (); extern _Float64 roundevenf64 (_Float64 __x) throw () __attribute__ ((__const__)); extern _Float64 __roundevenf64 (_Float64 __x) throw () __attribute__ ((__const__)); extern __intmax_t fromfpf64 (_Float64 __x, int __round, unsigned int __width) throw (); extern __intmax_t __fromfpf64 (_Float64 __x, int __round, unsigned int __width) throw () ; extern __uintmax_t ufromfpf64 (_Float64 __x, int __round, unsigned int __width) throw (); extern __uintmax_t __ufromfpf64 (_Float64 __x, int __round, unsigned int __width) throw () ; extern __intmax_t fromfpxf64 (_Float64 __x, int __round, unsigned int __width) throw (); extern __intmax_t __fromfpxf64 (_Float64 __x, int __round, unsigned int __width) throw () ; extern __uintmax_t ufromfpxf64 (_Float64 __x, int __round, unsigned int __width) throw (); extern __uintmax_t __ufromfpxf64 (_Float64 __x, int __round, unsigned int __width) throw () ; extern _Float64 fmaxmagf64 (_Float64 __x, _Float64 __y) throw () __attribute__ ((__const__)); extern _Float64 __fmaxmagf64 (_Float64 __x, _Float64 __y) throw () __attribute__ ((__const__)); extern _Float64 fminmagf64 (_Float64 __x, _Float64 __y) throw () __attribute__ ((__const__)); extern _Float64 __fminmagf64 (_Float64 __x, _Float64 __y) throw () __attribute__ ((__const__)); extern int canonicalizef64 (_Float64 *__cx, const _Float64 *__x) throw (); extern int totalorderf64 (const _Float64 *__x, const _Float64 *__y) throw () __attribute__ ((__pure__)); extern int totalordermagf64 (const _Float64 *__x, const _Float64 *__y) throw () __attribute__ ((__pure__)); extern _Float64 getpayloadf64 (const _Float64 *__x) throw (); extern _Float64 __getpayloadf64 (const _Float64 *__x) throw (); extern int setpayloadf64 (_Float64 *__x, _Float64 __payload) throw (); extern int setpayloadsigf64 (_Float64 *__x, _Float64 __payload) throw (); extern int __fpclassifyf128 (_Float128 __value) throw () __attribute__ ((__const__)); extern int __signbitf128 (_Float128 __value) throw () __attribute__ ((__const__)); extern int __isinff128 (_Float128 __value) throw () __attribute__ ((__const__)); extern int __finitef128 (_Float128 __value) throw () __attribute__ ((__const__)); extern int __isnanf128 (_Float128 __value) throw () __attribute__ ((__const__)); extern int __iseqsigf128 (_Float128 __x, _Float128 __y) throw (); extern int __issignalingf128 (_Float128 __value) throw () __attribute__ ((__const__)); extern _Float128 acosf128 (_Float128 __x) throw (); extern _Float128 __acosf128 (_Float128 __x) throw (); extern _Float128 asinf128 (_Float128 __x) throw (); extern _Float128 __asinf128 (_Float128 __x) throw (); extern _Float128 atanf128 (_Float128 __x) throw (); extern _Float128 __atanf128 (_Float128 __x) throw (); extern _Float128 atan2f128 (_Float128 __y, _Float128 __x) throw (); extern _Float128 __atan2f128 (_Float128 __y, _Float128 __x) throw (); extern _Float128 cosf128 (_Float128 __x) throw (); extern _Float128 __cosf128 (_Float128 __x) throw (); extern _Float128 sinf128 (_Float128 __x) throw (); extern _Float128 __sinf128 (_Float128 __x) throw (); extern _Float128 tanf128 (_Float128 __x) throw (); extern _Float128 __tanf128 (_Float128 __x) throw (); extern _Float128 coshf128 (_Float128 __x) throw (); extern _Float128 __coshf128 (_Float128 __x) throw (); extern _Float128 sinhf128 (_Float128 __x) throw (); extern _Float128 __sinhf128 (_Float128 __x) throw (); extern _Float128 tanhf128 (_Float128 __x) throw (); extern _Float128 __tanhf128 (_Float128 __x) throw (); extern void sincosf128 (_Float128 __x, _Float128 *__sinx, _Float128 *__cosx) throw (); extern void __sincosf128 (_Float128 __x, _Float128 *__sinx, _Float128 *__cosx) throw () ; extern _Float128 acoshf128 (_Float128 __x) throw (); extern _Float128 __acoshf128 (_Float128 __x) throw (); extern _Float128 asinhf128 (_Float128 __x) throw (); extern _Float128 __asinhf128 (_Float128 __x) throw (); extern _Float128 atanhf128 (_Float128 __x) throw (); extern _Float128 __atanhf128 (_Float128 __x) throw (); extern _Float128 expf128 (_Float128 __x) throw (); extern _Float128 __expf128 (_Float128 __x) throw (); extern _Float128 frexpf128 (_Float128 __x, int *__exponent) throw (); extern _Float128 __frexpf128 (_Float128 __x, int *__exponent) throw (); extern _Float128 ldexpf128 (_Float128 __x, int __exponent) throw (); extern _Float128 __ldexpf128 (_Float128 __x, int __exponent) throw (); extern _Float128 logf128 (_Float128 __x) throw (); extern _Float128 __logf128 (_Float128 __x) throw (); extern _Float128 log10f128 (_Float128 __x) throw (); extern _Float128 __log10f128 (_Float128 __x) throw (); extern _Float128 modff128 (_Float128 __x, _Float128 *__iptr) throw (); extern _Float128 __modff128 (_Float128 __x, _Float128 *__iptr) throw () __attribute__ ((__nonnull__ (2))); extern _Float128 exp10f128 (_Float128 __x) throw (); extern _Float128 __exp10f128 (_Float128 __x) throw (); extern _Float128 expm1f128 (_Float128 __x) throw (); extern _Float128 __expm1f128 (_Float128 __x) throw (); extern _Float128 log1pf128 (_Float128 __x) throw (); extern _Float128 __log1pf128 (_Float128 __x) throw (); extern _Float128 logbf128 (_Float128 __x) throw (); extern _Float128 __logbf128 (_Float128 __x) throw (); extern _Float128 exp2f128 (_Float128 __x) throw (); extern _Float128 __exp2f128 (_Float128 __x) throw (); extern _Float128 log2f128 (_Float128 __x) throw (); extern _Float128 __log2f128 (_Float128 __x) throw (); extern _Float128 powf128 (_Float128 __x, _Float128 __y) throw (); extern _Float128 __powf128 (_Float128 __x, _Float128 __y) throw (); extern _Float128 sqrtf128 (_Float128 __x) throw (); extern _Float128 __sqrtf128 (_Float128 __x) throw (); extern _Float128 hypotf128 (_Float128 __x, _Float128 __y) throw (); extern _Float128 __hypotf128 (_Float128 __x, _Float128 __y) throw (); extern _Float128 cbrtf128 (_Float128 __x) throw (); extern _Float128 __cbrtf128 (_Float128 __x) throw (); extern _Float128 ceilf128 (_Float128 __x) throw () __attribute__ ((__const__)); extern _Float128 __ceilf128 (_Float128 __x) throw () __attribute__ ((__const__)); extern _Float128 fabsf128 (_Float128 __x) throw () __attribute__ ((__const__)); extern _Float128 __fabsf128 (_Float128 __x) throw () __attribute__ ((__const__)); extern _Float128 floorf128 (_Float128 __x) throw () __attribute__ ((__const__)); extern _Float128 __floorf128 (_Float128 __x) throw () __attribute__ ((__const__)); extern _Float128 fmodf128 (_Float128 __x, _Float128 __y) throw (); extern _Float128 __fmodf128 (_Float128 __x, _Float128 __y) throw (); extern _Float128 copysignf128 (_Float128 __x, _Float128 __y) throw () __attribute__ ((__const__)); extern _Float128 __copysignf128 (_Float128 __x, _Float128 __y) throw () __attribute__ ((__const__)); extern _Float128 nanf128 (const char *__tagb) throw (); extern _Float128 __nanf128 (const char *__tagb) throw (); extern _Float128 j0f128 (_Float128) throw (); extern _Float128 __j0f128 (_Float128) throw (); extern _Float128 j1f128 (_Float128) throw (); extern _Float128 __j1f128 (_Float128) throw (); extern _Float128 jnf128 (int, _Float128) throw (); extern _Float128 __jnf128 (int, _Float128) throw (); extern _Float128 y0f128 (_Float128) throw (); extern _Float128 __y0f128 (_Float128) throw (); extern _Float128 y1f128 (_Float128) throw (); extern _Float128 __y1f128 (_Float128) throw (); extern _Float128 ynf128 (int, _Float128) throw (); extern _Float128 __ynf128 (int, _Float128) throw (); extern _Float128 erff128 (_Float128) throw (); extern _Float128 __erff128 (_Float128) throw (); extern _Float128 erfcf128 (_Float128) throw (); extern _Float128 __erfcf128 (_Float128) throw (); extern _Float128 lgammaf128 (_Float128) throw (); extern _Float128 __lgammaf128 (_Float128) throw (); extern _Float128 tgammaf128 (_Float128) throw (); extern _Float128 __tgammaf128 (_Float128) throw (); extern _Float128 lgammaf128_r (_Float128, int *__signgamp) throw (); extern _Float128 __lgammaf128_r (_Float128, int *__signgamp) throw (); extern _Float128 rintf128 (_Float128 __x) throw (); extern _Float128 __rintf128 (_Float128 __x) throw (); extern _Float128 nextafterf128 (_Float128 __x, _Float128 __y) throw (); extern _Float128 __nextafterf128 (_Float128 __x, _Float128 __y) throw (); extern _Float128 nextdownf128 (_Float128 __x) throw (); extern _Float128 __nextdownf128 (_Float128 __x) throw (); extern _Float128 nextupf128 (_Float128 __x) throw (); extern _Float128 __nextupf128 (_Float128 __x) throw (); extern _Float128 remainderf128 (_Float128 __x, _Float128 __y) throw (); extern _Float128 __remainderf128 (_Float128 __x, _Float128 __y) throw (); extern _Float128 scalbnf128 (_Float128 __x, int __n) throw (); extern _Float128 __scalbnf128 (_Float128 __x, int __n) throw (); extern int ilogbf128 (_Float128 __x) throw (); extern int __ilogbf128 (_Float128 __x) throw (); extern long int llogbf128 (_Float128 __x) throw (); extern long int __llogbf128 (_Float128 __x) throw (); extern _Float128 scalblnf128 (_Float128 __x, long int __n) throw (); extern _Float128 __scalblnf128 (_Float128 __x, long int __n) throw (); extern _Float128 nearbyintf128 (_Float128 __x) throw (); extern _Float128 __nearbyintf128 (_Float128 __x) throw (); extern _Float128 roundf128 (_Float128 __x) throw () __attribute__ ((__const__)); extern _Float128 __roundf128 (_Float128 __x) throw () __attribute__ ((__const__)); extern _Float128 truncf128 (_Float128 __x) throw () __attribute__ ((__const__)); extern _Float128 __truncf128 (_Float128 __x) throw () __attribute__ ((__const__)); extern _Float128 remquof128 (_Float128 __x, _Float128 __y, int *__quo) throw (); extern _Float128 __remquof128 (_Float128 __x, _Float128 __y, int *__quo) throw (); extern long int lrintf128 (_Float128 __x) throw (); extern long int __lrintf128 (_Float128 __x) throw (); __extension__ extern long long int llrintf128 (_Float128 __x) throw (); extern long long int __llrintf128 (_Float128 __x) throw (); extern long int lroundf128 (_Float128 __x) throw (); extern long int __lroundf128 (_Float128 __x) throw (); __extension__ extern long long int llroundf128 (_Float128 __x) throw (); extern long long int __llroundf128 (_Float128 __x) throw (); extern _Float128 fdimf128 (_Float128 __x, _Float128 __y) throw (); extern _Float128 __fdimf128 (_Float128 __x, _Float128 __y) throw (); extern _Float128 fmaxf128 (_Float128 __x, _Float128 __y) throw () __attribute__ ((__const__)); extern _Float128 __fmaxf128 (_Float128 __x, _Float128 __y) throw () __attribute__ ((__const__)); extern _Float128 fminf128 (_Float128 __x, _Float128 __y) throw () __attribute__ ((__const__)); extern _Float128 __fminf128 (_Float128 __x, _Float128 __y) throw () __attribute__ ((__const__)); extern _Float128 fmaf128 (_Float128 __x, _Float128 __y, _Float128 __z) throw (); extern _Float128 __fmaf128 (_Float128 __x, _Float128 __y, _Float128 __z) throw (); extern _Float128 roundevenf128 (_Float128 __x) throw () __attribute__ ((__const__)); extern _Float128 __roundevenf128 (_Float128 __x) throw () __attribute__ ((__const__)); extern __intmax_t fromfpf128 (_Float128 __x, int __round, unsigned int __width) throw (); extern __intmax_t __fromfpf128 (_Float128 __x, int __round, unsigned int __width) throw () ; extern __uintmax_t ufromfpf128 (_Float128 __x, int __round, unsigned int __width) throw (); extern __uintmax_t __ufromfpf128 (_Float128 __x, int __round, unsigned int __width) throw () ; extern __intmax_t fromfpxf128 (_Float128 __x, int __round, unsigned int __width) throw (); extern __intmax_t __fromfpxf128 (_Float128 __x, int __round, unsigned int __width) throw () ; extern __uintmax_t ufromfpxf128 (_Float128 __x, int __round, unsigned int __width) throw (); extern __uintmax_t __ufromfpxf128 (_Float128 __x, int __round, unsigned int __width) throw () ; extern _Float128 fmaxmagf128 (_Float128 __x, _Float128 __y) throw () __attribute__ ((__const__)); extern _Float128 __fmaxmagf128 (_Float128 __x, _Float128 __y) throw () __attribute__ ((__const__)); extern _Float128 fminmagf128 (_Float128 __x, _Float128 __y) throw () __attribute__ ((__const__)); extern _Float128 __fminmagf128 (_Float128 __x, _Float128 __y) throw () __attribute__ ((__const__)); extern int canonicalizef128 (_Float128 *__cx, const _Float128 *__x) throw (); extern int totalorderf128 (const _Float128 *__x, const _Float128 *__y) throw () __attribute__ ((__pure__)); extern int totalordermagf128 (const _Float128 *__x, const _Float128 *__y) throw () __attribute__ ((__pure__)); extern _Float128 getpayloadf128 (const _Float128 *__x) throw (); extern _Float128 __getpayloadf128 (const _Float128 *__x) throw (); extern int setpayloadf128 (_Float128 *__x, _Float128 __payload) throw (); extern int setpayloadsigf128 (_Float128 *__x, _Float128 __payload) throw (); extern _Float32x acosf32x (_Float32x __x) throw (); extern _Float32x __acosf32x (_Float32x __x) throw (); extern _Float32x asinf32x (_Float32x __x) throw (); extern _Float32x __asinf32x (_Float32x __x) throw (); extern _Float32x atanf32x (_Float32x __x) throw (); extern _Float32x __atanf32x (_Float32x __x) throw (); extern _Float32x atan2f32x (_Float32x __y, _Float32x __x) throw (); extern _Float32x __atan2f32x (_Float32x __y, _Float32x __x) throw (); extern _Float32x cosf32x (_Float32x __x) throw (); extern _Float32x __cosf32x (_Float32x __x) throw (); extern _Float32x sinf32x (_Float32x __x) throw (); extern _Float32x __sinf32x (_Float32x __x) throw (); extern _Float32x tanf32x (_Float32x __x) throw (); extern _Float32x __tanf32x (_Float32x __x) throw (); extern _Float32x coshf32x (_Float32x __x) throw (); extern _Float32x __coshf32x (_Float32x __x) throw (); extern _Float32x sinhf32x (_Float32x __x) throw (); extern _Float32x __sinhf32x (_Float32x __x) throw (); extern _Float32x tanhf32x (_Float32x __x) throw (); extern _Float32x __tanhf32x (_Float32x __x) throw (); extern void sincosf32x (_Float32x __x, _Float32x *__sinx, _Float32x *__cosx) throw (); extern void __sincosf32x (_Float32x __x, _Float32x *__sinx, _Float32x *__cosx) throw () ; extern _Float32x acoshf32x (_Float32x __x) throw (); extern _Float32x __acoshf32x (_Float32x __x) throw (); extern _Float32x asinhf32x (_Float32x __x) throw (); extern _Float32x __asinhf32x (_Float32x __x) throw (); extern _Float32x atanhf32x (_Float32x __x) throw (); extern _Float32x __atanhf32x (_Float32x __x) throw (); extern _Float32x expf32x (_Float32x __x) throw (); extern _Float32x __expf32x (_Float32x __x) throw (); extern _Float32x frexpf32x (_Float32x __x, int *__exponent) throw (); extern _Float32x __frexpf32x (_Float32x __x, int *__exponent) throw (); extern _Float32x ldexpf32x (_Float32x __x, int __exponent) throw (); extern _Float32x __ldexpf32x (_Float32x __x, int __exponent) throw (); extern _Float32x logf32x (_Float32x __x) throw (); extern _Float32x __logf32x (_Float32x __x) throw (); extern _Float32x log10f32x (_Float32x __x) throw (); extern _Float32x __log10f32x (_Float32x __x) throw (); extern _Float32x modff32x (_Float32x __x, _Float32x *__iptr) throw (); extern _Float32x __modff32x (_Float32x __x, _Float32x *__iptr) throw () __attribute__ ((__nonnull__ (2))); extern _Float32x exp10f32x (_Float32x __x) throw (); extern _Float32x __exp10f32x (_Float32x __x) throw (); extern _Float32x expm1f32x (_Float32x __x) throw (); extern _Float32x __expm1f32x (_Float32x __x) throw (); extern _Float32x log1pf32x (_Float32x __x) throw (); extern _Float32x __log1pf32x (_Float32x __x) throw (); extern _Float32x logbf32x (_Float32x __x) throw (); extern _Float32x __logbf32x (_Float32x __x) throw (); extern _Float32x exp2f32x (_Float32x __x) throw (); extern _Float32x __exp2f32x (_Float32x __x) throw (); extern _Float32x log2f32x (_Float32x __x) throw (); extern _Float32x __log2f32x (_Float32x __x) throw (); extern _Float32x powf32x (_Float32x __x, _Float32x __y) throw (); extern _Float32x __powf32x (_Float32x __x, _Float32x __y) throw (); extern _Float32x sqrtf32x (_Float32x __x) throw (); extern _Float32x __sqrtf32x (_Float32x __x) throw (); extern _Float32x hypotf32x (_Float32x __x, _Float32x __y) throw (); extern _Float32x __hypotf32x (_Float32x __x, _Float32x __y) throw (); extern _Float32x cbrtf32x (_Float32x __x) throw (); extern _Float32x __cbrtf32x (_Float32x __x) throw (); extern _Float32x ceilf32x (_Float32x __x) throw () __attribute__ ((__const__)); extern _Float32x __ceilf32x (_Float32x __x) throw () __attribute__ ((__const__)); extern _Float32x fabsf32x (_Float32x __x) throw () __attribute__ ((__const__)); extern _Float32x __fabsf32x (_Float32x __x) throw () __attribute__ ((__const__)); extern _Float32x floorf32x (_Float32x __x) throw () __attribute__ ((__const__)); extern _Float32x __floorf32x (_Float32x __x) throw () __attribute__ ((__const__)); extern _Float32x fmodf32x (_Float32x __x, _Float32x __y) throw (); extern _Float32x __fmodf32x (_Float32x __x, _Float32x __y) throw (); extern _Float32x copysignf32x (_Float32x __x, _Float32x __y) throw () __attribute__ ((__const__)); extern _Float32x __copysignf32x (_Float32x __x, _Float32x __y) throw () __attribute__ ((__const__)); extern _Float32x nanf32x (const char *__tagb) throw (); extern _Float32x __nanf32x (const char *__tagb) throw (); extern _Float32x j0f32x (_Float32x) throw (); extern _Float32x __j0f32x (_Float32x) throw (); extern _Float32x j1f32x (_Float32x) throw (); extern _Float32x __j1f32x (_Float32x) throw (); extern _Float32x jnf32x (int, _Float32x) throw (); extern _Float32x __jnf32x (int, _Float32x) throw (); extern _Float32x y0f32x (_Float32x) throw (); extern _Float32x __y0f32x (_Float32x) throw (); extern _Float32x y1f32x (_Float32x) throw (); extern _Float32x __y1f32x (_Float32x) throw (); extern _Float32x ynf32x (int, _Float32x) throw (); extern _Float32x __ynf32x (int, _Float32x) throw (); extern _Float32x erff32x (_Float32x) throw (); extern _Float32x __erff32x (_Float32x) throw (); extern _Float32x erfcf32x (_Float32x) throw (); extern _Float32x __erfcf32x (_Float32x) throw (); extern _Float32x lgammaf32x (_Float32x) throw (); extern _Float32x __lgammaf32x (_Float32x) throw (); extern _Float32x tgammaf32x (_Float32x) throw (); extern _Float32x __tgammaf32x (_Float32x) throw (); extern _Float32x lgammaf32x_r (_Float32x, int *__signgamp) throw (); extern _Float32x __lgammaf32x_r (_Float32x, int *__signgamp) throw (); extern _Float32x rintf32x (_Float32x __x) throw (); extern _Float32x __rintf32x (_Float32x __x) throw (); extern _Float32x nextafterf32x (_Float32x __x, _Float32x __y) throw (); extern _Float32x __nextafterf32x (_Float32x __x, _Float32x __y) throw (); extern _Float32x nextdownf32x (_Float32x __x) throw (); extern _Float32x __nextdownf32x (_Float32x __x) throw (); extern _Float32x nextupf32x (_Float32x __x) throw (); extern _Float32x __nextupf32x (_Float32x __x) throw (); extern _Float32x remainderf32x (_Float32x __x, _Float32x __y) throw (); extern _Float32x __remainderf32x (_Float32x __x, _Float32x __y) throw (); extern _Float32x scalbnf32x (_Float32x __x, int __n) throw (); extern _Float32x __scalbnf32x (_Float32x __x, int __n) throw (); extern int ilogbf32x (_Float32x __x) throw (); extern int __ilogbf32x (_Float32x __x) throw (); extern long int llogbf32x (_Float32x __x) throw (); extern long int __llogbf32x (_Float32x __x) throw (); extern _Float32x scalblnf32x (_Float32x __x, long int __n) throw (); extern _Float32x __scalblnf32x (_Float32x __x, long int __n) throw (); extern _Float32x nearbyintf32x (_Float32x __x) throw (); extern _Float32x __nearbyintf32x (_Float32x __x) throw (); extern _Float32x roundf32x (_Float32x __x) throw () __attribute__ ((__const__)); extern _Float32x __roundf32x (_Float32x __x) throw () __attribute__ ((__const__)); extern _Float32x truncf32x (_Float32x __x) throw () __attribute__ ((__const__)); extern _Float32x __truncf32x (_Float32x __x) throw () __attribute__ ((__const__)); extern _Float32x remquof32x (_Float32x __x, _Float32x __y, int *__quo) throw (); extern _Float32x __remquof32x (_Float32x __x, _Float32x __y, int *__quo) throw (); extern long int lrintf32x (_Float32x __x) throw (); extern long int __lrintf32x (_Float32x __x) throw (); __extension__ extern long long int llrintf32x (_Float32x __x) throw (); extern long long int __llrintf32x (_Float32x __x) throw (); extern long int lroundf32x (_Float32x __x) throw (); extern long int __lroundf32x (_Float32x __x) throw (); __extension__ extern long long int llroundf32x (_Float32x __x) throw (); extern long long int __llroundf32x (_Float32x __x) throw (); extern _Float32x fdimf32x (_Float32x __x, _Float32x __y) throw (); extern _Float32x __fdimf32x (_Float32x __x, _Float32x __y) throw (); extern _Float32x fmaxf32x (_Float32x __x, _Float32x __y) throw () __attribute__ ((__const__)); extern _Float32x __fmaxf32x (_Float32x __x, _Float32x __y) throw () __attribute__ ((__const__)); extern _Float32x fminf32x (_Float32x __x, _Float32x __y) throw () __attribute__ ((__const__)); extern _Float32x __fminf32x (_Float32x __x, _Float32x __y) throw () __attribute__ ((__const__)); extern _Float32x fmaf32x (_Float32x __x, _Float32x __y, _Float32x __z) throw (); extern _Float32x __fmaf32x (_Float32x __x, _Float32x __y, _Float32x __z) throw (); extern _Float32x roundevenf32x (_Float32x __x) throw () __attribute__ ((__const__)); extern _Float32x __roundevenf32x (_Float32x __x) throw () __attribute__ ((__const__)); extern __intmax_t fromfpf32x (_Float32x __x, int __round, unsigned int __width) throw (); extern __intmax_t __fromfpf32x (_Float32x __x, int __round, unsigned int __width) throw () ; extern __uintmax_t ufromfpf32x (_Float32x __x, int __round, unsigned int __width) throw (); extern __uintmax_t __ufromfpf32x (_Float32x __x, int __round, unsigned int __width) throw () ; extern __intmax_t fromfpxf32x (_Float32x __x, int __round, unsigned int __width) throw (); extern __intmax_t __fromfpxf32x (_Float32x __x, int __round, unsigned int __width) throw () ; extern __uintmax_t ufromfpxf32x (_Float32x __x, int __round, unsigned int __width) throw (); extern __uintmax_t __ufromfpxf32x (_Float32x __x, int __round, unsigned int __width) throw () ; extern _Float32x fmaxmagf32x (_Float32x __x, _Float32x __y) throw () __attribute__ ((__const__)); extern _Float32x __fmaxmagf32x (_Float32x __x, _Float32x __y) throw () __attribute__ ((__const__)); extern _Float32x fminmagf32x (_Float32x __x, _Float32x __y) throw () __attribute__ ((__const__)); extern _Float32x __fminmagf32x (_Float32x __x, _Float32x __y) throw () __attribute__ ((__const__)); extern int canonicalizef32x (_Float32x *__cx, const _Float32x *__x) throw (); extern int totalorderf32x (const _Float32x *__x, const _Float32x *__y) throw () __attribute__ ((__pure__)); extern int totalordermagf32x (const _Float32x *__x, const _Float32x *__y) throw () __attribute__ ((__pure__)); extern _Float32x getpayloadf32x (const _Float32x *__x) throw (); extern _Float32x __getpayloadf32x (const _Float32x *__x) throw (); extern int setpayloadf32x (_Float32x *__x, _Float32x __payload) throw (); extern int setpayloadsigf32x (_Float32x *__x, _Float32x __payload) throw (); extern _Float64x acosf64x (_Float64x __x) throw (); extern _Float64x __acosf64x (_Float64x __x) throw (); extern _Float64x asinf64x (_Float64x __x) throw (); extern _Float64x __asinf64x (_Float64x __x) throw (); extern _Float64x atanf64x (_Float64x __x) throw (); extern _Float64x __atanf64x (_Float64x __x) throw (); extern _Float64x atan2f64x (_Float64x __y, _Float64x __x) throw (); extern _Float64x __atan2f64x (_Float64x __y, _Float64x __x) throw (); extern _Float64x cosf64x (_Float64x __x) throw (); extern _Float64x __cosf64x (_Float64x __x) throw (); extern _Float64x sinf64x (_Float64x __x) throw (); extern _Float64x __sinf64x (_Float64x __x) throw (); extern _Float64x tanf64x (_Float64x __x) throw (); extern _Float64x __tanf64x (_Float64x __x) throw (); extern _Float64x coshf64x (_Float64x __x) throw (); extern _Float64x __coshf64x (_Float64x __x) throw (); extern _Float64x sinhf64x (_Float64x __x) throw (); extern _Float64x __sinhf64x (_Float64x __x) throw (); extern _Float64x tanhf64x (_Float64x __x) throw (); extern _Float64x __tanhf64x (_Float64x __x) throw (); extern void sincosf64x (_Float64x __x, _Float64x *__sinx, _Float64x *__cosx) throw (); extern void __sincosf64x (_Float64x __x, _Float64x *__sinx, _Float64x *__cosx) throw () ; extern _Float64x acoshf64x (_Float64x __x) throw (); extern _Float64x __acoshf64x (_Float64x __x) throw (); extern _Float64x asinhf64x (_Float64x __x) throw (); extern _Float64x __asinhf64x (_Float64x __x) throw (); extern _Float64x atanhf64x (_Float64x __x) throw (); extern _Float64x __atanhf64x (_Float64x __x) throw (); extern _Float64x expf64x (_Float64x __x) throw (); extern _Float64x __expf64x (_Float64x __x) throw (); extern _Float64x frexpf64x (_Float64x __x, int *__exponent) throw (); extern _Float64x __frexpf64x (_Float64x __x, int *__exponent) throw (); extern _Float64x ldexpf64x (_Float64x __x, int __exponent) throw (); extern _Float64x __ldexpf64x (_Float64x __x, int __exponent) throw (); extern _Float64x logf64x (_Float64x __x) throw (); extern _Float64x __logf64x (_Float64x __x) throw (); extern _Float64x log10f64x (_Float64x __x) throw (); extern _Float64x __log10f64x (_Float64x __x) throw (); extern _Float64x modff64x (_Float64x __x, _Float64x *__iptr) throw (); extern _Float64x __modff64x (_Float64x __x, _Float64x *__iptr) throw () __attribute__ ((__nonnull__ (2))); extern _Float64x exp10f64x (_Float64x __x) throw (); extern _Float64x __exp10f64x (_Float64x __x) throw (); extern _Float64x expm1f64x (_Float64x __x) throw (); extern _Float64x __expm1f64x (_Float64x __x) throw (); extern _Float64x log1pf64x (_Float64x __x) throw (); extern _Float64x __log1pf64x (_Float64x __x) throw (); extern _Float64x logbf64x (_Float64x __x) throw (); extern _Float64x __logbf64x (_Float64x __x) throw (); extern _Float64x exp2f64x (_Float64x __x) throw (); extern _Float64x __exp2f64x (_Float64x __x) throw (); extern _Float64x log2f64x (_Float64x __x) throw (); extern _Float64x __log2f64x (_Float64x __x) throw (); extern _Float64x powf64x (_Float64x __x, _Float64x __y) throw (); extern _Float64x __powf64x (_Float64x __x, _Float64x __y) throw (); extern _Float64x sqrtf64x (_Float64x __x) throw (); extern _Float64x __sqrtf64x (_Float64x __x) throw (); extern _Float64x hypotf64x (_Float64x __x, _Float64x __y) throw (); extern _Float64x __hypotf64x (_Float64x __x, _Float64x __y) throw (); extern _Float64x cbrtf64x (_Float64x __x) throw (); extern _Float64x __cbrtf64x (_Float64x __x) throw (); extern _Float64x ceilf64x (_Float64x __x) throw () __attribute__ ((__const__)); extern _Float64x __ceilf64x (_Float64x __x) throw () __attribute__ ((__const__)); extern _Float64x fabsf64x (_Float64x __x) throw () __attribute__ ((__const__)); extern _Float64x __fabsf64x (_Float64x __x) throw () __attribute__ ((__const__)); extern _Float64x floorf64x (_Float64x __x) throw () __attribute__ ((__const__)); extern _Float64x __floorf64x (_Float64x __x) throw () __attribute__ ((__const__)); extern _Float64x fmodf64x (_Float64x __x, _Float64x __y) throw (); extern _Float64x __fmodf64x (_Float64x __x, _Float64x __y) throw (); extern _Float64x copysignf64x (_Float64x __x, _Float64x __y) throw () __attribute__ ((__const__)); extern _Float64x __copysignf64x (_Float64x __x, _Float64x __y) throw () __attribute__ ((__const__)); extern _Float64x nanf64x (const char *__tagb) throw (); extern _Float64x __nanf64x (const char *__tagb) throw (); extern _Float64x j0f64x (_Float64x) throw (); extern _Float64x __j0f64x (_Float64x) throw (); extern _Float64x j1f64x (_Float64x) throw (); extern _Float64x __j1f64x (_Float64x) throw (); extern _Float64x jnf64x (int, _Float64x) throw (); extern _Float64x __jnf64x (int, _Float64x) throw (); extern _Float64x y0f64x (_Float64x) throw (); extern _Float64x __y0f64x (_Float64x) throw (); extern _Float64x y1f64x (_Float64x) throw (); extern _Float64x __y1f64x (_Float64x) throw (); extern _Float64x ynf64x (int, _Float64x) throw (); extern _Float64x __ynf64x (int, _Float64x) throw (); extern _Float64x erff64x (_Float64x) throw (); extern _Float64x __erff64x (_Float64x) throw (); extern _Float64x erfcf64x (_Float64x) throw (); extern _Float64x __erfcf64x (_Float64x) throw (); extern _Float64x lgammaf64x (_Float64x) throw (); extern _Float64x __lgammaf64x (_Float64x) throw (); extern _Float64x tgammaf64x (_Float64x) throw (); extern _Float64x __tgammaf64x (_Float64x) throw (); extern _Float64x lgammaf64x_r (_Float64x, int *__signgamp) throw (); extern _Float64x __lgammaf64x_r (_Float64x, int *__signgamp) throw (); extern _Float64x rintf64x (_Float64x __x) throw (); extern _Float64x __rintf64x (_Float64x __x) throw (); extern _Float64x nextafterf64x (_Float64x __x, _Float64x __y) throw (); extern _Float64x __nextafterf64x (_Float64x __x, _Float64x __y) throw (); extern _Float64x nextdownf64x (_Float64x __x) throw (); extern _Float64x __nextdownf64x (_Float64x __x) throw (); extern _Float64x nextupf64x (_Float64x __x) throw (); extern _Float64x __nextupf64x (_Float64x __x) throw (); extern _Float64x remainderf64x (_Float64x __x, _Float64x __y) throw (); extern _Float64x __remainderf64x (_Float64x __x, _Float64x __y) throw (); extern _Float64x scalbnf64x (_Float64x __x, int __n) throw (); extern _Float64x __scalbnf64x (_Float64x __x, int __n) throw (); extern int ilogbf64x (_Float64x __x) throw (); extern int __ilogbf64x (_Float64x __x) throw (); extern long int llogbf64x (_Float64x __x) throw (); extern long int __llogbf64x (_Float64x __x) throw (); extern _Float64x scalblnf64x (_Float64x __x, long int __n) throw (); extern _Float64x __scalblnf64x (_Float64x __x, long int __n) throw (); extern _Float64x nearbyintf64x (_Float64x __x) throw (); extern _Float64x __nearbyintf64x (_Float64x __x) throw (); extern _Float64x roundf64x (_Float64x __x) throw () __attribute__ ((__const__)); extern _Float64x __roundf64x (_Float64x __x) throw () __attribute__ ((__const__)); extern _Float64x truncf64x (_Float64x __x) throw () __attribute__ ((__const__)); extern _Float64x __truncf64x (_Float64x __x) throw () __attribute__ ((__const__)); extern _Float64x remquof64x (_Float64x __x, _Float64x __y, int *__quo) throw (); extern _Float64x __remquof64x (_Float64x __x, _Float64x __y, int *__quo) throw (); extern long int lrintf64x (_Float64x __x) throw (); extern long int __lrintf64x (_Float64x __x) throw (); __extension__ extern long long int llrintf64x (_Float64x __x) throw (); extern long long int __llrintf64x (_Float64x __x) throw (); extern long int lroundf64x (_Float64x __x) throw (); extern long int __lroundf64x (_Float64x __x) throw (); __extension__ extern long long int llroundf64x (_Float64x __x) throw (); extern long long int __llroundf64x (_Float64x __x) throw (); extern _Float64x fdimf64x (_Float64x __x, _Float64x __y) throw (); extern _Float64x __fdimf64x (_Float64x __x, _Float64x __y) throw (); extern _Float64x fmaxf64x (_Float64x __x, _Float64x __y) throw () __attribute__ ((__const__)); extern _Float64x __fmaxf64x (_Float64x __x, _Float64x __y) throw () __attribute__ ((__const__)); extern _Float64x fminf64x (_Float64x __x, _Float64x __y) throw () __attribute__ ((__const__)); extern _Float64x __fminf64x (_Float64x __x, _Float64x __y) throw () __attribute__ ((__const__)); extern _Float64x fmaf64x (_Float64x __x, _Float64x __y, _Float64x __z) throw (); extern _Float64x __fmaf64x (_Float64x __x, _Float64x __y, _Float64x __z) throw (); extern _Float64x roundevenf64x (_Float64x __x) throw () __attribute__ ((__const__)); extern _Float64x __roundevenf64x (_Float64x __x) throw () __attribute__ ((__const__)); extern __intmax_t fromfpf64x (_Float64x __x, int __round, unsigned int __width) throw (); extern __intmax_t __fromfpf64x (_Float64x __x, int __round, unsigned int __width) throw () ; extern __uintmax_t ufromfpf64x (_Float64x __x, int __round, unsigned int __width) throw (); extern __uintmax_t __ufromfpf64x (_Float64x __x, int __round, unsigned int __width) throw () ; extern __intmax_t fromfpxf64x (_Float64x __x, int __round, unsigned int __width) throw (); extern __intmax_t __fromfpxf64x (_Float64x __x, int __round, unsigned int __width) throw () ; extern __uintmax_t ufromfpxf64x (_Float64x __x, int __round, unsigned int __width) throw (); extern __uintmax_t __ufromfpxf64x (_Float64x __x, int __round, unsigned int __width) throw () ; extern _Float64x fmaxmagf64x (_Float64x __x, _Float64x __y) throw () __attribute__ ((__const__)); extern _Float64x __fmaxmagf64x (_Float64x __x, _Float64x __y) throw () __attribute__ ((__const__)); extern _Float64x fminmagf64x (_Float64x __x, _Float64x __y) throw () __attribute__ ((__const__)); extern _Float64x __fminmagf64x (_Float64x __x, _Float64x __y) throw () __attribute__ ((__const__)); extern int canonicalizef64x (_Float64x *__cx, const _Float64x *__x) throw (); extern int totalorderf64x (const _Float64x *__x, const _Float64x *__y) throw () __attribute__ ((__pure__)); extern int totalordermagf64x (const _Float64x *__x, const _Float64x *__y) throw () __attribute__ ((__pure__)); extern _Float64x getpayloadf64x (const _Float64x *__x) throw (); extern _Float64x __getpayloadf64x (const _Float64x *__x) throw (); extern int setpayloadf64x (_Float64x *__x, _Float64x __payload) throw (); extern int setpayloadsigf64x (_Float64x *__x, _Float64x __payload) throw (); extern float fadd (double __x, double __y) throw (); extern float fdiv (double __x, double __y) throw (); extern float fmul (double __x, double __y) throw (); extern float fsub (double __x, double __y) throw (); extern float faddl (long double __x, long double __y) throw (); extern float fdivl (long double __x, long double __y) throw (); extern float fmull (long double __x, long double __y) throw (); extern float fsubl (long double __x, long double __y) throw (); extern double daddl (long double __x, long double __y) throw (); extern double ddivl (long double __x, long double __y) throw (); extern double dmull (long double __x, long double __y) throw (); extern double dsubl (long double __x, long double __y) throw (); extern _Float32 f32addf32x (_Float32x __x, _Float32x __y) throw (); extern _Float32 f32divf32x (_Float32x __x, _Float32x __y) throw (); extern _Float32 f32mulf32x (_Float32x __x, _Float32x __y) throw (); extern _Float32 f32subf32x (_Float32x __x, _Float32x __y) throw (); extern _Float32 f32addf64 (_Float64 __x, _Float64 __y) throw (); extern _Float32 f32divf64 (_Float64 __x, _Float64 __y) throw (); extern _Float32 f32mulf64 (_Float64 __x, _Float64 __y) throw (); extern _Float32 f32subf64 (_Float64 __x, _Float64 __y) throw (); extern _Float32 f32addf64x (_Float64x __x, _Float64x __y) throw (); extern _Float32 f32divf64x (_Float64x __x, _Float64x __y) throw (); extern _Float32 f32mulf64x (_Float64x __x, _Float64x __y) throw (); extern _Float32 f32subf64x (_Float64x __x, _Float64x __y) throw (); extern _Float32 f32addf128 (_Float128 __x, _Float128 __y) throw (); extern _Float32 f32divf128 (_Float128 __x, _Float128 __y) throw (); extern _Float32 f32mulf128 (_Float128 __x, _Float128 __y) throw (); extern _Float32 f32subf128 (_Float128 __x, _Float128 __y) throw (); extern _Float32x f32xaddf64 (_Float64 __x, _Float64 __y) throw (); extern _Float32x f32xdivf64 (_Float64 __x, _Float64 __y) throw (); extern _Float32x f32xmulf64 (_Float64 __x, _Float64 __y) throw (); extern _Float32x f32xsubf64 (_Float64 __x, _Float64 __y) throw (); extern _Float32x f32xaddf64x (_Float64x __x, _Float64x __y) throw (); extern _Float32x f32xdivf64x (_Float64x __x, _Float64x __y) throw (); extern _Float32x f32xmulf64x (_Float64x __x, _Float64x __y) throw (); extern _Float32x f32xsubf64x (_Float64x __x, _Float64x __y) throw (); extern _Float32x f32xaddf128 (_Float128 __x, _Float128 __y) throw (); extern _Float32x f32xdivf128 (_Float128 __x, _Float128 __y) throw (); extern _Float32x f32xmulf128 (_Float128 __x, _Float128 __y) throw (); extern _Float32x f32xsubf128 (_Float128 __x, _Float128 __y) throw (); extern _Float64 f64addf64x (_Float64x __x, _Float64x __y) throw (); extern _Float64 f64divf64x (_Float64x __x, _Float64x __y) throw (); extern _Float64 f64mulf64x (_Float64x __x, _Float64x __y) throw (); extern _Float64 f64subf64x (_Float64x __x, _Float64x __y) throw (); extern _Float64 f64addf128 (_Float128 __x, _Float128 __y) throw (); extern _Float64 f64divf128 (_Float128 __x, _Float128 __y) throw (); extern _Float64 f64mulf128 (_Float128 __x, _Float128 __y) throw (); extern _Float64 f64subf128 (_Float128 __x, _Float128 __y) throw (); extern _Float64x f64xaddf128 (_Float128 __x, _Float128 __y) throw (); extern _Float64x f64xdivf128 (_Float128 __x, _Float128 __y) throw (); extern _Float64x f64xmulf128 (_Float128 __x, _Float128 __y) throw (); extern _Float64x f64xsubf128 (_Float128 __x, _Float128 __y) throw (); extern int signgam; enum { FP_NAN = 0, FP_INFINITE = 1, FP_ZERO = 2, FP_SUBNORMAL = 3, FP_NORMAL = 4 }; extern int __iscanonicall (long double __x) throw () __attribute__ ((__const__)); extern "C++" { inline int iscanonical (float __val) { return ((void) (__typeof (__val)) (__val), 1); } inline int iscanonical (double __val) { return ((void) (__typeof (__val)) (__val), 1); } inline int iscanonical (long double __val) { return __iscanonicall (__val); } inline int iscanonical (_Float128 __val) { return ((void) (__typeof (__val)) (__val), 1); } } extern "C++" { inline int issignaling (float __val) { return __issignalingf (__val); } inline int issignaling (double __val) { return __issignaling (__val); } inline int issignaling (long double __val) { return __issignalingl (__val); } inline int issignaling (_Float128 __val) { return __issignalingf128 (__val); } } extern "C++" { template <class __T> inline bool iszero (__T __val) { return __val == 0; } } extern "C++" { template<typename> struct __iseqsig_type; template<> struct __iseqsig_type<float> { static int __call (float __x, float __y) throw () { return __iseqsigf (__x, __y); } }; template<> struct __iseqsig_type<double> { static int __call (double __x, double __y) throw () { return __iseqsig (__x, __y); } }; template<> struct __iseqsig_type<long double> { static int __call (long double __x, long double __y) throw () { return __iseqsigl (__x, __y); } }; template<> struct __iseqsig_type<_Float128> { static int __call (_Float128 __x, _Float128 __y) throw () { return __iseqsigf128 (__x, __y); } }; template<typename _T1, typename _T2> inline int iseqsig (_T1 __x, _T2 __y) throw () { typedef decltype (((__x) + (__y) + 0.0f)) _T3; return __iseqsig_type<_T3>::__call (__x, __y); } } } extern "C++" { namespace std __attribute__ ((__visibility__ ("default"))) { using ::acos; inline constexpr float acos(float __x) { return __builtin_acosf(__x); } inline constexpr long double acos(long double __x) { return __builtin_acosl(__x); } template<typename _Tp> inline constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, double>::__type acos(_Tp __x) { return __builtin_acos(__x); } using ::asin; inline constexpr float asin(float __x) { return __builtin_asinf(__x); } inline constexpr long double asin(long double __x) { return __builtin_asinl(__x); } template<typename _Tp> inline constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, double>::__type asin(_Tp __x) { return __builtin_asin(__x); } using ::atan; inline constexpr float atan(float __x) { return __builtin_atanf(__x); } inline constexpr long double atan(long double __x) { return __builtin_atanl(__x); } template<typename _Tp> inline constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, double>::__type atan(_Tp __x) { return __builtin_atan(__x); } using ::atan2; inline constexpr float atan2(float __y, float __x) { return __builtin_atan2f(__y, __x); } inline constexpr long double atan2(long double __y, long double __x) { return __builtin_atan2l(__y, __x); } template<typename _Tp, typename _Up> inline constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type atan2(_Tp __y, _Up __x) { typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; return atan2(__type(__y), __type(__x)); } using ::ceil; inline constexpr float ceil(float __x) { return __builtin_ceilf(__x); } inline constexpr long double ceil(long double __x) { return __builtin_ceill(__x); } template<typename _Tp> inline constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, double>::__type ceil(_Tp __x) { return __builtin_ceil(__x); } using ::cos; inline constexpr float cos(float __x) { return __builtin_cosf(__x); } inline constexpr long double cos(long double __x) { return __builtin_cosl(__x); } template<typename _Tp> inline constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, double>::__type cos(_Tp __x) { return __builtin_cos(__x); } using ::cosh; inline constexpr float cosh(float __x) { return __builtin_coshf(__x); } inline constexpr long double cosh(long double __x) { return __builtin_coshl(__x); } template<typename _Tp> inline constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, double>::__type cosh(_Tp __x) { return __builtin_cosh(__x); } using ::exp; inline constexpr float exp(float __x) { return __builtin_expf(__x); } inline constexpr long double exp(long double __x) { return __builtin_expl(__x); } template<typename _Tp> inline constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, double>::__type exp(_Tp __x) { return __builtin_exp(__x); } using ::fabs; inline constexpr float fabs(float __x) { return __builtin_fabsf(__x); } inline constexpr long double fabs(long double __x) { return __builtin_fabsl(__x); } template<typename _Tp> inline constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, double>::__type fabs(_Tp __x) { return __builtin_fabs(__x); } using ::floor; inline constexpr float floor(float __x) { return __builtin_floorf(__x); } inline constexpr long double floor(long double __x) { return __builtin_floorl(__x); } template<typename _Tp> inline constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, double>::__type floor(_Tp __x) { return __builtin_floor(__x); } using ::fmod; inline constexpr float fmod(float __x, float __y) { return __builtin_fmodf(__x, __y); } inline constexpr long double fmod(long double __x, long double __y) { return __builtin_fmodl(__x, __y); } template<typename _Tp, typename _Up> inline constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type fmod(_Tp __x, _Up __y) { typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; return fmod(__type(__x), __type(__y)); } using ::frexp; inline float frexp(float __x, int* __exp) { return __builtin_frexpf(__x, __exp); } inline long double frexp(long double __x, int* __exp) { return __builtin_frexpl(__x, __exp); } template<typename _Tp> inline constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, double>::__type frexp(_Tp __x, int* __exp) { return __builtin_frexp(__x, __exp); } using ::ldexp; inline constexpr float ldexp(float __x, int __exp) { return __builtin_ldexpf(__x, __exp); } inline constexpr long double ldexp(long double __x, int __exp) { return __builtin_ldexpl(__x, __exp); } template<typename _Tp> inline constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, double>::__type ldexp(_Tp __x, int __exp) { return __builtin_ldexp(__x, __exp); } using ::log; inline constexpr float log(float __x) { return __builtin_logf(__x); } inline constexpr long double log(long double __x) { return __builtin_logl(__x); } template<typename _Tp> inline constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, double>::__type log(_Tp __x) { return __builtin_log(__x); } using ::log10; inline constexpr float log10(float __x) { return __builtin_log10f(__x); } inline constexpr long double log10(long double __x) { return __builtin_log10l(__x); } template<typename _Tp> inline constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, double>::__type log10(_Tp __x) { return __builtin_log10(__x); } using ::modf; inline float modf(float __x, float* __iptr) { return __builtin_modff(__x, __iptr); } inline long double modf(long double __x, long double* __iptr) { return __builtin_modfl(__x, __iptr); } using ::pow; inline constexpr float pow(float __x, float __y) { return __builtin_powf(__x, __y); } inline constexpr long double pow(long double __x, long double __y) { return __builtin_powl(__x, __y); } template<typename _Tp, typename _Up> inline constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type pow(_Tp __x, _Up __y) { typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; return pow(__type(__x), __type(__y)); } using ::sin; inline constexpr float sin(float __x) { return __builtin_sinf(__x); } inline constexpr long double sin(long double __x) { return __builtin_sinl(__x); } template<typename _Tp> inline constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, double>::__type sin(_Tp __x) { return __builtin_sin(__x); } using ::sinh; inline constexpr float sinh(float __x) { return __builtin_sinhf(__x); } inline constexpr long double sinh(long double __x) { return __builtin_sinhl(__x); } template<typename _Tp> inline constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, double>::__type sinh(_Tp __x) { return __builtin_sinh(__x); } using ::sqrt; inline constexpr float sqrt(float __x) { return __builtin_sqrtf(__x); } inline constexpr long double sqrt(long double __x) { return __builtin_sqrtl(__x); } template<typename _Tp> inline constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, double>::__type sqrt(_Tp __x) { return __builtin_sqrt(__x); } using ::tan; inline constexpr float tan(float __x) { return __builtin_tanf(__x); } inline constexpr long double tan(long double __x) { return __builtin_tanl(__x); } template<typename _Tp> inline constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, double>::__type tan(_Tp __x) { return __builtin_tan(__x); } using ::tanh; inline constexpr float tanh(float __x) { return __builtin_tanhf(__x); } inline constexpr long double tanh(long double __x) { return __builtin_tanhl(__x); } template<typename _Tp> inline constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, double>::__type tanh(_Tp __x) { return __builtin_tanh(__x); } constexpr int fpclassify(float __x) { return __builtin_fpclassify(0, 1, 4, 3, 2, __x); } constexpr int fpclassify(double __x) { return __builtin_fpclassify(0, 1, 4, 3, 2, __x); } constexpr int fpclassify(long double __x) { return __builtin_fpclassify(0, 1, 4, 3, 2, __x); } template<typename _Tp> constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, int>::__type fpclassify(_Tp __x) { return __x != 0 ? 4 : 2; } constexpr bool isfinite(float __x) { return __builtin_isfinite(__x); } constexpr bool isfinite(double __x) { return __builtin_isfinite(__x); } constexpr bool isfinite(long double __x) { return __builtin_isfinite(__x); } template<typename _Tp> constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, bool>::__type isfinite(_Tp __x) { return true; } constexpr bool isinf(float __x) { return __builtin_isinf(__x); } constexpr bool isinf(double __x) { return __builtin_isinf(__x); } constexpr bool isinf(long double __x) { return __builtin_isinf(__x); } template<typename _Tp> constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, bool>::__type isinf(_Tp __x) { return false; } constexpr bool isnan(float __x) { return __builtin_isnan(__x); } constexpr bool isnan(double __x) { return __builtin_isnan(__x); } constexpr bool isnan(long double __x) { return __builtin_isnan(__x); } template<typename _Tp> constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, bool>::__type isnan(_Tp __x) { return false; } constexpr bool isnormal(float __x) { return __builtin_isnormal(__x); } constexpr bool isnormal(double __x) { return __builtin_isnormal(__x); } constexpr bool isnormal(long double __x) { return __builtin_isnormal(__x); } template<typename _Tp> constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, bool>::__type isnormal(_Tp __x) { return __x != 0 ? true : false; } constexpr bool signbit(float __x) { return __builtin_signbit(__x); } constexpr bool signbit(double __x) { return __builtin_signbit(__x); } constexpr bool signbit(long double __x) { return __builtin_signbit(__x); } template<typename _Tp> constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, bool>::__type signbit(_Tp __x) { return __x < 0 ? true : false; } constexpr bool isgreater(float __x, float __y) { return __builtin_isgreater(__x, __y); } constexpr bool isgreater(double __x, double __y) { return __builtin_isgreater(__x, __y); } constexpr bool isgreater(long double __x, long double __y) { return __builtin_isgreater(__x, __y); } template<typename _Tp, typename _Up> constexpr typename __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value && __is_arithmetic<_Up>::__value), bool>::__type isgreater(_Tp __x, _Up __y) { typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; return __builtin_isgreater(__type(__x), __type(__y)); } constexpr bool isgreaterequal(float __x, float __y) { return __builtin_isgreaterequal(__x, __y); } constexpr bool isgreaterequal(double __x, double __y) { return __builtin_isgreaterequal(__x, __y); } constexpr bool isgreaterequal(long double __x, long double __y) { return __builtin_isgreaterequal(__x, __y); } template<typename _Tp, typename _Up> constexpr typename __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value && __is_arithmetic<_Up>::__value), bool>::__type isgreaterequal(_Tp __x, _Up __y) { typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; return __builtin_isgreaterequal(__type(__x), __type(__y)); } constexpr bool isless(float __x, float __y) { return __builtin_isless(__x, __y); } constexpr bool isless(double __x, double __y) { return __builtin_isless(__x, __y); } constexpr bool isless(long double __x, long double __y) { return __builtin_isless(__x, __y); } template<typename _Tp, typename _Up> constexpr typename __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value && __is_arithmetic<_Up>::__value), bool>::__type isless(_Tp __x, _Up __y) { typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; return __builtin_isless(__type(__x), __type(__y)); } constexpr bool islessequal(float __x, float __y) { return __builtin_islessequal(__x, __y); } constexpr bool islessequal(double __x, double __y) { return __builtin_islessequal(__x, __y); } constexpr bool islessequal(long double __x, long double __y) { return __builtin_islessequal(__x, __y); } template<typename _Tp, typename _Up> constexpr typename __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value && __is_arithmetic<_Up>::__value), bool>::__type islessequal(_Tp __x, _Up __y) { typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; return __builtin_islessequal(__type(__x), __type(__y)); } constexpr bool islessgreater(float __x, float __y) { return __builtin_islessgreater(__x, __y); } constexpr bool islessgreater(double __x, double __y) { return __builtin_islessgreater(__x, __y); } constexpr bool islessgreater(long double __x, long double __y) { return __builtin_islessgreater(__x, __y); } template<typename _Tp, typename _Up> constexpr typename __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value && __is_arithmetic<_Up>::__value), bool>::__type islessgreater(_Tp __x, _Up __y) { typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; return __builtin_islessgreater(__type(__x), __type(__y)); } constexpr bool isunordered(float __x, float __y) { return __builtin_isunordered(__x, __y); } constexpr bool isunordered(double __x, double __y) { return __builtin_isunordered(__x, __y); } constexpr bool isunordered(long double __x, long double __y) { return __builtin_isunordered(__x, __y); } template<typename _Tp, typename _Up> constexpr typename __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value && __is_arithmetic<_Up>::__value), bool>::__type isunordered(_Tp __x, _Up __y) { typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; return __builtin_isunordered(__type(__x), __type(__y)); } using ::double_t; using ::float_t; using ::acosh; using ::acoshf; using ::acoshl; using ::asinh; using ::asinhf; using ::asinhl; using ::atanh; using ::atanhf; using ::atanhl; using ::cbrt; using ::cbrtf; using ::cbrtl; using ::copysign; using ::copysignf; using ::copysignl; using ::erf; using ::erff; using ::erfl; using ::erfc; using ::erfcf; using ::erfcl; using ::exp2; using ::exp2f; using ::exp2l; using ::expm1; using ::expm1f; using ::expm1l; using ::fdim; using ::fdimf; using ::fdiml; using ::fma; using ::fmaf; using ::fmal; using ::fmax; using ::fmaxf; using ::fmaxl; using ::fmin; using ::fminf; using ::fminl; using ::hypot; using ::hypotf; using ::hypotl; using ::ilogb; using ::ilogbf; using ::ilogbl; using ::lgamma; using ::lgammaf; using ::lgammal; using ::llrint; using ::llrintf; using ::llrintl; using ::llround; using ::llroundf; using ::llroundl; using ::log1p; using ::log1pf; using ::log1pl; using ::log2; using ::log2f; using ::log2l; using ::logb; using ::logbf; using ::logbl; using ::lrint; using ::lrintf; using ::lrintl; using ::lround; using ::lroundf; using ::lroundl; using ::nan; using ::nanf; using ::nanl; using ::nearbyint; using ::nearbyintf; using ::nearbyintl; using ::nextafter; using ::nextafterf; using ::nextafterl; using ::nexttoward; using ::nexttowardf; using ::nexttowardl; using ::remainder; using ::remainderf; using ::remainderl; using ::remquo; using ::remquof; using ::remquol; using ::rint; using ::rintf; using ::rintl; using ::round; using ::roundf; using ::roundl; using ::scalbln; using ::scalblnf; using ::scalblnl; using ::scalbn; using ::scalbnf; using ::scalbnl; using ::tgamma; using ::tgammaf; using ::tgammal; using ::trunc; using ::truncf; using ::truncl; constexpr float acosh(float __x) { return __builtin_acoshf(__x); } constexpr long double acosh(long double __x) { return __builtin_acoshl(__x); } template<typename _Tp> constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, double>::__type acosh(_Tp __x) { return __builtin_acosh(__x); } constexpr float asinh(float __x) { return __builtin_asinhf(__x); } constexpr long double asinh(long double __x) { return __builtin_asinhl(__x); } template<typename _Tp> constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, double>::__type asinh(_Tp __x) { return __builtin_asinh(__x); } constexpr float atanh(float __x) { return __builtin_atanhf(__x); } constexpr long double atanh(long double __x) { return __builtin_atanhl(__x); } template<typename _Tp> constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, double>::__type atanh(_Tp __x) { return __builtin_atanh(__x); } constexpr float cbrt(float __x) { return __builtin_cbrtf(__x); } constexpr long double cbrt(long double __x) { return __builtin_cbrtl(__x); } template<typename _Tp> constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, double>::__type cbrt(_Tp __x) { return __builtin_cbrt(__x); } constexpr float copysign(float __x, float __y) { return __builtin_copysignf(__x, __y); } constexpr long double copysign(long double __x, long double __y) { return __builtin_copysignl(__x, __y); } template<typename _Tp, typename _Up> constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type copysign(_Tp __x, _Up __y) { typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; return copysign(__type(__x), __type(__y)); } constexpr float erf(float __x) { return __builtin_erff(__x); } constexpr long double erf(long double __x) { return __builtin_erfl(__x); } template<typename _Tp> constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, double>::__type erf(_Tp __x) { return __builtin_erf(__x); } constexpr float erfc(float __x) { return __builtin_erfcf(__x); } constexpr long double erfc(long double __x) { return __builtin_erfcl(__x); } template<typename _Tp> constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, double>::__type erfc(_Tp __x) { return __builtin_erfc(__x); } constexpr float exp2(float __x) { return __builtin_exp2f(__x); } constexpr long double exp2(long double __x) { return __builtin_exp2l(__x); } template<typename _Tp> constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, double>::__type exp2(_Tp __x) { return __builtin_exp2(__x); } constexpr float expm1(float __x) { return __builtin_expm1f(__x); } constexpr long double expm1(long double __x) { return __builtin_expm1l(__x); } template<typename _Tp> constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, double>::__type expm1(_Tp __x) { return __builtin_expm1(__x); } constexpr float fdim(float __x, float __y) { return __builtin_fdimf(__x, __y); } constexpr long double fdim(long double __x, long double __y) { return __builtin_fdiml(__x, __y); } template<typename _Tp, typename _Up> constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type fdim(_Tp __x, _Up __y) { typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; return fdim(__type(__x), __type(__y)); } constexpr float fma(float __x, float __y, float __z) { return __builtin_fmaf(__x, __y, __z); } constexpr long double fma(long double __x, long double __y, long double __z) { return __builtin_fmal(__x, __y, __z); } template<typename _Tp, typename _Up, typename _Vp> constexpr typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type fma(_Tp __x, _Up __y, _Vp __z) { typedef typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type __type; return fma(__type(__x), __type(__y), __type(__z)); } constexpr float fmax(float __x, float __y) { return __builtin_fmaxf(__x, __y); } constexpr long double fmax(long double __x, long double __y) { return __builtin_fmaxl(__x, __y); } template<typename _Tp, typename _Up> constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type fmax(_Tp __x, _Up __y) { typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; return fmax(__type(__x), __type(__y)); } constexpr float fmin(float __x, float __y) { return __builtin_fminf(__x, __y); } constexpr long double fmin(long double __x, long double __y) { return __builtin_fminl(__x, __y); } template<typename _Tp, typename _Up> constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type fmin(_Tp __x, _Up __y) { typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; return fmin(__type(__x), __type(__y)); } constexpr float hypot(float __x, float __y) { return __builtin_hypotf(__x, __y); } constexpr long double hypot(long double __x, long double __y) { return __builtin_hypotl(__x, __y); } template<typename _Tp, typename _Up> constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type hypot(_Tp __x, _Up __y) { typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; return hypot(__type(__x), __type(__y)); } constexpr int ilogb(float __x) { return __builtin_ilogbf(__x); } constexpr int ilogb(long double __x) { return __builtin_ilogbl(__x); } template<typename _Tp> constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, int>::__type ilogb(_Tp __x) { return __builtin_ilogb(__x); } constexpr float lgamma(float __x) { return __builtin_lgammaf(__x); } constexpr long double lgamma(long double __x) { return __builtin_lgammal(__x); } template<typename _Tp> constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, double>::__type lgamma(_Tp __x) { return __builtin_lgamma(__x); } constexpr long long llrint(float __x) { return __builtin_llrintf(__x); } constexpr long long llrint(long double __x) { return __builtin_llrintl(__x); } template<typename _Tp> constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, long long>::__type llrint(_Tp __x) { return __builtin_llrint(__x); } constexpr long long llround(float __x) { return __builtin_llroundf(__x); } constexpr long long llround(long double __x) { return __builtin_llroundl(__x); } template<typename _Tp> constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, long long>::__type llround(_Tp __x) { return __builtin_llround(__x); } constexpr float log1p(float __x) { return __builtin_log1pf(__x); } constexpr long double log1p(long double __x) { return __builtin_log1pl(__x); } template<typename _Tp> constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, double>::__type log1p(_Tp __x) { return __builtin_log1p(__x); } constexpr float log2(float __x) { return __builtin_log2f(__x); } constexpr long double log2(long double __x) { return __builtin_log2l(__x); } template<typename _Tp> constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, double>::__type log2(_Tp __x) { return __builtin_log2(__x); } constexpr float logb(float __x) { return __builtin_logbf(__x); } constexpr long double logb(long double __x) { return __builtin_logbl(__x); } template<typename _Tp> constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, double>::__type logb(_Tp __x) { return __builtin_logb(__x); } constexpr long lrint(float __x) { return __builtin_lrintf(__x); } constexpr long lrint(long double __x) { return __builtin_lrintl(__x); } template<typename _Tp> constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, long>::__type lrint(_Tp __x) { return __builtin_lrint(__x); } constexpr long lround(float __x) { return __builtin_lroundf(__x); } constexpr long lround(long double __x) { return __builtin_lroundl(__x); } template<typename _Tp> constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, long>::__type lround(_Tp __x) { return __builtin_lround(__x); } constexpr float nearbyint(float __x) { return __builtin_nearbyintf(__x); } constexpr long double nearbyint(long double __x) { return __builtin_nearbyintl(__x); } template<typename _Tp> constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, double>::__type nearbyint(_Tp __x) { return __builtin_nearbyint(__x); } constexpr float nextafter(float __x, float __y) { return __builtin_nextafterf(__x, __y); } constexpr long double nextafter(long double __x, long double __y) { return __builtin_nextafterl(__x, __y); } template<typename _Tp, typename _Up> constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type nextafter(_Tp __x, _Up __y) { typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; return nextafter(__type(__x), __type(__y)); } constexpr float nexttoward(float __x, long double __y) { return __builtin_nexttowardf(__x, __y); } constexpr long double nexttoward(long double __x, long double __y) { return __builtin_nexttowardl(__x, __y); } template<typename _Tp> constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, double>::__type nexttoward(_Tp __x, long double __y) { return __builtin_nexttoward(__x, __y); } constexpr float remainder(float __x, float __y) { return __builtin_remainderf(__x, __y); } constexpr long double remainder(long double __x, long double __y) { return __builtin_remainderl(__x, __y); } template<typename _Tp, typename _Up> constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type remainder(_Tp __x, _Up __y) { typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; return remainder(__type(__x), __type(__y)); } inline float remquo(float __x, float __y, int* __pquo) { return __builtin_remquof(__x, __y, __pquo); } inline long double remquo(long double __x, long double __y, int* __pquo) { return __builtin_remquol(__x, __y, __pquo); } template<typename _Tp, typename _Up> inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type remquo(_Tp __x, _Up __y, int* __pquo) { typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; return remquo(__type(__x), __type(__y), __pquo); } constexpr float rint(float __x) { return __builtin_rintf(__x); } constexpr long double rint(long double __x) { return __builtin_rintl(__x); } template<typename _Tp> constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, double>::__type rint(_Tp __x) { return __builtin_rint(__x); } constexpr float round(float __x) { return __builtin_roundf(__x); } constexpr long double round(long double __x) { return __builtin_roundl(__x); } template<typename _Tp> constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, double>::__type round(_Tp __x) { return __builtin_round(__x); } constexpr float scalbln(float __x, long __ex) { return __builtin_scalblnf(__x, __ex); } constexpr long double scalbln(long double __x, long __ex) { return __builtin_scalblnl(__x, __ex); } template<typename _Tp> constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, double>::__type scalbln(_Tp __x, long __ex) { return __builtin_scalbln(__x, __ex); } constexpr float scalbn(float __x, int __ex) { return __builtin_scalbnf(__x, __ex); } constexpr long double scalbn(long double __x, int __ex) { return __builtin_scalbnl(__x, __ex); } template<typename _Tp> constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, double>::__type scalbn(_Tp __x, int __ex) { return __builtin_scalbn(__x, __ex); } constexpr float tgamma(float __x) { return __builtin_tgammaf(__x); } constexpr long double tgamma(long double __x) { return __builtin_tgammal(__x); } template<typename _Tp> constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, double>::__type tgamma(_Tp __x) { return __builtin_tgamma(__x); } constexpr float trunc(float __x) { return __builtin_truncf(__x); } constexpr long double trunc(long double __x) { return __builtin_truncl(__x); } template<typename _Tp> constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, double>::__type trunc(_Tp __x) { return __builtin_trunc(__x); } } } namespace CryptoPP { } namespace CryptoPP { class Integer; class RandomNumberGenerator; class BufferedTransformation; enum CipherDir { ENCRYPTION, DECRYPTION}; const unsigned long INFINITE_TIME = (0x7fffffffffffffffL * 2UL + 1UL) ; template <typename ENUM_TYPE, int VALUE> struct EnumToType { static ENUM_TYPE ToEnum() {return static_cast<ENUM_TYPE>(VALUE);} }; enum ByteOrder { LITTLE_ENDIAN_ORDER = 0, BIG_ENDIAN_ORDER = 1}; typedef EnumToType<ByteOrder, LITTLE_ENDIAN_ORDER> LittleEndian; typedef EnumToType<ByteOrder, BIG_ENDIAN_ORDER> BigEndian; class Exception : public std::exception { public: enum ErrorType { NOT_IMPLEMENTED, INVALID_ARGUMENT, CANNOT_FLUSH, DATA_INTEGRITY_CHECK_FAILED, INVALID_DATA_FORMAT, IO_ERROR, OTHER_ERROR }; virtual ~Exception() throw() {} explicit Exception(ErrorType errorType, const std::string &s) : m_errorType(errorType), m_what(s) {} const char *what() const throw() {return (m_what.c_str());} const std::string &GetWhat() const {return m_what;} void SetWhat(const std::string &s) {m_what = s;} ErrorType GetErrorType() const {return m_errorType;} void SetErrorType(ErrorType errorType) {m_errorType = errorType;} private: ErrorType m_errorType; std::string m_what; }; class InvalidArgument : public Exception { public: explicit InvalidArgument(const std::string &s) : Exception(INVALID_ARGUMENT, s) {} }; class InvalidDataFormat : public Exception { public: explicit InvalidDataFormat(const std::string &s) : Exception(INVALID_DATA_FORMAT, s) {} }; class InvalidCiphertext : public InvalidDataFormat { public: explicit InvalidCiphertext(const std::string &s) : InvalidDataFormat(s) {} }; class NotImplemented : public Exception { public: explicit NotImplemented(const std::string &s) : Exception(NOT_IMPLEMENTED, s) {} }; class CannotFlush : public Exception { public: explicit CannotFlush(const std::string &s) : Exception(CANNOT_FLUSH, s) {} }; class OS_Error : public Exception { public: virtual ~OS_Error() throw() {} OS_Error(ErrorType errorType, const std::string &s, const std::string& operation, int errorCode) : Exception(errorType, s), m_operation(operation), m_errorCode(errorCode) {} const std::string & GetOperation() const {return m_operation;} int GetErrorCode() const {return m_errorCode;} protected: std::string m_operation; int m_errorCode; }; struct DecodingResult { explicit DecodingResult() : isValidCoding(false), messageLength(0) {} explicit DecodingResult(size_t len) : isValidCoding(true), messageLength(len) {} bool operator==(const DecodingResult &rhs) const {return isValidCoding == rhs.isValidCoding && messageLength == rhs.messageLength;} bool operator!=(const DecodingResult &rhs) const {return !operator==(rhs);} bool isValidCoding; size_t messageLength; }; class NameValuePairs { public: virtual ~NameValuePairs() {} class ValueTypeMismatch : public InvalidArgument { public: ValueTypeMismatch(const std::string &name, const std::type_info &stored, const std::type_info &retrieving) : InvalidArgument("NameValuePairs: type mismatch for '" + name + "', stored '" + stored.name() + "', trying to retrieve '" + retrieving.name() + "'") , m_stored(stored), m_retrieving(retrieving) {} const std::type_info & GetStoredTypeInfo() const {return m_stored;} const std::type_info & GetRetrievingTypeInfo() const {return m_retrieving;} private: const std::type_info &m_stored; const std::type_info &m_retrieving; }; template <class T> bool GetThisObject(T &object) const { return GetValue((std::string("ThisObject:")+typeid(T).name()).c_str(), object); } template <class T> bool GetThisPointer(T *&ptr) const { return GetValue((std::string("ThisPointer:")+typeid(T).name()).c_str(), ptr); } template <class T> bool GetValue(const char *name, T &value) const { return GetVoidValue(name, typeid(T), &value); } template <class T> T GetValueWithDefault(const char *name, T defaultValue) const { T value; bool result = GetValue(name, value); if (result) {return value;} return defaultValue; } std::string GetValueNames() const {std::string result; GetValue("ValueNames", result); return result;} bool GetIntValue(const char *name, int &value) const {return GetValue(name, value);} int GetIntValueWithDefault(const char *name, int defaultValue) const {return GetValueWithDefault(name, defaultValue);} bool GetWord64Value(const char *name, word64 &value) const {return GetValue(name, value);} word64 GetWord64ValueWithDefault(const char *name, word64 defaultValue) const {return GetValueWithDefault(name, defaultValue);} static void ThrowIfTypeMismatch(const char *name, const std::type_info &stored, const std::type_info &retrieving) {if (stored != retrieving) throw ValueTypeMismatch(name, stored, retrieving);} template <class T> void GetRequiredParameter(const char *className, const char *name, T &value) const { if (!GetValue(name, value)) throw InvalidArgument(std::string(className) + ": missing required parameter '" + name + "'"); } void GetRequiredIntParameter(const char *className, const char *name, int &value) const { if (!GetIntValue(name, value)) throw InvalidArgument(std::string(className) + ": missing required parameter '" + name + "'"); } virtual bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const =0; }; extern const std::string DEFAULT_CHANNEL; extern const std::string AAD_CHANNEL; extern const NameValuePairs& g_nullNameValuePairs; namespace NaCl { } namespace Test { } class Clonable { public: virtual ~Clonable() {} virtual Clonable* Clone() const {throw NotImplemented("Clone() is not implemented yet.");} }; class Algorithm : public Clonable { public: virtual ~Algorithm() {} Algorithm(bool checkSelfTestStatus = true); virtual std::string AlgorithmName() const {return "unknown";} virtual std::string AlgorithmProvider() const {return "C++";} }; class SimpleKeyingInterface { public: virtual ~SimpleKeyingInterface() {} virtual size_t MinKeyLength() const =0; virtual size_t MaxKeyLength() const =0; virtual size_t DefaultKeyLength() const =0; virtual size_t GetValidKeyLength(size_t keylength) const =0; virtual bool IsValidKeyLength(size_t keylength) const {return keylength == GetValidKeyLength(keylength);} virtual void SetKey(const byte *key, size_t length, const NameValuePairs ¶ms = g_nullNameValuePairs); void SetKeyWithRounds(const byte *key, size_t length, int rounds); void SetKeyWithIV(const byte *key, size_t length, const byte *iv, size_t ivLength); void SetKeyWithIV(const byte *key, size_t length, const byte *iv) {SetKeyWithIV(key, length, iv, IVSize());} enum IV_Requirement { UNIQUE_IV = 0, RANDOM_IV, UNPREDICTABLE_RANDOM_IV, INTERNALLY_GENERATED_IV, NOT_RESYNCHRONIZABLE }; virtual IV_Requirement IVRequirement() const =0; bool IsResynchronizable() const {return IVRequirement() < NOT_RESYNCHRONIZABLE;} bool CanUseRandomIVs() const {return IVRequirement() <= UNPREDICTABLE_RANDOM_IV;} bool CanUsePredictableIVs() const {return IVRequirement() <= RANDOM_IV;} bool CanUseStructuredIVs() const {return IVRequirement() <= UNIQUE_IV;} virtual unsigned int IVSize() const {throw NotImplemented(GetAlgorithm().AlgorithmName() + ": this object doesn't support resynchronization");} unsigned int DefaultIVLength() const {return IVSize();} virtual unsigned int MinIVLength() const {return IVSize();} virtual unsigned int MaxIVLength() const {return IVSize();} virtual void Resynchronize(const byte *iv, int ivLength=-1) { ((void)(iv)); ((void)(ivLength)); throw NotImplemented(GetAlgorithm().AlgorithmName() + ": this object doesn't support resynchronization"); } virtual void GetNextIV(RandomNumberGenerator &rng, byte *iv); protected: virtual const Algorithm & GetAlgorithm() const =0; virtual void UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs ¶ms) =0; void ThrowIfInvalidKeyLength(size_t length); void ThrowIfResynchronizable(); void ThrowIfInvalidIV(const byte *iv); size_t ThrowIfInvalidIVLength(int length); const byte * GetIVAndThrowIfInvalid(const NameValuePairs ¶ms, size_t &size); inline void AssertValidKeyLength(size_t length) const {((void)(length)); (void)0;} }; class BlockTransformation : public Algorithm { public: virtual ~BlockTransformation() {} virtual void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const =0; void ProcessBlock(const byte *inBlock, byte *outBlock) const {ProcessAndXorBlock(inBlock, nullptr, outBlock);} void ProcessBlock(byte *inoutBlock) const {ProcessAndXorBlock(inoutBlock, nullptr, inoutBlock);} virtual unsigned int BlockSize() const =0; virtual unsigned int OptimalDataAlignment() const; virtual bool IsPermutation() const {return true;} virtual bool IsForwardTransformation() const =0; virtual unsigned int OptimalNumberOfParallelBlocks() const {return 1;} enum FlagsForAdvancedProcessBlocks { BT_InBlockIsCounter=1, BT_DontIncrementInOutPointers=2, BT_XorInput=4, BT_ReverseDirection=8, BT_AllowParallel=16}; virtual size_t AdvancedProcessBlocks(const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags) const; inline CipherDir GetCipherDirection() const {return IsForwardTransformation() ? ENCRYPTION : DECRYPTION;} }; class StreamTransformation : public Algorithm { public: virtual ~StreamTransformation() {} StreamTransformation& Ref() {return *this;} virtual unsigned int MandatoryBlockSize() const {return 1;} virtual unsigned int OptimalBlockSize() const {return MandatoryBlockSize();} virtual unsigned int GetOptimalBlockSizeUsed() const {return 0;} virtual unsigned int OptimalDataAlignment() const; virtual void ProcessData(byte *outString, const byte *inString, size_t length) =0; virtual size_t ProcessLastBlock(byte *outString, size_t outLength, const byte *inString, size_t inLength); virtual unsigned int MinLastBlockSize() const {return 0;} virtual bool IsLastBlockSpecial() const {return false;} inline void ProcessString(byte *inoutString, size_t length) {ProcessData(inoutString, inoutString, length);} inline void ProcessString(byte *outString, const byte *inString, size_t length) {ProcessData(outString, inString, length);} inline byte ProcessByte(byte input) {ProcessData(&input, &input, 1); return input;} virtual bool IsRandomAccess() const =0; virtual void Seek(lword pos) { ((void)(pos)); (void)0; throw NotImplemented("StreamTransformation: this object doesn't support random access"); } virtual bool IsSelfInverting() const =0; virtual bool IsForwardTransformation() const =0; }; class HashTransformation : public Algorithm { public: virtual ~HashTransformation() {} HashTransformation& Ref() {return *this;} virtual void Update(const byte *input, size_t length) =0; virtual byte * CreateUpdateSpace(size_t &size) {size=0; return nullptr;} virtual void Final(byte *digest) {TruncatedFinal(digest, DigestSize());} virtual void Restart() {TruncatedFinal(nullptr, 0);} virtual unsigned int DigestSize() const =0; unsigned int TagSize() const {return DigestSize();} virtual unsigned int BlockSize() const {return 0;} virtual unsigned int OptimalBlockSize() const {return 1;} virtual unsigned int OptimalDataAlignment() const; virtual void CalculateDigest(byte *digest, const byte *input, size_t length) {Update(input, length); Final(digest);} virtual bool Verify(const byte *digest) {return TruncatedVerify(digest, DigestSize());} virtual bool VerifyDigest(const byte *digest, const byte *input, size_t length) {Update(input, length); return Verify(digest);} virtual void TruncatedFinal(byte *digest, size_t digestSize) =0; virtual void CalculateTruncatedDigest(byte *digest, size_t digestSize, const byte *input, size_t length) {Update(input, length); TruncatedFinal(digest, digestSize);} virtual bool TruncatedVerify(const byte *digest, size_t digestLength); virtual bool VerifyTruncatedDigest(const byte *digest, size_t digestLength, const byte *input, size_t length) {Update(input, length); return TruncatedVerify(digest, digestLength);} protected: void ThrowIfInvalidTruncatedSize(size_t size) const; }; class BlockCipher : public SimpleKeyingInterface, public BlockTransformation { protected: const Algorithm & GetAlgorithm() const {return *this;} }; class SymmetricCipher : public SimpleKeyingInterface, public StreamTransformation { protected: const Algorithm & GetAlgorithm() const {return *this;} }; class MessageAuthenticationCode : public SimpleKeyingInterface, public HashTransformation { protected: const Algorithm & GetAlgorithm() const {return *this;} }; class AuthenticatedSymmetricCipher : public MessageAuthenticationCode, public StreamTransformation { public: virtual ~AuthenticatedSymmetricCipher() {} class BadState : public Exception { public: explicit BadState(const std::string &name, const char *message) : Exception(OTHER_ERROR, name + ": " + message) {} explicit BadState(const std::string &name, const char *function, const char *state) : Exception(OTHER_ERROR, name + ": " + function + " was called before " + state) {} }; virtual lword MaxHeaderLength() const =0; virtual lword MaxMessageLength() const =0; virtual lword MaxFooterLength() const {return 0;} virtual bool NeedsPrespecifiedDataLengths() const {return false;} void SpecifyDataLengths(lword headerLength, lword messageLength, lword footerLength=0); virtual void EncryptAndAuthenticate(byte *ciphertext, byte *mac, size_t macSize, const byte *iv, int ivLength, const byte *header, size_t headerLength, const byte *message, size_t messageLength); virtual bool DecryptAndVerify(byte *message, const byte *mac, size_t macSize, const byte *iv, int ivLength, const byte *header, size_t headerLength, const byte *ciphertext, size_t ciphertextLength); virtual std::string AlgorithmName() const; protected: const Algorithm & GetAlgorithm() const {return *static_cast<const MessageAuthenticationCode *>(this);} virtual void UncheckedSpecifyDataLengths(lword headerLength, lword messageLength, lword footerLength) {((void)(headerLength)); ((void)(messageLength)); ((void)(footerLength));} }; class RandomNumberGenerator : public Algorithm { public: virtual ~RandomNumberGenerator() {} virtual void IncorporateEntropy(const byte *input, size_t length) { ((void)(input)); ((void)(length)); throw NotImplemented("RandomNumberGenerator: IncorporateEntropy not implemented"); } virtual bool CanIncorporateEntropy() const {return false;} virtual byte GenerateByte(); virtual unsigned int GenerateBit(); virtual word32 GenerateWord32(word32 min=0, word32 max=0xffffffffUL); virtual void GenerateBlock(byte *output, size_t size); virtual void GenerateIntoBufferedTransformation(BufferedTransformation &target, const std::string &channel, lword length); virtual void DiscardBytes(size_t n); template <class IT> void Shuffle(IT begin, IT end) { for (; begin != end; ++begin) std::iter_swap(begin, begin + GenerateWord32(0, static_cast<word32>(end-begin-1))); } }; class KeyDerivationFunction : public Algorithm { public: virtual ~KeyDerivationFunction() {} virtual std::string AlgorithmName() const =0; virtual size_t MinDerivedKeyLength() const; virtual size_t MaxDerivedKeyLength() const; virtual size_t GetValidDerivedLength(size_t keylength) const =0; virtual bool IsValidDerivedLength(size_t keylength) const { return keylength == GetValidDerivedLength(keylength); } virtual size_t DeriveKey(byte *derived, size_t derivedLen, const byte *secret, size_t secretLen, const NameValuePairs& params = g_nullNameValuePairs) const =0; virtual void SetParameters(const NameValuePairs& params); protected: virtual const Algorithm & GetAlgorithm() const =0; void ThrowIfInvalidDerivedKeyLength(size_t length) const; }; struct PasswordBasedKeyDerivationFunction : public KeyDerivationFunction { }; RandomNumberGenerator & NullRNG(); class WaitObjectContainer; class CallStack; class Waitable { public: virtual ~Waitable() {} virtual unsigned int GetMaxWaitObjectCount() const =0; virtual void GetWaitObjects(WaitObjectContainer &container, CallStack const& callStack) =0; bool Wait(unsigned long milliseconds, CallStack const& callStack); }; class BufferedTransformation : public Algorithm, public Waitable { public: virtual ~BufferedTransformation() {} BufferedTransformation() : Algorithm(false) {} BufferedTransformation& Ref() {return *this;} size_t Put(byte inByte, bool blocking=true) {return Put(&inByte, 1, blocking);} size_t Put(const byte *inString, size_t length, bool blocking=true) {return Put2(inString, length, 0, blocking);} size_t PutWord16(word16 value, ByteOrder order=BIG_ENDIAN_ORDER, bool blocking=true); size_t PutWord32(word32 value, ByteOrder order=BIG_ENDIAN_ORDER, bool blocking=true); size_t PutWord64(word64 value, ByteOrder order=BIG_ENDIAN_ORDER, bool blocking=true); virtual byte * CreatePutSpace(size_t &size) {size=0; return nullptr;} virtual bool CanModifyInput() const {return false;} size_t PutModifiable(byte *inString, size_t length, bool blocking=true) {return PutModifiable2(inString, length, 0, blocking);} bool MessageEnd(int propagation=-1, bool blocking=true) {return !!Put2(nullptr, 0, propagation < 0 ? -1 : propagation+1, blocking);} size_t PutMessageEnd(const byte *inString, size_t length, int propagation=-1, bool blocking=true) {return Put2(inString, length, propagation < 0 ? -1 : propagation+1, blocking);} virtual size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking) =0; virtual size_t PutModifiable2(byte *inString, size_t length, int messageEnd, bool blocking) {return Put2(inString, length, messageEnd, blocking);} struct BlockingInputOnly : public NotImplemented {BlockingInputOnly(const std::string &s) : NotImplemented(s + ": Nonblocking input is not implemented by this object.") {}}; unsigned int GetMaxWaitObjectCount() const; void GetWaitObjects(WaitObjectContainer &container, CallStack const& callStack); virtual void IsolatedInitialize(const NameValuePairs ¶meters) { ((void)(parameters)); throw NotImplemented("BufferedTransformation: this object can't be reinitialized"); } virtual bool IsolatedFlush(bool hardFlush, bool blocking) =0; virtual bool IsolatedMessageSeriesEnd(bool blocking) {((void)(blocking)); return false;} virtual void Initialize(const NameValuePairs ¶meters=g_nullNameValuePairs, int propagation=-1); virtual bool Flush(bool hardFlush, int propagation=-1, bool blocking=true); virtual bool MessageSeriesEnd(int propagation=-1, bool blocking=true); virtual void SetAutoSignalPropagation(int propagation) {((void)(propagation));} virtual int GetAutoSignalPropagation() const {return 0;} public: virtual lword MaxRetrievable() const; virtual bool AnyRetrievable() const; virtual size_t Get(byte &outByte); virtual size_t Get(byte *outString, size_t getMax); virtual size_t Peek(byte &outByte) const; virtual size_t Peek(byte *outString, size_t peekMax) const; size_t GetWord16(word16 &value, ByteOrder order=BIG_ENDIAN_ORDER); size_t GetWord32(word32 &value, ByteOrder order=BIG_ENDIAN_ORDER); size_t GetWord64(word64 &value, ByteOrder order=BIG_ENDIAN_ORDER); size_t PeekWord16(word16 &value, ByteOrder order=BIG_ENDIAN_ORDER) const; size_t PeekWord32(word32 &value, ByteOrder order=BIG_ENDIAN_ORDER) const; size_t PeekWord64(word64 &value, ByteOrder order=BIG_ENDIAN_ORDER) const; lword TransferTo(BufferedTransformation &target, lword transferMax=LWORD_MAX, const std::string &channel=DEFAULT_CHANNEL) {TransferTo2(target, transferMax, channel); return transferMax;} virtual lword Skip(lword skipMax=LWORD_MAX); lword CopyTo(BufferedTransformation &target, lword copyMax=LWORD_MAX, const std::string &channel=DEFAULT_CHANNEL) const {return CopyRangeTo(target, 0, copyMax, channel);} lword CopyRangeTo(BufferedTransformation &target, lword position, lword copyMax=LWORD_MAX, const std::string &channel=DEFAULT_CHANNEL) const {lword i = position; CopyRangeTo2(target, i, i+copyMax, channel); return i-position;} virtual lword TotalBytesRetrievable() const; virtual unsigned int NumberOfMessages() const; virtual bool AnyMessages() const; virtual bool GetNextMessage(); virtual unsigned int SkipMessages(unsigned int count= (0x7fffffff * 2U + 1U) ); unsigned int TransferMessagesTo(BufferedTransformation &target, unsigned int count= (0x7fffffff * 2U + 1U) , const std::string &channel=DEFAULT_CHANNEL) {TransferMessagesTo2(target, count, channel); return count;} unsigned int CopyMessagesTo(BufferedTransformation &target, unsigned int count= (0x7fffffff * 2U + 1U) , const std::string &channel=DEFAULT_CHANNEL) const; virtual void SkipAll(); void TransferAllTo(BufferedTransformation &target, const std::string &channel=DEFAULT_CHANNEL) {TransferAllTo2(target, channel);} void CopyAllTo(BufferedTransformation &target, const std::string &channel=DEFAULT_CHANNEL) const; virtual bool GetNextMessageSeries() {return false;} virtual unsigned int NumberOfMessagesInThisSeries() const {return NumberOfMessages();} virtual unsigned int NumberOfMessageSeries() const {return 0;} virtual size_t TransferTo2(BufferedTransformation &target, lword &byteCount, const std::string &channel=DEFAULT_CHANNEL, bool blocking=true) =0; virtual size_t CopyRangeTo2(BufferedTransformation &target, lword &begin, lword end=LWORD_MAX, const std::string &channel=DEFAULT_CHANNEL, bool blocking=true) const =0; size_t TransferMessagesTo2(BufferedTransformation &target, unsigned int &messageCount, const std::string &channel=DEFAULT_CHANNEL, bool blocking=true); size_t TransferAllTo2(BufferedTransformation &target, const std::string &channel=DEFAULT_CHANNEL, bool blocking=true); struct NoChannelSupport : public NotImplemented {NoChannelSupport(const std::string &name) : NotImplemented(name + ": this object doesn't support multiple channels") {}}; struct InvalidChannelName : public InvalidArgument {InvalidChannelName(const std::string &name, const std::string &channel) : InvalidArgument(name + ": unexpected channel name \"" + channel + "\"") {}}; size_t ChannelPut(const std::string &channel, byte inByte, bool blocking=true) {return ChannelPut(channel, &inByte, 1, blocking);} size_t ChannelPut(const std::string &channel, const byte *inString, size_t length, bool blocking=true) {return ChannelPut2(channel, inString, length, 0, blocking);} size_t ChannelPutModifiable(const std::string &channel, byte *inString, size_t length, bool blocking=true) {return ChannelPutModifiable2(channel, inString, length, 0, blocking);} size_t ChannelPutWord16(const std::string &channel, word16 value, ByteOrder order=BIG_ENDIAN_ORDER, bool blocking=true); size_t ChannelPutWord32(const std::string &channel, word32 value, ByteOrder order=BIG_ENDIAN_ORDER, bool blocking=true); size_t ChannelPutWord64(const std::string &channel, word64 value, ByteOrder order=BIG_ENDIAN_ORDER, bool blocking=true); bool ChannelMessageEnd(const std::string &channel, int propagation=-1, bool blocking=true) {return !!ChannelPut2(channel, nullptr, 0, propagation < 0 ? -1 : propagation+1, blocking);} size_t ChannelPutMessageEnd(const std::string &channel, const byte *inString, size_t length, int propagation=-1, bool blocking=true) {return ChannelPut2(channel, inString, length, propagation < 0 ? -1 : propagation+1, blocking);} virtual byte * ChannelCreatePutSpace(const std::string &channel, size_t &size); virtual size_t ChannelPut2(const std::string &channel, const byte *inString, size_t length, int messageEnd, bool blocking); virtual size_t ChannelPutModifiable2(const std::string &channel, byte *inString, size_t length, int messageEnd, bool blocking); virtual bool ChannelFlush(const std::string &channel, bool hardFlush, int propagation=-1, bool blocking=true); virtual bool ChannelMessageSeriesEnd(const std::string &channel, int propagation=-1, bool blocking=true); virtual void SetRetrievalChannel(const std::string &channel); virtual bool Attachable() {return false;} virtual BufferedTransformation *AttachedTransformation() {(void)0; return nullptr;} virtual const BufferedTransformation *AttachedTransformation() const {return const_cast<BufferedTransformation *>(this)->AttachedTransformation();} virtual void Detach(BufferedTransformation *newAttachment = nullptr) { ((void)(newAttachment)); (void)0; throw NotImplemented("BufferedTransformation: this object is not attachable"); } virtual void Attach(BufferedTransformation *newAttachment); protected: static int DecrementPropagation(int propagation) {return propagation != 0 ? propagation - 1 : 0;} private: byte m_buf[8]; }; BufferedTransformation & TheBitBucket(); class CryptoMaterial : public NameValuePairs { public: class InvalidMaterial : public InvalidDataFormat { public: explicit InvalidMaterial(const std::string &s) : InvalidDataFormat(s) {} }; virtual ~CryptoMaterial() {} virtual void AssignFrom(const NameValuePairs &source) =0; virtual bool Validate(RandomNumberGenerator &rng, unsigned int level) const =0; virtual void ThrowIfInvalid(RandomNumberGenerator &rng, unsigned int level) const {if (!Validate(rng, level)) throw InvalidMaterial("CryptoMaterial: this object contains invalid values");} virtual void Save(BufferedTransformation &bt) const {((void)(bt)); throw NotImplemented("CryptoMaterial: this object does not support saving");} virtual void Load(BufferedTransformation &bt) {((void)(bt)); throw NotImplemented("CryptoMaterial: this object does not support loading");} virtual bool SupportsPrecomputation() const {return false;} virtual void Precompute(unsigned int precomputationStorage) { ((void)(precomputationStorage)); (void)0; throw NotImplemented("CryptoMaterial: this object does not support precomputation"); } virtual void LoadPrecomputation(BufferedTransformation &storedPrecomputation) {((void)(storedPrecomputation)); (void)0; throw NotImplemented("CryptoMaterial: this object does not support precomputation");} virtual void SavePrecomputation(BufferedTransformation &storedPrecomputation) const {((void)(storedPrecomputation)); (void)0; throw NotImplemented("CryptoMaterial: this object does not support precomputation");} void DoQuickSanityCheck() const {ThrowIfInvalid(NullRNG(), 0);} }; class GeneratableCryptoMaterial : virtual public CryptoMaterial { public: virtual ~GeneratableCryptoMaterial() {} virtual void GenerateRandom(RandomNumberGenerator &rng, const NameValuePairs ¶ms = g_nullNameValuePairs) { ((void)(rng)); ((void)(params)); throw NotImplemented("GeneratableCryptoMaterial: this object does not support key/parameter generation"); } void GenerateRandomWithKeySize(RandomNumberGenerator &rng, unsigned int keySize); }; class PublicKey : virtual public CryptoMaterial { }; class PrivateKey : public GeneratableCryptoMaterial { }; class CryptoParameters : public GeneratableCryptoMaterial { }; class Certificate : virtual public CryptoMaterial { }; class AsymmetricAlgorithm : public Algorithm { public: virtual ~AsymmetricAlgorithm() {} virtual CryptoMaterial & AccessMaterial() =0; virtual const CryptoMaterial & GetMaterial() const =0; }; class PublicKeyAlgorithm : public AsymmetricAlgorithm { public: virtual ~PublicKeyAlgorithm() {} CryptoMaterial & AccessMaterial() {return AccessPublicKey();} const CryptoMaterial & GetMaterial() const {return GetPublicKey();} virtual PublicKey & AccessPublicKey() =0; virtual const PublicKey & GetPublicKey() const {return const_cast<PublicKeyAlgorithm *>(this)->AccessPublicKey();} }; class PrivateKeyAlgorithm : public AsymmetricAlgorithm { public: virtual ~PrivateKeyAlgorithm() {} CryptoMaterial & AccessMaterial() {return AccessPrivateKey();} const CryptoMaterial & GetMaterial() const {return GetPrivateKey();} virtual PrivateKey & AccessPrivateKey() =0; virtual const PrivateKey & GetPrivateKey() const {return const_cast<PrivateKeyAlgorithm *>(this)->AccessPrivateKey();} }; class KeyAgreementAlgorithm : public AsymmetricAlgorithm { public: virtual ~KeyAgreementAlgorithm() {} CryptoMaterial & AccessMaterial() {return AccessCryptoParameters();} const CryptoMaterial & GetMaterial() const {return GetCryptoParameters();} virtual CryptoParameters & AccessCryptoParameters() =0; virtual const CryptoParameters & GetCryptoParameters() const {return const_cast<KeyAgreementAlgorithm *>(this)->AccessCryptoParameters();} }; class PK_CryptoSystem { public: virtual ~PK_CryptoSystem() {} virtual size_t MaxPlaintextLength(size_t ciphertextLength) const =0; virtual size_t CiphertextLength(size_t plaintextLength) const =0; virtual bool ParameterSupported(const char *name) const =0; virtual size_t FixedCiphertextLength() const {return 0;} virtual size_t FixedMaxPlaintextLength() const {return 0;} }; class PK_Encryptor : public PK_CryptoSystem, public PublicKeyAlgorithm { public: class InvalidPlaintextLength : public Exception { public: InvalidPlaintextLength() : Exception(OTHER_ERROR, "PK_Encryptor: invalid plaintext length") {} }; virtual void Encrypt(RandomNumberGenerator &rng, const byte *plaintext, size_t plaintextLength, byte *ciphertext, const NameValuePairs ¶meters = g_nullNameValuePairs) const =0; virtual BufferedTransformation * CreateEncryptionFilter(RandomNumberGenerator &rng, BufferedTransformation *attachment=nullptr, const NameValuePairs ¶meters = g_nullNameValuePairs) const; }; class PK_Decryptor : public PK_CryptoSystem, public PrivateKeyAlgorithm { public: virtual ~PK_Decryptor() {} virtual DecodingResult Decrypt(RandomNumberGenerator &rng, const byte *ciphertext, size_t ciphertextLength, byte *plaintext, const NameValuePairs ¶meters = g_nullNameValuePairs) const =0; virtual BufferedTransformation * CreateDecryptionFilter(RandomNumberGenerator &rng, BufferedTransformation *attachment=nullptr, const NameValuePairs ¶meters = g_nullNameValuePairs) const; DecodingResult FixedLengthDecrypt(RandomNumberGenerator &rng, const byte *ciphertext, byte *plaintext, const NameValuePairs ¶meters = g_nullNameValuePairs) const {return Decrypt(rng, ciphertext, FixedCiphertextLength(), plaintext, parameters);} }; class PK_SignatureScheme { public: class InvalidKeyLength : public Exception { public: InvalidKeyLength(const std::string &message) : Exception(OTHER_ERROR, message) {} }; class KeyTooShort : public InvalidKeyLength { public: KeyTooShort() : InvalidKeyLength("PK_Signer: key too short for this signature scheme") {} }; virtual ~PK_SignatureScheme() {} virtual size_t SignatureLength() const =0; virtual size_t MaxSignatureLength(size_t recoverablePartLength = 0) const {((void)(recoverablePartLength)); return SignatureLength();} virtual size_t MaxRecoverableLength() const =0; virtual size_t MaxRecoverableLengthFromSignatureLength(size_t signatureLength) const =0; virtual bool IsProbabilistic() const =0; virtual bool AllowNonrecoverablePart() const =0; virtual bool SignatureUpfront() const {return false;} virtual bool RecoverablePartFirst() const =0; }; class PK_MessageAccumulator : public HashTransformation { public: unsigned int DigestSize() const {throw NotImplemented("PK_MessageAccumulator: DigestSize() should not be called");} void TruncatedFinal(byte *digest, size_t digestSize) { ((void)(digest)); ((void)(digestSize)); throw NotImplemented("PK_MessageAccumulator: TruncatedFinal() should not be called"); } }; class PK_Signer : public PK_SignatureScheme, public PrivateKeyAlgorithm { public: virtual ~PK_Signer() {} virtual PK_MessageAccumulator * NewSignatureAccumulator(RandomNumberGenerator &rng) const =0; virtual void InputRecoverableMessage(PK_MessageAccumulator &messageAccumulator, const byte *recoverableMessage, size_t recoverableMessageLength) const =0; virtual size_t Sign(RandomNumberGenerator &rng, PK_MessageAccumulator *messageAccumulator, byte *signature) const; virtual size_t SignAndRestart(RandomNumberGenerator &rng, PK_MessageAccumulator &messageAccumulator, byte *signature, bool restart=true) const =0; virtual size_t SignMessage(RandomNumberGenerator &rng, const byte *message, size_t messageLen, byte *signature) const; virtual size_t SignMessageWithRecovery(RandomNumberGenerator &rng, const byte *recoverableMessage, size_t recoverableMessageLength, const byte *nonrecoverableMessage, size_t nonrecoverableMessageLength, byte *signature) const; }; class PK_Verifier : public PK_SignatureScheme, public PublicKeyAlgorithm { public: virtual ~PK_Verifier() {} virtual PK_MessageAccumulator * NewVerificationAccumulator() const =0; virtual void InputSignature(PK_MessageAccumulator &messageAccumulator, const byte *signature, size_t signatureLength) const =0; virtual bool Verify(PK_MessageAccumulator *messageAccumulator) const; virtual bool VerifyAndRestart(PK_MessageAccumulator &messageAccumulator) const =0; virtual bool VerifyMessage(const byte *message, size_t messageLen, const byte *signature, size_t signatureLen) const; virtual DecodingResult Recover(byte *recoveredMessage, PK_MessageAccumulator *messageAccumulator) const; virtual DecodingResult RecoverAndRestart(byte *recoveredMessage, PK_MessageAccumulator &messageAccumulator) const =0; virtual DecodingResult RecoverMessage(byte *recoveredMessage, const byte *nonrecoverableMessage, size_t nonrecoverableMessageLength, const byte *signature, size_t signatureLength) const; }; class SimpleKeyAgreementDomain : public KeyAgreementAlgorithm { public: virtual ~SimpleKeyAgreementDomain() {} virtual unsigned int AgreedValueLength() const =0; virtual unsigned int PrivateKeyLength() const =0; virtual unsigned int PublicKeyLength() const =0; virtual void GeneratePrivateKey(RandomNumberGenerator &rng, byte *privateKey) const =0; virtual void GeneratePublicKey(RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const =0; virtual void GenerateKeyPair(RandomNumberGenerator &rng, byte *privateKey, byte *publicKey) const; virtual bool Agree(byte *agreedValue, const byte *privateKey, const byte *otherPublicKey, bool validateOtherPublicKey=true) const =0; }; class AuthenticatedKeyAgreementDomain : public KeyAgreementAlgorithm { public: virtual ~AuthenticatedKeyAgreementDomain() {} virtual unsigned int AgreedValueLength() const =0; virtual unsigned int StaticPrivateKeyLength() const =0; virtual unsigned int StaticPublicKeyLength() const =0; virtual void GenerateStaticPrivateKey(RandomNumberGenerator &rng, byte *privateKey) const =0; virtual void GenerateStaticPublicKey(RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const =0; virtual void GenerateStaticKeyPair(RandomNumberGenerator &rng, byte *privateKey, byte *publicKey) const; virtual unsigned int EphemeralPrivateKeyLength() const =0; virtual unsigned int EphemeralPublicKeyLength() const =0; virtual void GenerateEphemeralPrivateKey(RandomNumberGenerator &rng, byte *privateKey) const =0; virtual void GenerateEphemeralPublicKey(RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const =0; virtual void GenerateEphemeralKeyPair(RandomNumberGenerator &rng, byte *privateKey, byte *publicKey) const; virtual bool Agree(byte *agreedValue, const byte *staticPrivateKey, const byte *ephemeralPrivateKey, const byte *staticOtherPublicKey, const byte *ephemeralOtherPublicKey, bool validateStaticOtherPublicKey=true) const =0; }; class BERDecodeErr : public InvalidArgument { public: BERDecodeErr() : InvalidArgument("BER decode error") {} BERDecodeErr(const std::string &s) : InvalidArgument(s) {} }; class ASN1Object { public: virtual ~ASN1Object() {} virtual void BERDecode(BufferedTransformation &bt) =0; virtual void DEREncode(BufferedTransformation &bt) const =0; virtual void BEREncode(BufferedTransformation &bt) const {DEREncode(bt);} }; extern "C" { int LibraryVersion(); } extern "C" { inline int HeaderVersion() { return 830; } } } namespace CryptoPP { template <class T, class A> class SecBlock; template <class T, bool A> class AllocatorWithCleanup; typedef SecBlock<byte, AllocatorWithCleanup<byte, false> > SecByteBlock; typedef SecBlock<word, AllocatorWithCleanup<word, false> > SecWordBlock; typedef SecBlock<byte, AllocatorWithCleanup<byte, true> > AlignedSecByteBlock; } namespace CryptoPP { template <class T> class simple_ptr { public: simple_ptr(T *p = nullptr) : m_p(p) {} ~simple_ptr() { delete m_p; m_p = nullptr; } T *m_p; }; template <class T> class member_ptr { public: explicit member_ptr(T *p = nullptr) : m_p(p) {} ~member_ptr(); const T& operator*() const { return *m_p; } T& operator*() { return *m_p; } const T* operator->() const { return m_p; } T* operator->() { return m_p; } const T* get() const { return m_p; } T* get() { return m_p; } T* release() { T *old_p = m_p; m_p = nullptr; return old_p; } void reset(T *p = nullptr); protected: member_ptr(const member_ptr<T>& rhs); void operator=(const member_ptr<T>& rhs); T *m_p; }; template <class T> member_ptr<T>::~member_ptr() {delete m_p;} template <class T> void member_ptr<T>::reset(T *p) {delete m_p; m_p = p;} template<class T> class value_ptr : public member_ptr<T> { public: value_ptr(const T &obj) : member_ptr<T>(new T(obj)) {} value_ptr(T *p = nullptr) : member_ptr<T>(p) {} value_ptr(const value_ptr<T>& rhs) : member_ptr<T>(rhs.m_p ? new T(*rhs.m_p) : nullptr) {} value_ptr<T>& operator=(const value_ptr<T>& rhs); bool operator==(const value_ptr<T>& rhs) { return (!this->m_p && !rhs.m_p) || (this->m_p && rhs.m_p && *this->m_p == *rhs.m_p); } }; template <class T> value_ptr<T>& value_ptr<T>::operator=(const value_ptr<T>& rhs) { T *old_p = this->m_p; this->m_p = rhs.m_p ? new T(*rhs.m_p) : nullptr; delete old_p; return *this; } template<class T> class clonable_ptr : public member_ptr<T> { public: clonable_ptr(const T &obj) : member_ptr<T>(obj.Clone()) {} clonable_ptr(T *p = nullptr) : member_ptr<T>(p) {} clonable_ptr(const clonable_ptr<T>& rhs) : member_ptr<T>(rhs.m_p ? rhs.m_p->Clone() : nullptr) {} clonable_ptr<T>& operator=(const clonable_ptr<T>& rhs); }; template <class T> clonable_ptr<T>& clonable_ptr<T>::operator=(const clonable_ptr<T>& rhs) { T *old_p = this->m_p; this->m_p = rhs.m_p ? rhs.m_p->Clone() : nullptr; delete old_p; return *this; } template<class T> class counted_ptr { public: explicit counted_ptr(T *p = nullptr); counted_ptr(const T &r) : m_p(0) {attach(r);} counted_ptr(const counted_ptr<T>& rhs); ~counted_ptr(); const T& operator*() const { return *m_p; } T& operator*() { return *m_p; } const T* operator->() const { return m_p; } T* operator->() { return get(); } const T* get() const { return m_p; } T* get(); void attach(const T &p); counted_ptr<T> & operator=(const counted_ptr<T>& rhs); private: T *m_p; }; template <class T> counted_ptr<T>::counted_ptr(T *p) : m_p(p) { if (m_p) m_p->m_referenceCount = 1; } template <class T> counted_ptr<T>::counted_ptr(const counted_ptr<T>& rhs) : m_p(rhs.m_p) { if (m_p) m_p->m_referenceCount++; } template <class T> counted_ptr<T>::~counted_ptr() { if (m_p && --m_p->m_referenceCount == 0) delete m_p; } template <class T> void counted_ptr<T>::attach(const T &r) { if (m_p && --m_p->m_referenceCount == 0) delete m_p; if (r.m_referenceCount == 0) { m_p = r.clone(); m_p->m_referenceCount = 1; } else { m_p = const_cast<T *>(&r); m_p->m_referenceCount++; } } template <class T> T* counted_ptr<T>::get() { if (m_p && m_p->m_referenceCount > 1) { T *temp = m_p->clone(); m_p->m_referenceCount--; m_p = temp; m_p->m_referenceCount = 1; } return m_p; } template <class T> counted_ptr<T> & counted_ptr<T>::operator=(const counted_ptr<T>& rhs) { if (m_p != rhs.m_p) { if (m_p && --m_p->m_referenceCount == 0) delete m_p; m_p = rhs.m_p; if (m_p) m_p->m_referenceCount++; } return *this; } template <class T> class vector_member_ptrs { public: vector_member_ptrs(size_t size=0) : m_size(size), m_ptr(new member_ptr<T>[size]) {} ~vector_member_ptrs() {delete [] this->m_ptr;} member_ptr<T>& operator[](size_t index) {(void)0; return this->m_ptr[index];} const member_ptr<T>& operator[](size_t index) const {(void)0; return this->m_ptr[index];} size_t size() const {return this->m_size;} void resize(size_t newSize) { member_ptr<T> *newPtr = new member_ptr<T>[newSize]; for (size_t i=0; i<this->m_size && i<newSize; i++) newPtr[i].reset(this->m_ptr[i].release()); delete [] this->m_ptr; this->m_size = newSize; this->m_ptr = newPtr; } private: vector_member_ptrs(const vector_member_ptrs<T> &c); void operator=(const vector_member_ptrs<T> &x); size_t m_size; member_ptr<T> *m_ptr; }; } namespace CryptoPP { class Integer; template <bool b> struct CompileAssert { static char dummy[2*b-1]; }; class Empty { }; template <class BASE1, class BASE2> class TwoBases : public BASE1, public BASE2 { }; template <class BASE1, class BASE2, class BASE3> class ThreeBases : public BASE1, public BASE2, public BASE3 { }; template <class T> class ObjectHolder { protected: T m_object; }; class NotCopyable { public: NotCopyable() {} NotCopyable(const NotCopyable &) = delete; void operator=(const NotCopyable &) = delete; }; template <class T> struct NewObject { T* operator()() const {return new T;} }; template <class T, class F = NewObject<T>, int instance=0> class Singleton { public: Singleton(F objectFactory = F()) : m_objectFactory(objectFactory) {} __attribute__((noinline)) const T & Ref() const; private: F m_objectFactory; }; template <class T, class F, int instance> const T & Singleton<T, F, instance>::Ref() const { static std::mutex s_mutex; static std::atomic<T*> s_pObject; T *p = s_pObject.load(std::memory_order_relaxed); std::atomic_thread_fence(std::memory_order_acquire); if (p) return *p; std::lock_guard<std::mutex> lock(s_mutex); p = s_pObject.load(std::memory_order_relaxed); std::atomic_thread_fence(std::memory_order_acquire); if (p) return *p; T *newObject = m_objectFactory(); s_pObject.store(newObject, std::memory_order_relaxed); std::atomic_thread_fence(std::memory_order_release); return *newObject; } template <typename PTR, typename OFF> inline PTR PtrAdd(PTR pointer, OFF offset) { return pointer+static_cast<ptrdiff_t>(offset); } template <typename PTR, typename OFF> inline PTR PtrSub(PTR pointer, OFF offset) { return pointer-static_cast<ptrdiff_t>(offset); } template <typename PTR> inline ptrdiff_t PtrDiff(const PTR pointer1, const PTR pointer2) { return pointer1 - pointer2; } template <typename PTR> inline size_t PtrByteDiff(const PTR pointer1, const PTR pointer2) { return (size_t)(reinterpret_cast<uintptr_t>(pointer1) - reinterpret_cast<uintptr_t>(pointer2)); } inline byte* BytePtr(std::string& str) { (void)0; if (str.empty()) return nullptr; return reinterpret_cast<byte*>(&str[0]); } byte* BytePtr(SecByteBlock& str); inline const byte* ConstBytePtr(const std::string& str) { if (str.empty()) return nullptr; return reinterpret_cast<const byte*>(&str[0]); } const byte* ConstBytePtr(const SecByteBlock& str); inline size_t BytePtrSize(const std::string& str) { return str.size(); } size_t BytePtrSize(const SecByteBlock& str); inline void memcpy_s(void *dest, size_t sizeInBytes, const void *src, size_t count) { (void)0; (void)0; (void)0; (void)0; if (count > sizeInBytes) throw InvalidArgument("memcpy_s: buffer overflow"); if (src && dest) memcpy(dest, src, count); } inline void memmove_s(void *dest, size_t sizeInBytes, const void *src, size_t count) { (void)0; (void)0; (void)0; if (count > sizeInBytes) throw InvalidArgument("memmove_s: buffer overflow"); if (src && dest) memmove(dest, src, count); } template <class T> inline void vec_swap(T& a, T& b) { std::swap(a, b); } inline void * memset_z(void *ptr, int value, size_t num) { if (__builtin_constant_p(num) && num==0) return ptr; volatile void* x = memset(ptr, value, num); return const_cast<void*>(x); } template <class T> inline const T& STDMIN(const T& a, const T& b) { return b < a ? b : a; } template <class T> inline const T& STDMAX(const T& a, const T& b) { return a < b ? b : a; } template <class T1, class T2> inline const T1 UnsignedMin(const T1& a, const T2& b) { static CompileAssert<((sizeof(T1)<=sizeof(T2) && T2(-1)>0) || (sizeof(T1)>sizeof(T2) && T1(-1)>0))> cryptopp_CRYPTOPP_ASSERT_673 __attribute__ ((unused)); if (sizeof(T1)<=sizeof(T2)) return b < (T2)a ? (T1)b : a; else return (T1)b < a ? (T1)b : a; } template <class T1, class T2> inline bool SafeConvert(T1 from, T2 &to) { to = static_cast<T2>(from); if (from != to || (from > 0) != (to > 0)) return false; return true; } template <class T> std::string IntToString(T value, unsigned int base = 10) { const unsigned int HIGH_BIT = (1U << 31); const char CH = !!(base & HIGH_BIT) ? 'A' : 'a'; base &= ~HIGH_BIT; (void)0; if (value == 0) return "0"; bool negate = false; if (value < 0) { negate = true; value = 0-value; } std::string result; while (value > 0) { T digit = value % base; result = char((digit < 10 ? '0' : (CH - 10)) + digit) + result; value /= base; } if (negate) result = "-" + result; return result; } template <> std::string IntToString<word64>(word64 value, unsigned int base); template <> std::string IntToString<Integer>(Integer value, unsigned int base); template <class T> unsigned int Parity(T value) { for (unsigned int i=8*sizeof(value)/2; i>0; i/=2) value ^= value >> i; return (unsigned int)value&1; } template <class T> unsigned int BytePrecision(const T &value) { if (!value) return 0; unsigned int l=0, h=8*sizeof(value); while (h-l > 8) { unsigned int t = (l+h)/2; if (value >> t) l = t; else h = t; } return h/8; } template <class T> unsigned int BitPrecision(const T &value) { if (!value) return 0; unsigned int l=0, h=8*sizeof(value); while (h-l > 1) { unsigned int t = (l+h)/2; if (value >> t) l = t; else h = t; } return h; } inline unsigned int TrailingZeros(word32 v) { (void)0; return (unsigned int)__builtin_ctz(v); } inline unsigned int TrailingZeros(word64 v) { (void)0; return (unsigned int)__builtin_ctzll(v); } template <class T> inline T Crop(T value, size_t bits) { if (bits < 8*sizeof(value)) return T(value & ((T(1) << bits) - 1)); else return value; } inline size_t BitsToBytes(size_t bitCount) { return ((bitCount+7)/(8)); } inline size_t BytesToWords(size_t byteCount) { return ((byteCount+WORD_SIZE-1)/WORD_SIZE); } inline size_t BitsToWords(size_t bitCount) { return ((bitCount+WORD_BITS-1)/(WORD_BITS)); } inline size_t BitsToDwords(size_t bitCount) { return ((bitCount+2*WORD_BITS-1)/(2*WORD_BITS)); } void xorbuf(byte *buf, const byte *mask, size_t count); void xorbuf(byte *output, const byte *input, const byte *mask, size_t count); bool VerifyBufsEqual(const byte *buf1, const byte *buf2, size_t count); template <class T> inline bool IsPowerOf2(const T &value) { return value > 0 && (value & (value-1)) == 0; } template<class T> inline T NumericLimitsMin() { (void)0; return (std::numeric_limits<T>::min)(); } template<class T> inline T NumericLimitsMax() { (void)0; return (std::numeric_limits<T>::max)(); } template<> inline word128 NumericLimitsMin() { return 0; } template<> inline word128 NumericLimitsMax() { return (static_cast<word128>(LWORD_MAX) << 64U) | LWORD_MAX; } template <class T1, class T2> inline T1 SaturatingSubtract(const T1 &a, const T2 &b) { return T1((a > b) ? (a - b) : 0); } template <class T1, class T2> inline T1 SaturatingSubtract1(const T1 &a, const T2 &b) { return T1((a > b) ? (a - b) : 1); } template <class T1, class T2> inline T2 ModPowerOf2(const T1 &a, const T2 &b) { (void)0; return T2(a) & SaturatingSubtract(b,1U); } template <class T1, class T2> inline T1 RoundDownToMultipleOf(const T1 &n, const T2 &m) { (void)0; (void)0; (void)0; (void)0; if (IsPowerOf2(m)) return n - ModPowerOf2(n, m); else return n - n%m; } template <class T1, class T2> inline T1 RoundUpToMultipleOf(const T1 &n, const T2 &m) { (void)0; (void)0; (void)0; (void)0; if (NumericLimitsMax<T1>() - m + 1 < n) throw InvalidArgument("RoundUpToMultipleOf: integer overflow"); return RoundDownToMultipleOf(T1(n+m-1), m); } template <class T> inline unsigned int GetAlignmentOf() { return alignof(T); } inline bool IsAlignedOn(const void *ptr, unsigned int alignment) { const uintptr_t x = reinterpret_cast<uintptr_t>(ptr); return alignment==1 || (IsPowerOf2(alignment) ? ModPowerOf2(x, alignment) == 0 : x % alignment == 0); } template <class T> inline bool IsAligned(const void *ptr) { return IsAlignedOn(ptr, GetAlignmentOf<T>()); } typedef LittleEndian NativeByteOrder; inline ByteOrder GetNativeByteOrder() { return NativeByteOrder::ToEnum(); } inline bool NativeByteOrderIs(ByteOrder order) { return order == GetNativeByteOrder(); } template <class T> inline CipherDir GetCipherDir(const T &obj) { return obj.IsForwardTransformation() ? ENCRYPTION : DECRYPTION; } inline void IncrementCounterByOne(byte *inout, unsigned int size) { (void)0; unsigned int carry=1; while (carry && size != 0) { carry = ! ++inout[size-1]; size--; } } inline void IncrementCounterByOne(byte *output, const byte *input, unsigned int size) { (void)0; (void)0; unsigned int carry=1; while (carry && size != 0) { carry = ! (output[size-1] = input[size-1] + 1); size--; } while (size != 0) { output[size-1] = input[size-1]; size--; } } template <class T> inline void ConditionalSwap(bool c, T &a, T &b) { T t = c * (a ^ b); a ^= t; b ^= t; } template <class T> inline void ConditionalSwapPointers(bool c, T &a, T &b) { ptrdiff_t t = size_t(c) * (a - b); a -= t; b += t; } template <class T> void SecureWipeBuffer(T *buf, size_t n) { volatile T *p = buf+n; while (n--) *(--p) = 0; } template<> inline void SecureWipeBuffer(byte *buf, size_t n) { volatile byte *p = buf; asm volatile("rep stosb" : "+c"(n), "+D"(p) : "a"(0) : "memory"); } template<> inline void SecureWipeBuffer(word16 *buf, size_t n) { volatile word16 *p = buf; asm volatile("rep stosw" : "+c"(n), "+D"(p) : "a"(0) : "memory"); } template<> inline void SecureWipeBuffer(word32 *buf, size_t n) { volatile word32 *p = buf; asm volatile("rep stosl" : "+c"(n), "+D"(p) : "a"(0) : "memory"); } template<> inline void SecureWipeBuffer(word64 *buf, size_t n) { volatile word64 *p = buf; asm volatile("rep stosq" : "+c"(n), "+D"(p) : "a"(0) : "memory"); } template <class T> inline void SecureWipeArray(T *buf, size_t n) { if (sizeof(T) % 8 == 0 && GetAlignmentOf<T>() % GetAlignmentOf<word64>() == 0) SecureWipeBuffer(reinterpret_cast<word64 *>(static_cast<void *>(buf)), n * (sizeof(T)/8)); else if (sizeof(T) % 4 == 0 && GetAlignmentOf<T>() % GetAlignmentOf<word32>() == 0) SecureWipeBuffer(reinterpret_cast<word32 *>(static_cast<void *>(buf)), n * (sizeof(T)/4)); else if (sizeof(T) % 2 == 0 && GetAlignmentOf<T>() % GetAlignmentOf<word16>() == 0) SecureWipeBuffer(reinterpret_cast<word16 *>(static_cast<void *>(buf)), n * (sizeof(T)/2)); else SecureWipeBuffer(reinterpret_cast<byte *>(static_cast<void *>(buf)), n * sizeof(T)); } std::string StringNarrow(const wchar_t *str, bool throwOnError = true); std::wstring StringWiden(const char *str, bool throwOnError = true); template <unsigned int R, class T> inline T rotlConstant(T x) { enum : int { THIS_SIZE = sizeof(T)*8 }; enum : int { MASK = THIS_SIZE-1 }; (void)0; return T((x<<R)|(x>>(-R&MASK))); } template <unsigned int R, class T> inline T rotrConstant(T x) { enum : int { THIS_SIZE = sizeof(T)*8 }; enum : int { MASK = THIS_SIZE-1 }; (void)0; return T((x >> R)|(x<<(-R&MASK))); } template <class T> inline T rotlFixed(T x, unsigned int y) { enum : int { THIS_SIZE = sizeof(T)*8 }; enum : int { MASK = THIS_SIZE-1 }; (void)0; return T((x<<y)|(x>>(-y&MASK))); } template <class T> inline T rotrFixed(T x, unsigned int y) { enum : int { THIS_SIZE = sizeof(T)*8 }; enum : int { MASK = THIS_SIZE-1 }; (void)0; return T((x >> y)|(x<<(-y&MASK))); } template <class T> inline T rotlVariable(T x, unsigned int y) { enum : int { THIS_SIZE = sizeof(T)*8 }; enum : int { MASK = THIS_SIZE-1 }; (void)0; return T((x<<y)|(x>>(-y&MASK))); } template <class T> inline T rotrVariable(T x, unsigned int y) { enum : int { THIS_SIZE = sizeof(T)*8 }; enum : int { MASK = THIS_SIZE-1 }; (void)0; return T((x>>y)|(x<<(-y&MASK))); } template <class T> inline T rotlMod(T x, unsigned int y) { enum : int { THIS_SIZE = sizeof(T)*8 }; enum : int { MASK = THIS_SIZE-1 }; return T((x<<(y&MASK))|(x>>(-y&MASK))); } template <class T> inline T rotrMod(T x, unsigned int y) { enum : int { THIS_SIZE = sizeof(T)*8 }; enum : int { MASK = THIS_SIZE-1 }; return T((x>>(y&MASK))|(x<<(-y&MASK))); } template <class T> inline unsigned int GetByte(ByteOrder order, T value, unsigned int index) { if (order == LITTLE_ENDIAN_ORDER) return (unsigned int)byte((value)>>(8*(index))); else return (unsigned int)byte((value)>>(8*(sizeof(T)-index-1))); } inline byte ByteReverse(byte value) { return value; } inline word16 ByteReverse(word16 value) { return __bswap_16 ( value ) ; } inline word32 ByteReverse(word32 value) { return __bswap_32 ( value ) ; } inline word64 ByteReverse(word64 value) { return __bswap_64 ( value ) ; } inline byte BitReverse(byte value) { value = byte((value & 0xAA) >> 1) | byte((value & 0x55) << 1); value = byte((value & 0xCC) >> 2) | byte((value & 0x33) << 2); return rotlFixed(value, 4U); } inline word16 BitReverse(word16 value) { value = word16((value & 0xAAAA) >> 1) | word16((value & 0x5555) << 1); value = word16((value & 0xCCCC) >> 2) | word16((value & 0x3333) << 2); value = word16((value & 0xF0F0) >> 4) | word16((value & 0x0F0F) << 4); return ByteReverse(value); } inline word32 BitReverse(word32 value) { value = word32((value & 0xAAAAAAAA) >> 1) | word32((value & 0x55555555) << 1); value = word32((value & 0xCCCCCCCC) >> 2) | word32((value & 0x33333333) << 2); value = word32((value & 0xF0F0F0F0) >> 4) | word32((value & 0x0F0F0F0F) << 4); return ByteReverse(value); } inline word64 BitReverse(word64 value) { value = word64((value & 0xAAAAAAAAAAAAAAAAUL) >> 1) | word64((value & 0x5555555555555555UL) << 1); value = word64((value & 0xCCCCCCCCCCCCCCCCUL) >> 2) | word64((value & 0x3333333333333333UL) << 2); value = word64((value & 0xF0F0F0F0F0F0F0F0UL) >> 4) | word64((value & 0x0F0F0F0F0F0F0F0FUL) << 4); return ByteReverse(value); } template <class T> inline T BitReverse(T value) { if (sizeof(T) == 1) return (T)BitReverse((byte)value); else if (sizeof(T) == 2) return (T)BitReverse((word16)value); else if (sizeof(T) == 4) return (T)BitReverse((word32)value); else if (sizeof(T) == 8) return (T)BitReverse((word64)value); else { (void)0; return (T)BitReverse((word64)value); } } template <class T> inline T ConditionalByteReverse(ByteOrder order, T value) { return NativeByteOrderIs(order) ? value : ByteReverse(value); } template <class T> void ByteReverse(T *out, const T *in, size_t byteCount) { (void)0; (void)0; (void)0; size_t count = byteCount/sizeof(T); for (size_t i=0; i<count; i++) out[i] = ByteReverse(in[i]); } template <class T> inline void ConditionalByteReverse(ByteOrder order, T *out, const T *in, size_t byteCount) { if (!NativeByteOrderIs(order)) ByteReverse(out, in, byteCount); else if (in != out) memcpy_s(out, byteCount, in, byteCount); } template <class T> inline void GetUserKey(ByteOrder order, T *out, size_t outlen, const byte *in, size_t inlen) { const size_t U = sizeof(T); (void)0; memcpy_s(out, outlen*U, in, inlen); memset_z((byte *)out+inlen, 0, outlen*U-inlen); ConditionalByteReverse(order, out, out, RoundUpToMultipleOf(inlen, U)); } inline byte UnalignedGetWordNonTemplate(ByteOrder order, const byte *block, const byte *) { ((void)(order)); return block[0]; } inline word16 UnalignedGetWordNonTemplate(ByteOrder order, const byte *block, const word16 *) { return (order == BIG_ENDIAN_ORDER) ? block[1] | (block[0] << 8) : block[0] | (block[1] << 8); } inline word32 UnalignedGetWordNonTemplate(ByteOrder order, const byte *block, const word32 *) { return (order == BIG_ENDIAN_ORDER) ? word32(block[3]) | (word32(block[2]) << 8) | (word32(block[1]) << 16) | (word32(block[0]) << 24) : word32(block[0]) | (word32(block[1]) << 8) | (word32(block[2]) << 16) | (word32(block[3]) << 24); } inline word64 UnalignedGetWordNonTemplate(ByteOrder order, const byte *block, const word64 *) { return (order == BIG_ENDIAN_ORDER) ? (word64(block[7]) | (word64(block[6]) << 8) | (word64(block[5]) << 16) | (word64(block[4]) << 24) | (word64(block[3]) << 32) | (word64(block[2]) << 40) | (word64(block[1]) << 48) | (word64(block[0]) << 56)) : (word64(block[0]) | (word64(block[1]) << 8) | (word64(block[2]) << 16) | (word64(block[3]) << 24) | (word64(block[4]) << 32) | (word64(block[5]) << 40) | (word64(block[6]) << 48) | (word64(block[7]) << 56)); } inline void UnalignedbyteNonTemplate(ByteOrder order, byte *block, byte value, const byte *xorBlock) { ((void)(order)); block[0] = static_cast<byte>(xorBlock ? (value ^ xorBlock[0]) : value); } inline void UnalignedbyteNonTemplate(ByteOrder order, byte *block, word16 value, const byte *xorBlock) { if (order == BIG_ENDIAN_ORDER) { if (xorBlock) { block[0] = xorBlock[0] ^ byte((value)>>(8*(1))); block[1] = xorBlock[1] ^ byte((value)>>(8*(0))); } else { block[0] = byte((value)>>(8*(1))); block[1] = byte((value)>>(8*(0))); } } else { if (xorBlock) { block[0] = xorBlock[0] ^ byte((value)>>(8*(0))); block[1] = xorBlock[1] ^ byte((value)>>(8*(1))); } else { block[0] = byte((value)>>(8*(0))); block[1] = byte((value)>>(8*(1))); } } } inline void UnalignedbyteNonTemplate(ByteOrder order, byte *block, word32 value, const byte *xorBlock) { if (order == BIG_ENDIAN_ORDER) { if (xorBlock) { block[0] = xorBlock[0] ^ byte((value)>>(8*(3))); block[1] = xorBlock[1] ^ byte((value)>>(8*(2))); block[2] = xorBlock[2] ^ byte((value)>>(8*(1))); block[3] = xorBlock[3] ^ byte((value)>>(8*(0))); } else { block[0] = byte((value)>>(8*(3))); block[1] = byte((value)>>(8*(2))); block[2] = byte((value)>>(8*(1))); block[3] = byte((value)>>(8*(0))); } } else { if (xorBlock) { block[0] = xorBlock[0] ^ byte((value)>>(8*(0))); block[1] = xorBlock[1] ^ byte((value)>>(8*(1))); block[2] = xorBlock[2] ^ byte((value)>>(8*(2))); block[3] = xorBlock[3] ^ byte((value)>>(8*(3))); } else { block[0] = byte((value)>>(8*(0))); block[1] = byte((value)>>(8*(1))); block[2] = byte((value)>>(8*(2))); block[3] = byte((value)>>(8*(3))); } } } inline void UnalignedbyteNonTemplate(ByteOrder order, byte *block, word64 value, const byte *xorBlock) { if (order == BIG_ENDIAN_ORDER) { if (xorBlock) { block[0] = xorBlock[0] ^ byte((value)>>(8*(7))); block[1] = xorBlock[1] ^ byte((value)>>(8*(6))); block[2] = xorBlock[2] ^ byte((value)>>(8*(5))); block[3] = xorBlock[3] ^ byte((value)>>(8*(4))); block[4] = xorBlock[4] ^ byte((value)>>(8*(3))); block[5] = xorBlock[5] ^ byte((value)>>(8*(2))); block[6] = xorBlock[6] ^ byte((value)>>(8*(1))); block[7] = xorBlock[7] ^ byte((value)>>(8*(0))); } else { block[0] = byte((value)>>(8*(7))); block[1] = byte((value)>>(8*(6))); block[2] = byte((value)>>(8*(5))); block[3] = byte((value)>>(8*(4))); block[4] = byte((value)>>(8*(3))); block[5] = byte((value)>>(8*(2))); block[6] = byte((value)>>(8*(1))); block[7] = byte((value)>>(8*(0))); } } else { if (xorBlock) { block[0] = xorBlock[0] ^ byte((value)>>(8*(0))); block[1] = xorBlock[1] ^ byte((value)>>(8*(1))); block[2] = xorBlock[2] ^ byte((value)>>(8*(2))); block[3] = xorBlock[3] ^ byte((value)>>(8*(3))); block[4] = xorBlock[4] ^ byte((value)>>(8*(4))); block[5] = xorBlock[5] ^ byte((value)>>(8*(5))); block[6] = xorBlock[6] ^ byte((value)>>(8*(6))); block[7] = xorBlock[7] ^ byte((value)>>(8*(7))); } else { block[0] = byte((value)>>(8*(0))); block[1] = byte((value)>>(8*(1))); block[2] = byte((value)>>(8*(2))); block[3] = byte((value)>>(8*(3))); block[4] = byte((value)>>(8*(4))); block[5] = byte((value)>>(8*(5))); block[6] = byte((value)>>(8*(6))); block[7] = byte((value)>>(8*(7))); } } } template <class T> inline T GetWord(bool assumeAligned, ByteOrder order, const byte *block) { ((void)(assumeAligned)); T temp; memcpy(&temp, block, sizeof(T)); return ConditionalByteReverse(order, temp); } template <class T> inline void GetWord(bool assumeAligned, ByteOrder order, T &result, const byte *block) { result = GetWord<T>(assumeAligned, order, block); } template <class T> inline void PutWord(bool assumeAligned, ByteOrder order, byte *block, T value, const byte *xorBlock = nullptr) { ((void)(assumeAligned)); T t1, t2; t1 = ConditionalByteReverse(order, value); if (xorBlock) {memcpy(&t2, xorBlock, sizeof(T)); t1 ^= t2;} memcpy(block, &t1, sizeof(T)); } template <class T, class B, bool A=false> class GetBlock { public: GetBlock(const void *block) : m_block((const byte *)block) {} template <class U> inline GetBlock<T, B, A> & operator()(U &x) { static CompileAssert<(sizeof(U) >= sizeof(T))> cryptopp_CRYPTOPP_ASSERT_2526 __attribute__ ((unused)); x = GetWord<T>(A, B::ToEnum(), m_block); m_block += sizeof(T); return *this; } private: const byte *m_block; }; template <class T, class B, bool A=false> class PutBlock { public: PutBlock(const void *xorBlock, void *block) : m_xorBlock((const byte *)xorBlock), m_block((byte *)block) {} template <class U> inline PutBlock<T, B, A> & operator()(U x) { PutWord(A, B::ToEnum(), m_block, (T)x, m_xorBlock); m_block += sizeof(T); if (m_xorBlock) m_xorBlock += sizeof(T); return *this; } private: const byte *m_xorBlock; byte *m_block; }; template <class T, class B, bool GA=false, bool PA=false> struct BlockGetAndPut { static inline GetBlock<T, B, GA> Get(const void *block) {return GetBlock<T, B, GA>(block);} typedef PutBlock<T, B, PA> Put; }; template <class T> std::string WordToString(T value, ByteOrder order = BIG_ENDIAN_ORDER) { if (!NativeByteOrderIs(order)) value = ByteReverse(value); return std::string((char *)&value, sizeof(value)); } template <class T> T StringToWord(const std::string &str, ByteOrder order = BIG_ENDIAN_ORDER) { T value = 0; memcpy_s(&value, sizeof(value), str.data(), UnsignedMin(str.size(), sizeof(value))); return NativeByteOrderIs(order) ? value : ByteReverse(value); } template <bool overflow> struct SafeShifter; template<> struct SafeShifter<true> { template <class T> static inline T RightShift(T value, unsigned int bits) { ((void)(value)); ((void)(bits)); return 0; } template <class T> static inline T LeftShift(T value, unsigned int bits) { ((void)(value)); ((void)(bits)); return 0; } }; template<> struct SafeShifter<false> { template <class T> static inline T RightShift(T value, unsigned int bits) { return value >> bits; } template <class T> static inline T LeftShift(T value, unsigned int bits) { return value << bits; } }; template <unsigned int bits, class T> inline T SafeRightShift(T value) { return SafeShifter<(bits>=(8*sizeof(T)))>::RightShift(value, bits); } template <unsigned int bits, class T> inline T SafeLeftShift(T value) { return SafeShifter<(bits>=(8*sizeof(T)))>::LeftShift(value, bits); } template<typename InputIt, typename T> inline InputIt FindIfNot(InputIt first, InputIt last, const T &value) { return std::find_if(first, last, [&value](const T &o) { return value!=o; }); } } namespace CryptoPP { template <class DERIVED, class BASE> class ClonableImpl : public BASE { public: Clonable * Clone() const {return new DERIVED(*static_cast<const DERIVED *>(this));} }; template <class BASE, class ALGORITHM_INFO=BASE> class AlgorithmImpl : public BASE { public: static std::string StaticAlgorithmName() {return ALGORITHM_INFO::StaticAlgorithmName();} std::string AlgorithmName() const {return ALGORITHM_INFO::StaticAlgorithmName();} }; class InvalidKeyLength : public InvalidArgument { public: explicit InvalidKeyLength(const std::string &algorithm, size_t length) : InvalidArgument(algorithm + ": " + IntToString(length) + " is not a valid key length") {} }; class InvalidRounds : public InvalidArgument { public: explicit InvalidRounds(const std::string &algorithm, unsigned int rounds) : InvalidArgument(algorithm + ": " + IntToString(rounds) + " is not a valid number of rounds") {} }; class InvalidBlockSize : public InvalidArgument { public: explicit InvalidBlockSize(const std::string &algorithm, size_t length) : InvalidArgument(algorithm + ": " + IntToString(length) + " is not a valid block size") {} }; class InvalidDerivedKeyLength : public InvalidArgument { public: explicit InvalidDerivedKeyLength(const std::string &algorithm, size_t length) : InvalidArgument(algorithm + ": " + IntToString(length) + " is not a valid derived key length") {} }; class InvalidPersonalizationLength : public InvalidArgument { public: explicit InvalidPersonalizationLength(const std::string &algorithm, size_t length) : InvalidArgument(algorithm + ": " + IntToString(length) + " is not a valid salt length") {} }; class InvalidSaltLength : public InvalidArgument { public: explicit InvalidSaltLength(const std::string &algorithm, size_t length) : InvalidArgument(algorithm + ": " + IntToString(length) + " is not a valid salt length") {} }; template <class T> class Bufferless : public T { public: bool IsolatedFlush(bool hardFlush, bool blocking) {((void)(hardFlush)); ((void)(blocking)); return false;} }; template <class T> class Unflushable : public T { public: bool Flush(bool completeFlush, int propagation=-1, bool blocking=true) {return ChannelFlush(DEFAULT_CHANNEL, completeFlush, propagation, blocking);} bool IsolatedFlush(bool hardFlush, bool blocking) {((void)(hardFlush)); ((void)(blocking)); (void)0; return false;} bool ChannelFlush(const std::string &channel, bool hardFlush, int propagation=-1, bool blocking=true) { if (hardFlush && !InputBufferIsEmpty()) throw CannotFlush("Unflushable<T>: this object has buffered input that cannot be flushed"); else { BufferedTransformation *attached = this->AttachedTransformation(); return attached && propagation ? attached->ChannelFlush(channel, hardFlush, propagation-1, blocking) : false; } } protected: virtual bool InputBufferIsEmpty() const {return false;} }; template <class T> class InputRejecting : public T { public: struct InputRejected : public NotImplemented {InputRejected() : NotImplemented("BufferedTransformation: this object doesn't allow input") {}}; size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking) {((void)(inString)); ((void)(length)); ((void)(messageEnd)); ((void)(blocking)); throw InputRejected();} bool IsolatedFlush(bool hardFlush, bool blocking) {((void)(hardFlush)); ((void)(blocking)); return false;} bool IsolatedMessageSeriesEnd(bool blocking) {((void)(blocking)); throw InputRejected();} size_t ChannelPut2(const std::string &channel, const byte *inString, size_t length, int messageEnd, bool blocking) {((void)(channel)); ((void)(inString)); ((void)(length)); ((void)(messageEnd)); ((void)(blocking)); throw InputRejected();} bool ChannelMessageSeriesEnd(const std::string& channel, int messageEnd, bool blocking) {((void)(channel)); ((void)(messageEnd)); ((void)(blocking)); throw InputRejected();} }; template <class T> class CustomFlushPropagation : public T { public: virtual bool Flush(bool hardFlush, int propagation=-1, bool blocking=true) =0; private: bool IsolatedFlush(bool hardFlush, bool blocking) {((void)(hardFlush)); ((void)(blocking)); (void)0; return false;} }; template <class T> class CustomSignalPropagation : public CustomFlushPropagation<T> { public: virtual void Initialize(const NameValuePairs ¶meters=g_nullNameValuePairs, int propagation=-1) =0; private: void IsolatedInitialize(const NameValuePairs ¶meters) {((void)(parameters)); (void)0;} }; template <class T> class Multichannel : public CustomFlushPropagation<T> { public: bool Flush(bool hardFlush, int propagation=-1, bool blocking=true) {return this->ChannelFlush(DEFAULT_CHANNEL, hardFlush, propagation, blocking);} bool MessageSeriesEnd(int propagation=-1, bool blocking=true) {return this->ChannelMessageSeriesEnd(DEFAULT_CHANNEL, propagation, blocking);} byte * CreatePutSpace(size_t &size) {return this->ChannelCreatePutSpace(DEFAULT_CHANNEL, size);} size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking) {return this->ChannelPut2(DEFAULT_CHANNEL, inString, length, messageEnd, blocking);} size_t PutModifiable2(byte *inString, size_t length, int messageEnd, bool blocking) {return this->ChannelPutModifiable2(DEFAULT_CHANNEL, inString, length, messageEnd, blocking);} byte * ChannelCreatePutSpace(const std::string &channel, size_t &size) {((void)(channel)); size = 0; return nullptr;} bool ChannelPutModifiable(const std::string &channel, byte *inString, size_t length) {this->ChannelPut(channel, inString, length); return false;} virtual size_t ChannelPut2(const std::string &channel, const byte *begin, size_t length, int messageEnd, bool blocking) =0; size_t ChannelPutModifiable2(const std::string &channel, byte *begin, size_t length, int messageEnd, bool blocking) {return ChannelPut2(channel, begin, length, messageEnd, blocking);} virtual bool ChannelFlush(const std::string &channel, bool hardFlush, int propagation=-1, bool blocking=true) =0; }; template <class T> class AutoSignaling : public T { public: AutoSignaling(int propagation=-1) : m_autoSignalPropagation(propagation) {} void SetAutoSignalPropagation(int propagation) {m_autoSignalPropagation = propagation;} int GetAutoSignalPropagation() const {return m_autoSignalPropagation;} private: int m_autoSignalPropagation; }; class Store : public AutoSignaling<InputRejecting<BufferedTransformation> > { public: Store() : m_messageEnd(false) {} void IsolatedInitialize(const NameValuePairs ¶meters) { m_messageEnd = false; StoreInitialize(parameters); } unsigned int NumberOfMessages() const {return m_messageEnd ? 0 : 1;} bool GetNextMessage(); unsigned int CopyMessagesTo(BufferedTransformation &target, unsigned int count= (0x7fffffff * 2U + 1U) , const std::string &channel=DEFAULT_CHANNEL) const; protected: virtual void StoreInitialize(const NameValuePairs ¶meters) =0; bool m_messageEnd; }; class Sink : public BufferedTransformation { public: size_t TransferTo2(BufferedTransformation &target, lword &transferBytes, const std::string &channel=DEFAULT_CHANNEL, bool blocking=true) {((void)(target)); ((void)(transferBytes)); ((void)(channel)); ((void)(blocking)); transferBytes = 0; return 0;} size_t CopyRangeTo2(BufferedTransformation &target, lword &begin, lword end=LWORD_MAX, const std::string &channel=DEFAULT_CHANNEL, bool blocking=true) const {((void)(target)); ((void)(begin)); ((void)(end)); ((void)(channel)); ((void)(blocking)); return 0;} }; class BitBucket : public Bufferless<Sink> { public: std::string AlgorithmName() const {return "BitBucket";} void IsolatedInitialize(const NameValuePairs ¶ms) {((void)(params));} size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking) {((void)(inString)); ((void)(length)); ((void)(messageEnd)); ((void)(blocking)); return 0;} }; } namespace CryptoPP { inline CipherDir ReverseCipherDir(CipherDir dir) { return (dir == ENCRYPTION) ? DECRYPTION : ENCRYPTION; } template <unsigned int N> class FixedBlockSize { public: enum : int { BLOCKSIZE = N }; }; template <unsigned int R> class FixedRounds { public: enum : int { ROUNDS = R }; }; template <unsigned int D, unsigned int N=1, unsigned int M=0x7fffffff> class VariableRounds { public: enum : int { DEFAULT_ROUNDS = D }; enum : int { MIN_ROUNDS = N }; enum : int { MAX_ROUNDS = M }; static constexpr unsigned int StaticGetDefaultRounds(size_t keylength) { return ((void)(keylength)), static_cast<unsigned int>(DEFAULT_ROUNDS); } protected: inline void ThrowIfInvalidRounds(int rounds, const Algorithm *alg) { if (M == 0x7fffffff) { if (rounds < MIN_ROUNDS) throw InvalidRounds(alg ? alg->AlgorithmName() : std::string("VariableRounds"), rounds); } else { if (rounds < MIN_ROUNDS || rounds > MAX_ROUNDS) throw InvalidRounds(alg ? alg->AlgorithmName() : std::string("VariableRounds"), rounds); } } inline unsigned int GetRoundsAndThrowIfInvalid(const NameValuePairs ¶m, const Algorithm *alg) { int rounds = param.GetIntValueWithDefault("Rounds", DEFAULT_ROUNDS); ThrowIfInvalidRounds(rounds, alg); return static_cast<unsigned int>(rounds); } }; template <unsigned int N, unsigned int IV_REQ = SimpleKeyingInterface::NOT_RESYNCHRONIZABLE, unsigned int IV_L = 0> class FixedKeyLength { public: enum : int { KEYLENGTH=N }; enum : int { MIN_KEYLENGTH=N }; enum : int { MAX_KEYLENGTH=N }; enum : int { DEFAULT_KEYLENGTH=N }; enum : int { IV_REQUIREMENT = IV_REQ }; enum : int { IV_LENGTH = IV_L }; static constexpr size_t StaticGetValidKeyLength(size_t keylength) { return ((void)(keylength)), static_cast<size_t>(KEYLENGTH); } }; template <unsigned int D, unsigned int N, unsigned int M, unsigned int Q = 1, unsigned int IV_REQ = SimpleKeyingInterface::NOT_RESYNCHRONIZABLE, unsigned int IV_L = 0> class VariableKeyLength { static CompileAssert<(Q > 0)> cryptopp_CRYPTOPP_ASSERT_168 __attribute__ ((unused)); static CompileAssert<(N % Q == 0)> cryptopp_CRYPTOPP_ASSERT_169 __attribute__ ((unused)); static CompileAssert<(M % Q == 0)> cryptopp_CRYPTOPP_ASSERT_170 __attribute__ ((unused)); static CompileAssert<(N < M)> cryptopp_CRYPTOPP_ASSERT_171 __attribute__ ((unused)); static CompileAssert<(D >= N)> cryptopp_CRYPTOPP_ASSERT_172 __attribute__ ((unused)); static CompileAssert<(M >= D)> cryptopp_CRYPTOPP_ASSERT_173 __attribute__ ((unused)); public: enum : int { MIN_KEYLENGTH=N }; enum : int { MAX_KEYLENGTH=M }; enum : int { DEFAULT_KEYLENGTH=D }; enum : int { KEYLENGTH_MULTIPLE=Q }; enum : int { IV_REQUIREMENT=IV_REQ }; enum : int { IV_LENGTH=IV_L }; static constexpr size_t StaticGetValidKeyLength(size_t keylength) { return (keylength <= N) ? N : (keylength >= M) ? M : (keylength+Q-1) - (keylength+Q-1)%Q; } }; template <class T, unsigned int IV_REQ = SimpleKeyingInterface::NOT_RESYNCHRONIZABLE, unsigned int IV_L = 0> class SameKeyLengthAs { public: enum : int { MIN_KEYLENGTH=T::MIN_KEYLENGTH }; enum : int { MAX_KEYLENGTH=T::MAX_KEYLENGTH }; enum : int { DEFAULT_KEYLENGTH=T::DEFAULT_KEYLENGTH }; enum : int { IV_REQUIREMENT=IV_REQ }; enum : int { IV_LENGTH=IV_L }; static constexpr size_t StaticGetValidKeyLength(size_t keylength) {return T::StaticGetValidKeyLength(keylength);} }; template <class BASE, class INFO = BASE> class SimpleKeyingInterfaceImpl : public BASE { public: size_t MinKeyLength() const {return INFO::MIN_KEYLENGTH;} size_t MaxKeyLength() const {return static_cast<size_t>(INFO::MAX_KEYLENGTH);} size_t DefaultKeyLength() const {return INFO::DEFAULT_KEYLENGTH;} size_t GetValidKeyLength(size_t keylength) const {return INFO::StaticGetValidKeyLength(keylength);} SimpleKeyingInterface::IV_Requirement IVRequirement() const {return static_cast<SimpleKeyingInterface::IV_Requirement>(INFO::IV_REQUIREMENT);} unsigned int IVSize() const {return INFO::IV_LENGTH;} }; template <class INFO, class BASE = BlockCipher> class BlockCipherImpl : public AlgorithmImpl<SimpleKeyingInterfaceImpl<TwoBases<BASE, INFO> > > { public: unsigned int BlockSize() const {return this->BLOCKSIZE;} }; template <CipherDir DIR, class BASE> class BlockCipherFinal : public ClonableImpl<BlockCipherFinal<DIR, BASE>, BASE> { public: BlockCipherFinal() {} BlockCipherFinal(const byte *key) {this->SetKey(key, this->DEFAULT_KEYLENGTH);} BlockCipherFinal(const byte *key, size_t length) {this->SetKey(key, length);} BlockCipherFinal(const byte *key, size_t length, unsigned int rounds) {this->SetKeyWithRounds(key, length, rounds);} bool IsForwardTransformation() const {return DIR == ENCRYPTION;} }; template <class BASE, class INFO = BASE> class MessageAuthenticationCodeImpl : public AlgorithmImpl<SimpleKeyingInterfaceImpl<BASE, INFO>, INFO> { }; template <class BASE> class MessageAuthenticationCodeFinal : public ClonableImpl<MessageAuthenticationCodeFinal<BASE>, MessageAuthenticationCodeImpl<BASE> > { public: MessageAuthenticationCodeFinal() {} MessageAuthenticationCodeFinal(const byte *key) {this->SetKey(key, this->DEFAULT_KEYLENGTH);} MessageAuthenticationCodeFinal(const byte *key, size_t length) {this->SetKey(key, length);} }; struct BlockCipherDocumentation { typedef BlockCipher Encryption; typedef BlockCipher Decryption; }; struct SymmetricCipherDocumentation { typedef SymmetricCipher Encryption; typedef SymmetricCipher Decryption; }; struct AuthenticatedSymmetricCipherDocumentation { typedef AuthenticatedSymmetricCipher Encryption; typedef AuthenticatedSymmetricCipher Decryption; }; } namespace CryptoPP { void CallNewHandler(); void* AlignedAllocate(size_t size); void AlignedDeallocate(void *ptr); void * UnalignedAllocate(size_t size); void UnalignedDeallocate(void *ptr); } namespace CryptoPP { template<class T> class AllocatorBase { public: typedef T value_type; typedef size_t size_type; typedef std::ptrdiff_t difference_type; typedef T * pointer; typedef const T * const_pointer; typedef T & reference; typedef const T & const_reference; pointer address(reference r) const {return (&r);} const_pointer address(const_reference r) const {return (&r); } void construct(pointer p, const T& val) {new (p) T(val);} void destroy(pointer p) {((void)(p)); p->~T();} enum : size_type {ELEMS_MAX = (18446744073709551615UL) /sizeof(T)}; constexpr size_type max_size() const {return ELEMS_MAX;} template<typename V, typename... Args> void construct(V* ptr, Args&&... args) {::new ((void*)ptr) V(std::forward<Args>(args)...);} template<typename V> void destroy(V* ptr) {if (ptr) ptr->~V();} protected: static void CheckSize(size_t size) { ((void)(size)); if (sizeof(T) != 1 && size > ELEMS_MAX) throw InvalidArgument("AllocatorBase: requested size would cause integer overflow"); } }; template <class T, class A> typename A::pointer StandardReallocate(A& alloc, T *oldPtr, typename A::size_type oldSize, typename A::size_type newSize, bool preserve) { if (oldSize == newSize) return oldPtr; if (preserve) { typename A::pointer newPointer = alloc.allocate(newSize, nullptr); const typename A::size_type copySize = STDMIN(oldSize, newSize) * sizeof(T); if (oldPtr && newPointer) memcpy_s(newPointer, copySize, oldPtr, copySize); if (oldPtr) alloc.deallocate(oldPtr, oldSize); return newPointer; } else { if (oldPtr) alloc.deallocate(oldPtr, oldSize); return alloc.allocate(newSize, nullptr); } } template <class T, bool T_Align16 = false> class AllocatorWithCleanup : public AllocatorBase<T> { public: typedef typename AllocatorBase<T>::value_type value_type;typedef typename AllocatorBase<T>::size_type size_type;typedef typename AllocatorBase<T>::difference_type difference_type;typedef typename AllocatorBase<T>::pointer pointer;typedef typename AllocatorBase<T>::const_pointer const_pointer;typedef typename AllocatorBase<T>::reference reference;typedef typename AllocatorBase<T>::const_reference const_reference; pointer allocate(size_type size, const void *ptr = nullptr) { ((void)(ptr)); (void)0; this->CheckSize(size); if (size == 0) return nullptr; if (T_Align16) return reinterpret_cast<pointer>(AlignedAllocate(size*sizeof(T))); return reinterpret_cast<pointer>(UnalignedAllocate(size*sizeof(T))); } void deallocate(void *ptr, size_type size) { if (ptr) { SecureWipeArray(reinterpret_cast<pointer>(ptr), size); if (T_Align16) return AlignedDeallocate(ptr); UnalignedDeallocate(ptr); } } pointer reallocate(T *oldPtr, size_type oldSize, size_type newSize, bool preserve) { (void)0; return StandardReallocate(*this, oldPtr, oldSize, newSize, preserve); } template <class V> struct rebind { typedef AllocatorWithCleanup<V, T_Align16> other; }; }; extern template class AllocatorWithCleanup<byte>; extern template class AllocatorWithCleanup<word16>; extern template class AllocatorWithCleanup<word32>; extern template class AllocatorWithCleanup<word64>; extern template class AllocatorWithCleanup<word128, true>; template <class T> class NullAllocator : public AllocatorBase<T> { public: typedef typename AllocatorBase<T>::value_type value_type;typedef typename AllocatorBase<T>::size_type size_type;typedef typename AllocatorBase<T>::difference_type difference_type;typedef typename AllocatorBase<T>::pointer pointer;typedef typename AllocatorBase<T>::const_pointer const_pointer;typedef typename AllocatorBase<T>::reference reference;typedef typename AllocatorBase<T>::const_reference const_reference; pointer allocate(size_type n, const void* unused = nullptr) { ((void)(n)); ((void)(unused)); (void)0; return nullptr; } void deallocate(void *p, size_type n) { ((void)(p)); ((void)(n)); (void)0; } constexpr size_type max_size() const {return 0;} }; template <class T, size_t S, class A = NullAllocator<T>, bool T_Align16 = false> class FixedSizeAllocatorWithCleanup : public AllocatorBase<T> { }; template <class T, size_t S, class A> class FixedSizeAllocatorWithCleanup<T, S, A, true> : public AllocatorBase<T> { public: typedef typename AllocatorBase<T>::value_type value_type;typedef typename AllocatorBase<T>::size_type size_type;typedef typename AllocatorBase<T>::difference_type difference_type;typedef typename AllocatorBase<T>::pointer pointer;typedef typename AllocatorBase<T>::const_pointer const_pointer;typedef typename AllocatorBase<T>::reference reference;typedef typename AllocatorBase<T>::const_reference const_reference; FixedSizeAllocatorWithCleanup() : m_allocated(false) {} pointer allocate(size_type size) { (void)0; if (size <= S && !m_allocated) { m_allocated = true; return GetAlignedArray(); } else return m_fallbackAllocator.allocate(size); } pointer allocate(size_type size, const void *hint) { if (size <= S && !m_allocated) { m_allocated = true; return GetAlignedArray(); } else return m_fallbackAllocator.allocate(size, hint); } void deallocate(void *ptr, size_type size) { if (ptr == GetAlignedArray()) { (void)0; (void)0; m_allocated = false; SecureWipeArray(reinterpret_cast<pointer>(ptr), size); } else { if (ptr) m_fallbackAllocator.deallocate(ptr, size); } } pointer reallocate(pointer oldPtr, size_type oldSize, size_type newSize, bool preserve) { if (oldPtr == GetAlignedArray() && newSize <= S) { (void)0; if (oldSize > newSize) SecureWipeArray(oldPtr+newSize, oldSize-newSize); return oldPtr; } pointer newPointer = allocate(newSize, nullptr); if (preserve && newSize) { const size_type copySize = STDMIN(oldSize, newSize); memcpy_s(newPointer, sizeof(T)*newSize, oldPtr, sizeof(T)*copySize); } deallocate(oldPtr, oldSize); return newPointer; } constexpr size_type max_size() const { return STDMAX(m_fallbackAllocator.max_size(), S); } private: T* GetAlignedArray() { (void)0; return m_array; } alignas(16) T m_array[S]; A m_fallbackAllocator; bool m_allocated; }; template <class T, size_t S, class A> class FixedSizeAllocatorWithCleanup<T, S, A, false> : public AllocatorBase<T> { public: typedef typename AllocatorBase<T>::value_type value_type;typedef typename AllocatorBase<T>::size_type size_type;typedef typename AllocatorBase<T>::difference_type difference_type;typedef typename AllocatorBase<T>::pointer pointer;typedef typename AllocatorBase<T>::const_pointer const_pointer;typedef typename AllocatorBase<T>::reference reference;typedef typename AllocatorBase<T>::const_reference const_reference; FixedSizeAllocatorWithCleanup() : m_allocated(false) {} pointer allocate(size_type size) { (void)0; if (size <= S && !m_allocated) { m_allocated = true; return GetAlignedArray(); } else return m_fallbackAllocator.allocate(size); } pointer allocate(size_type size, const void *hint) { if (size <= S && !m_allocated) { m_allocated = true; return GetAlignedArray(); } else return m_fallbackAllocator.allocate(size, hint); } void deallocate(void *ptr, size_type size) { if (ptr == GetAlignedArray()) { (void)0; (void)0; m_allocated = false; SecureWipeArray((pointer)ptr, size); } else { if (ptr) m_fallbackAllocator.deallocate(ptr, size); m_allocated = false; } } pointer reallocate(pointer oldPtr, size_type oldSize, size_type newSize, bool preserve) { if (oldPtr == GetAlignedArray() && newSize <= S) { (void)0; if (oldSize > newSize) SecureWipeArray(oldPtr+newSize, oldSize-newSize); return oldPtr; } pointer newPointer = allocate(newSize, nullptr); if (preserve && newSize) { const size_type copySize = STDMIN(oldSize, newSize); memcpy_s(newPointer, sizeof(T)*newSize, oldPtr, sizeof(T)*copySize); } deallocate(oldPtr, oldSize); return newPointer; } constexpr size_type max_size() const { return STDMAX(m_fallbackAllocator.max_size(), S); } private: T* GetAlignedArray() {return m_array;} alignas(8) T m_array[S]; A m_fallbackAllocator; bool m_allocated; }; template <class T, class A = AllocatorWithCleanup<T> > class SecBlock { public: typedef typename A::value_type value_type; typedef typename A::pointer iterator; typedef typename A::const_pointer const_iterator; typedef typename A::size_type size_type; enum : size_type {ELEMS_MAX = A::ELEMS_MAX}; explicit SecBlock(size_type size=0) : m_mark(ELEMS_MAX), m_size(size), m_ptr(m_alloc.allocate(size, nullptr)) { } SecBlock(const SecBlock<T, A> &t) : m_mark(t.m_mark), m_size(t.m_size), m_ptr(m_alloc.allocate(t.m_size, nullptr)) { (void)0; if (m_ptr && t.m_ptr) memcpy_s(m_ptr, m_size*sizeof(T), t.m_ptr, t.m_size*sizeof(T)); } SecBlock(const T *ptr, size_type len) : m_mark(ELEMS_MAX), m_size(len), m_ptr(m_alloc.allocate(len, nullptr)) { (void)0; if (ptr && m_ptr) memcpy_s(m_ptr, m_size*sizeof(T), ptr, len*sizeof(T)); else if (m_ptr && m_size) memset(m_ptr, 0, m_size*sizeof(T)); } ~SecBlock() {m_alloc.deallocate(m_ptr, STDMIN(m_size, m_mark));} operator const void *() const {return m_ptr;} operator void *() {return m_ptr;} operator const T *() const {return m_ptr;} operator T *() {return m_ptr;} iterator begin() {return m_ptr;} const_iterator begin() const {return m_ptr;} iterator end() {return m_ptr+m_size;} const_iterator end() const {return m_ptr+m_size;} typename A::pointer data() {return m_ptr;} typename A::const_pointer data() const {return m_ptr;} size_type size() const {return m_size;} bool empty() const {return m_size == 0;} byte * BytePtr() {return (byte *)m_ptr;} const byte * BytePtr() const {return (const byte *)m_ptr;} size_type SizeInBytes() const {return m_size*sizeof(T);} void SetMark(size_t count) {m_mark = count;} void Assign(const T *ptr, size_type len) { New(len); if (m_ptr && ptr) {memcpy_s(m_ptr, m_size*sizeof(T), ptr, len*sizeof(T));} m_mark = ELEMS_MAX; } void Assign(size_type count, T value) { New(count); for (size_t i=0; i<count; ++i) m_ptr[i] = value; m_mark = ELEMS_MAX; } void Assign(const SecBlock<T, A> &t) { if (this != &t) { New(t.m_size); if (m_ptr && t.m_ptr) {memcpy_s(m_ptr, m_size*sizeof(T), t, t.m_size*sizeof(T));} } m_mark = ELEMS_MAX; } SecBlock<T, A>& operator=(const SecBlock<T, A> &t) { Assign(t); return *this; } SecBlock<T, A>& operator+=(const SecBlock<T, A> &t) { (void)0; if (t.m_size) { const size_type oldSize = m_size; if (this != &t) { Grow(m_size+t.m_size); memcpy_s(m_ptr+oldSize, (m_size-oldSize)*sizeof(T), t.m_ptr, t.m_size*sizeof(T)); } else { Grow(m_size*2); memcpy_s(m_ptr+oldSize, (m_size-oldSize)*sizeof(T), m_ptr, oldSize*sizeof(T)); } } m_mark = ELEMS_MAX; return *this; } SecBlock<T, A> operator+(const SecBlock<T, A> &t) { (void)0; (void)0; if(!t.m_size) return SecBlock(*this); SecBlock<T, A> result(m_size+t.m_size); if (m_size) {memcpy_s(result.m_ptr, result.m_size*sizeof(T), m_ptr, m_size*sizeof(T));} memcpy_s(result.m_ptr+m_size, (result.m_size-m_size)*sizeof(T), t.m_ptr, t.m_size*sizeof(T)); return result; } bool operator==(const SecBlock<T, A> &t) const { return m_size == t.m_size && VerifyBufsEqual( reinterpret_cast<const byte*>(m_ptr), reinterpret_cast<const byte*>(t.m_ptr), m_size*sizeof(T)); } bool operator!=(const SecBlock<T, A> &t) const { return !operator==(t); } void New(size_type newSize) { m_ptr = m_alloc.reallocate(m_ptr, m_size, newSize, false); m_size = newSize; m_mark = ELEMS_MAX; } void CleanNew(size_type newSize) { New(newSize); if (m_ptr) {memset_z(m_ptr, 0, m_size*sizeof(T));} m_mark = ELEMS_MAX; } void Grow(size_type newSize) { if (newSize > m_size) { m_ptr = m_alloc.reallocate(m_ptr, m_size, newSize, true); m_size = newSize; } m_mark = ELEMS_MAX; } void CleanGrow(size_type newSize) { if (newSize > m_size) { m_ptr = m_alloc.reallocate(m_ptr, m_size, newSize, true); memset_z(m_ptr+m_size, 0, (newSize-m_size)*sizeof(T)); m_size = newSize; } m_mark = ELEMS_MAX; } void resize(size_type newSize) { m_ptr = m_alloc.reallocate(m_ptr, m_size, newSize, true); m_size = newSize; m_mark = ELEMS_MAX; } void swap(SecBlock<T, A> &b) { std::swap(m_alloc, b.m_alloc); std::swap(m_mark, b.m_mark); std::swap(m_size, b.m_size); std::swap(m_ptr, b.m_ptr); } protected: A m_alloc; size_type m_mark, m_size; T *m_ptr; }; typedef SecBlock<byte> SecByteBlock; typedef SecBlock<word> SecWordBlock; typedef SecBlock<byte, AllocatorWithCleanup<byte, true> > AlignedSecByteBlock; template <class T, unsigned int S, class A = FixedSizeAllocatorWithCleanup<T, S> > class FixedSizeSecBlock : public SecBlock<T, A> { public: explicit FixedSizeSecBlock() : SecBlock<T, A>(S) {} }; template <class T, unsigned int S, bool T_Align16 = true> class FixedSizeAlignedSecBlock : public FixedSizeSecBlock<T, S, FixedSizeAllocatorWithCleanup<T, S, NullAllocator<T>, T_Align16> > { }; template <class T, unsigned int S, class A = FixedSizeAllocatorWithCleanup<T, S, AllocatorWithCleanup<T> > > class SecBlockWithHint : public SecBlock<T, A> { public: explicit SecBlockWithHint(size_t size) : SecBlock<T, A>(size) {} }; template<class T, bool A, class V, bool B> inline bool operator==(const CryptoPP::AllocatorWithCleanup<T, A>&, const CryptoPP::AllocatorWithCleanup<V, B>&) {return (true);} template<class T, bool A, class V, bool B> inline bool operator!=(const CryptoPP::AllocatorWithCleanup<T, A>&, const CryptoPP::AllocatorWithCleanup<V, B>&) {return (false);} } namespace std { template <class T, class A> inline void swap(CryptoPP::SecBlock<T, A> &a, CryptoPP::SecBlock<T, A> &b) { a.swap(b); } } namespace CryptoPP { struct IDEA_Info : public FixedBlockSize<8>, public FixedKeyLength<16>, public FixedRounds<8> { static constexpr const char* StaticAlgorithmName() {return "IDEA";} }; class IDEA : public IDEA_Info, public BlockCipherDocumentation { public: typedef word Word; private: class Base : public BlockCipherImpl<IDEA_Info> { public: unsigned int OptimalDataAlignment() const {return 2;} void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const; void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs ¶ms); private: void EnKey(const byte *); void DeKey(); FixedSizeSecBlock<Word, 6*ROUNDS+4> m_key; }; public: typedef BlockCipherFinal<ENCRYPTION, Base> Encryption; typedef BlockCipherFinal<DECRYPTION, Base> Decryption; }; typedef IDEA::Encryption IDEAEncryption; typedef IDEA::Decryption IDEADecryption; } namespace CryptoPP { static const int IDEA_KEYLEN=(6*IDEA::ROUNDS+4); static CompileAssert<(sizeof(IDEA::Word) >= 2)> cryptopp_CRYPTOPP_ASSERT_15 __attribute__ ((unused)); void IDEA::Base::UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs &) { AssertValidKeyLength(length); EnKey(userKey); if (!IsForwardTransformation()) DeKey(); } void IDEA::Base::EnKey (const byte *userKey) { unsigned int i; for (i=0; i<8; i++) m_key[i] = ((IDEA::Word)userKey[2*i]<<8) | userKey[2*i+1]; for (; i<IDEA_KEYLEN; i++) { unsigned int j = RoundDownToMultipleOf(i,8U)-8; m_key[i] = (((m_key[j+(i+1)%8] << 9) | (m_key[j+(i+2)%8] >> 7))&0xffff); } } static IDEA::Word MulInv(IDEA::Word x) { IDEA::Word y=x; for (unsigned i=0; i<15; i++) { { word32 p=(word32)((y)&0xffff)*((y)&0xffff); if (p) { p = ((p)&0xffff) - ((p)>>16); y = (IDEA::Word)p - (IDEA::Word)((p)>>16); } else y = 1-y-((y)&0xffff); }; { word32 p=(word32)((y)&0xffff)*x; if (p) { p = ((p)&0xffff) - ((p)>>16); y = (IDEA::Word)p - (IDEA::Word)((p)>>16); } else y = 1-y-x; }; } return ((y)&0xffff); } static inline IDEA::Word AddInv(IDEA::Word x) { return ((0-x)&0xffff); } void IDEA::Base::DeKey() { FixedSizeSecBlock<IDEA::Word, 6*ROUNDS+4> tempkey; size_t i; for (i=0; i<ROUNDS; i++) { tempkey[i*6+0] = MulInv(m_key[(ROUNDS-i)*6+0]); tempkey[i*6+1] = AddInv(m_key[(ROUNDS-i)*6+1+(i>0)]); tempkey[i*6+2] = AddInv(m_key[(ROUNDS-i)*6+2-(i>0)]); tempkey[i*6+3] = MulInv(m_key[(ROUNDS-i)*6+3]); tempkey[i*6+4] = m_key[(ROUNDS-1-i)*6+4]; tempkey[i*6+5] = m_key[(ROUNDS-1-i)*6+5]; } tempkey[i*6+0] = MulInv(m_key[(ROUNDS-i)*6+0]); tempkey[i*6+1] = AddInv(m_key[(ROUNDS-i)*6+1]); tempkey[i*6+2] = AddInv(m_key[(ROUNDS-i)*6+2]); tempkey[i*6+3] = MulInv(m_key[(ROUNDS-i)*6+3]); m_key = tempkey; } void IDEA::Base::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const { typedef BlockGetAndPut<word16, BigEndian> Block; const IDEA::Word *key = m_key; IDEA::Word x0,x1,x2,x3,t0,t1; Block::Get(inBlock)(x0)(x1)(x2)(x3); for (unsigned int i=0; i<ROUNDS; i++) { { word32 p=(word32)((x0)&0xffff)*key[i*6+0]; if (p) { p = ((p)&0xffff) - ((p)>>16); x0 = (IDEA::Word)p - (IDEA::Word)((p)>>16); } else x0 = 1-x0-key[i*6+0]; }; x1 += key[i*6+1]; x2 += key[i*6+2]; { word32 p=(word32)((x3)&0xffff)*key[i*6+3]; if (p) { p = ((p)&0xffff) - ((p)>>16); x3 = (IDEA::Word)p - (IDEA::Word)((p)>>16); } else x3 = 1-x3-key[i*6+3]; }; t0 = x0^x2; { word32 p=(word32)((t0)&0xffff)*key[i*6+4]; if (p) { p = ((p)&0xffff) - ((p)>>16); t0 = (IDEA::Word)p - (IDEA::Word)((p)>>16); } else t0 = 1-t0-key[i*6+4]; }; t1 = t0 + (x1^x3); { word32 p=(word32)((t1)&0xffff)*key[i*6+5]; if (p) { p = ((p)&0xffff) - ((p)>>16); t1 = (IDEA::Word)p - (IDEA::Word)((p)>>16); } else t1 = 1-t1-key[i*6+5]; }; t0 += t1; x0 ^= t1; x3 ^= t0; t0 ^= x1; x1 = x2^t1; x2 = t0; } { word32 p=(word32)((x0)&0xffff)*key[ROUNDS*6+0]; if (p) { p = ((p)&0xffff) - ((p)>>16); x0 = (IDEA::Word)p - (IDEA::Word)((p)>>16); } else x0 = 1-x0-key[ROUNDS*6+0]; }; x2 += key[ROUNDS*6+1]; x1 += key[ROUNDS*6+2]; { word32 p=(word32)((x3)&0xffff)*key[ROUNDS*6+3]; if (p) { p = ((p)&0xffff) - ((p)>>16); x3 = (IDEA::Word)p - (IDEA::Word)((p)>>16); } else x3 = 1-x3-key[ROUNDS*6+3]; }; Block::Put(xorBlock, outBlock)(x0)(x2)(x1)(x3); } }
Become a Patron
Sponsor on GitHub
Donate via PayPal
Source on GitHub
Mailing list
Installed libraries
Wiki
Report an issue
How it works
Contact the author
CE on Mastodon
About the author
Statistics
Changelog
Version tree