From 16f7a1f0038e4eceb143f6f26566f3562d843465 Mon Sep 17 00:00:00 2001 From: ykiko Date: Thu, 29 Aug 2024 20:10:14 +0800 Subject: [PATCH] clear the project. --- .txt | 7440 ----------------- docs/clang/Diagnostic.md | 0 docs/clang/Preprocessor.md | 59 - docs/clang/README.md | 202 - docs/clang/SourceLocation.md | 0 docs/clangd.md | 113 - docs/clangd2.md | 64 - docs/clice.md | 65 - docs/examples/ASTVisitor.cpp | 742 -- docs/examples/CodeCompletion.cpp | 175 - docs/examples/Module.cpp | 203 - docs/examples/Preamble.cpp | 136 - docs/examples/Preprocessor.cpp | 192 - docs/examples/TreeTransform.cpp | 130 - include/Clang/Clang.h | 25 - include/Clang/CompileDatabase.h | 30 - include/Clang/Compiler.h | 18 - include/Clang/Diagnostic.h | 15 - include/Clang/Directive.h | 142 - include/Clang/Module.h | 0 include/Clang/ParsedAST.h | 54 - include/Clang/Preamble.h | 19 - include/Clang/SelectionTree.h | 0 include/Feature/SemanticToken.h | 16 - include/Protocol/Basic.h | 187 - include/Protocol/Document/DidChange.h | 0 include/Protocol/Document/DidClose.h | 0 include/Protocol/Document/DidOpen.h | 0 include/Protocol/Document/DidSave.h | 0 include/Protocol/Language/CallHierarchy.h | 92 - include/Protocol/Language/CodeAction.h | 1 - include/Protocol/Language/CodeLens.h | 38 - include/Protocol/Language/Completion.h | 1 - include/Protocol/Language/Declaration.h | 32 - include/Protocol/Language/Definition.h | 31 - include/Protocol/Language/DocumentColor.h | 1 - include/Protocol/Language/DocumentHighlight.h | 48 - include/Protocol/Language/DocumentLink.h | 52 - include/Protocol/Language/DocumentSymbol.h | 72 - include/Protocol/Language/FoldingRange.h | 1 - include/Protocol/Language/Formatting.h | 1 - include/Protocol/Language/Hover.h | 41 - include/Protocol/Language/Implementation.h | 31 - include/Protocol/Language/InlayHint.h | 1 - include/Protocol/Language/InlineValue.h | 1 - include/Protocol/Language/OnTypeFormatting.h | 1 - include/Protocol/Language/RangeFormatting.h | 1 - include/Protocol/Language/Reference.h | 37 - include/Protocol/Language/Rename.h | 1 - include/Protocol/Language/SelectionRange.h | 1 - include/Protocol/Language/SemanticToken.h | 195 - include/Protocol/Language/SignatureHelp.h | 1 - include/Protocol/Language/TypeDefinition.h | 31 - include/Protocol/Language/TypeHierarchy.h | 63 - include/Protocol/Lifecycle/Exit.h | 0 include/Protocol/Lifecycle/Initialize.h | 0 include/Protocol/Lifecycle/Initialized.h | 0 include/Protocol/Lifecycle/Shutdown.h | 0 include/Protocol/Message.h | 73 - include/Protocol/Protocol.h | 709 -- include/Protocol/README.md | 93 - include/Server/Scheduler.h | 24 - include/Server/Server.h | 68 - include/Server/Setting.h | 16 - include/Server/Transport.h | 57 - include/Support/Async.h | 152 - include/Support/Filesystem.h | 24 - include/Support/Logger.h | 35 - include/Support/Reflection.h | 183 - include/Support/Serialize.h | 81 - main.cpp | 174 - scripts/build.sh | 9 - scripts/clone.sh | 5 - src/Clang/CompileDatabase.cpp | 15 - src/Clang/Compiler.cpp | 108 - src/Clang/Directive.cpp | 117 - src/Clang/ParsedAST.cpp | 12 - src/Clang/Preamble.cpp | 49 - src/Feature/SemanticToken.cpp | 270 - src/Server/Scheduler.cpp | 17 - src/Server/Server.cpp | 76 - src/Server/Transport.cpp | 119 - src/Support/Logger.cpp | 34 - src/main.cpp | 6 - test.cpp | 1 - tests/Clang/Preamble.cpp | 135 - tests/Support/Reflection.cpp | 11 - 87 files changed, 13475 deletions(-) delete mode 100644 .txt delete mode 100644 docs/clang/Diagnostic.md delete mode 100644 docs/clang/Preprocessor.md delete mode 100644 docs/clang/README.md delete mode 100644 docs/clang/SourceLocation.md delete mode 100644 docs/clangd.md delete mode 100644 docs/clangd2.md delete mode 100644 docs/clice.md delete mode 100644 docs/examples/ASTVisitor.cpp delete mode 100644 docs/examples/CodeCompletion.cpp delete mode 100644 docs/examples/Module.cpp delete mode 100644 docs/examples/Preamble.cpp delete mode 100644 docs/examples/Preprocessor.cpp delete mode 100644 docs/examples/TreeTransform.cpp delete mode 100644 include/Clang/Clang.h delete mode 100644 include/Clang/CompileDatabase.h delete mode 100644 include/Clang/Compiler.h delete mode 100644 include/Clang/Diagnostic.h delete mode 100644 include/Clang/Directive.h delete mode 100644 include/Clang/Module.h delete mode 100644 include/Clang/ParsedAST.h delete mode 100644 include/Clang/Preamble.h delete mode 100644 include/Clang/SelectionTree.h delete mode 100644 include/Feature/SemanticToken.h delete mode 100644 include/Protocol/Basic.h delete mode 100644 include/Protocol/Document/DidChange.h delete mode 100644 include/Protocol/Document/DidClose.h delete mode 100644 include/Protocol/Document/DidOpen.h delete mode 100644 include/Protocol/Document/DidSave.h delete mode 100644 include/Protocol/Language/CallHierarchy.h delete mode 100644 include/Protocol/Language/CodeAction.h delete mode 100644 include/Protocol/Language/CodeLens.h delete mode 100644 include/Protocol/Language/Completion.h delete mode 100644 include/Protocol/Language/Declaration.h delete mode 100644 include/Protocol/Language/Definition.h delete mode 100644 include/Protocol/Language/DocumentColor.h delete mode 100644 include/Protocol/Language/DocumentHighlight.h delete mode 100644 include/Protocol/Language/DocumentLink.h delete mode 100644 include/Protocol/Language/DocumentSymbol.h delete mode 100644 include/Protocol/Language/FoldingRange.h delete mode 100644 include/Protocol/Language/Formatting.h delete mode 100644 include/Protocol/Language/Hover.h delete mode 100644 include/Protocol/Language/Implementation.h delete mode 100644 include/Protocol/Language/InlayHint.h delete mode 100644 include/Protocol/Language/InlineValue.h delete mode 100644 include/Protocol/Language/OnTypeFormatting.h delete mode 100644 include/Protocol/Language/RangeFormatting.h delete mode 100644 include/Protocol/Language/Reference.h delete mode 100644 include/Protocol/Language/Rename.h delete mode 100644 include/Protocol/Language/SelectionRange.h delete mode 100644 include/Protocol/Language/SemanticToken.h delete mode 100644 include/Protocol/Language/SignatureHelp.h delete mode 100644 include/Protocol/Language/TypeDefinition.h delete mode 100644 include/Protocol/Language/TypeHierarchy.h delete mode 100644 include/Protocol/Lifecycle/Exit.h delete mode 100644 include/Protocol/Lifecycle/Initialize.h delete mode 100644 include/Protocol/Lifecycle/Initialized.h delete mode 100644 include/Protocol/Lifecycle/Shutdown.h delete mode 100644 include/Protocol/Message.h delete mode 100644 include/Protocol/Protocol.h delete mode 100644 include/Protocol/README.md delete mode 100644 include/Server/Scheduler.h delete mode 100644 include/Server/Server.h delete mode 100644 include/Server/Setting.h delete mode 100644 include/Server/Transport.h delete mode 100644 include/Support/Async.h delete mode 100644 include/Support/Filesystem.h delete mode 100644 include/Support/Logger.h delete mode 100644 include/Support/Reflection.h delete mode 100644 include/Support/Serialize.h delete mode 100644 main.cpp delete mode 100755 scripts/build.sh delete mode 100755 scripts/clone.sh delete mode 100644 src/Clang/CompileDatabase.cpp delete mode 100644 src/Clang/Compiler.cpp delete mode 100644 src/Clang/Directive.cpp delete mode 100644 src/Clang/ParsedAST.cpp delete mode 100644 src/Clang/Preamble.cpp delete mode 100644 src/Feature/SemanticToken.cpp delete mode 100644 src/Server/Scheduler.cpp delete mode 100644 src/Server/Server.cpp delete mode 100644 src/Server/Transport.cpp delete mode 100644 src/Support/Logger.cpp delete mode 100644 src/main.cpp delete mode 100644 test.cpp delete mode 100644 tests/Clang/Preamble.cpp delete mode 100644 tests/Support/Reflection.cpp diff --git a/.txt b/.txt deleted file mode 100644 index c946f7e8..00000000 --- a/.txt +++ /dev/null @@ -1,7440 +0,0 @@ -running ASTVisitor... -Comment: // -*- C++ -*- -Comment: // Copyright (C) 2001-2023 Free Software Foundation, Inc. -Comment: // -Comment: // This file is part of the GNU ISO C++ Library. This library is free -Comment: // software; you can redistribute it and/or modify it under the -Comment: // terms of the GNU General Public License as published by the -Comment: // Free Software Foundation; either version 3, or (at your option) -Comment: // any later version. -Comment: // This library is distributed in the hope that it will be useful, -Comment: // but WITHOUT ANY WARRANTY; without even the implied warranty of -Comment: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -Comment: // GNU General Public License for more details. -Comment: // Under Section 7 of GPL version 3, you are granted additional -Comment: // permissions described in the GCC Runtime Library Exception, version -Comment: // 3.1, as published by the Free Software Foundation. -Comment: // You should have received a copy of the GNU General Public License and -Comment: // a copy of the GCC Runtime Library Exception along with this program; -Comment: // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -Comment: // . -Comment: /* - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1996 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ -Comment: /** @file include/vector - * This is a Standard C++ Library header. - */ -Comment: // container -Comment: // Copyright The GNU Toolchain Authors. -Comment: // -Comment: // This file is part of the GNU ISO C++ Library. This library is free -Comment: // software; you can redistribute it and/or modify it under the -Comment: // terms of the GNU General Public License as published by the -Comment: // Free Software Foundation; either version 3, or (at your option) -Comment: // any later version. -Comment: // This library is distributed in the hope that it will be useful, -Comment: // but WITHOUT ANY WARRANTY; without even the implied warranty of -Comment: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -Comment: // GNU General Public License for more details. -Comment: // Under Section 7 of GPL version 3, you are granted additional -Comment: // permissions described in the GCC Runtime Library Exception, version -Comment: // 3.1, as published by the Free Software Foundation. -Comment: // You should have received a copy of the GNU General Public License and -Comment: // a copy of the GCC Runtime Library Exception along with this program; -Comment: // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -Comment: // . -Comment: /** @file bits/requires_hosted.h - * This is an internal header file, included by other library headers. - * Do not attempt to use it directly. @headername{version} - */ -Comment: // Predefined symbols and macros -*- C++ -*- -Comment: // Copyright (C) 1997-2023 Free Software Foundation, Inc. -Comment: // -Comment: // This file is part of the GNU ISO C++ Library. This library is free -Comment: // software; you can redistribute it and/or modify it under the -Comment: // terms of the GNU General Public License as published by the -Comment: // Free Software Foundation; either version 3, or (at your option) -Comment: // any later version. -Comment: // This library is distributed in the hope that it will be useful, -Comment: // but WITHOUT ANY WARRANTY; without even the implied warranty of -Comment: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -Comment: // GNU General Public License for more details. -Comment: // Under Section 7 of GPL version 3, you are granted additional -Comment: // permissions described in the GCC Runtime Library Exception, version -Comment: // 3.1, as published by the Free Software Foundation. -Comment: // You should have received a copy of the GNU General Public License and -Comment: // a copy of the GCC Runtime Library Exception along with this program; -Comment: // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -Comment: // . -Comment: /** @file bits/c++config.h - * This is an internal header file, included by other library headers. - * Do not attempt to use it directly. @headername{version} - */ -Comment: // The major release number for the GCC release the C++ library belongs to. -Comment: // The datestamp of the C++ library in compressed ISO date format. -Comment: // Macros for various attributes. -Comment: // _GLIBCXX_PURE -Comment: // _GLIBCXX_CONST -Comment: // _GLIBCXX_NORETURN -Comment: // _GLIBCXX_NOTHROW -Comment: // _GLIBCXX_VISIBILITY -Comment: // See below for C++ -Comment: // Macros for visibility attributes. -Comment: // _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY -Comment: // _GLIBCXX_VISIBILITY -Comment: // Macros for deprecated attributes. -Comment: // _GLIBCXX_USE_DEPRECATED -Comment: // _GLIBCXX_DEPRECATED -Comment: // _GLIBCXX_DEPRECATED_SUGGEST( string-literal ) -Comment: // _GLIBCXX11_DEPRECATED -Comment: // _GLIBCXX11_DEPRECATED_SUGGEST( string-literal ) -Comment: // _GLIBCXX14_DEPRECATED -Comment: // _GLIBCXX14_DEPRECATED_SUGGEST( string-literal ) -Comment: // _GLIBCXX17_DEPRECATED -Comment: // _GLIBCXX17_DEPRECATED_SUGGEST( string-literal ) -Comment: // _GLIBCXX20_DEPRECATED -Comment: // _GLIBCXX20_DEPRECATED_SUGGEST( string-literal ) -Comment: // _GLIBCXX23_DEPRECATED -Comment: // _GLIBCXX23_DEPRECATED_SUGGEST( string-literal ) -Comment: // Macros for ABI tag attributes. -Comment: // Macro to warn about unused results. -Comment: // Macro for constexpr, to support in mixed 03/0x mode. -Comment: // Macro for noexcept, to support in mixed 03/0x mode. -Comment: // Macro for extern template, ie controlling template linkage via use -Comment: // of extern keyword on template declaration. As documented in the g++ -Comment: // manual, it inhibits all implicit instantiations and is used -Comment: // throughout the library to avoid multiple weak definitions for -Comment: // required types that are already explicitly instantiated in the -Comment: // library binary. This substantially reduces the binary size of -Comment: // resulting executables. -Comment: // Special case: _GLIBCXX_EXTERN_TEMPLATE == -1 disallows extern -Comment: // templates only in basic_string, thus activating its debug-mode -Comment: // checks even at -O0. -Comment: /* - Outline of libstdc++ namespaces. - - namespace std - { - namespace __debug { } - namespace __parallel { } - namespace __cxx1998 { } - - namespace __detail { - namespace __variant { } // C++17 - } - - namespace rel_ops { } - - namespace tr1 - { - namespace placeholders { } - namespace regex_constants { } - namespace __detail { } - } - - namespace tr2 { } - - namespace decimal { } - - namespace chrono { } // C++11 - namespace placeholders { } // C++11 - namespace regex_constants { } // C++11 - namespace this_thread { } // C++11 - inline namespace literals { // C++14 - inline namespace chrono_literals { } // C++14 - inline namespace complex_literals { } // C++14 - inline namespace string_literals { } // C++14 - inline namespace string_view_literals { } // C++17 - } - } - - namespace abi { } - - namespace __gnu_cxx - { - namespace __detail { } - } - - For full details see: - http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/namespaces.html -*/ -Comment: // This allows the library to terminate without including all of -Comment: // and without making the declaration of std::terminate visible to users. -Comment: // Non-zero if inline namespaces are used for versioning the entire library. -Comment: // Unused. -Comment: // Used to version individual components, e.g. std::_V2::error_category. -Comment: // inline namespace X -Comment: // In the case that we don't have a hosted environment, we can't provide the -Comment: // debugging mode. Instead, we do our best and downgrade to assertions. -Comment: // Inline namespaces for special modes: debug, parallel. -Comment: // Macros for namespace scope. Either namespace std:: or the name -Comment: // of some nested namespace within it corresponding to the active mode. -Comment: // _GLIBCXX_STD_A -Comment: // _GLIBCXX_STD_C -Comment: // -Comment: // Macros for opening/closing conditional namespaces. -Comment: // _GLIBCXX_BEGIN_NAMESPACE_ALGO -Comment: // _GLIBCXX_END_NAMESPACE_ALGO -Comment: // _GLIBCXX_BEGIN_NAMESPACE_CONTAINER -Comment: // _GLIBCXX_END_NAMESPACE_CONTAINER -Comment: // GLIBCXX_ABI Deprecated -Comment: // Define if compatibility should be provided for -mlong-double-64. -Comment: // Define if compatibility should be provided for alternative 128-bit long -Comment: // double formats. Not possible for Clang until __ibm128 is supported. -Comment: // Inline namespaces for long double 128 modes. -Comment: // _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT && IEEE128 -Comment: // _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT && IEEE128 -Comment: // Internal version of std::is_constant_evaluated(). -Comment: // This can be used without checking if the compiler supports the feature. -Comment: // The macro _GLIBCXX_HAVE_IS_CONSTANT_EVALUATED can be used to check if -Comment: // the compiler support is present to make this function work as expected. -Comment: // Debug Mode implies checking assertions. -Comment: // Disable std::string explicit instantiation declarations in order to assert. -Comment: /* precondition violation detected! */ -Comment: // Assert. -Comment: // Macro indicating that TSAN is in use. -Comment: // Macros for race detectors. -Comment: // _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(A) and -Comment: // _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(A) should be used to explain -Comment: // atomic (lock-free) synchronization to race detectors: -Comment: // the race detector will infer a happens-before arc from the former to the -Comment: // latter when they share the same argument pointer. -Comment: // -Comment: // The most frequent use case for these macros (and the only case in the -Comment: // current implementation of the library) is atomic reference counting: -Comment: // void _M_remove_reference() -Comment: // { -Comment: // _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&this->_M_refcount); -Comment: // if (__gnu_cxx::__exchange_and_add_dispatch(&this->_M_refcount, -1) <= 0) -Comment: // { -Comment: // _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&this->_M_refcount); -Comment: // _M_destroy(__a); -Comment: // } -Comment: // } -Comment: // The annotations in this example tell the race detector that all memory -Comment: // accesses occurred when the refcount was positive do not race with -Comment: // memory accesses which occurred after the refcount became zero. -Comment: // Macros for C linkage: define extern "C" linkage only when using C++. -Comment: // !__cplusplus -Comment: // First includes. -Comment: // Pick up any OS-specific definitions. -Comment: // Specific definitions for GNU/Linux -*- C++ -*- -Comment: // Copyright (C) 2000-2023 Free Software Foundation, Inc. -Comment: // -Comment: // This file is part of the GNU ISO C++ Library. This library is free -Comment: // software; you can redistribute it and/or modify it under the -Comment: // terms of the GNU General Public License as published by the -Comment: // Free Software Foundation; either version 3, or (at your option) -Comment: // any later version. -Comment: // This library is distributed in the hope that it will be useful, -Comment: // but WITHOUT ANY WARRANTY; without even the implied warranty of -Comment: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -Comment: // GNU General Public License for more details. -Comment: // Under Section 7 of GPL version 3, you are granted additional -Comment: // permissions described in the GCC Runtime Library Exception, version -Comment: // 3.1, as published by the Free Software Foundation. -Comment: // You should have received a copy of the GNU General Public License and -Comment: // a copy of the GCC Runtime Library Exception along with this program; -Comment: // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -Comment: // . -Comment: /** @file bits/os_defines.h - * This is an internal header file, included by other library headers. - * Do not attempt to use it directly. @headername{iosfwd} - */ -Comment: // System-specific #define, typedefs, corrections, etc, go here. This -Comment: // file will come before all others. -Comment: // This keeps isalnum, et al from being propagated as macros. -Comment: /* Copyright (C) 1991-2024 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ -Comment: /* These are defined by the user (or the compiler) - to specify the desired environment: - - __STRICT_ANSI__ ISO Standard C. - _ISOC99_SOURCE Extensions to ISO C89 from ISO C99. - _ISOC11_SOURCE Extensions to ISO C99 from ISO C11. - _ISOC2X_SOURCE Extensions to ISO C99 from ISO C2X. - __STDC_WANT_LIB_EXT2__ - Extensions to ISO C99 from TR 27431-2:2010. - __STDC_WANT_IEC_60559_BFP_EXT__ - Extensions to ISO C11 from TS 18661-1:2014. - __STDC_WANT_IEC_60559_FUNCS_EXT__ - Extensions to ISO C11 from TS 18661-4:2015. - __STDC_WANT_IEC_60559_TYPES_EXT__ - Extensions to ISO C11 from TS 18661-3:2015. - __STDC_WANT_IEC_60559_EXT__ - ISO C2X interfaces defined only in Annex F. - - _POSIX_SOURCE IEEE Std 1003.1. - _POSIX_C_SOURCE If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2; - if >=199309L, add IEEE Std 1003.1b-1993; - if >=199506L, add IEEE Std 1003.1c-1995; - if >=200112L, all of IEEE 1003.1-2004 - if >=200809L, all of IEEE 1003.1-2008 - _XOPEN_SOURCE Includes POSIX and XPG things. Set to 500 if - Single Unix conformance is wanted, to 600 for the - sixth revision, to 700 for the seventh revision. - _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions. - _LARGEFILE_SOURCE Some more functions for correct standard I/O. - _LARGEFILE64_SOURCE Additional functionality from LFS for large files. - _FILE_OFFSET_BITS=N Select default filesystem interface. - _ATFILE_SOURCE Additional *at interfaces. - _DYNAMIC_STACK_SIZE_SOURCE Select correct (but non compile-time constant) - MINSIGSTKSZ, SIGSTKSZ and PTHREAD_STACK_MIN. - _GNU_SOURCE All of the above, plus GNU extensions. - _DEFAULT_SOURCE The default set of features (taking precedence over - __STRICT_ANSI__). - - _FORTIFY_SOURCE Add security hardening to many library functions. - Set to 1, 2 or 3; 3 performs stricter checks than 2, which - performs stricter checks than 1. - - _REENTRANT, _THREAD_SAFE - Obsolete; equivalent to _POSIX_C_SOURCE=199506L. - - The `-ansi' switch to the GNU C compiler, and standards conformance - options such as `-std=c99', define __STRICT_ANSI__. If none of - these are defined, or if _DEFAULT_SOURCE is defined, the default is - to have _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to - 200809L, as well as enabling miscellaneous functions from BSD and - SVID. If more than one of these are defined, they accumulate. For - example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE together - give you ISO C, 1003.1, and 1003.2, but nothing else. - - These are defined by this file and are used by the - header files to decide what to declare or define: - - __GLIBC_USE (F) Define things from feature set F. This is defined - to 1 or 0; the subsequent macros are either defined - or undefined, and those tests should be moved to - __GLIBC_USE. - __USE_ISOC11 Define ISO C11 things. - __USE_ISOC99 Define ISO C99 things. - __USE_ISOC95 Define ISO C90 AMD1 (C95) things. - __USE_ISOCXX11 Define ISO C++11 things. - __USE_POSIX Define IEEE Std 1003.1 things. - __USE_POSIX2 Define IEEE Std 1003.2 things. - __USE_POSIX199309 Define IEEE Std 1003.1, and .1b things. - __USE_POSIX199506 Define IEEE Std 1003.1, .1b, .1c and .1i things. - __USE_XOPEN Define XPG things. - __USE_XOPEN_EXTENDED Define X/Open Unix things. - __USE_UNIX98 Define Single Unix V2 things. - __USE_XOPEN2K Define XPG6 things. - __USE_XOPEN2KXSI Define XPG6 XSI things. - __USE_XOPEN2K8 Define XPG7 things. - __USE_XOPEN2K8XSI Define XPG7 XSI things. - __USE_LARGEFILE Define correct standard I/O things. - __USE_LARGEFILE64 Define LFS things with separate names. - __USE_FILE_OFFSET64 Define 64bit interface as default. - __USE_MISC Define things from 4.3BSD or System V Unix. - __USE_ATFILE Define *at interfaces and AT_* constants for them. - __USE_DYNAMIC_STACK_SIZE Define correct (but non compile-time constant) - MINSIGSTKSZ, SIGSTKSZ and PTHREAD_STACK_MIN. - __USE_GNU Define GNU extensions. - __USE_FORTIFY_LEVEL Additional security measures used, according to level. - - The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are - defined by this file unconditionally. `__GNU_LIBRARY__' is provided - only for compatibility. All new code should use the other symbols - to test for features. - - All macros listed above as possibly being defined by this file are - explicitly undefined if they are not explicitly defined. - Feature-test macros that are not defined by the user or compiler - but are implied by the other feature-test macros defined (or by the - lack of any definitions) are defined by the file. - - ISO C feature test macros depend on the definition of the macro - when an affected header is included, not when the first system - header is included, and so they are handled in - , which does not have a multiple include - guard. Feature test macros that can be handled from the first - system header included are handled here. */ -Comment: /* Undefine everything, so we get a clean slate. */ -Comment: /* Suppress kernel-name space pollution unless user expressedly asks - for it. */ -Comment: /* Convenience macro to test the version of gcc. - Use like this: - #if __GNUC_PREREQ (2,8) - ... code requiring gcc 2.8 or later ... - #endif - Note: only works for GCC 2.0 and later, because __GNUC_MINOR__ was - added in 2.0. */ -Comment: /* Similarly for clang. Features added to GCC after version 4.2 may - or may not also be available in clang, and clang's definitions of - __GNUC(_MINOR)__ are fixed at 4 and 2 respectively. Not all such - features can be queried via __has_extension/__has_feature. */ -Comment: /* Whether to use feature set F. */ -Comment: /* _BSD_SOURCE and _SVID_SOURCE are deprecated aliases for - _DEFAULT_SOURCE. If _DEFAULT_SOURCE is present we do not - issue a warning; the expectation is that the source is being - transitioned to use the new macro. */ -Comment: /* If _GNU_SOURCE was defined by the user, turn on all the other features. */ -Comment: /* If nothing (other than _GNU_SOURCE and _DEFAULT_SOURCE) is defined, - define _DEFAULT_SOURCE. */ -Comment: /* This is to enable the ISO C2X extension. */ -Comment: /* This is to enable the ISO C11 extension. */ -Comment: /* This is to enable the ISO C99 extension. */ -Comment: /* This is to enable the ISO C90 Amendment 1:1995 extension. */ -Comment: /* This is to enable compatibility for ISO C++17. */ -Comment: /* This is to enable compatibility for ISO C++11. - Check the temporary macro for now, too. */ -Comment: /* If none of the ANSI/POSIX macros are defined, or if _DEFAULT_SOURCE - is defined, use POSIX.1-2008 (or another version depending on - _XOPEN_SOURCE). */ -Comment: /* Some C libraries once required _REENTRANT and/or _THREAD_SAFE to be - defined in all multithreaded code. GNU libc has not required this - for many years. We now treat them as compatibility synonyms for - _POSIX_C_SOURCE=199506L, which is the earliest level of POSIX with - comprehensive support for multithreaded code. Using them never - lowers the selected level of POSIX conformance, only raises it. */ -Comment: /* Features part to handle 64-bit time_t support. - Copyright (C) 2021-2024 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ -Comment: /* We need to know the word size in order to check the time size. */ -Comment: /* Determine the wordsize from the preprocessor defines. */ -Comment: /* Both x86-64 and x32 use the 64-bit system call interface. */ -Comment: /* Bit size of the time_t type at glibc build time, x86-64 and x32 case. - Copyright (C) 2018-2024 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ -Comment: /* Determine the wordsize from the preprocessor defines. */ -Comment: /* Both x86-64 and x32 use the 64-bit system call interface. */ -Comment: /* For others, time size is word size. */ -Comment: /* The function 'gets' existed in C89, but is impossible to use - safely. It has been removed from ISO C11 and ISO C++14. Note: for - compatibility with various implementations of , this test - must consider only the value of __cplusplus when compiling C++. */ -Comment: /* GNU formerly extended the scanf functions with modified format - specifiers %as, %aS, and %a[...] that allocate a buffer for the - input using malloc. This extension conflicts with ISO C99, which - defines %a as a standalone format specifier that reads a floating- - point number; moreover, POSIX.1-2008 provides the same feature - using the modifier letter 'm' instead (%ms, %mS, %m[...]). - - We now follow C99 unless GNU extensions are active and the compiler - is specifically in C89 or C++98 mode (strict or not). For - instance, with GCC, -std=gnu11 will have C99-compliant scanf with - or without -D_GNU_SOURCE, but -std=c89 -D_GNU_SOURCE will have the - old extension. */ -Comment: /* ISO C2X added support for a 0b or 0B prefix on binary constants as - inputs to strtol-family functions (base 0 or 2). This macro is - used to condition redirection in headers to allow that redirection - to be disabled when building those functions, despite _GNU_SOURCE - being defined. */ -Comment: /* Get definitions of __STDC_* predefined macros, if the compiler has - not preincluded this header automatically. */ -Comment: /* Copyright (C) 1991-2024 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ -Comment: /* This header is separate from features.h so that the compiler can - include it implicitly at the start of every compilation. It must - not itself include or any other header that includes - because the implicit include comes before any feature - test macros that may be defined in a source file before it first - explicitly includes a system header. GCC knows the name of this - header in order to preinclude it. */ -Comment: /* glibc's intent is to support the IEC 559 math functionality, real - and complex. If the GCC (4.9 and later) predefined macros - specifying compiler intent are available, use them to determine - whether the overall intent is to support these features; otherwise, - presume an older compiler has intent to support these features and - define these macros by default. */ -Comment: /* wchar_t uses Unicode 10.0.0. Version 10.0 of the Unicode Standard is - synchronized with ISO/IEC 10646:2017, fifth edition, plus - the following additions from Amendment 1 to the fifth edition: - - 56 emoji characters - - 285 hentaigana - - 3 additional Zanabazar Square characters */ -Comment: /* This macro indicates that the installed library is the GNU C Library. - For historic reasons the value now is 6 and this will stay from now - on. The use of this variable is deprecated. Use __GLIBC__ and - __GLIBC_MINOR__ now (see below) when you want to test for a specific - GNU C library version and use the values in to get - the sonames of the shared libraries. */ -Comment: /* Major and minor version number of the GNU C library package. Use - these macros to test for features in specific releases. */ -Comment: /* This is here only because every header file already includes this one. */ -Comment: /* Copyright (C) 1992-2024 Free Software Foundation, Inc. - Copyright The GNU Toolchain Authors. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ -Comment: /* We are almost always included from features.h. */ -Comment: /* The GNU libc does not support any K&R compilers or the traditional mode - of ISO C compilers anymore. Check for some of the combinations not - supported anymore. */ -Comment: /* Some user header file might have defined this before. */ -Comment: /* Compilers that lack __has_attribute may object to - #if defined __has_attribute && __has_attribute (...) - even though they do not need to evaluate the right-hand side of the &&. - Similarly for __has_builtin, etc. */ -Comment: /* All functions, except those with callbacks or those that - synchronize memory, are leaf functions. */ -Comment: /* GCC can always grok prototypes. For C++ programs we add throw() - to help it optimize the function calls. But this only works with - gcc 2.8.x and egcs. For gcc 3.4 and up we even mark C functions - as non-throwing using a function attribute since programs can use - the -fexceptions options for C code as well. */ -Comment: /* Not GCC or clang. */ -Comment: /* GCC || clang. */ -Comment: /* These two macros are not used in glibc anymore. They are kept here - only because some other projects expect the macros to be defined. */ -Comment: /* For these things, GCC behaves the ANSI way normally, - and the non-ANSI way under -traditional. */ -Comment: /* This is not a typedef so `const __ptr_t' does the right thing. */ -Comment: /* C++ needs to know that types and declarations are C, not C++. */ -Comment: /* Fortify support. */ -Comment: /* Use __builtin_dynamic_object_size at _FORTIFY_SOURCE=3 when available. */ -Comment: /* Support for flexible arrays. - Headers that should use flexible arrays only if they're "real" - (e.g. only if they won't affect sizeof()) should test - #if __glibc_c99_flexarr_available. */ -Comment: /* GCC 2.97 and clang support C99 flexible array members as an extension, - even when in C89 mode or compiling C++ (any version). */ -Comment: /* __asm__ ("xyz") is used throughout the headers to rename functions - at the assembly language level. This is wrapped by the __REDIRECT - macro, in order to support compilers that can do this some other - way. When compilers don't support asm-names at all, we have to do - preprocessor tricks instead (which don't have exactly the right - semantics, but it's the best we can do). - - Example: - int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); */ -Comment: /* -#elif __SOME_OTHER_COMPILER__ - -# define __REDIRECT(name, proto, alias) name proto; \ - _Pragma("let " #name " = " #alias) -*/ -Comment: /* GCC and clang have various useful declarations that can be made with - the '__attribute__' syntax. All of the ways we use this do fine if - they are omitted for compilers that don't understand it. */ -Comment: /* At some point during the gcc 2.96 development the `malloc' attribute - for functions was introduced. We don't want to use it unconditionally - (although this would be possible) since it generates warnings. */ -Comment: /* Tell the compiler which arguments to an allocation function - indicate the size of the allocation. */ -Comment: /* Ignore. */ -Comment: /* Tell the compiler which argument to an allocation function - indicates the alignment of the allocation. */ -Comment: /* At some point during the gcc 2.96 development the `pure' attribute - for functions was introduced. We don't want to use it unconditionally - (although this would be possible) since it generates warnings. */ -Comment: /* This declaration tells the compiler that the value is constant. */ -Comment: /* At some point during the gcc 3.1 development the `used' attribute - for functions was introduced. We don't want to use it unconditionally - (although this would be possible) since it generates warnings. */ -Comment: /* Since version 3.2, gcc allows marking deprecated functions. */ -Comment: /* Since version 4.5, gcc also allows one to specify the message printed - when a deprecated function is used. clang claims to be gcc 4.2, but - may also support this feature. */ -Comment: /* At some point during the gcc 2.8 development the `format_arg' attribute - for functions was introduced. We don't want to use it unconditionally - (although this would be possible) since it generates warnings. - If several `format_arg' attributes are given for the same function, in - gcc-3.0 and older, all but the last one are ignored. In newer gccs, - all designated arguments are considered. */ -Comment: /* At some point during the gcc 2.97 development the `strfmon' format - attribute for functions was introduced. We don't want to use it - unconditionally (although this would be possible) since it - generates warnings. */ -Comment: /* The nonnull function attribute marks pointer parameters that - must not be NULL. This has the name __nonnull in glibc, - and __attribute_nonnull__ in files shared with Gnulib to avoid - collision with a different __nonnull in DragonFlyBSD 5.9. */ -Comment: /* The returns_nonnull function attribute marks the return type of the function - as always being non-null. */ -Comment: /* If fortification mode, we warn about unused results of certain - function calls which can lead to problems. */ -Comment: /* Ignore */ -Comment: /* Forces a function to be always inlined. */ -Comment: /* The Linux kernel defines __always_inline in stddef.h (283d7573), and - it conflicts with this definition. Therefore undefine it first to - allow either header to be included first. */ -Comment: /* Associate error messages with the source location of the call site rather - than with the source location inside the function. */ -Comment: /* GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99 - inline semantics, unless -fgnu89-inline is used. Using __GNUC_STDC_INLINE__ - or __GNUC_GNU_INLINE is not a good enough check for gcc because gcc versions - older than 4.3 may define these macros and still not guarantee GNU inlining - semantics. - - clang++ identifies itself as gcc-4.2, but has support for GNU inlining - semantics, that can be checked for by using the __GNUC_STDC_INLINE_ and - __GNUC_GNU_INLINE__ macro definitions. */ -Comment: /* GCC 4.3 and above allow passing all anonymous arguments of an - __extern_always_inline function to some other vararg function. */ -Comment: /* It is possible to compile containing GCC extensions even if GCC is - run in pedantic mode if the uses are carefully marked using the - `__extension__' keyword. But this is not generally available before - version 2.8. */ -Comment: /* __restrict is known in EGCS 1.2 and above, and in clang. - It works also in C++ mode (outside of arrays), but only when spelled - as '__restrict', not 'restrict'. */ -Comment: /* ISO C99 also allows to declare arrays as non-overlapping. The syntax is - array_name[restrict] - GCC 3.1 and clang support this. - This syntax is not usable in C++ mode. */ -Comment: /* Not supported in old GCC. */ -Comment: /* Undefine (also defined in libc-symbols.h). */ -Comment: /* Gnulib avoids including these, as they don't work on non-glibc or - older glibc platforms. */ -Comment: /* Determine the wordsize from the preprocessor defines. */ -Comment: /* Both x86-64 and x32 use the 64-bit system call interface. */ -Comment: /* Properties of long double type. ldbl-96 version. - Copyright (C) 2016-2024 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ -Comment: /* long double is distinct from double, so there is nothing to - define here. */ -Comment: /* __glibc_macro_warning (MESSAGE) issues warning MESSAGE. This is - intended for use in preprocessor macros. - - Note: MESSAGE must be a _single_ string; concatenation of string - literals is not supported. */ -Comment: /* Generic selection (ISO C11) is a C-only feature, available in GCC - since version 4.9. Previous versions do not provide generic - selection, even though they might set __STDC_VERSION__ to 201112L, - when in -std=c11 mode. Thus, we must check for !defined __GNUC__ - when testing __STDC_VERSION__ for generic selection support. - On the other hand, Clang also defines __GNUC__, so a clang-specific - check is required to enable the use of generic selection. */ -Comment: /* Specify that a function such as setjmp or vfork may return - twice. */ -Comment: /* sys/cdefs.h */ -Comment: /* If we don't have __REDIRECT, prototypes will be missing if - __USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. */ -Comment: /* !ASSEMBLER */ -Comment: /* Decide whether we can define 'extern inline' functions in headers. */ -Comment: /* This is here only because every header file already includes this one. - Get the definitions of all the appropriate `__stub_FUNCTION' symbols. - contains `#define __stub_FUNCTION' when FUNCTION is a stub - that will always return failure (and set errno to ENOSYS). */ -Comment: /* This file is automatically generated. - This file selects the right generated file of `__stub_FUNCTION' macros - based on the architecture being compiled for. */ -Comment: /* This file is automatically generated. - It defines a symbol `__stub_FUNCTION' for each function - in the C library which is a stub, meaning it will fail - every time called, usually setting errno to ENOSYS. */ -Comment: /* features.h */ -Comment: // Provide a declaration for the possibly deprecated gets function, as -Comment: // glibc 2.15 and later does not declare gets for ISO C11 when -Comment: // __GNU_SOURCE is defined. -Comment: // Glibc 2.23 removed the obsolete isinf and isnan declarations. Check the -Comment: // version dynamically in case it has changed since libstdc++ was configured. -Comment: // Glibc 2.26 on i?86/x86-64/ia64/ppc64le added *f128 support. -Comment: // Glibc 2.27 added it also on many other arches but those have IEEE quad -Comment: // long double. -Comment: // The following libpthread properties only apply to Linux, not GNU/Hurd. -Comment: // Since glibc 2.27 pthread_self() is usable without linking to libpthread. -Comment: // Since glibc 2.34 all pthreads functions are usable without linking to -Comment: // libpthread. -Comment: // __linux__ -Comment: // Pick up any CPU-specific definitions. -Comment: // Specific definitions for generic platforms -*- C++ -*- -Comment: // Copyright (C) 2005-2023 Free Software Foundation, Inc. -Comment: // -Comment: // This file is part of the GNU ISO C++ Library. This library is free -Comment: // software; you can redistribute it and/or modify it under the -Comment: // terms of the GNU General Public License as published by the -Comment: // Free Software Foundation; either version 3, or (at your option) -Comment: // any later version. -Comment: // This library is distributed in the hope that it will be useful, -Comment: // but WITHOUT ANY WARRANTY; without even the implied warranty of -Comment: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -Comment: // GNU General Public License for more details. -Comment: // Under Section 7 of GPL version 3, you are granted additional -Comment: // permissions described in the GCC Runtime Library Exception, version -Comment: // 3.1, as published by the Free Software Foundation. -Comment: // You should have received a copy of the GNU General Public License and -Comment: // a copy of the GCC Runtime Library Exception along with this program; -Comment: // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -Comment: // . -Comment: /** @file bits/cpu_defines.h - * This is an internal header file, included by other library headers. - * Do not attempt to use it directly. @headername{iosfwd} - */ -Comment: // If platform uses neither visibility nor psuedo-visibility, -Comment: // specify empty default for namespace annotation macros. -Comment: // Certain function definitions that are meant to be overridable from -Comment: // user code are decorated with this macro. For some targets, this -Comment: // macro causes these definitions to be weak. -Comment: // By default, we assume that __GXX_WEAK__ also means that there is support -Comment: // for declaring functions as weak while not defining such functions. This -Comment: // allows for referring to functions provided by other libraries (e.g., -Comment: // libitm) without depending on them if the respective features are not used. -Comment: // Conditionally enable annotations for the Transactional Memory TS on C++11. -Comment: // Most of the following conditions are due to limitations in the current -Comment: // implementation. -Comment: // In C++17 mathematical special functions are in namespace std. -Comment: // The remainder of the prewritten config is automatic; all the -Comment: // user hooks are listed above. -Comment: // Create a boolean flag to be used to determine if --fast-math is set. -Comment: // This marks string literals in header files to be extracted for eventual -Comment: // translation. It is primarily used for messages in thrown exceptions; see -Comment: // src/functexcept.cc. We use __N because the more traditional _N is used -Comment: // for something else under certain OSes (see BADNAMES). -Comment: // For example, is known to #define min and max as macros... -Comment: // N.B. these _GLIBCXX_USE_C99_XXX macros are defined unconditionally -Comment: // so they should be tested with #if not with #ifdef. -Comment: // Unless explicitly specified, enable char8_t extensions only if the core -Comment: // language char8_t feature macro is defined. -Comment: /* Define if __float128 is supported on this host. */ -Comment: /* For powerpc64 don't use __float128 when it's the same type as long double. */ -Comment: // Define if float has the IEEE binary32 format. -Comment: // Define if double has the IEEE binary64 format. -Comment: // Define if long double has the IEEE binary128 format. -Comment: // Intel and older Clang require !__is_identifier for some built-ins: -Comment: // Mark code that should be ignored by the compiler, but seen by Doxygen. -Comment: // PSTL configuration -Comment: // This header is not installed for freestanding: -Comment: // Preserved here so we have some idea which version of upstream we've pulled in -Comment: // #define PSTL_VERSION 9000 -Comment: // For now this defaults to being based on the presence of Thread Building Blocks -Comment: // This section will need some rework when a new (default) backend type is added -Comment: // -*- C++ -*- -Comment: //===-- pstl_config.h -----------------------------------------------------===// -Comment: // -Comment: // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -Comment: // See https://llvm.org/LICENSE.txt for license information. -Comment: // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -Comment: // -Comment: //===----------------------------------------------------------------------===// -Comment: // The version is XYYZ, where X is major, YY is minor, and Z is patch (i.e. X.YY.Z) -Comment: // Check the user-defined macro for warnings -Comment: // Portability "#pragma" definition -Comment: /* nothing */ -Comment: /* nothing */ -Comment: // note that when ICC or Clang is in use, _PSTL_GCC_VERSION might not fully match -Comment: // the actual GCC version on the system. -Comment: // according to clang documentation, version can be vendor specific -Comment: // Enable SIMD for compilers that support OpenMP 4.0 -Comment: //#pragma simd -Comment: //Enable SIMD -Comment: // Should be defined to 1 for environments with a vendor implementation of C++17 execution policies -Comment: // Declaration of reduction functor, where -Comment: // NAME - the name of the functor -Comment: // OP - type of the callable object with the reduction operation -Comment: // omp_in - refers to the local partial result -Comment: // omp_out - refers to the final value of the combiner operator -Comment: // omp_priv - refers to the private copy of the initial value -Comment: // omp_orig - refers to the original variable to be reduced -Comment: // Check the user-defined macro to use non-temporal stores -Comment: //the preprocessors don't type a message location -Comment: // broken macros -Comment: /* _PSTL_CONFIG_H */ -Comment: // __has_include -Comment: // C++17 -Comment: // End of prewritten config; the settings discovered at configure time follow. -Comment: /* config.h. Generated from config.h.in by configure. */ -Comment: /* config.h.in. Generated from configure.ac by autoheader. */ -Comment: /* Define to 1 if you have the `acosf' function. */ -Comment: /* Define to 1 if you have the `acosl' function. */ -Comment: /* Define to 1 if you have the `aligned_alloc' function. */ -Comment: /* Define if arc4random is available in . */ -Comment: /* Define to 1 if you have the header file. */ -Comment: /* Define to 1 if you have the `asinf' function. */ -Comment: /* Define to 1 if you have the `asinl' function. */ -Comment: /* Define to 1 if the target assembler supports .symver directive. */ -Comment: /* Define to 1 if you have the `atan2f' function. */ -Comment: /* Define to 1 if you have the `atan2l' function. */ -Comment: /* Define to 1 if you have the `atanf' function. */ -Comment: /* Define to 1 if you have the `atanl' function. */ -Comment: /* Defined if shared_ptr reference counting should use atomic operations. */ -Comment: /* Define to 1 if you have the `at_quick_exit' function. */ -Comment: /* Define to 1 if the target assembler supports thread-local storage. */ -Comment: /* #undef _GLIBCXX_HAVE_CC_TLS */ -Comment: /* Define to 1 if you have the `ceilf' function. */ -Comment: /* Define to 1 if you have the `ceill' function. */ -Comment: /* Define to 1 if you have the header file. */ -Comment: /* Define to 1 if you have the `cosf' function. */ -Comment: /* Define to 1 if you have the `coshf' function. */ -Comment: /* Define to 1 if you have the `coshl' function. */ -Comment: /* Define to 1 if you have the `cosl' function. */ -Comment: /* Define to 1 if you have the declaration of `strnlen', and to 0 if you - don't. */ -Comment: /* Define to 1 if you have the header file. */ -Comment: /* Define if dirfd is available in . */ -Comment: /* Define to 1 if you have the header file. */ -Comment: /* Define to 1 if you have the header file. */ -Comment: /* Define to 1 if GCC 4.6 supported std::exception_ptr for the target */ -Comment: /* Define to 1 if you have the header file. */ -Comment: /* Define to 1 if you have the `expf' function. */ -Comment: /* Define to 1 if you have the `expl' function. */ -Comment: /* Define to 1 if you have the `fabsf' function. */ -Comment: /* Define to 1 if you have the `fabsl' function. */ -Comment: /* Define to 1 if you have the header file. */ -Comment: /* Define if fdopendir is available in . */ -Comment: /* Define to 1 if you have the header file. */ -Comment: /* Define to 1 if you have the `finite' function. */ -Comment: /* Define to 1 if you have the `finitef' function. */ -Comment: /* Define to 1 if you have the `finitel' function. */ -Comment: /* Define to 1 if you have the header file. */ -Comment: /* Define to 1 if you have the `floorf' function. */ -Comment: /* Define to 1 if you have the `floorl' function. */ -Comment: /* Define to 1 if you have the `fmodf' function. */ -Comment: /* Define to 1 if you have the `fmodl' function. */ -Comment: /* Define to 1 if you have the `fpclass' function. */ -Comment: /* #undef _GLIBCXX_HAVE_FPCLASS */ -Comment: /* Define to 1 if you have the header file. */ -Comment: /* #undef _GLIBCXX_HAVE_FP_H */ -Comment: /* Define to 1 if you have the `frexpf' function. */ -Comment: /* Define to 1 if you have the `frexpl' function. */ -Comment: /* Define if getentropy is available in . */ -Comment: /* Define if _Unwind_GetIPInfo is available. */ -Comment: /* Define if gets is available in before C++14. */ -Comment: /* Define to 1 if you have the `hypot' function. */ -Comment: /* Define to 1 if you have the `hypotf' function. */ -Comment: /* Define to 1 if you have the `hypotl' function. */ -Comment: /* Define if you have the iconv() function. */ -Comment: /* Define to 1 if you have the header file. */ -Comment: /* #undef _GLIBCXX_HAVE_IEEEFP_H */ -Comment: /* Define to 1 if you have the header file. */ -Comment: /* Define to 1 if you have the `isinf' function. */ -Comment: /* #undef _GLIBCXX_HAVE_ISINF */ -Comment: /* Define to 1 if you have the `isinff' function. */ -Comment: /* Define to 1 if you have the `isinfl' function. */ -Comment: /* Define to 1 if you have the `isnan' function. */ -Comment: /* #undef _GLIBCXX_HAVE_ISNAN */ -Comment: /* Define to 1 if you have the `isnanf' function. */ -Comment: /* Define to 1 if you have the `isnanl' function. */ -Comment: /* Defined if iswblank exists. */ -Comment: /* Define if LC_MESSAGES is available in . */ -Comment: /* Define to 1 if you have the `ldexpf' function. */ -Comment: /* Define to 1 if you have the `ldexpl' function. */ -Comment: /* Define to 1 if you have the header file. */ -Comment: /* Only used in build directory testsuite_hooks.h. */ -Comment: /* Only used in build directory testsuite_hooks.h. */ -Comment: /* Only used in build directory testsuite_hooks.h. */ -Comment: /* Only used in build directory testsuite_hooks.h. */ -Comment: /* Only used in build directory testsuite_hooks.h. */ -Comment: /* Define if link is available in . */ -Comment: /* Define to 1 if you have the header file. */ -Comment: /* Define if futex syscall is available. */ -Comment: /* Define to 1 if you have the header file. */ -Comment: /* Define to 1 if you have the header file. */ -Comment: /* Define to 1 if you have the header file. */ -Comment: /* Define to 1 if you have the `log10f' function. */ -Comment: /* Define to 1 if you have the `log10l' function. */ -Comment: /* Define to 1 if you have the `logf' function. */ -Comment: /* Define to 1 if you have the `logl' function. */ -Comment: /* Define to 1 if you have the header file. */ -Comment: /* #undef _GLIBCXX_HAVE_MACHINE_ENDIAN_H */ -Comment: /* Define to 1 if you have the header file. */ -Comment: /* #undef _GLIBCXX_HAVE_MACHINE_PARAM_H */ -Comment: /* Define if mbstate_t exists in wchar.h. */ -Comment: /* Define to 1 if you have the `memalign' function. */ -Comment: /* Define to 1 if you have the header file. */ -Comment: /* Define to 1 if you have the `modf' function. */ -Comment: /* Define to 1 if you have the `modff' function. */ -Comment: /* Define to 1 if you have the `modfl' function. */ -Comment: /* Define to 1 if you have the header file. */ -Comment: /* #undef _GLIBCXX_HAVE_NAN_H */ -Comment: /* Define to 1 if you have the header file. */ -Comment: /* Define to 1 if you have the header file. */ -Comment: /* Define to 1 if you have the header file. */ -Comment: /* Define if defines obsolete isinf function. */ -Comment: /* #undef _GLIBCXX_HAVE_OBSOLETE_ISINF */ -Comment: /* Define if defines obsolete isnan function. */ -Comment: /* #undef _GLIBCXX_HAVE_OBSOLETE_ISNAN */ -Comment: /* Define if openat is available in . */ -Comment: /* Define if poll is available in . */ -Comment: /* Define to 1 if you have the header file. */ -Comment: /* Define to 1 if you have the `posix_memalign' function. */ -Comment: /* Define to 1 if POSIX Semaphores with sem_timedwait are available in - . */ -Comment: /* Define to 1 if you have the `powf' function. */ -Comment: /* Define to 1 if you have the `powl' function. */ -Comment: /* Define to 1 if you have the `qfpclass' function. */ -Comment: /* #undef _GLIBCXX_HAVE_QFPCLASS */ -Comment: /* Define to 1 if you have the `quick_exit' function. */ -Comment: /* Define if readlink is available in . */ -Comment: /* Define to 1 if you have the `secure_getenv' function. */ -Comment: /* Define to 1 if you have the `setenv' function. */ -Comment: /* Define to 1 if you have the `sincos' function. */ -Comment: /* Define to 1 if you have the `sincosf' function. */ -Comment: /* Define to 1 if you have the `sincosl' function. */ -Comment: /* Define to 1 if you have the `sinf' function. */ -Comment: /* Define to 1 if you have the `sinhf' function. */ -Comment: /* Define to 1 if you have the `sinhl' function. */ -Comment: /* Define to 1 if you have the `sinl' function. */ -Comment: /* Defined if sleep exists. */ -Comment: /* #undef _GLIBCXX_HAVE_SLEEP */ -Comment: /* Define to 1 if you have the `sockatmark' function. */ -Comment: /* Define to 1 if you have the `sqrtf' function. */ -Comment: /* Define to 1 if you have the `sqrtl' function. */ -Comment: /* Define if the header is supported. */ -Comment: /* Define to 1 if you have the header file. */ -Comment: /* Define to 1 if you have the header file. */ -Comment: /* Define to 1 if you have the header file. */ -Comment: /* Define to 1 if you have the header file. */ -Comment: /* Define if strerror_l is available in . */ -Comment: /* Define if strerror_r is available in . */ -Comment: /* Define to 1 if you have the header file. */ -Comment: /* Define to 1 if you have the header file. */ -Comment: /* Define to 1 if you have the `strtof' function. */ -Comment: /* Define to 1 if you have the `strtold' function. */ -Comment: /* Define to 1 if `d_type' is a member of `struct dirent'. */ -Comment: /* Define if strxfrm_l is available in . */ -Comment: /* Define if symlink is available in . */ -Comment: /* Define to 1 if the target runtime linker supports binding the same symbol - to different versions. */ -Comment: /* Define to 1 if you have the header file. */ -Comment: /* #undef _GLIBCXX_HAVE_SYS_FILIO_H */ -Comment: /* Define to 1 if you have the header file. */ -Comment: /* Define to 1 if you have the header file. */ -Comment: /* Define to 1 if you have the header file. */ -Comment: /* #undef _GLIBCXX_HAVE_SYS_ISA_DEFS_H */ -Comment: /* Define to 1 if you have the header file. */ -Comment: /* #undef _GLIBCXX_HAVE_SYS_MACHINE_H */ -Comment: /* Define to 1 if you have the header file. */ -Comment: /* Define to 1 if you have the header file. */ -Comment: /* Define to 1 if you have the header file. */ -Comment: /* Define to 1 if you have a suitable header file */ -Comment: /* Define to 1 if you have the header file. */ -Comment: /* Define to 1 if you have the header file. */ -Comment: /* Define to 1 if you have the header file. */ -Comment: /* Define to 1 if you have the header file. */ -Comment: /* Define to 1 if you have the header file. */ -Comment: /* Define to 1 if you have the header file. */ -Comment: /* Define to 1 if you have the header file. */ -Comment: /* Define to 1 if you have the header file. */ -Comment: /* Define if S_IFREG is available in . */ -Comment: /* #undef _GLIBCXX_HAVE_S_IFREG */ -Comment: /* Define if S_ISREG is available in . */ -Comment: /* Define to 1 if you have the `tanf' function. */ -Comment: /* Define to 1 if you have the `tanhf' function. */ -Comment: /* Define to 1 if you have the `tanhl' function. */ -Comment: /* Define to 1 if you have the `tanl' function. */ -Comment: /* Define to 1 if you have the header file. */ -Comment: /* Define to 1 if you have the `timespec_get' function. */ -Comment: /* Define to 1 if the target supports thread-local storage. */ -Comment: /* Define if truncate is available in . */ -Comment: /* Define to 1 if you have the header file. */ -Comment: /* Define to 1 if you have the header file. */ -Comment: /* Define if unlinkat is available in . */ -Comment: /* Define to 1 if you have the `uselocale' function. */ -Comment: /* Defined if usleep exists. */ -Comment: /* #undef _GLIBCXX_HAVE_USLEEP */ -Comment: /* Define to 1 if you have the header file. */ -Comment: /* Defined if vfwscanf exists. */ -Comment: /* Defined if vswscanf exists. */ -Comment: /* Defined if vwscanf exists. */ -Comment: /* Define to 1 if you have the header file. */ -Comment: /* Defined if wcstof exists. */ -Comment: /* Define to 1 if you have the header file. */ -Comment: /* Define to 1 if you have the header file. */ -Comment: /* #undef _GLIBCXX_HAVE_WINDOWS_H */ -Comment: /* Define if writev is available in . */ -Comment: /* Define to 1 if you have the header file. */ -Comment: /* #undef _GLIBCXX_HAVE_XLOCALE_H */ -Comment: /* Define to 1 if you have the `_acosf' function. */ -Comment: /* #undef _GLIBCXX_HAVE__ACOSF */ -Comment: /* Define to 1 if you have the `_acosl' function. */ -Comment: /* #undef _GLIBCXX_HAVE__ACOSL */ -Comment: /* Define to 1 if you have the `_aligned_malloc' function. */ -Comment: /* #undef _GLIBCXX_HAVE__ALIGNED_MALLOC */ -Comment: /* Define to 1 if you have the `_asinf' function. */ -Comment: /* #undef _GLIBCXX_HAVE__ASINF */ -Comment: /* Define to 1 if you have the `_asinl' function. */ -Comment: /* #undef _GLIBCXX_HAVE__ASINL */ -Comment: /* Define to 1 if you have the `_atan2f' function. */ -Comment: /* #undef _GLIBCXX_HAVE__ATAN2F */ -Comment: /* Define to 1 if you have the `_atan2l' function. */ -Comment: /* #undef _GLIBCXX_HAVE__ATAN2L */ -Comment: /* Define to 1 if you have the `_atanf' function. */ -Comment: /* #undef _GLIBCXX_HAVE__ATANF */ -Comment: /* Define to 1 if you have the `_atanl' function. */ -Comment: /* #undef _GLIBCXX_HAVE__ATANL */ -Comment: /* Define to 1 if you have the `_ceilf' function. */ -Comment: /* #undef _GLIBCXX_HAVE__CEILF */ -Comment: /* Define to 1 if you have the `_ceill' function. */ -Comment: /* #undef _GLIBCXX_HAVE__CEILL */ -Comment: /* Define to 1 if you have the `_cosf' function. */ -Comment: /* #undef _GLIBCXX_HAVE__COSF */ -Comment: /* Define to 1 if you have the `_coshf' function. */ -Comment: /* #undef _GLIBCXX_HAVE__COSHF */ -Comment: /* Define to 1 if you have the `_coshl' function. */ -Comment: /* #undef _GLIBCXX_HAVE__COSHL */ -Comment: /* Define to 1 if you have the `_cosl' function. */ -Comment: /* #undef _GLIBCXX_HAVE__COSL */ -Comment: /* Define to 1 if you have the `_expf' function. */ -Comment: /* #undef _GLIBCXX_HAVE__EXPF */ -Comment: /* Define to 1 if you have the `_expl' function. */ -Comment: /* #undef _GLIBCXX_HAVE__EXPL */ -Comment: /* Define to 1 if you have the `_fabsf' function. */ -Comment: /* #undef _GLIBCXX_HAVE__FABSF */ -Comment: /* Define to 1 if you have the `_fabsl' function. */ -Comment: /* #undef _GLIBCXX_HAVE__FABSL */ -Comment: /* Define to 1 if you have the `_finite' function. */ -Comment: /* #undef _GLIBCXX_HAVE__FINITE */ -Comment: /* Define to 1 if you have the `_finitef' function. */ -Comment: /* #undef _GLIBCXX_HAVE__FINITEF */ -Comment: /* Define to 1 if you have the `_finitel' function. */ -Comment: /* #undef _GLIBCXX_HAVE__FINITEL */ -Comment: /* Define to 1 if you have the `_floorf' function. */ -Comment: /* #undef _GLIBCXX_HAVE__FLOORF */ -Comment: /* Define to 1 if you have the `_floorl' function. */ -Comment: /* #undef _GLIBCXX_HAVE__FLOORL */ -Comment: /* Define to 1 if you have the `_fmodf' function. */ -Comment: /* #undef _GLIBCXX_HAVE__FMODF */ -Comment: /* Define to 1 if you have the `_fmodl' function. */ -Comment: /* #undef _GLIBCXX_HAVE__FMODL */ -Comment: /* Define to 1 if you have the `_fpclass' function. */ -Comment: /* #undef _GLIBCXX_HAVE__FPCLASS */ -Comment: /* Define to 1 if you have the `_frexpf' function. */ -Comment: /* #undef _GLIBCXX_HAVE__FREXPF */ -Comment: /* Define to 1 if you have the `_frexpl' function. */ -Comment: /* #undef _GLIBCXX_HAVE__FREXPL */ -Comment: /* Define to 1 if you have the `_hypot' function. */ -Comment: /* #undef _GLIBCXX_HAVE__HYPOT */ -Comment: /* Define to 1 if you have the `_hypotf' function. */ -Comment: /* #undef _GLIBCXX_HAVE__HYPOTF */ -Comment: /* Define to 1 if you have the `_hypotl' function. */ -Comment: /* #undef _GLIBCXX_HAVE__HYPOTL */ -Comment: /* Define to 1 if you have the `_isinf' function. */ -Comment: /* #undef _GLIBCXX_HAVE__ISINF */ -Comment: /* Define to 1 if you have the `_isinff' function. */ -Comment: /* #undef _GLIBCXX_HAVE__ISINFF */ -Comment: /* Define to 1 if you have the `_isinfl' function. */ -Comment: /* #undef _GLIBCXX_HAVE__ISINFL */ -Comment: /* Define to 1 if you have the `_isnan' function. */ -Comment: /* #undef _GLIBCXX_HAVE__ISNAN */ -Comment: /* Define to 1 if you have the `_isnanf' function. */ -Comment: /* #undef _GLIBCXX_HAVE__ISNANF */ -Comment: /* Define to 1 if you have the `_isnanl' function. */ -Comment: /* #undef _GLIBCXX_HAVE__ISNANL */ -Comment: /* Define to 1 if you have the `_ldexpf' function. */ -Comment: /* #undef _GLIBCXX_HAVE__LDEXPF */ -Comment: /* Define to 1 if you have the `_ldexpl' function. */ -Comment: /* #undef _GLIBCXX_HAVE__LDEXPL */ -Comment: /* Define to 1 if you have the `_log10f' function. */ -Comment: /* #undef _GLIBCXX_HAVE__LOG10F */ -Comment: /* Define to 1 if you have the `_log10l' function. */ -Comment: /* #undef _GLIBCXX_HAVE__LOG10L */ -Comment: /* Define to 1 if you have the `_logf' function. */ -Comment: /* #undef _GLIBCXX_HAVE__LOGF */ -Comment: /* Define to 1 if you have the `_logl' function. */ -Comment: /* #undef _GLIBCXX_HAVE__LOGL */ -Comment: /* Define to 1 if you have the `_modf' function. */ -Comment: /* #undef _GLIBCXX_HAVE__MODF */ -Comment: /* Define to 1 if you have the `_modff' function. */ -Comment: /* #undef _GLIBCXX_HAVE__MODFF */ -Comment: /* Define to 1 if you have the `_modfl' function. */ -Comment: /* #undef _GLIBCXX_HAVE__MODFL */ -Comment: /* Define to 1 if you have the `_powf' function. */ -Comment: /* #undef _GLIBCXX_HAVE__POWF */ -Comment: /* Define to 1 if you have the `_powl' function. */ -Comment: /* #undef _GLIBCXX_HAVE__POWL */ -Comment: /* Define to 1 if you have the `_qfpclass' function. */ -Comment: /* #undef _GLIBCXX_HAVE__QFPCLASS */ -Comment: /* Define to 1 if you have the `_sincos' function. */ -Comment: /* #undef _GLIBCXX_HAVE__SINCOS */ -Comment: /* Define to 1 if you have the `_sincosf' function. */ -Comment: /* #undef _GLIBCXX_HAVE__SINCOSF */ -Comment: /* Define to 1 if you have the `_sincosl' function. */ -Comment: /* #undef _GLIBCXX_HAVE__SINCOSL */ -Comment: /* Define to 1 if you have the `_sinf' function. */ -Comment: /* #undef _GLIBCXX_HAVE__SINF */ -Comment: /* Define to 1 if you have the `_sinhf' function. */ -Comment: /* #undef _GLIBCXX_HAVE__SINHF */ -Comment: /* Define to 1 if you have the `_sinhl' function. */ -Comment: /* #undef _GLIBCXX_HAVE__SINHL */ -Comment: /* Define to 1 if you have the `_sinl' function. */ -Comment: /* #undef _GLIBCXX_HAVE__SINL */ -Comment: /* Define to 1 if you have the `_sqrtf' function. */ -Comment: /* #undef _GLIBCXX_HAVE__SQRTF */ -Comment: /* Define to 1 if you have the `_sqrtl' function. */ -Comment: /* #undef _GLIBCXX_HAVE__SQRTL */ -Comment: /* Define to 1 if you have the `_tanf' function. */ -Comment: /* #undef _GLIBCXX_HAVE__TANF */ -Comment: /* Define to 1 if you have the `_tanhf' function. */ -Comment: /* #undef _GLIBCXX_HAVE__TANHF */ -Comment: /* Define to 1 if you have the `_tanhl' function. */ -Comment: /* #undef _GLIBCXX_HAVE__TANHL */ -Comment: /* Define to 1 if you have the `_tanl' function. */ -Comment: /* #undef _GLIBCXX_HAVE__TANL */ -Comment: /* Define to 1 if you have the `_wfopen' function. */ -Comment: /* #undef _GLIBCXX_HAVE__WFOPEN */ -Comment: /* Define to 1 if you have the `__cxa_thread_atexit' function. */ -Comment: /* #undef _GLIBCXX_HAVE___CXA_THREAD_ATEXIT */ -Comment: /* Define to 1 if you have the `__cxa_thread_atexit_impl' function. */ -Comment: /* Define as const if the declaration of iconv() needs const. */ -Comment: /* Define to the sub-directory in which libtool stores uninstalled libraries. - */ -Comment: /* Name of package */ -Comment: /* #undef _GLIBCXX_PACKAGE */ -Comment: /* Define to the address where bug reports for this package should be sent. */ -Comment: /* Define to the full name of this package. */ -Comment: /* Define to the full name and version of this package. */ -Comment: /* Define to the one symbol short name of this package. */ -Comment: /* Define to the home page for this package. */ -Comment: /* Define to the version of this package. */ -Comment: /* Define to 1 if you have the ANSI C header files. */ -Comment: /* Version number of package */ -Comment: /* #undef _GLIBCXX_VERSION */ -Comment: /* Enable large inode numbers on Mac OS X 10.5. */ -Comment: /* Number of bits in a file offset, on hosts where this is settable. */ -Comment: /* #undef _GLIBCXX_FILE_OFFSET_BITS */ -Comment: /* Define if C99 functions in should be used in for - C++11. Using compiler builtins for these functions requires corresponding - C99 library functions to be present. */ -Comment: /* Define if C99 functions or macros in should be imported in - in namespace std for C++11. */ -Comment: /* Define if C99 functions or macros in should be imported in - in namespace std for C++11. */ -Comment: /* Define if C99 functions or macros in should be imported in - in namespace std for C++11. */ -Comment: /* Define if C99 functions or macros in should be imported in - in namespace std for C++11. */ -Comment: /* Define if C99 functions in should be used in for - C++98. Using compiler builtins for these functions requires corresponding - C99 library functions to be present. */ -Comment: /* Define if C99 functions or macros in should be imported in - in namespace std for C++98. */ -Comment: /* Define if C99 functions or macros in should be imported in - in namespace std for C++98. */ -Comment: /* Define if C99 functions or macros in should be imported in - in namespace std for C++98. */ -Comment: /* Define if C99 functions or macros in should be imported in - in namespace std for C++98. */ -Comment: /* Define if the compiler supports C++11 atomics. */ -Comment: /* Define if global objects can be aligned to - std::hardware_destructive_interference_size. */ -Comment: /* Define to use concept checking code from the boost libraries. */ -Comment: /* #undef _GLIBCXX_CONCEPT_CHECKS */ -Comment: /* Define to 1 if a fully dynamic basic_string is wanted, 0 to disable, - undefined for platform defaults */ -Comment: /* Define if gthreads library is available. */ -Comment: /* Define to 1 if a full hosted library is built, or 0 if freestanding. */ -Comment: /* Define if compatibility should be provided for alternative 128-bit long - double formats. */ -Comment: /* Define if compatibility should be provided for -mlong-double-64. */ -Comment: /* Define to the letter to which size_t is mangled. */ -Comment: /* Define if C99 llrint and llround functions are missing from . */ -Comment: /* #undef _GLIBCXX_NO_C99_ROUNDING_FUNCS */ -Comment: /* Defined if no way to sleep is available. */ -Comment: /* #undef _GLIBCXX_NO_SLEEP */ -Comment: /* Define if ptrdiff_t is int. */ -Comment: /* #undef _GLIBCXX_PTRDIFF_T_IS_INT */ -Comment: /* Define if using setrlimit to set resource limits during "make check" */ -Comment: /* Define if size_t is unsigned int. */ -Comment: /* #undef _GLIBCXX_SIZE_T_IS_UINT */ -Comment: /* Define if static tzdata should be compiled into the library. */ -Comment: /* Define to the value of the EOF integer constant. */ -Comment: /* Define to the value of the SEEK_CUR integer constant. */ -Comment: /* Define to the value of the SEEK_END integer constant. */ -Comment: /* Define to use symbol versioning in the shared library. */ -Comment: /* Define to use darwin versioning in the shared library. */ -Comment: /* #undef _GLIBCXX_SYMVER_DARWIN */ -Comment: /* Define to use GNU versioning in the shared library. */ -Comment: /* Define to use GNU namespace versioning in the shared library. */ -Comment: /* #undef _GLIBCXX_SYMVER_GNU_NAMESPACE */ -Comment: /* Define to use Sun versioning in the shared library. */ -Comment: /* #undef _GLIBCXX_SYMVER_SUN */ -Comment: /* Define if C11 functions in should be imported into namespace std - in . */ -Comment: /* Define if C99 functions or macros from , , , - , and can be used or exposed. */ -Comment: /* Define if C99 functions in should be used in . - Using compiler builtins for these functions requires corresponding C99 - library functions to be present. */ -Comment: /* Define if C99 functions in should be imported in in - namespace std::tr1. */ -Comment: /* Define if C99 functions in should be imported in in - namespace std::tr1. */ -Comment: /* Define if C99 functions in should be imported in - in namespace std::tr1. */ -Comment: /* Define if wchar_t C99 functions in should be imported in - in namespace std::tr1. */ -Comment: /* Define if C99 functions or macros in should be imported in - in namespace std::tr1. */ -Comment: /* Define if C99 types in should be imported in in - namespace std::tr1. */ -Comment: /* Define if usable chdir is available in . */ -Comment: /* Define if usable chmod is available in . */ -Comment: /* Defined if clock_gettime syscall has monotonic and realtime clock support. - */ -Comment: /* #undef _GLIBCXX_USE_CLOCK_GETTIME_SYSCALL */ -Comment: /* Defined if clock_gettime has monotonic clock support. */ -Comment: /* Defined if clock_gettime has realtime clock support. */ -Comment: /* Define if ISO/IEC TR 24733 decimal floating point types are supported on - this host. */ -Comment: /* Define if /dev/random and /dev/urandom are available for - std::random_device. */ -Comment: /* Define if fchmod is available in . */ -Comment: /* Define if fchmodat is available in . */ -Comment: /* Define if fseeko and ftello are available. */ -Comment: /* Define if usable getcwd is available in . */ -Comment: /* Defined if gettimeofday is available. */ -Comment: /* Define if get_nprocs is available in . */ -Comment: /* Define if init_priority should be used for iostream initialization. */ -Comment: /* Define if LFS support is available. */ -Comment: /* Define if code specialized for long long should be used. */ -Comment: /* Define if lstat is available in . */ -Comment: /* Define if usable mkdir is available in . */ -Comment: /* Defined if nanosleep is available. */ -Comment: /* Define if NLS translations are to be used. */ -Comment: /* Define if pthreads_num_processors_np is available in . */ -Comment: /* #undef _GLIBCXX_USE_PTHREADS_NUM_PROCESSORS_NP */ -Comment: /* Define if pthread_cond_clockwait is available in . */ -Comment: /* Define if pthread_mutex_clocklock is available in . */ -Comment: /* Define if pthread_rwlock_clockrdlock and pthread_rwlock_clockwrlock are - available in . */ -Comment: /* Define if POSIX read/write locks are available in . */ -Comment: /* Define if /dev/random and /dev/urandom are available for the random_device - of TR1 (Chapter 5.1). */ -Comment: /* Define if usable realpath is available in . */ -Comment: /* Defined if sched_yield is available. */ -Comment: /* Define if _SC_NPROCESSORS_ONLN is available in . */ -Comment: /* Define if _SC_NPROC_ONLN is available in . */ -Comment: /* #undef _GLIBCXX_USE_SC_NPROC_ONLN */ -Comment: /* Define if sendfile is available in . */ -Comment: /* Define to restrict std::__basic_file<> to stdio APIs. */ -Comment: /* #undef _GLIBCXX_USE_STDIO_PURE */ -Comment: /* Define if struct stat has timespec members. */ -Comment: /* Define if sysctl(), CTL_HW and HW_NCPU are available in . */ -Comment: /* #undef _GLIBCXX_USE_SYSCTL_HW_NCPU */ -Comment: /* Define if obsolescent tmpnam is available in . */ -Comment: /* Define if c8rtomb and mbrtoc8 functions in should be imported - into namespace std in for C++20. */ -Comment: /* Define if c8rtomb and mbrtoc8 functions in should be imported - into namespace std in for -fchar8_t. */ -Comment: /* Define if utime is available in . */ -Comment: /* Define if utimensat and UTIME_OMIT are available in and - AT_FDCWD in . */ -Comment: /* Define if code specialized for wchar_t should be used. */ -Comment: /* Defined if Sleep exists. */ -Comment: /* #undef _GLIBCXX_USE_WIN32_SLEEP */ -Comment: /* Define to 1 if a verbose library is built, or 0 otherwise. */ -Comment: /* Defined if as can handle rdrand. */ -Comment: /* Defined if as can handle rdseed. */ -Comment: /* Define if a directory should be searched for tzdata files. */ -Comment: /* Define to 1 if mutex_timedlock is available. */ -Comment: /* Define for large files, on AIX-style hosts. */ -Comment: /* #undef _GLIBCXX_LARGE_FILES */ -Comment: /* Define if all C++11 floating point overloads are available in . */ -Comment: /* #undef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP */ -Comment: /* Define if all C++11 integral type overloads are available in . */ -Comment: /* #undef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT */ -Comment: // _GLIBCXX_CXX_CONFIG_H -Comment: // Core algorithmic facilities -*- C++ -*- -Comment: // Copyright (C) 2001-2023 Free Software Foundation, Inc. -Comment: // -Comment: // This file is part of the GNU ISO C++ Library. This library is free -Comment: // software; you can redistribute it and/or modify it under the -Comment: // terms of the GNU General Public License as published by the -Comment: // Free Software Foundation; either version 3, or (at your option) -Comment: // any later version. -Comment: // This library is distributed in the hope that it will be useful, -Comment: // but WITHOUT ANY WARRANTY; without even the implied warranty of -Comment: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -Comment: // GNU General Public License for more details. -Comment: // Under Section 7 of GPL version 3, you are granted additional -Comment: // permissions described in the GCC Runtime Library Exception, version -Comment: // 3.1, as published by the Free Software Foundation. -Comment: // You should have received a copy of the GNU General Public License and -Comment: // a copy of the GCC Runtime Library Exception along with this program; -Comment: // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -Comment: // . -Comment: /* - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1996-1998 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ -Comment: /** @file bits/stl_algobase.h - * This is an internal header file, included by other library headers. - * Do not attempt to use it directly. @headername{algorithm} - */ -Comment: // Function-Based Exception Support -*- C++ -*- -Comment: // Copyright (C) 2001-2023 Free Software Foundation, Inc. -Comment: // -Comment: // This file is part of the GNU ISO C++ Library. This library is free -Comment: // software; you can redistribute it and/or modify it under the -Comment: // terms of the GNU General Public License as published by the -Comment: // Free Software Foundation; either version 3, or (at your option) -Comment: // any later version. -Comment: // This library is distributed in the hope that it will be useful, -Comment: // but WITHOUT ANY WARRANTY; without even the implied warranty of -Comment: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -Comment: // GNU General Public License for more details. -Comment: // Under Section 7 of GPL version 3, you are granted additional -Comment: // permissions described in the GCC Runtime Library Exception, version -Comment: // 3.1, as published by the Free Software Foundation. -Comment: // You should have received a copy of the GNU General Public License and -Comment: // a copy of the GCC Runtime Library Exception along with this program; -Comment: // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -Comment: // . -Comment: /** @file bits/functexcept.h - * This is an internal header file, included by other library headers. - * Do not attempt to use it directly. @headername{exception} - * - * This header provides support for -fno-exceptions. - */ -Comment: // -Comment: // ISO C++ 14882: 19.1 Exception classes -Comment: // -Comment: // -fno-exceptions Support -*- C++ -*- -Comment: // Copyright (C) 2001-2023 Free Software Foundation, Inc. -Comment: // -Comment: // This file is part of the GNU ISO C++ Library. This library is free -Comment: // software; you can redistribute it and/or modify it under the -Comment: // terms of the GNU General Public License as published by the -Comment: // Free Software Foundation; either version 3, or (at your option) -Comment: // any later version. -Comment: // This library is distributed in the hope that it will be useful, -Comment: // but WITHOUT ANY WARRANTY; without even the implied warranty of -Comment: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -Comment: // GNU General Public License for more details. -Comment: // Under Section 7 of GPL version 3, you are granted additional -Comment: // permissions described in the GCC Runtime Library Exception, version -Comment: // 3.1, as published by the Free Software Foundation. -Comment: // You should have received a copy of the GNU General Public License and -Comment: // a copy of the GCC Runtime Library Exception along with this program; -Comment: // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -Comment: // . -Comment: /** @file bits/exception_defines.h - * This is an internal header file, included by other library headers. - * Do not attempt to use it directly. @headername{exception} - */ -Comment: // Else proceed normally. -Comment: // Helper for exception objects in -Comment: // Helper for exception objects in -Comment: // Helper for exception objects in -Comment: // Helpers for exception objects in -Comment: // Helpers for exception objects in -Comment: // Helpers for exception objects in -Comment: // Helpers for exception objects in -Comment: // Helpers for exception objects in -Comment: // ! HOSTED -Comment: // HOSTED -Comment: // namespace -Comment: // The -*- C++ -*- type traits classes for internal use in libstdc++ -Comment: // Copyright (C) 2000-2023 Free Software Foundation, Inc. -Comment: // -Comment: // This file is part of the GNU ISO C++ Library. This library is free -Comment: // software; you can redistribute it and/or modify it under the -Comment: // terms of the GNU General Public License as published by the -Comment: // Free Software Foundation; either version 3, or (at your option) -Comment: // any later version. -Comment: // This library is distributed in the hope that it will be useful, -Comment: // but WITHOUT ANY WARRANTY; without even the implied warranty of -Comment: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -Comment: // GNU General Public License for more details. -Comment: // Under Section 7 of GPL version 3, you are granted additional -Comment: // permissions described in the GCC Runtime Library Exception, version -Comment: // 3.1, as published by the Free Software Foundation. -Comment: // You should have received a copy of the GNU General Public License and -Comment: // a copy of the GCC Runtime Library Exception along with this program; -Comment: // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -Comment: // . -Comment: /** @file bits/cpp_type_traits.h - * This is an internal header file, included by other library headers. - * Do not attempt to use it directly. @headername{ext/type_traits} - */ -Comment: // Written by Gabriel Dos Reis -Comment: // -Comment: // This file provides some compile-time information about various types. -Comment: // These representations were designed, on purpose, to be constant-expressions -Comment: // and not types as found in . In particular, they -Comment: // can be used in control structures and the optimizer hopefully will do -Comment: // the obvious thing. -Comment: // -Comment: // Why integral expressions, and not functions nor types? -Comment: // Firstly, these compile-time entities are used as template-arguments -Comment: // so function return values won't work: We need compile-time entities. -Comment: // We're left with types and constant integral expressions. -Comment: // Secondly, from the point of view of ease of use, type-based compile-time -Comment: // information is -not- *that* convenient. One has to write lots of -Comment: // overloaded functions and to hope that the compiler will select the right -Comment: // one. As a net effect, the overall structure isn't very clear at first -Comment: // glance. -Comment: // Thirdly, partial ordering and overload resolution (of function templates) -Comment: // is highly costly in terms of compiler-resource. It is a Good Thing to -Comment: // keep these resource consumption as least as possible. -Comment: // -Comment: // See valarray_array.h for a case use. -Comment: // -Comment: // -- Gaby (dosreis@cmla.ens-cachan.fr) 2000-03-06. -Comment: // -Comment: // Update 2005: types are also provided and has been -Comment: // removed. -Comment: // -Comment: // N.B. The conversions to bool are needed due to the issue -Comment: // explained in c++/19404. -Comment: // Compare for equality of types. -Comment: // Holds if the template-argument is a void type. -Comment: // -Comment: // Integer types -Comment: // -Comment: // Thirteen specializations (yes there are eleven standard integer -Comment: // types; long long and unsigned long long are -Comment: // supported as extensions). Up to four target-specific __int -Comment: // types are supported as well. -Comment: // -Comment: // Floating point types -Comment: // -Comment: // three specializations (float, double and 'long double') -Comment: // -Comment: // Pointer types -Comment: // -Comment: // -Comment: // An arithmetic type is an integer type or a floating point type -Comment: // -Comment: // -Comment: // A scalar type is an arithmetic type or a pointer type -Comment: // -Comment: // -Comment: // For use in std::copy and std::find overloads for streambuf iterators. -Comment: // -Comment: // C++17 -Comment: // A type that is safe for use with memcpy, memmove, memcmp etc. -Comment: // Cannot use memcpy/memmove/memcmp on volatile types even if they are -Comment: // trivially copyable, so ensure __memcpyable -Comment: // and similar will be false. -Comment: // Whether two iterator types can be used with memcpy/memmove. -Comment: // Whether two iterator types can be used with memcmp. -Comment: // This trait only says it's well-formed to use memcmp, not that it -Comment: // gives the right answer for a given algorithm. So for example, std::equal -Comment: // needs to add additional checks that the types are integers or pointers, -Comment: // because other trivially copyable types can overload operator==. -Comment: // OK to use memcmp with pointers to trivially copyable types. -Comment: // Whether memcmp can be used to determine ordering for a type -Comment: // e.g. in std::lexicographical_compare or three-way comparisons. -Comment: // True for unsigned integer-like types where comparing each byte in turn -Comment: // as an unsigned char yields the right result. This is true for all -Comment: // unsigned integers on big endian targets, but only unsigned narrow -Comment: // character types (and std::byte) on little endian targets. -Comment: // is unsigned -Comment: // Whether two types can be compared using memcmp. -Comment: // std::byte can only be compared to itself, not to other types. -Comment: // -Comment: // Move iterator type -Comment: // -Comment: // Fallback implementation of the function in bits/stl_iterator.h used to -Comment: // remove the move_iterator wrapper. -Comment: // namespace -Comment: // extern "C++" -Comment: //_CPP_TYPE_TRAITS_H -Comment: // -*- C++ -*- -Comment: // Copyright (C) 2005-2023 Free Software Foundation, Inc. -Comment: // -Comment: // This file is part of the GNU ISO C++ Library. This library is free -Comment: // software; you can redistribute it and/or modify it under the terms -Comment: // of the GNU General Public License as published by the Free Software -Comment: // Foundation; either version 3, or (at your option) any later -Comment: // version. -Comment: // This library is distributed in the hope that it will be useful, but -Comment: // WITHOUT ANY WARRANTY; without even the implied warranty of -Comment: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Comment: // General Public License for more details. -Comment: // Under Section 7 of GPL version 3, you are granted additional -Comment: // permissions described in the GCC Runtime Library Exception, version -Comment: // 3.1, as published by the Free Software Foundation. -Comment: // You should have received a copy of the GNU General Public License and -Comment: // a copy of the GCC Runtime Library Exception along with this program; -Comment: // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -Comment: // . -Comment: /** @file ext/type_traits.h - * This file is a GNU extension to the Standard C++ Library. - */ -Comment: // Define a nested type if some predicate holds. -Comment: // Conditional expression for types. If true, first, if false, second. -Comment: // Given an integral builtin type, return the corresponding unsigned type. -Comment: // Declare but don't define. -Comment: // Given an integral builtin type, return the corresponding signed type. -Comment: // Declare but don't define. -Comment: // For use in string and vstring. -Comment: // For arithmetic promotions in and -Comment: // No nested __type member for non-integer non-floating point types, -Comment: // allows this type to be used for SFINAE to constrain overloads in -Comment: // and to only the intended types. -Comment: // Deducing the promoted type is done by __promoted_t<_Tp...>, -Comment: // then __promote is used to provide the nested __type member. -Comment: // namespace -Comment: // extern "C++" -Comment: // -*- C++ -*- -Comment: // Copyright (C) 2007-2023 Free Software Foundation, Inc. -Comment: // -Comment: // This file is part of the GNU ISO C++ Library. This library is free -Comment: // software; you can redistribute it and/or modify it under the terms -Comment: // of the GNU General Public License as published by the Free Software -Comment: // Foundation; either version 3, or (at your option) any later -Comment: // version. -Comment: // This library is distributed in the hope that it will be useful, but -Comment: // WITHOUT ANY WARRANTY; without even the implied warranty of -Comment: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Comment: // General Public License for more details. -Comment: // Under Section 7 of GPL version 3, you are granted additional -Comment: // permissions described in the GCC Runtime Library Exception, version -Comment: // 3.1, as published by the Free Software Foundation. -Comment: // You should have received a copy of the GNU General Public License and -Comment: // a copy of the GCC Runtime Library Exception along with this program; -Comment: // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -Comment: // . -Comment: /** @file ext/numeric_traits.h - * This file is a GNU extension to the Standard C++ Library. - */ -Comment: // Compile time constants for builtin types. -Comment: // In C++98 std::numeric_limits member functions are not constant expressions -Comment: // (that changed in C++11 with the addition of 'constexpr'). -Comment: // Even for C++11, this header is smaller than and can be used -Comment: // when only is_signed, digits, min, or max values are needed for integers, -Comment: // or is_signed, digits10, max_digits10, or max_exponent10 for floats. -Comment: // Unlike __is_integer (and std::is_integral) this trait is true for -Comment: // non-standard built-in integer types such as __int128 and __int20. -Comment: // The number of bits in the value representation. -Comment: // NB: these two are also available in std::numeric_limits as compile -Comment: // time constants, but is big and we can avoid including it. -Comment: // The initializers must be constants so that __max and __min are too. -Comment: // Enable __numeric_traits_integer for types where the __is_integer_nonstrict -Comment: // primary template doesn't give the right answer. -Comment: // We need to specify the width for some __intNN types because they -Comment: // have padding bits, e.g. the object representation of __int20 has 32 bits, -Comment: // but its width (number of bits in the value representation) is only 20. -Comment: // In strict modes __is_integer<__int128> is false, -Comment: // but we still want to define __numeric_traits_integer<__int128>. -Comment: /// Convenience alias for __numeric_traits. -Comment: // N.B. this only supports float, double and long double (no __float128 etc.) -Comment: // Only floating point types. See N1822. -Comment: // See above comment... -Comment: // namespace -Comment: // Pair implementation -*- C++ -*- -Comment: // Copyright (C) 2001-2023 Free Software Foundation, Inc. -Comment: // -Comment: // This file is part of the GNU ISO C++ Library. This library is free -Comment: // software; you can redistribute it and/or modify it under the -Comment: // terms of the GNU General Public License as published by the -Comment: // Free Software Foundation; either version 3, or (at your option) -Comment: // any later version. -Comment: // This library is distributed in the hope that it will be useful, -Comment: // but WITHOUT ANY WARRANTY; without even the implied warranty of -Comment: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -Comment: // GNU General Public License for more details. -Comment: // Under Section 7 of GPL version 3, you are granted additional -Comment: // permissions described in the GCC Runtime Library Exception, version -Comment: // 3.1, as published by the Free Software Foundation. -Comment: // You should have received a copy of the GNU General Public License and -Comment: // a copy of the GCC Runtime Library Exception along with this program; -Comment: // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -Comment: // . -Comment: /* - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1996,1997 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ -Comment: /** @file bits/stl_pair.h - * This is an internal header file, included by other library headers. - * Do not attempt to use it directly. @headername{utility} - */ -Comment: // for std::__decay_and_strip -Comment: // C++11 -*- C++ -*- -Comment: // Copyright (C) 2007-2023 Free Software Foundation, Inc. -Comment: // -Comment: // This file is part of the GNU ISO C++ Library. This library is free -Comment: // software; you can redistribute it and/or modify it under the -Comment: // terms of the GNU General Public License as published by the -Comment: // Free Software Foundation; either version 3, or (at your option) -Comment: // any later version. -Comment: // This library is distributed in the hope that it will be useful, -Comment: // but WITHOUT ANY WARRANTY; without even the implied warranty of -Comment: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -Comment: // GNU General Public License for more details. -Comment: // Under Section 7 of GPL version 3, you are granted additional -Comment: // permissions described in the GCC Runtime Library Exception, version -Comment: // 3.1, as published by the Free Software Foundation. -Comment: // You should have received a copy of the GNU General Public License and -Comment: // a copy of the GCC Runtime Library Exception along with this program; -Comment: // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -Comment: // . -Comment: /** @file include/type_traits - * This is a Standard C++ Library header. - */ -Comment: /** - * @defgroup metaprogramming Metaprogramming - * @ingroup utilities - * - * Template utilities for compile-time introspection and modification, - * including type classification traits, type property inspection traits - * and type transformation traits. - * - * @since C++11 - * - * @{ - */ -Comment: /// integral_constant -Comment: /// The type used as a compile-time boolean with true value. -Comment: /// The type used as a compile-time boolean with false value. -Comment: /// @cond undocumented -Comment: /// bool_constant for C++11 -Comment: /// @endcond -Comment: /// Alias template for compile-time boolean constant types. -Comment: /// @since C++17 -Comment: // Metaprogramming helper types. -Comment: // Primary template. -Comment: /// Define a member typedef `type` only if a boolean constant is true. -Comment: // Partial specialization for true. -Comment: // __enable_if_t (std::enable_if_t for C++11) -Comment: // More efficient version of std::conditional_t for internal use (and C++11) -Comment: /// @cond undocumented -Comment: // A variadic alias template that resolves to its first argument. -Comment: // These are deliberately not defined. -Comment: // namespace detail -Comment: // Like C++17 std::dis/conjunction, but usable in C++11 and resolves -Comment: // to either true_type or false_type which allows for a more efficient -Comment: // implementation that avoids recursive class template instantiation. -Comment: /// @endcond -Comment: /// @cond undocumented -Comment: /* = void */ -Comment: /* = void */ -Comment: // namespace __detail -Comment: /// @endcond -Comment: /** @ingroup variable_templates - * @{ - */ -Comment: /// @} -Comment: // C++17 -Comment: // Forward declarations -Comment: /// @cond undocumented -Comment: // Helper functions that return false_type for incomplete classes, -Comment: // incomplete unions and arrays of known bound from those. -Comment: // __remove_cv_t (std::remove_cv_t for C++11). -Comment: /// @endcond -Comment: // Primary type categories. -Comment: /// is_void -Comment: /// @cond undocumented -Comment: // We want is_integral to be true (and make_signed/unsigned to work) -Comment: // even when libc doesn't provide working and related functions, -Comment: // so don't check _GLIBCXX_USE_WCHAR_T here. -Comment: // Conditionalizing on __STRICT_ANSI__ here will break any port that -Comment: // uses one of these types for size_t. -Comment: /// @endcond -Comment: /// is_integral -Comment: /// @cond undocumented -Comment: /// @endcond -Comment: /// is_floating_point -Comment: /// is_array -Comment: /// is_pointer -Comment: /// is_lvalue_reference -Comment: /// is_rvalue_reference -Comment: /// is_member_object_pointer -Comment: /// is_member_function_pointer -Comment: /// is_enum -Comment: /// is_union -Comment: /// is_class -Comment: /// is_function -Comment: /// is_null_pointer (LWG 2247). -Comment: /// __is_nullptr_t (deprecated extension). -Comment: /// @deprecated Non-standard. Use `is_null_pointer` instead. -Comment: // Composite type categories. -Comment: /// is_reference -Comment: /// is_arithmetic -Comment: /// is_fundamental -Comment: /// is_object -Comment: /// is_scalar -Comment: /// is_compound -Comment: /// @cond undocumented -Comment: /// @endcond -Comment: /// is_member_pointer -Comment: /// @cond undocumented -Comment: // Check if a type is one of the signed integer types. -Comment: // Check if a type is one of the unsigned integer types. -Comment: // Check if a type is one of the signed or unsigned integer types. -Comment: // __void_t (std::void_t for C++11) -Comment: /// @endcond -Comment: // Type properties. -Comment: /// is_const -Comment: /// is_volatile -Comment: /// is_trivial -Comment: /// is_trivially_copyable -Comment: /// is_standard_layout -Comment: /** is_pod - * @deprecated Deprecated in C++20. - * Use `is_standard_layout && is_trivial` instead. - */ -Comment: // Could use is_standard_layout && is_trivial instead of the builtin. -Comment: /** is_literal_type - * @deprecated Deprecated in C++17, removed in C++20. - * The idea of a literal type isn't useful. - */ -Comment: /// is_empty -Comment: /// is_polymorphic -Comment: /// is_final -Comment: /// @since C++14 -Comment: /// is_abstract -Comment: /// @cond undocumented -Comment: /// @endcond -Comment: /// is_signed -Comment: /// is_unsigned -Comment: /// @cond undocumented -Comment: /// @endcond -Comment: /// @cond undocumented -Comment: // Destructible and constructible type properties. -Comment: // In N3290 is_destructible does not say anything about function -Comment: // types and abstract types, see LWG 2049. This implementation -Comment: // describes function types as non-destructible and all complete -Comment: // object types as destructible, iff the explicit destructor -Comment: // call expression is wellformed. -Comment: /// @endcond -Comment: /// is_destructible -Comment: /// @cond undocumented -Comment: // is_nothrow_destructible requires that is_destructible is -Comment: // satisfied as well. We realize that by mimicing the -Comment: // implementation of is_destructible but refer to noexcept(expr) -Comment: // instead of decltype(expr). -Comment: /// @endcond -Comment: /// is_nothrow_destructible -Comment: /// @cond undocumented -Comment: /// @endcond -Comment: /// is_constructible -Comment: /// is_default_constructible -Comment: /// @cond undocumented -Comment: /// @endcond -Comment: /// is_copy_constructible -Comment: /// @cond undocumented -Comment: /// @endcond -Comment: /// is_move_constructible -Comment: /// @cond undocumented -Comment: /// @endcond -Comment: /// is_nothrow_constructible -Comment: /// is_nothrow_default_constructible -Comment: /// is_nothrow_copy_constructible -Comment: /// is_nothrow_move_constructible -Comment: /// @cond undocumented -Comment: /// @endcond -Comment: /// is_assignable -Comment: /// is_copy_assignable -Comment: /// is_move_assignable -Comment: /// @cond undocumented -Comment: /// @endcond -Comment: /// is_nothrow_assignable -Comment: /// is_nothrow_copy_assignable -Comment: /// is_nothrow_move_assignable -Comment: /// @cond undocumented -Comment: /// @endcond -Comment: /// is_trivially_constructible -Comment: /// is_trivially_default_constructible -Comment: /// is_trivially_copy_constructible -Comment: /// is_trivially_move_constructible -Comment: /// @cond undocumented -Comment: /// @endcond -Comment: /// is_trivially_assignable -Comment: /// is_trivially_copy_assignable -Comment: /// is_trivially_move_assignable -Comment: /// is_trivially_destructible -Comment: /// has_virtual_destructor -Comment: // type property queries. -Comment: /// alignment_of -Comment: /// rank -Comment: /// extent -Comment: // Type relations. -Comment: /// is_same -Comment: /// is_base_of -Comment: // helper trait for unique_ptr, shared_ptr, and span -Comment: /// is_nothrow_convertible_v -Comment: /// is_nothrow_convertible -Comment: // C++2a -Comment: // Const-volatile modifications. -Comment: /// remove_const -Comment: /// remove_volatile -Comment: /// remove_cv -Comment: /// add_const -Comment: /// add_volatile -Comment: /// add_cv -Comment: /// Alias template for remove_const -Comment: /// Alias template for remove_volatile -Comment: /// Alias template for remove_cv -Comment: /// Alias template for add_const -Comment: /// Alias template for add_volatile -Comment: /// Alias template for add_cv -Comment: // Reference transformations. -Comment: /// remove_reference -Comment: /// add_lvalue_reference -Comment: /// add_rvalue_reference -Comment: /// Alias template for remove_reference -Comment: /// Alias template for add_lvalue_reference -Comment: /// Alias template for add_rvalue_reference -Comment: // Sign modifications. -Comment: /// @cond undocumented -Comment: // Utility for constructing identically cv-qualified types. -Comment: // Utility for finding the unsigned versions of signed integral types. -Comment: // Select between integral and enum: not possible to be both. -Comment: // Choose unsigned integer type with the smallest rank and same size as _Tp -Comment: // With -fshort-enums, an enum may be as small as a char. -Comment: // wchar_t, char8_t, char16_t and char32_t are integral types but are -Comment: // neither signed integer types nor unsigned integer types, so must be -Comment: // transformed to the unsigned integer type with the smallest rank. -Comment: // Use the partial specialization for enumeration types to do that. -Comment: /// @endcond -Comment: // Given an integral/enum type, return the corresponding unsigned -Comment: // integer type. -Comment: // Primary template. -Comment: /// make_unsigned -Comment: // Integral, but don't define. -Comment: /// @cond undocumented -Comment: // Utility for finding the signed versions of unsigned integral types. -Comment: // Select between integral and enum: not possible to be both. -Comment: // Choose signed integer type with the smallest rank and same size as _Tp -Comment: // wchar_t, char16_t and char32_t are integral types but are neither -Comment: // signed integer types nor unsigned integer types, so must be -Comment: // transformed to the signed integer type with the smallest rank. -Comment: // Use the partial specialization for enumeration types to do that. -Comment: /// @endcond -Comment: // Given an integral/enum type, return the corresponding signed -Comment: // integer type. -Comment: // Primary template. -Comment: /// make_signed -Comment: // Integral, but don't define. -Comment: /// Alias template for make_signed -Comment: /// Alias template for make_unsigned -Comment: // Array modifications. -Comment: /// remove_extent -Comment: /// remove_all_extents -Comment: /// Alias template for remove_extent -Comment: /// Alias template for remove_all_extents -Comment: // Pointer modifications. -Comment: /// remove_pointer -Comment: /// add_pointer -Comment: /// Alias template for remove_pointer -Comment: /// Alias template for add_pointer -Comment: /** - * @brief Alignment type. - * - * The value of _Align is a default-alignment which shall be the - * most stringent alignment requirement for any C++ object type - * whose size is no greater than _Len (3.9). The member typedef - * type shall be a POD type suitable for use as uninitialized - * storage for any object whose size is at most _Len and whose - * alignment is a divisor of _Align. - * - * @deprecated Deprecated in C++23. Uses can be replaced by an - * array std::byte[_Len] declared with alignas(_Align). - */ -Comment: /** - * @brief Provide aligned storage for types. - * - * [meta.trans.other] - * - * Provides aligned storage for any of the provided types of at - * least size _Len. - * - * @see aligned_storage - * - * @deprecated Deprecated in C++23. - */ -Comment: /// The value of the strictest alignment of _Types. -Comment: /// The storage. -Comment: /// @cond undocumented -Comment: // Decay trait for arrays and functions, used for perfect forwarding -Comment: // in make_pair, make_tuple, etc. -Comment: // false for functions -Comment: // N.B. DR 705. -Comment: // function decays to pointer -Comment: /// @endcond -Comment: /// decay -Comment: /// @cond undocumented -Comment: // Helper which adds a reference to a type when given a reference_wrapper -Comment: // __decay_t (std::decay_t for C++11). -Comment: /// @endcond -Comment: /// @cond undocumented -Comment: // Helper for SFINAE constraints -Comment: // __remove_cvref_t (std::remove_cvref_t for C++11). -Comment: /// @endcond -Comment: // Primary template. -Comment: /// Define a member typedef @c type to one of two argument types. -Comment: // Partial specialization for false. -Comment: /// common_type -Comment: // Sfinae-friendly common_type implementation: -Comment: /// @cond undocumented -Comment: // For several sfinae-friendly trait implementations we transport both the -Comment: // result information (as the member type) and the failure information (no -Comment: // member type). This is very similar to std::enable_if, but we cannot use -Comment: // that, because we need to derive from them as an implementation detail. -Comment: // if decay_t() : declval())> -Comment: // denotes a valid type, let C denote that type. -Comment: // Otherwise, if COND-RES(CREF(D1), CREF(D2)) denotes a type, -Comment: // let C denote the type decay_t. -Comment: // If sizeof...(T) is zero, there shall be no member type. -Comment: // If sizeof...(T) is one, the same type, if any, as common_type_t. -Comment: // If sizeof...(T) is two, ... -Comment: // If is_same_v is false or is_same_v is false, -Comment: // let C denote the same type, if any, as common_type_t. -Comment: // Otherwise, if decay_t() : declval())> -Comment: // denotes a valid type, let C denote that type. -Comment: // If sizeof...(T) is two, ... -Comment: // If sizeof...(T) is greater than two, ... -Comment: // Let C denote the same type, if any, as common_type_t. -Comment: // If there is such a type C, type shall denote the same type, if any, -Comment: // as common_type_t. -Comment: // Otherwise, there shall be no member type. -Comment: /// @endcond -Comment: /// The underlying type of an enum. -Comment: /// @cond undocumented -Comment: /// @endcond -Comment: /** Utility to simplify expressions used in unevaluated operands - * @since C++11 - * @ingroup utilities - */ -Comment: /// result_of -Comment: // Sfinae-friendly result_of implementation: -Comment: /// @cond undocumented -Comment: // Associate a tag type with a specialization of __success_type. -Comment: // [func.require] paragraph 1 bullet 1: -Comment: // [func.require] paragraph 1 bullet 2: -Comment: // [func.require] paragraph 1 bullet 3: -Comment: // [func.require] paragraph 1 bullet 4: -Comment: // _GLIBCXX_RESOLVE_LIB_DEFECTS -Comment: // 2219. INVOKE-ing a pointer to member with a reference_wrapper -Comment: // as the object expression -Comment: // Used by result_of, invoke etc. to unwrap a reference_wrapper. -Comment: // [func.require] paragraph 1 bullet 5: -Comment: // __invoke_result (std::invoke_result for C++11) -Comment: /// @endcond -Comment: /// Alias template for aligned_storage -Comment: /// Alias template for decay -Comment: /// Alias template for enable_if -Comment: /// Alias template for conditional -Comment: /// Alias template for common_type -Comment: /// Alias template for underlying_type -Comment: /// Alias template for result_of -Comment: // C++14 -Comment: // c++17 or gnu++11 -Comment: /// A metafunction that always yields void, used for detecting valid types. -Comment: /// @cond undocumented -Comment: // Detection idiom. -Comment: // Detect whether _Op<_Args...> is a valid type, use default _Def if not. -Comment: // Implementation of the detection idiom (negative case). -Comment: // Implementation of the detection idiom (positive case). -Comment: // __cpp_concepts -Comment: // _Op<_Args...> if that is a valid type, otherwise _Default. -Comment: /** - * Use SFINAE to determine if the type _Tp has a publicly-accessible - * member type _NTYPE. - */ -Comment: // Internal type trait that allows us to sfinae-protect tuple_cat. -Comment: /// @endcond -Comment: /// @cond undocumented -Comment: // namespace __swappable_details -Comment: /// @endcond -Comment: // c++1z or gnu++11 -Comment: /// Metafunctions used for detecting swappable types: p0185r1 -Comment: /// is_swappable -Comment: /// is_nothrow_swappable -Comment: /// is_swappable_v -Comment: /// is_nothrow_swappable_v -Comment: // __cplusplus >= 201402L -Comment: /// @cond undocumented -Comment: // namespace __swappable_with_details -Comment: // Optimization for the homogenous lvalue case, not required: -Comment: // Optimization for the homogenous lvalue case, not required: -Comment: /// @endcond -Comment: /// is_swappable_with -Comment: /// is_nothrow_swappable_with -Comment: /// is_swappable_with_v -Comment: /// is_nothrow_swappable_with_v -Comment: // __cplusplus >= 201402L -Comment: // c++1z or gnu++11 -Comment: /// @cond undocumented -Comment: // __is_invocable (std::is_invocable for C++11) -Comment: // The primary template is used for invalid INVOKE expressions. -Comment: // For is_nothrow_invocable_r -Comment: // Used for valid INVOKE and INVOKE expressions. -Comment: /* is_void<_Ret> = */ -Comment: // For is_nothrow_invocable_r -Comment: // Used for INVOKE expressions to check the implicit conversion to R. -Comment: /* is_void<_Ret> = */ -Comment: // The type of the INVOKE expression. -Comment: // Unlike declval, this doesn't add_rvalue_reference, so it respects -Comment: // guaranteed copy elision. -Comment: // Used to check if _Res_t can implicitly convert to _Tp. -Comment: // This overload is viable if INVOKE(f, args...) can convert to _Tp. -Comment: // For is_invocable_r -Comment: /* Nothrow = */ -Comment: // For is_nothrow_invocable_r -Comment: // __is_nothrow_invocable (std::is_nothrow_invocable for C++11) -Comment: /// @endcond -Comment: /// std::invoke_result -Comment: /// std::invoke_result_t -Comment: /// std::is_invocable -Comment: /// std::is_invocable_r -Comment: /// std::is_nothrow_invocable -Comment: /// @cond undocumented -Comment: // This checks that the INVOKE expression is well-formed and that the -Comment: // conversion to R does not throw. It does *not* check whether the INVOKE -Comment: // expression itself can throw. That is done by __call_is_nothrow_ instead. -Comment: /// @endcond -Comment: /// std::is_nothrow_invocable_r -Comment: // C++17 -Comment: /** - * @defgroup variable_templates Variable templates for type traits - * @ingroup metaprogramming - * - * Each variable `is_xxx_v` is a boolean constant with the same value - * as the `value` member of the corresponding type trait `is_xxx`. - * - * @since C++17 unless noted otherwise. - */ -Comment: /** - * @{ - * @ingroup variable_templates - */ -Comment: /// @} -Comment: /// has_unique_object_representations -Comment: /// @since C++17 -Comment: /// @ingroup variable_templates -Comment: /// is_aggregate - true if the type is an aggregate. -Comment: /// @since C++17 -Comment: /** is_aggregate_v - true if the type is an aggregate. - * @ingroup variable_templates - * @since C++17 - */ -Comment: // C++17 -Comment: /** * Remove references and cv-qualifiers. - * @since C++20 - * @{ - */ -Comment: /// @} -Comment: /** * Identity metafunction. - * @since C++20 - * @{ - */ -Comment: /// @} -Comment: /** Unwrap a reference_wrapper - * @since C++20 - * @{ - */ -Comment: /// @} -Comment: /** Decay type and if it's a reference_wrapper, unwrap it - * @since C++20 - * @{ - */ -Comment: /// @} -Comment: /// True for a type that is an array of known bound. -Comment: /// @ingroup variable_templates -Comment: /// @since C++20 -Comment: /// True for a type that is an array of unknown bound. -Comment: /// @ingroup variable_templates -Comment: /// @since C++20 -Comment: /// True for a type that is an array of known bound. -Comment: /// @since C++20 -Comment: /// True for a type that is an array of unknown bound. -Comment: /// @since C++20 -Comment: /// @since C++20 -Comment: /// @ingroup variable_templates -Comment: /// @since C++20 -Comment: /// True if `_Derived` is standard-layout and has a base class of type `_Base` -Comment: /// @since C++20 -Comment: /// @ingroup variable_templates -Comment: /// @since C++20 -Comment: // C++23 -Comment: /// Returns true only when called during constant evaluation. -Comment: /// @since C++20 -Comment: /// @cond undocumented -Comment: // [meta.trans.other], COMMON-REF(A, B) -Comment: // COND-RES(COPYCV(X, Y) &, COPYCV(Y, X) &) -Comment: // If A and B are both lvalue reference types, ... -Comment: // let C be remove_reference_t&& -Comment: // If A and B are both rvalue reference types, ... -Comment: // let D be COMMON-REF(const X&, Y&) -Comment: // If A is an rvalue reference and B is an lvalue reference, ... -Comment: // If A is an lvalue reference and B is an rvalue reference, ... -Comment: /// @endcond -Comment: /// @cond undocumented -Comment: /// @endcond -Comment: // If sizeof...(T) is zero, there shall be no member type. -Comment: // If sizeof...(T) is one ... -Comment: /// @cond undocumented -Comment: // If sizeof...(T) is two ... -Comment: // If T1 and T2 are reference types and COMMON-REF(T1, T2) is well-formed, ... -Comment: // Otherwise, if basic_common_reference<...>::type is well-formed, ... -Comment: // Otherwise, if COND-RES(T1, T2) is well-formed, ... -Comment: // Otherwise, if common_type_t is well-formed, ... -Comment: // Otherwise, there shall be no member type. -Comment: // Otherwise, if sizeof...(T) is greater than two, ... -Comment: // Reuse __common_type_fold for common_reference -Comment: /// @endcond -Comment: // C++2a -Comment: /// @} group metaprogramming -Comment: // namespace std -Comment: // C++11 -Comment: // _GLIBCXX_TYPE_TRAITS -Comment: // for std::move / std::forward, and std::swap -Comment: // Move, forward and identity for C++11 + swap -*- C++ -*- -Comment: // Copyright (C) 2007-2023 Free Software Foundation, Inc. -Comment: // -Comment: // This file is part of the GNU ISO C++ Library. This library is free -Comment: // software; you can redistribute it and/or modify it under the -Comment: // terms of the GNU General Public License as published by the -Comment: // Free Software Foundation; either version 3, or (at your option) -Comment: // any later version. -Comment: // This library is distributed in the hope that it will be useful, -Comment: // but WITHOUT ANY WARRANTY; without even the implied warranty of -Comment: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -Comment: // GNU General Public License for more details. -Comment: // Under Section 7 of GPL version 3, you are granted additional -Comment: // permissions described in the GCC Runtime Library Exception, version -Comment: // 3.1, as published by the Free Software Foundation. -Comment: // You should have received a copy of the GNU General Public License and -Comment: // a copy of the GCC Runtime Library Exception along with this program; -Comment: // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -Comment: // . -Comment: /** @file bits/move.h - * This is an internal header file, included by other library headers. - * Do not attempt to use it directly. @headername{utility} - */ -Comment: // Brings in std::declval too. -Comment: // Used, in C++03 mode too, by allocators, etc. -Comment: /** - * @brief Same as C++11 std::addressof - * @ingroup utilities - */ -Comment: /** - * @addtogroup utilities - * @{ - */ -Comment: /** - * @brief Forward an lvalue. - * @return The parameter cast to the specified type. - * - * This function is used to implement "perfect forwarding". - */ -Comment: /** - * @brief Forward an rvalue. - * @return The parameter cast to the specified type. - * - * This function is used to implement "perfect forwarding". - */ -Comment: /** - * @brief Convert a value to an rvalue. - * @param __t A thing of arbitrary type. - * @return The parameter cast to an rvalue-reference to allow moving it. - */ -Comment: /** - * @brief Conditionally convert a value to an rvalue. - * @param __x A thing of arbitrary type. - * @return The parameter, possibly cast to an rvalue-reference. - * - * Same as std::move unless the type's move constructor could throw and the - * type is copyable, in which case an lvalue-reference is returned instead. - */ -Comment: // declval, from type_traits. -Comment: // _GLIBCXX_RESOLVE_LIB_DEFECTS -Comment: // 2296. std::addressof should be constexpr -Comment: /** - * @brief Returns the actual address of the object or function - * referenced by r, even in the presence of an overloaded - * operator&. - * @param __r Reference to an object or function. - * @return The actual address. - */ -Comment: // _GLIBCXX_RESOLVE_LIB_DEFECTS -Comment: // 2598. addressof works on temporaries -Comment: // C++11 version of std::exchange for internal use. -Comment: /// @} group utilities -Comment: /** - * @addtogroup utilities - * @{ - */ -Comment: /** - * @brief Swaps two values. - * @param __a A thing of arbitrary type. - * @param __b Another thing of arbitrary type. - * @return Nothing. - */ -Comment: // _GLIBCXX_RESOLVE_LIB_DEFECTS -Comment: // DR 809. std::swap should be overloaded for array types. -Comment: /// Swap the contents of two arrays. -Comment: /// @} group utilities -Comment: // namespace -Comment: /* _MOVE_H */ -Comment: // for std::tuple_element, std::tuple_size -Comment: // Utilities used throughout the library -*- C++ -*- -Comment: // Copyright (C) 2004-2023 Free Software Foundation, Inc. -Comment: // -Comment: // This file is part of the GNU ISO C++ Library. This library is free -Comment: // software; you can redistribute it and/or modify it under the -Comment: // terms of the GNU General Public License as published by the -Comment: // Free Software Foundation; either version 3, or (at your option) -Comment: // any later version. -Comment: // This library is distributed in the hope that it will be useful, -Comment: // but WITHOUT ANY WARRANTY; without even the implied warranty of -Comment: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -Comment: // GNU General Public License for more details. -Comment: // Under Section 7 of GPL version 3, you are granted additional -Comment: // permissions described in the GCC Runtime Library Exception, version -Comment: // 3.1, as published by the Free Software Foundation. -Comment: // You should have received a copy of the GNU General Public License and -Comment: // a copy of the GCC Runtime Library Exception along with this program; -Comment: // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -Comment: // . -Comment: /** @file include/bits/utility.h - * This is an internal header file, included by other library headers. - * Do not attempt to use it directly. @headername{utility} - * - * This file contains the parts of `` needed by other headers, - * so they don't need to include the whole of ``. - */ -Comment: /// Finds the size of a given tuple type. -Comment: // _GLIBCXX_RESOLVE_LIB_DEFECTS -Comment: // 2313. tuple_size should always derive from integral_constant -Comment: // 2770. tuple_size specialization is not SFINAE compatible -Comment: /// Gives the type of the ith element of a given tuple type. -Comment: // Duplicate of C++14's tuple_element_t for internal use in C++11 mode -Comment: // Return the index of _Tp in _Types, if it occurs exactly once. -Comment: // Otherwise, return sizeof...(_Types). -Comment: // more than one _Tp found -Comment: // The standard says this macro and alias template should be in but we -Comment: // define them here, to be available in , and too. -Comment: // _GLIBCXX_RESOLVE_LIB_DEFECTS -Comment: // 3378. tuple_size_v/tuple_element_t should be available when -Comment: // tuple_size/tuple_element are -Comment: // C++14 -Comment: // Stores a tuple of indices. Used by tuple and pair, and by bind() to -Comment: // extract the elements in a tuple. -Comment: // Builds an _Index_tuple<0, 1, 2, ..., _Num-1>. -Comment: // Clang defines __make_integer_seq for this purpose. -Comment: /// Class template integer_sequence -Comment: /// Alias template make_integer_sequence -Comment: /// Alias template index_sequence -Comment: /// Alias template make_index_sequence -Comment: /// Alias template index_sequence_for -Comment: // C++17 -Comment: // C++14 -Comment: // Need additional specializations to avoid ambiguities. -Comment: // namespace -Comment: // C++11 -Comment: /* _GLIBCXX_UTILITY_H */ -Comment: // -*- C++ -*- operator<=> three-way comparison support. -Comment: // Copyright (C) 2019-2023 Free Software Foundation, Inc. -Comment: // -Comment: // This file is part of GCC. -Comment: // -Comment: // GCC is free software; you can redistribute it and/or modify -Comment: // it under the terms of the GNU General Public License as published by -Comment: // the Free Software Foundation; either version 3, or (at your option) -Comment: // any later version. -Comment: // -Comment: // GCC is distributed in the hope that it will be useful, -Comment: // but WITHOUT ANY WARRANTY; without even the implied warranty of -Comment: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -Comment: // GNU General Public License for more details. -Comment: // -Comment: // Under Section 7 of GPL version 3, you are granted additional -Comment: // permissions described in the GCC Runtime Library Exception, version -Comment: // 3.1, as published by the Free Software Foundation. -Comment: // You should have received a copy of the GNU General Public License and -Comment: // a copy of the GCC Runtime Library Exception along with this program; -Comment: // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -Comment: // . -Comment: /** @file compare - * This is a Standard C++ Library header. - */ -Comment: // -*- C++ -*- -Comment: // Copyright (C) 2019-2023 Free Software Foundation, Inc. -Comment: // -Comment: // This file is part of the GNU ISO C++ Library. This library is free -Comment: // software; you can redistribute it and/or modify it under the -Comment: // terms of the GNU General Public License as published by the -Comment: // Free Software Foundation; either version 3, or (at your option) -Comment: // any later version. -Comment: // This library is distributed in the hope that it will be useful, -Comment: // but WITHOUT ANY WARRANTY; without even the implied warranty of -Comment: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -Comment: // GNU General Public License for more details. -Comment: // Under Section 7 of GPL version 3, you are granted additional -Comment: // permissions described in the GCC Runtime Library Exception, version -Comment: // 3.1, as published by the Free Software Foundation. -Comment: // You should have received a copy of the GNU General Public License and -Comment: // a copy of the GCC Runtime Library Exception along with this program; -Comment: // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -Comment: // . -Comment: /** @file include/concepts - * This is a Standard C++ Library header. - * @ingroup concepts - */ -Comment: /** - * @defgroup concepts Concepts - * @ingroup utilities - * - * Concepts for checking type requirements. - */ -Comment: // [concepts.lang], language-related concepts -Comment: // namespace __detail -Comment: /// [concept.same], concept same_as -Comment: /// [concept.derived], concept derived_from -Comment: /// [concept.convertible], concept convertible_to -Comment: /// [concept.commonref], concept common_reference_with -Comment: /// [concept.common], concept common_with -Comment: // [concepts.arithmetic], arithmetic concepts -Comment: // namespace __detail -Comment: /// [concept.assignable], concept assignable_from -Comment: /// [concept.destructible], concept destructible -Comment: /// [concept.constructible], concept constructible_from -Comment: /// [concept.defaultinitializable], concept default_initializable -Comment: /// [concept.moveconstructible], concept move_constructible -Comment: /// [concept.copyconstructible], concept copy_constructible -Comment: // [concept.swappable], concept swappable -Comment: // namespace __cust_swap -Comment: // inline namespace __cust -Comment: // namespace ranges -Comment: // [concepts.object], Object concepts -Comment: // [concepts.compare], comparison concepts -Comment: // [concept.booleantestable], Boolean testability -Comment: // namespace __detail -Comment: // [concept.equalitycomparable], concept equality_comparable -Comment: // namespace __detail -Comment: // namespace __detail -Comment: // [concept.totallyordered], concept totally_ordered -Comment: // [concepts.callable], callable concepts -Comment: /// [concept.invocable], concept invocable -Comment: /// [concept.regularinvocable], concept regular_invocable -Comment: /// [concept.predicate], concept predicate -Comment: /// [concept.relation], concept relation -Comment: /// [concept.equiv], concept equivalence_relation -Comment: /// [concept.strictweakorder], concept strict_weak_order -Comment: // namespace -Comment: // C++2a -Comment: /* _GLIBCXX_CONCEPTS */ -Comment: // [cmp.categories], comparison category types -Comment: // less=0xff, equiv=0x00, greater=0x01, unordered=0x02 -Comment: // valid values -Comment: // comparisons -Comment: // valid values' definitions -Comment: // valid values -Comment: // comparisons -Comment: // valid values' definitions -Comment: // valid values -Comment: // comparisons -Comment: // valid values' definitions -Comment: // named comparison functions -Comment: // If any Ti is not a comparison category type, U is void. -Comment: // Otherwise, if at least one Ti is std::partial_ordering, -Comment: // U is std::partial_ordering. -Comment: // Otherwise, if at least one Ti is std::weak_ordering, -Comment: // U is std::weak_ordering. -Comment: // Otherwise, U is std::strong_ordering. -Comment: // namespace __detail -Comment: // [cmp.common], common comparison category type -Comment: // Partial specializations for one and zero argument cases. -Comment: // namespace __detail -Comment: // [cmp.concept], concept three_way_comparable -Comment: // Implementation of std::compare_three_way_result. -Comment: // It is undefined for a program to add specializations of -Comment: // std::compare_three_way_result, so the std::compare_three_way_result_t -Comment: // alias ignores std::compare_three_way_result and uses -Comment: // __detail::__cmp3way_res_impl directly instead. -Comment: // namespace __detail -Comment: /// [cmp.result], result of three-way comparison -Comment: /// [cmp.result], result of three-way comparison -Comment: // BUILTIN-PTR-THREE-WAY(T, U) -Comment: // This determines whether t <=> u results in a call to a built-in -Comment: // operator<=> comparing pointers. It doesn't work for function pointers -Comment: // (PR 93628). -Comment: // namespace __detail -Comment: // _GLIBCXX_RESOLVE_LIB_DEFECTS -Comment: // 3530 BUILTIN-PTR-MEOW should not opt the type out of syntactic checks -Comment: // [cmp.object], typename compare_three_way -Comment: // Returns an integer with the same sign as the argument, and magnitude -Comment: // indicating the classification: zero=1 subnorm=2 norm=3 inf=4 nan=5 -Comment: // unordered, at least one argument is NaN -Comment: // return -1 for negative nan, +1 for positive nan, 0 otherwise. -Comment: // Names for the supported floating-point representations. -Comment: // IEEE -Comment: // x86 80-bit extended precision -Comment: // m68k 80-bit extended precision -Comment: // IBM 128-bit double-double -Comment: // std::bfloat16_t -Comment: // Identify the format used by a floating-point type. -Comment: // Identify these formats first, then assume anything else is IEEE. -Comment: // N.B. ARM __fp16 alternative format can be handled as binary16. -Comment: // IEEE binary16 (or ARM fp16). -Comment: // IEEE binary32 -Comment: // IEEE binary64 -Comment: // IEEE binary128 -Comment: // So we don't need to include and pollute the namespace. -Comment: // Used to unpack floating-point types that do not fit into an integer. -Comment: // Sign extend to get all ones or all zeros. -Comment: // If the sign bit was set, this flips all bits below it. -Comment: // This converts ones' complement to two's complement. -Comment: // As above but works on both parts of _Int. -Comment: // Bit-cast a floating-point value to an unsigned integer. -Comment: // All bits are equal, we're done. -Comment: // double-double -Comment: // Unpack the double-double into two parts. -Comment: // We never inspect the low double as a double, cast to integer. -Comment: // Compare the high doubles first and use result if unequal. -Comment: // For NaN the low double is unused, so if the high doubles -Comment: // are the same NaN, we don't need to compare the low doubles. -Comment: // Similarly, if the low doubles are +zero or -zero (which is -Comment: // true for all infinities and some other values), we're done. -Comment: // Otherwise, compare the low parts. -Comment: // For m68k the MSB of the significand is ignored for the -Comment: // greatest exponent, so either 0 or 1 is valid there. -Comment: // Set it before comparing, so that we never have 0 there. -Comment: // __op_eq_lt<_Tp, _Up> -Comment: // __op_eq_lt<_Tp, _Up> -Comment: // _GLIBCXX_RESOLVE_LIB_DEFECTS -Comment: // 3465. compare_partial_order_fallback requires F < E -Comment: // __op_eq_lt_lt<_Tp, _Up> -Comment: // namespace __cmp_cust -Comment: // [cmp.alg], comparison algorithms -Comment: // [expos.only.func] synth-three-way -Comment: // [expos.only.func] synth-three-way-result -Comment: // namespace __detail -Comment: // concepts -Comment: // namespace std -Comment: // C++20 -Comment: // _COMPARE -Comment: /** - * @addtogroup utilities - * @{ - */ -Comment: /// Tag type for piecewise construction of std::pair objects. -Comment: /// Tag for piecewise construction of std::pair objects. -Comment: /// @cond undocumented -Comment: // Forward declarations. -Comment: // lib concepts -Comment: // C++11 -Comment: // C++11 -Comment: /// @endcond -Comment: /** - * @brief Struct holding two objects of arbitrary type. - * - * @tparam _T1 Type of first object. - * @tparam _T2 Type of second object. - * - * - * - * @headerfile utility - */ -Comment: ///< The type of the `first` member -Comment: ///< The type of the `second` member -Comment: ///< The first member -Comment: ///< The second member -Comment: ///< Copy constructor -Comment: ///< Move constructor -Comment: /// Swap the first members and then the second members. -Comment: // C++23 -Comment: // C++20 implementation using concepts, explicit(bool), fully constexpr. -Comment: /// Default constructor -Comment: /// @cond undocumented -Comment: // True if construction from _U1 and _U2 would create a dangling ref. -Comment: /// @endcond -Comment: /// Constructor accepting lvalues of `first_type` and `second_type` -Comment: /// Constructor accepting two values of arbitrary types -Comment: /// Converting constructor from a const `pair` lvalue -Comment: /// Converting constructor from a non-const `pair` rvalue -Comment: // C++23 -Comment: /// @cond undocumented -Comment: /// @endcond -Comment: /// Copy assignment operator -Comment: /// Move assignment operator -Comment: /// Converting assignment from a const `pair` lvalue -Comment: /// Converting assignment from a non-const `pair` rvalue -Comment: // C++23 -Comment: // !__cpp_lib_concepts -Comment: // lib concepts -Comment: // C++11 -Comment: /// @relates pair @{ -Comment: /// Two pairs of the same type are equal iff their members are equal. -Comment: // !(three_way_comparison && concepts) -Comment: /** Swap overload for pairs. Calls std::pair::swap(). - * - * @note This std::swap overload is not declared in C++03 mode, - * which has performance implications, e.g. see https://gcc.gnu.org/PR38466 - */ -Comment: // c++1z or gnu++11 -Comment: // Constrained free swap overload, see p0185r1 -Comment: // C++23 -Comment: // c++1z or gnu++11 -Comment: // __cplusplus >= 201103L -Comment: /// @} relates pair -Comment: /** - * @brief A convenience wrapper for creating a pair from two objects. - * @param __x The first object. - * @param __y The second object. - * @return A newly-constructed pair<> object of the appropriate type. - * - * The C++98 standard says the objects are passed by reference-to-const, - * but C++03 says they are passed by value (this was LWG issue #181). - * - * Since C++11 they have been passed by forwarding reference and then - * forwarded to the new members of the pair. To create a pair with a - * member of reference type, pass a `reference_wrapper` to this function. - */ -Comment: // _GLIBCXX_RESOLVE_LIB_DEFECTS -Comment: // 181. make_pair() unintended behavior -Comment: // NB: DR 706. -Comment: /// @} -Comment: // Various functions which give std::pair a tuple-like interface. -Comment: /// @cond undocumented -Comment: /// @endcond -Comment: /// Partial specialization for std::pair -Comment: /// Partial specialization for std::pair -Comment: /// Partial specialization for std::pair -Comment: /// @cond undocumented -Comment: /// @endcond -Comment: /** @{ - * std::get overloads for accessing members of std::pair - */ -Comment: // C++23 -Comment: // C++14 -Comment: /// @} -Comment: // C++11 -Comment: // namespace std -Comment: /* _STL_PAIR_H */ -Comment: // Types used in iterator implementation -*- C++ -*- -Comment: // Copyright (C) 2001-2023 Free Software Foundation, Inc. -Comment: // -Comment: // This file is part of the GNU ISO C++ Library. This library is free -Comment: // software; you can redistribute it and/or modify it under the -Comment: // terms of the GNU General Public License as published by the -Comment: // Free Software Foundation; either version 3, or (at your option) -Comment: // any later version. -Comment: // This library is distributed in the hope that it will be useful, -Comment: // but WITHOUT ANY WARRANTY; without even the implied warranty of -Comment: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -Comment: // GNU General Public License for more details. -Comment: // Under Section 7 of GPL version 3, you are granted additional -Comment: // permissions described in the GCC Runtime Library Exception, version -Comment: // 3.1, as published by the Free Software Foundation. -Comment: // You should have received a copy of the GNU General Public License and -Comment: // a copy of the GCC Runtime Library Exception along with this program; -Comment: // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -Comment: // . -Comment: /* - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1996-1998 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ -Comment: /** @file bits/stl_iterator_base_types.h - * This is an internal header file, included by other library headers. - * Do not attempt to use it directly. @headername{iterator} - * - * This file contains all of the general iterator-related utility types, - * such as iterator_traits and struct iterator. - */ -Comment: // For __void_t, is_convertible -Comment: // Concepts and traits for use with iterators -*- C++ -*- -Comment: // Copyright (C) 2019-2023 Free Software Foundation, Inc. -Comment: // -Comment: // This file is part of the GNU ISO C++ Library. This library is free -Comment: // software; you can redistribute it and/or modify it under the -Comment: // terms of the GNU General Public License as published by the -Comment: // Free Software Foundation; either version 3, or (at your option) -Comment: // any later version. -Comment: // This library is distributed in the hope that it will be useful, -Comment: // but WITHOUT ANY WARRANTY; without even the implied warranty of -Comment: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -Comment: // GNU General Public License for more details. -Comment: // Under Section 7 of GPL version 3, you are granted additional -Comment: // permissions described in the GCC Runtime Library Exception, version -Comment: // 3.1, as published by the Free Software Foundation. -Comment: // You should have received a copy of the GNU General Public License and -Comment: // a copy of the GCC Runtime Library Exception along with this program; -Comment: // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -Comment: // . -Comment: /** @file bits/iterator_concepts.h - * This is an internal header file, included by other library headers. - * Do not attempt to use it directly. @headername{iterator} - */ -Comment: // to_address -Comment: // Pointer Traits -*- C++ -*- -Comment: // Copyright (C) 2011-2023 Free Software Foundation, Inc. -Comment: // -Comment: // This file is part of the GNU ISO C++ Library. This library is free -Comment: // software; you can redistribute it and/or modify it under the -Comment: // terms of the GNU General Public License as published by the -Comment: // Free Software Foundation; either version 3, or (at your option) -Comment: // any later version. -Comment: // This library is distributed in the hope that it will be useful, -Comment: // but WITHOUT ANY WARRANTY; without even the implied warranty of -Comment: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -Comment: // GNU General Public License for more details. -Comment: // Under Section 7 of GPL version 3, you are granted additional -Comment: // permissions described in the GCC Runtime Library Exception, version -Comment: // 3.1, as published by the Free Software Foundation. -Comment: // You should have received a copy of the GNU General Public License and -Comment: // a copy of the GCC Runtime Library Exception along with this program; -Comment: // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -Comment: // . -Comment: /** @file bits/ptr_traits.h - * This is an internal header file, included by other library headers. - * Do not attempt to use it directly. @headername{memory} - */ -Comment: /* Duplicate definition with unique_ptr.h. */ -Comment: /// @cond undocumented -Comment: // For a specialization `SomeTemplate` the member `type` is T, -Comment: // otherwise `type` is `__undefined`. -Comment: // For a specialization `SomeTemplate` and a type `U` the member -Comment: // `type` is `SomeTemplate`, otherwise there is no member `type`. -Comment: // Detect the element type of a pointer-like type. -Comment: // Use _Ptr::element_type if is a valid type. -Comment: /// @endcond -Comment: // Define pointer_traits

::pointer_to. -Comment: /** - * @brief Obtain a pointer to an object - * @param __r A reference to an object of type `element_type` - * @return `pointer::pointer_to(__r)` - * @pre `pointer::pointer_to(__r)` is a valid expression. - */ -Comment: // Do not define pointer_traits

::pointer_to if element type is void. -Comment: // Partial specialization defining pointer_traits::pointer_to(T&). -Comment: /** - * @brief Obtain a pointer to an object - * @param __r A reference to an object of type `element_type` - * @return `addressof(__r)` - */ -Comment: /// The pointer type. -Comment: /// The type pointed to. -Comment: /// The type used to represent the difference between two pointers. -Comment: /// A pointer to a different type. -Comment: // _GLIBCXX_RESOLVE_LIB_DEFECTS -Comment: // 3545. std::pointer_traits should be SFINAE-friendly -Comment: /** - * @brief Uniform interface to all pointer-like types - * @headerfile memory - * @ingroup pointer_abstractions - * @since C++11 - */ -Comment: /** - * @brief Partial specialization for built-in pointers. - * @headerfile memory - * @ingroup pointer_abstractions - * @since C++11 - */ -Comment: /// The pointer type -Comment: /// The type pointed to -Comment: /// Type used to represent the difference between two pointers -Comment: /// A pointer to a different type. -Comment: /// Convenience alias for rebinding pointers. -Comment: /** - * @brief Obtain address referenced by a pointer to an object - * @param __ptr A pointer to an object - * @return @c __ptr - * @ingroup pointer_abstractions - */ -Comment: /** - * @brief Obtain address referenced by a pointer to an object - * @param __ptr A pointer to an object - * @return @c pointer_traits<_Ptr>::to_address(__ptr) if that expression is - well-formed, otherwise @c to_address(__ptr.operator->()) - * @ingroup pointer_abstractions - */ -Comment: // C++2a -Comment: // namespace std -Comment: // identity, ranges::less -Comment: // Concept-constrained comparison implementations -*- C++ -*- -Comment: // Copyright (C) 2019-2023 Free Software Foundation, Inc. -Comment: // -Comment: // This file is part of the GNU ISO C++ Library. This library is free -Comment: // software; you can redistribute it and/or modify it under the -Comment: // terms of the GNU General Public License as published by the -Comment: // Free Software Foundation; either version 3, or (at your option) -Comment: // any later version. -Comment: // This library is distributed in the hope that it will be useful, -Comment: // but WITHOUT ANY WARRANTY; without even the implied warranty of -Comment: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -Comment: // GNU General Public License for more details. -Comment: // Under Section 7 of GPL version 3, you are granted additional -Comment: // permissions described in the GCC Runtime Library Exception, version -Comment: // 3.1, as published by the Free Software Foundation. -Comment: // You should have received a copy of the GNU General Public License and -Comment: // a copy of the GCC Runtime Library Exception along with this program; -Comment: // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -Comment: // . -Comment: /** @file bits/ranges_cmp.h - * This is an internal header file, included by other library headers. - * Do not attempt to use it directly. @headername{functional} - */ -Comment: // not defined -Comment: // Define std::identity here so that and -Comment: // don't need to include to get it. -Comment: /// [func.identity] The identity function. -Comment: // Define this here, included by all the headers that need to define it. -Comment: // BUILTIN-PTR-CMP(T, <, U) -Comment: // This determines whether t < u results in a call to a built-in operator< -Comment: // comparing pointers. It doesn't work for function pointers (PR 93628). -Comment: // namespace __detail -Comment: // [range.cmp] Concept-constrained comparisons -Comment: // _GLIBCXX_RESOLVE_LIB_DEFECTS -Comment: // 3530 BUILTIN-PTR-MEOW should not opt the type out of syntactic checks -Comment: /// ranges::equal_to function object type. -Comment: /// ranges::not_equal_to function object type. -Comment: /// ranges::less function object type. -Comment: /// ranges::greater function object type. -Comment: /// ranges::greater_equal function object type. -Comment: /// ranges::less_equal function object type. -Comment: // namespace ranges -Comment: // library concepts -Comment: // namespace std -Comment: // C++20 -Comment: // _RANGES_CMP_H -Comment: /** A sentinel type that can be used to check for the end of a range. - * - * For some iterator types the past-the-end sentinel value is independent - * of the underlying sequence, and a default sentinel can be used with them. - * For example, a `std::counted_iterator` keeps a count of how many elements - * remain, and so checking for the past-the-end value only requires checking - * if that count has reached zero. A past-the-end `std::istream_iterator` is - * equal to the default-constructed value, which can be easily checked. - * - * Comparing iterators of these types to `std::default_sentinel` is a - * convenient way to check if the end has been reached. - * - * @since C++20 - */ -Comment: /// A default sentinel value. -Comment: // namespace __detail -Comment: // The result type of iter_move(std::declval<_Tp>()) -Comment: // namespace __cust_imove -Comment: // inline namespace __cust -Comment: // namespace ranges -Comment: // __int128 is incrementable even if !integral<__int128> -Comment: // An iterator such that iterator_traits<_Iter> names a specialization -Comment: // generated from the primary template. -Comment: // ITER_TRAITS -Comment: // namespace __detail -Comment: // namespace __detail -Comment: // _GLIBCXX_RESOLVE_LIB_DEFECTS -Comment: // 3446. indirectly_readable_traits ambiguity for types with both [...] -Comment: // _GLIBCXX_RESOLVE_LIB_DEFECTS -Comment: // 3541. indirectly_readable_traits should be SFINAE-friendly for all types -Comment: // namespace __detail -Comment: // _GLIBCXX_RESOLVE_LIB_DEFECTS -Comment: // 3420. cpp17-iterator should check [type] looks like an iterator first -Comment: // namespace __detail -Comment: // ITER_CONCEPT(I) is ITER_TRAITS(I)::iterator_concept if that is valid. -Comment: // Otherwise, ITER_TRAITS(I)::iterator_category if that is valid. -Comment: // Otherwise, random_access_tag if iterator_traits is not specialized. -Comment: // Otherwise, there is no ITER_CONCEPT(I) type. -Comment: // ITER_CONCEPT -Comment: // namespace __detail -Comment: /// Requirements for types that are readable by applying operator*. -Comment: /// Requirements for writing a value into an iterator's referenced object. -Comment: // namespace ranges::__detail -Comment: /// Requirements on types that can be incremented with ++. -Comment: // [indirectcallable], indirect callable requirements -Comment: // [indirectcallable.indirectinvocable], indirect callables -Comment: // not defined -Comment: // not defined -Comment: // namespace __detail -Comment: /// [projected], projected -Comment: // [alg.req], common algorithm requirements -Comment: /// [alg.req.ind.move], concept `indirectly_movable` -Comment: /// [alg.req.ind.copy], concept `indirectly_copyable` -Comment: // namespace __cust_iswap -Comment: // inline namespace __cust -Comment: // namespace ranges -Comment: /// [alg.req.ind.swap], concept `indirectly_swappable` -Comment: /// [alg.req.ind.cmp], concept `indirectly_comparable` -Comment: /// [alg.req.permutable], concept `permutable` -Comment: /// [alg.req.mergeable], concept `mergeable` -Comment: /// [alg.req.sortable], concept `sortable` -Comment: // This is the namespace for [range.access] CPOs. -Comment: // Poison pills so that unqualified lookup doesn't find std::begin. -Comment: // Simplified version of std::ranges::begin that only supports lvalues, -Comment: // for use by __range_iter_t below. -Comment: // namespace ranges::__cust_access -Comment: // Implementation of std::ranges::iterator_t, without using ranges::begin. -Comment: // namespace __detail -Comment: // C++20 library concepts -Comment: // namespace std -Comment: // C++20 -Comment: // _ITERATOR_CONCEPTS_H -Comment: /** - * @defgroup iterators Iterators - * Abstractions for uniform iterating through various underlying types. - */ -Comment: ///@{ -Comment: /** - * @defgroup iterator_tags Iterator Tags - * These are empty types, used to distinguish different iterators. The - * distinction is not made by what they contain, but simply by what they - * are. Different underlying algorithms can then be used based on the - * different operations supported by different iterator types. - */ -Comment: ///@{ -Comment: /// Marking input iterators. -Comment: /// Marking output iterators. -Comment: /// Forward iterators support a superset of input iterator operations. -Comment: /// Bidirectional iterators support a superset of forward iterator -Comment: /// operations. -Comment: /// Random-access iterators support a superset of bidirectional -Comment: /// iterator operations. -Comment: /// Contiguous iterators point to objects stored contiguously in memory. -Comment: ///@} -Comment: /** - * @brief Common %iterator class. - * - * This class does nothing but define nested typedefs. %Iterator classes - * can inherit from this class to save some work. The typedefs are then - * used in specializations and overloading. - * - * In particular, there are no default implementations of requirements - * such as @c operator++ and the like. (How could there be?) - */ -Comment: /// One of the @link iterator_tags tag types@endlink. -Comment: /// The type "pointed to" by the iterator. -Comment: /// Distance between iterators is represented as this type. -Comment: /// This type represents a pointer-to-value_type. -Comment: /// This type represents a reference-to-value_type. -Comment: /** - * @brief Traits class for iterators. - * - * This class does nothing but define nested typedefs. The general - * version simply @a forwards the nested typedefs from the Iterator - * argument. Specialized versions for pointers and pointers-to-const - * provide tighter, more correct semantics. - */ -Comment: // _GLIBCXX_RESOLVE_LIB_DEFECTS -Comment: // 2408. SFINAE-friendly common_type/iterator_traits is missing in C++14 -Comment: // ! concepts -Comment: // ! C++11 -Comment: // C++11 -Comment: /// Partial specialization for object pointer types. -Comment: /** - * This function is not a part of the C++ standard but is syntactic - * sugar for internal library use only. - */ -Comment: ///@} -Comment: // namespace -Comment: /* _STL_ITERATOR_BASE_TYPES_H */ -Comment: // Functions used by iterators -*- C++ -*- -Comment: // Copyright (C) 2001-2023 Free Software Foundation, Inc. -Comment: // -Comment: // This file is part of the GNU ISO C++ Library. This library is free -Comment: // software; you can redistribute it and/or modify it under the -Comment: // terms of the GNU General Public License as published by the -Comment: // Free Software Foundation; either version 3, or (at your option) -Comment: // any later version. -Comment: // This library is distributed in the hope that it will be useful, -Comment: // but WITHOUT ANY WARRANTY; without even the implied warranty of -Comment: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -Comment: // GNU General Public License for more details. -Comment: // Under Section 7 of GPL version 3, you are granted additional -Comment: // permissions described in the GCC Runtime Library Exception, version -Comment: // 3.1, as published by the Free Software Foundation. -Comment: // You should have received a copy of the GNU General Public License and -Comment: // a copy of the GCC Runtime Library Exception along with this program; -Comment: // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -Comment: // . -Comment: /* - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1996-1998 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ -Comment: /** @file bits/stl_iterator_base_funcs.h - * This is an internal header file, included by other library headers. - * Do not attempt to use it directly. @headername{iterator} - * - * This file contains all of the general iterator-related utility - * functions, such as distance() and advance(). - */ -Comment: // Concept-checking control -*- C++ -*- -Comment: // Copyright (C) 2001-2023 Free Software Foundation, Inc. -Comment: // -Comment: // This file is part of the GNU ISO C++ Library. This library is free -Comment: // software; you can redistribute it and/or modify it under the -Comment: // terms of the GNU General Public License as published by the -Comment: // Free Software Foundation; either version 3, or (at your option) -Comment: // any later version. -Comment: // This library is distributed in the hope that it will be useful, -Comment: // but WITHOUT ANY WARRANTY; without even the implied warranty of -Comment: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -Comment: // GNU General Public License for more details. -Comment: // Under Section 7 of GPL version 3, you are granted additional -Comment: // permissions described in the GCC Runtime Library Exception, version -Comment: // 3.1, as published by the Free Software Foundation. -Comment: // You should have received a copy of the GNU General Public License and -Comment: // a copy of the GCC Runtime Library Exception along with this program; -Comment: // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -Comment: // . -Comment: /** @file bits/concept_check.h - * This is an internal header file, included by other library headers. - * Do not attempt to use it directly. @headername{iterator} - */ -Comment: // All places in libstdc++-v3 where these are used, or /might/ be used, or -Comment: // don't need to be used, or perhaps /should/ be used, are commented with -Comment: // "concept requirements" (and maybe some more text). So grep like crazy -Comment: // if you're looking for additional places to use these. -Comment: // Concept-checking code is off by default unless users turn it on via -Comment: // configure options or editing c++config.h. -Comment: // It is not supported for freestanding implementations. -Comment: // the checks are on -Comment: // enable/disable -Comment: // _GLIBCXX_CONCEPT_CHECK -Comment: // Debugging support implementation -*- C++ -*- -Comment: // Copyright (C) 2003-2023 Free Software Foundation, Inc. -Comment: // -Comment: // This file is part of the GNU ISO C++ Library. This library is free -Comment: // software; you can redistribute it and/or modify it under the -Comment: // terms of the GNU General Public License as published by the -Comment: // Free Software Foundation; either version 3, or (at your option) -Comment: // any later version. -Comment: // This library is distributed in the hope that it will be useful, -Comment: // but WITHOUT ANY WARRANTY; without even the implied warranty of -Comment: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -Comment: // GNU General Public License for more details. -Comment: // Under Section 7 of GPL version 3, you are granted additional -Comment: // permissions described in the GCC Runtime Library Exception, version -Comment: // 3.1, as published by the Free Software Foundation. -Comment: // You should have received a copy of the GNU General Public License and -Comment: // a copy of the GCC Runtime Library Exception along with this program; -Comment: // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -Comment: // . -Comment: /** @file debug/assertions.h - * This file is a GNU debug extension to the Standard C++ Library. - */ -Comment: // _GLIBCXX_DEBUG_ASSERTIONS -Comment: // Forward declaration for the overloads of __distance. -Comment: // concept requirements -Comment: // concept requirements -Comment: // Forward declaration because of the qualified call in distance. -Comment: // Give better error if std::distance called with a non-Cpp17InputIterator. -Comment: /** - * @brief A generalization of pointer arithmetic. - * @param __first An input iterator. - * @param __last An input iterator. - * @return The distance between them. - * - * Returns @c n such that __first + n == __last. This requires - * that @p __last must be reachable from @p __first. Note that @c - * n may be negative. - * - * For random access iterators, this uses their @c + and @c - operations - * and are constant time. For other %iterator classes they are linear time. - */ -Comment: // concept requirements -- taken care of in __distance -Comment: // concept requirements -Comment: // concept requirements -Comment: // concept requirements -Comment: // Give better error if std::advance called with a non-Cpp17InputIterator. -Comment: /** - * @brief A generalization of pointer arithmetic. - * @param __i An input iterator. - * @param __n The @a delta by which to change @p __i. - * @return Nothing. - * - * This increments @p i by @p n. For bidirectional and random access - * iterators, @p __n may be negative, in which case @p __i is decremented. - * - * For random access iterators, this uses their @c + and @c - operations - * and are constant time. For other %iterator classes they are linear time. - */ -Comment: // concept requirements -- taken care of in __advance -Comment: // concept requirements -Comment: // concept requirements -Comment: // C++11 -Comment: // namespace -Comment: /* _STL_ITERATOR_BASE_FUNCS_H */ -Comment: // Iterators -*- C++ -*- -Comment: // Copyright (C) 2001-2023 Free Software Foundation, Inc. -Comment: // -Comment: // This file is part of the GNU ISO C++ Library. This library is free -Comment: // software; you can redistribute it and/or modify it under the -Comment: // terms of the GNU General Public License as published by the -Comment: // Free Software Foundation; either version 3, or (at your option) -Comment: // any later version. -Comment: // This library is distributed in the hope that it will be useful, -Comment: // but WITHOUT ANY WARRANTY; without even the implied warranty of -Comment: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -Comment: // GNU General Public License for more details. -Comment: // Under Section 7 of GPL version 3, you are granted additional -Comment: // permissions described in the GCC Runtime Library Exception, version -Comment: // 3.1, as published by the Free Software Foundation. -Comment: // You should have received a copy of the GNU General Public License and -Comment: // a copy of the GCC Runtime Library Exception along with this program; -Comment: // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -Comment: // . -Comment: /* - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1996-1998 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ -Comment: /** @file bits/stl_iterator.h - * This is an internal header file, included by other library headers. - * Do not attempt to use it directly. @headername{iterator} - * - * This file implements reverse_iterator, back_insert_iterator, - * front_insert_iterator, insert_iterator, __normal_iterator, and their - * supporting functions and overloaded operators. - */ -Comment: // The -*- C++ -*- dynamic memory management header. -Comment: // Copyright (C) 1994-2023 Free Software Foundation, Inc. -Comment: // This file is part of GCC. -Comment: // -Comment: // GCC is free software; you can redistribute it and/or modify -Comment: // it under the terms of the GNU General Public License as published by -Comment: // the Free Software Foundation; either version 3, or (at your option) -Comment: // any later version. -Comment: // -Comment: // GCC is distributed in the hope that it will be useful, -Comment: // but WITHOUT ANY WARRANTY; without even the implied warranty of -Comment: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -Comment: // GNU General Public License for more details. -Comment: // -Comment: // Under Section 7 of GPL version 3, you are granted additional -Comment: // permissions described in the GCC Runtime Library Exception, version -Comment: // 3.1, as published by the Free Software Foundation. -Comment: // You should have received a copy of the GNU General Public License and -Comment: // a copy of the GCC Runtime Library Exception along with this program; -Comment: // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -Comment: // . -Comment: /** @file new - * This is a Standard C++ Library header. - * - * The header @c new defines several functions to manage dynamic memory and - * handling memory allocation errors; see - * https://gcc.gnu.org/onlinedocs/libstdc++/manual/dynamic_memory.html - * for more. - */ -Comment: // Exception Handling support header for -*- C++ -*- -Comment: // Copyright (C) 2016-2023 Free Software Foundation, Inc. -Comment: // -Comment: // This file is part of GCC. -Comment: // -Comment: // GCC is free software; you can redistribute it and/or modify -Comment: // it under the terms of the GNU General Public License as published by -Comment: // the Free Software Foundation; either version 3, or (at your option) -Comment: // any later version. -Comment: // -Comment: // GCC is distributed in the hope that it will be useful, -Comment: // but WITHOUT ANY WARRANTY; without even the implied warranty of -Comment: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -Comment: // GNU General Public License for more details. -Comment: // -Comment: // Under Section 7 of GPL version 3, you are granted additional -Comment: // permissions described in the GCC Runtime Library Exception, version -Comment: // 3.1, as published by the Free Software Foundation. -Comment: // You should have received a copy of the GNU General Public License and -Comment: // a copy of the GCC Runtime Library Exception along with this program; -Comment: // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -Comment: // . -Comment: /** @file bits/exception.h - * This is an internal header file, included by other library headers. - * Do not attempt to use it directly. - */ -Comment: /** - * @defgroup exceptions Exceptions - * @ingroup diagnostics - * @since C++98 - * - * Classes and functions for reporting errors via exceptions. - * @{ - */ -Comment: /** - * @brief Base class for all library exceptions. - * - * This is the base class for all exceptions thrown by the standard - * library, and by certain language expressions. You are free to derive - * your own %exception classes, or use a different hierarchy, or to - * throw non-class data (e.g., fundamental types). - */ -Comment: /** Returns a C-style character string describing the general cause - * of the current error. */ -Comment: /// @} -Comment: // namespace std -Comment: /** - * @brief Exception possibly thrown by @c new. - * @ingroup exceptions - * - * @c bad_alloc (or classes derived from it) is used to report allocation - * errors from the throwing forms of @c new. */ -Comment: // This declaration is not useless: -Comment: // http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118 -Comment: // See comment in eh_exception.cc. -Comment: // This declaration is not useless: -Comment: // http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118 -Comment: // See comment in eh_exception.cc. -Comment: /** If you write your own error handler to be called by @c new, it must - * be of this type. */ -Comment: /// Takes a replacement handler as the argument, returns the -Comment: /// previous handler. -Comment: /// Return the current new handler. -Comment: // namespace std -Comment: //@{ -Comment: /** These are replaceable signatures: - * - normal single new and delete (no arguments, throw @c bad_alloc on error) - * - normal array new and delete (same) - * - @c nothrow single new and delete (take a @c nothrow argument, return - * @c NULL on error) - * - @c nothrow array new and delete (same) - * - * Placement new and delete signatures (take a memory address argument, - * does nothing) may not be replaced by a user's program. -*/ -Comment: // __cpp_sized_deallocation -Comment: // __cpp_aligned_new -Comment: // Default placement versions of operator new. -Comment: // Default placement versions of operator delete. -Comment: //@} -Comment: // extern "C++" -Comment: /// Pointer optimization barrier [ptr.launder] -Comment: // The program is ill-formed if T is a function type or -Comment: // (possibly cv-qualified) void. -Comment: // _GLIBCXX_HAVE_BUILTIN_LAUNDER -Comment: // __GCC_DESTRUCTIVE_SIZE -Comment: // C++17 -Comment: /// Tag type used to declare a class-specific operator delete that can -Comment: /// invoke the destructor before deallocating the memory. -Comment: /// Tag variable of type destroying_delete_t. -Comment: // Only define the feature test macro if the compiler supports the feature: -Comment: // C++20 -Comment: // nonstandard construct and destroy functions -*- C++ -*- -Comment: // Copyright (C) 2001-2023 Free Software Foundation, Inc. -Comment: // -Comment: // This file is part of the GNU ISO C++ Library. This library is free -Comment: // software; you can redistribute it and/or modify it under the -Comment: // terms of the GNU General Public License as published by the -Comment: // Free Software Foundation; either version 3, or (at your option) -Comment: // any later version. -Comment: // This library is distributed in the hope that it will be useful, -Comment: // but WITHOUT ANY WARRANTY; without even the implied warranty of -Comment: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -Comment: // GNU General Public License for more details. -Comment: // Under Section 7 of GPL version 3, you are granted additional -Comment: // permissions described in the GCC Runtime Library Exception, version -Comment: // 3.1, as published by the Free Software Foundation. -Comment: // You should have received a copy of the GNU General Public License and -Comment: // a copy of the GCC Runtime Library Exception along with this program; -Comment: // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -Comment: // . -Comment: /* - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1996,1997 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ -Comment: /** @file bits/stl_construct.h - * This is an internal header file, included by other library headers. - * Do not attempt to use it directly. @headername{memory} - */ -Comment: // for iterator_traits -Comment: // for advance -Comment: /* This file provides the C++17 functions std::destroy_at, std::destroy, and - * std::destroy_n, and the C++20 function std::construct_at. - * It also provides std::_Construct, std::_Destroy,and std::_Destroy_n functions - * which are defined in all standard modes and so can be used in C++98-14 code. - * The _Destroy functions will dispatch to destroy_at during constant - * evaluation, because calls to that function are intercepted by the compiler - * to allow use in constant expressions. - */ -Comment: // C++20 -Comment: // C++17 -Comment: /** - * Constructs an object in existing memory by invoking an allocated - * object's constructor with an initializer. - */ -Comment: // Allow std::_Construct to be used in constant expressions. -Comment: /** - * Destroy the object pointed to by a pointer type. - */ -Comment: /** - * Destroy a range of objects. If the value_type of the object has - * a trivial destructor, the compiler should optimize all of this - * away, otherwise the objects' destructors must be invoked. - */ -Comment: // A deleted destructor is trivial, this ensures we reject such types: -Comment: /** - * Destroy a range of objects. If the value_type of the object has - * a trivial destructor, the compiler should optimize all of this - * away, otherwise the objects' destructors must be invoked. - */ -Comment: // A deleted destructor is trivial, this ensures we reject such types: -Comment: // C++17 -Comment: // namespace std -Comment: /* _STL_CONSTRUCT_H */ -Comment: /** - * @addtogroup iterators - * @{ - */ -Comment: // Weaken iterator_category _Cat to _Limit if it is derived from that, -Comment: // otherwise use _Otherwise. -Comment: // Ignore warnings about std::iterator. -Comment: // 24.4.1 Reverse iterators -Comment: /** - * Bidirectional and random access iterators have corresponding reverse - * %iterator adaptors that iterate through the data structure in the - * opposite direction. They have the same signatures as the corresponding - * iterators. The fundamental relation between a reverse %iterator and its - * corresponding %iterator @c i is established by the identity: - * @code - * &*(reverse_iterator(i)) == &*(i - 1) - * @endcode - * - * This mapping is dictated by the fact that while there is always a - * pointer past the end of an array, there might not be a valid pointer - * before the beginning of an array. [24.4.1]/1,2 - * - * Reverse iterators can be tricky and surprising at first. Their - * semantics make sense, however, and the trickiness is a side effect of - * the requirement that the iterators must be safe. - */ -Comment: // _GLIBCXX_RESOLVE_LIB_DEFECTS -Comment: // 3435. three_way_comparable_with, [...]> -Comment: /** - * The default constructor value-initializes member @p current. - * If it is a pointer, that means it is zero-initialized. - */ -Comment: // _GLIBCXX_RESOLVE_LIB_DEFECTS -Comment: // 235 No specification of default ctor for reverse_iterator -Comment: // 1012. reverse_iterator default ctor should value initialize -Comment: /** - * This %iterator will move in the opposite direction that @p x does. - */ -Comment: /** - * The copy constructor is normal. - */ -Comment: /** - * A %reverse_iterator across other types can be copied if the - * underlying %iterator can be converted to the type of @c current. - */ -Comment: /** - * @return @c current, the %iterator used for underlying work. - */ -Comment: /** - * @return A reference to the value at @c --current - * - * This requires that @c --current is dereferenceable. - * - * @warning This implementation requires that for an iterator of the - * underlying iterator type, @c x, a reference obtained by - * @c *x remains valid after @c x has been modified or - * destroyed. This is a bug: http://gcc.gnu.org/PR51823 - */ -Comment: /** - * @return A pointer to the value at @c --current - * - * This requires that @c --current is dereferenceable. - */ -Comment: // _GLIBCXX_RESOLVE_LIB_DEFECTS -Comment: // 1052. operator-> should also support smart pointers -Comment: /** - * @return @c *this - * - * Decrements the underlying iterator. - */ -Comment: /** - * @return The original value of @c *this - * - * Decrements the underlying iterator. - */ -Comment: /** - * @return @c *this - * - * Increments the underlying iterator. - */ -Comment: /** - * @return A reverse_iterator with the previous value of @c *this - * - * Increments the underlying iterator. - */ -Comment: /** - * @return A reverse_iterator that refers to @c current - @a __n - * - * The underlying iterator must be a Random Access Iterator. - */ -Comment: /** - * @return *this - * - * Moves the underlying iterator backwards @a __n steps. - * The underlying iterator must be a Random Access Iterator. - */ -Comment: /** - * @return A reverse_iterator that refers to @c current - @a __n - * - * The underlying iterator must be a Random Access Iterator. - */ -Comment: /** - * @return *this - * - * Moves the underlying iterator forwards @a __n steps. - * The underlying iterator must be a Random Access Iterator. - */ -Comment: /** - * @return The value at @c current - @a __n - 1 - * - * The underlying iterator must be a Random Access Iterator. - */ -Comment: ///@{ -Comment: /** - * @param __x A %reverse_iterator. - * @param __y A %reverse_iterator. - * @return A simple bool. - * - * Reverse iterators forward comparisons to their underlying base() - * iterators. - * - */ -Comment: // C++20 -Comment: // Additional, non-standard overloads to avoid ambiguities with greedy, -Comment: // unconstrained overloads in associated namespaces. -Comment: // C++20 -Comment: ///@} -Comment: // _GLIBCXX_RESOLVE_LIB_DEFECTS -Comment: // DR 685. reverse_iterator/move_iterator difference has invalid signatures -Comment: // Same as C++14 make_reverse_iterator but used in C++11 mode too. -Comment: // _GLIBCXX_RESOLVE_LIB_DEFECTS -Comment: // DR 2285. make_reverse_iterator -Comment: /// Generator function for reverse_iterator. -Comment: // C++20 -Comment: // C++14 -Comment: // C++11 -Comment: // 24.4.2.2.1 back_insert_iterator -Comment: /** - * @brief Turns assignment into insertion. - * - * These are output iterators, constructed from a container-of-T. - * Assigning a T to the iterator appends it to the container using - * push_back. - * - * Tip: Using the back_inserter function to create these iterators can - * save typing. - */ -Comment: /// A nested typedef for the type of whatever container you used. -Comment: /// The only way to create this %iterator is with a container. -Comment: /** - * @param __value An instance of whatever type - * container_type::const_reference is; presumably a - * reference-to-const T for container. - * @return This %iterator, for chained operations. - * - * This kind of %iterator doesn't really have a @a position in the - * container (you can think of the position as being permanently at - * the end, if you like). Assigning a value to the %iterator will - * always append the value to the end of the container. - */ -Comment: /// Simply returns *this. -Comment: /// Simply returns *this. (This %iterator does not @a move.) -Comment: /// Simply returns *this. (This %iterator does not @a move.) -Comment: /** - * @param __x A container of arbitrary type. - * @return An instance of back_insert_iterator working on @p __x. - * - * This wrapper function helps in creating back_insert_iterator instances. - * Typing the name of the %iterator requires knowing the precise full - * type of the container, which can be tedious and impedes generic - * programming. Using this function lets you take advantage of automatic - * template parameter deduction, making the compiler match the correct - * types for you. - */ -Comment: /** - * @brief Turns assignment into insertion. - * - * These are output iterators, constructed from a container-of-T. - * Assigning a T to the iterator prepends it to the container using - * push_front. - * - * Tip: Using the front_inserter function to create these iterators can - * save typing. - */ -Comment: /// A nested typedef for the type of whatever container you used. -Comment: /// The only way to create this %iterator is with a container. -Comment: /** - * @param __value An instance of whatever type - * container_type::const_reference is; presumably a - * reference-to-const T for container. - * @return This %iterator, for chained operations. - * - * This kind of %iterator doesn't really have a @a position in the - * container (you can think of the position as being permanently at - * the front, if you like). Assigning a value to the %iterator will - * always prepend the value to the front of the container. - */ -Comment: /// Simply returns *this. -Comment: /// Simply returns *this. (This %iterator does not @a move.) -Comment: /// Simply returns *this. (This %iterator does not @a move.) -Comment: /** - * @param __x A container of arbitrary type. - * @return An instance of front_insert_iterator working on @p x. - * - * This wrapper function helps in creating front_insert_iterator instances. - * Typing the name of the %iterator requires knowing the precise full - * type of the container, which can be tedious and impedes generic - * programming. Using this function lets you take advantage of automatic - * template parameter deduction, making the compiler match the correct - * types for you. - */ -Comment: /** - * @brief Turns assignment into insertion. - * - * These are output iterators, constructed from a container-of-T. - * Assigning a T to the iterator inserts it in the container at the - * %iterator's position, rather than overwriting the value at that - * position. - * - * (Sequences will actually insert a @e copy of the value before the - * %iterator's position.) - * - * Tip: Using the inserter function to create these iterators can - * save typing. - */ -Comment: /// A nested typedef for the type of whatever container you used. -Comment: /** - * The only way to create this %iterator is with a container and an - * initial position (a normal %iterator into the container). - */ -Comment: /** - * @param __value An instance of whatever type - * container_type::const_reference is; presumably a - * reference-to-const T for container. - * @return This %iterator, for chained operations. - * - * This kind of %iterator maintains its own position in the - * container. Assigning a value to the %iterator will insert the - * value into the container at the place before the %iterator. - * - * The position is maintained such that subsequent assignments will - * insert values immediately after one another. For example, - * @code - * // vector v contains A and Z - * - * insert_iterator i (v, ++v.begin()); - * i = 1; - * i = 2; - * i = 3; - * - * // vector v contains A, 1, 2, 3, and Z - * @endcode - */ -Comment: /// Simply returns *this. -Comment: /// Simply returns *this. (This %iterator does not @a move.) -Comment: /// Simply returns *this. (This %iterator does not @a move.) -Comment: /** - * @param __x A container of arbitrary type. - * @param __i An iterator into the container. - * @return An instance of insert_iterator working on @p __x. - * - * This wrapper function helps in creating insert_iterator instances. - * Typing the name of the %iterator requires knowing the precise full - * type of the container, which can be tedious and impedes generic - * programming. Using this function lets you take advantage of automatic - * template parameter deduction, making the compiler match the correct - * types for you. - */ -Comment: /// @} group iterators -Comment: // namespace -Comment: // This iterator adapter is @a normal in the sense that it does not -Comment: // change the semantics of any of the operators of its iterator -Comment: // parameter. Its primary purpose is to convert an iterator that is -Comment: // not a class, e.g. a pointer, into an iterator that is a class. -Comment: // The _Container parameter exists solely so that different containers -Comment: // using this template can instantiate different types, even if the -Comment: // _Iterator parameter is the same. -Comment: // Allow iterator to const_iterator conversion -Comment: // Forward iterator requirements -Comment: // Bidirectional iterator requirements -Comment: // Random access iterator requirements -Comment: // Note: In what follows, the left- and right-hand-side iterators are -Comment: // allowed to vary in types (conceptually in cv-qualification) so that -Comment: // comparison between cv-qualified and non-cv-qualified iterators be -Comment: // valid. However, the greedy and unfriendly operators in std::rel_ops -Comment: // will make overload resolution ambiguous (when in scope) if we don't -Comment: // provide overloads whose operands are of the same type. Can someone -Comment: // remind me what generic programming is about? -- Gaby -Comment: // three-way comparison -Comment: // _GLIBCXX_RESOLVE_LIB_DEFECTS -Comment: // According to the resolution of DR179 not only the various comparison -Comment: // operators but also operator- must accept mixed iterator/const_iterator -Comment: // parameters. -Comment: // DR 685. -Comment: // namespace -Comment: /** - * @addtogroup iterators - * @{ - */ -Comment: // C++20 -Comment: // 24.4.3 Move iterators -Comment: /** - * Class template move_iterator is an iterator adapter with the same - * behavior as the underlying iterator except that its dereference - * operator implicitly converts the value returned by the underlying - * iterator's dereference operator to an rvalue reference. Some - * generic algorithms can be called with move iterators to replace - * copying with moving. - */ -Comment: // _GLIBCXX_RESOLVE_LIB_DEFECTS -Comment: // 3435. three_way_comparable_with, [...]> -Comment: // This is P2520R0, a C++23 change, but we treat it as a DR against C++20. -Comment: // iterator_category defined in __move_iter_cat -Comment: // C++20 -Comment: // Note: See __normal_iterator operators note from Gaby to understand -Comment: // why we have these extra overloads for some move_iterator operators. -Comment: // ! C++20 -Comment: // DR 685. -Comment: // Overload for pointers that matches std::move_if_noexcept more closely, -Comment: // returning a constant iterator when we don't want to move. -Comment: // [iterators.common] Common iterators -Comment: // namespace __detail -Comment: /// An iterator/sentinel adaptor for representing a non-common range. -Comment: // Constrained special member functions -Comment: // 0 == _M_it, 1 == _M_sent, 2 == valueless -Comment: // [iterators.counted] Counted iterators -Comment: /// An iterator adaptor that keeps track of the distance to the end. -Comment: // value_type defined in __counted_iter_value_type -Comment: // iterator_concept defined in __counted_iter_concept -Comment: // iterator_category defined in __counted_iter_cat -Comment: // C++23 -Comment: // C++20 -Comment: /// @} group iterators -Comment: // C++11 -Comment: // These helper traits are used for deduction guides -Comment: // of associative containers. -Comment: // __cpp_deduction_guides -Comment: // namespace -Comment: // Debugging support implementation -*- C++ -*- -Comment: // Copyright (C) 2003-2023 Free Software Foundation, Inc. -Comment: // -Comment: // This file is part of the GNU ISO C++ Library. This library is free -Comment: // software; you can redistribute it and/or modify it under the -Comment: // terms of the GNU General Public License as published by the -Comment: // Free Software Foundation; either version 3, or (at your option) -Comment: // any later version. -Comment: // This library is distributed in the hope that it will be useful, -Comment: // but WITHOUT ANY WARRANTY; without even the implied warranty of -Comment: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -Comment: // GNU General Public License for more details. -Comment: // Under Section 7 of GPL version 3, you are granted additional -Comment: // permissions described in the GCC Runtime Library Exception, version -Comment: // 3.1, as published by the Free Software Foundation. -Comment: // You should have received a copy of the GNU General Public License and -Comment: // a copy of the GCC Runtime Library Exception along with this program; -Comment: // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -Comment: // . -Comment: /** @file debug/debug.h - * This file is a GNU debug extension to the Standard C++ Library. - */ -Comment: /** Macros and namespaces used by the implementation outside of debug - * wrappers to verify certain properties. The __glibcxx_requires_xxx - * macros are merely wrappers around the __glibcxx_check_xxx wrappers - * when we are compiling with debug mode, but disappear when we are - * in release mode so that there is no checking performed in, e.g., - * the standard library algorithms. -*/ -Comment: // Debug mode namespaces. -Comment: /** - * @namespace std::__debug - * @brief GNU debug code, replaces standard behavior with debug behavior. - */ -Comment: /** @namespace __gnu_debug - * @brief GNU debug classes for public use. -*/ -Comment: // _GLIBCXX_DEBUG_MACRO_SWITCH_H -Comment: // For std::swap -Comment: // Default predicates for internal use -*- C++ -*- -Comment: // Copyright (C) 2013-2023 Free Software Foundation, Inc. -Comment: // -Comment: // This file is part of the GNU ISO C++ Library. This library is free -Comment: // software; you can redistribute it and/or modify it under the -Comment: // terms of the GNU General Public License as published by the -Comment: // Free Software Foundation; either version 3, or (at your option) -Comment: // any later version. -Comment: // This library is distributed in the hope that it will be useful, -Comment: // but WITHOUT ANY WARRANTY; without even the implied warranty of -Comment: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -Comment: // GNU General Public License for more details. -Comment: // Under Section 7 of GPL version 3, you are granted additional -Comment: // permissions described in the GCC Runtime Library Exception, version -Comment: // 3.1, as published by the Free Software Foundation. -Comment: // You should have received a copy of the GNU General Public License and -Comment: // a copy of the GCC Runtime Library Exception along with this program; -Comment: // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -Comment: // . -Comment: /** @file predefined_ops.h - * This is an internal header file, included by other library headers. - * You should not attempt to use it directly. @headername{algorithm} - */ -Comment: // namespace __ops -Comment: // namespace __gnu_cxx -Comment: // std::__bit_width -Comment: // -*- C++ -*- -Comment: // Copyright (C) 2018-2023 Free Software Foundation, Inc. -Comment: // -Comment: // This file is part of the GNU ISO C++ Library. This library is free -Comment: // software; you can redistribute it and/or modify it under the -Comment: // terms of the GNU General Public License as published by the -Comment: // Free Software Foundation; either version 3, or (at your option) -Comment: // any later version. -Comment: // This library is distributed in the hope that it will be useful, -Comment: // but WITHOUT ANY WARRANTY; without even the implied warranty of -Comment: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -Comment: // GNU General Public License for more details. -Comment: // Under Section 7 of GPL version 3, you are granted additional -Comment: // permissions described in the GCC Runtime Library Exception, version -Comment: // 3.1, as published by the Free Software Foundation. -Comment: // You should have received a copy of the GNU General Public License and -Comment: // a copy of the GCC Runtime Library Exception along with this program; -Comment: // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -Comment: // . -Comment: /** @file include/bit - * This is a Standard C++ Library header. - */ -Comment: /** - * @defgroup bit_manip Bit manipulation - * @ingroup numerics - * - * Utilities for examining and manipulating individual bits. - * - * @{ - */ -Comment: /// Create a value of type `To` from the bits of `from`. -Comment: /** - * @tparam _To A trivially-copyable type. - * @param __from A trivially-copyable object of the same size as `_To`. - * @return An object of type `_To`. - * @since C++20 - */ -Comment: /// @cond undocumented -Comment: // Variant for power of two _Nd which the compiler can -Comment: // easily pattern match. -Comment: // rotr(x, -r) -Comment: // Variant for power of two _Nd which the compiler can -Comment: // easily pattern match. -Comment: // rotl(x, -r) -Comment: // (_Nd > _Nd_ull) -Comment: // (_Nd > _Nd_ull) -Comment: // (_Nd > _Nd_ull) -Comment: // If the shift exponent equals _Nd then the correct result is not -Comment: // representable as a value of _Tp, and so the result is undefined. -Comment: // Want that undefined behaviour to be detected in constant expressions, -Comment: // by UBSan, and by debug assertions. -Comment: // If __x undergoes integral promotion then shifting by _Nd is -Comment: // not undefined. In order to make the shift undefined, so that -Comment: // it is diagnosed in constant expressions and by UBsan, we also -Comment: // need to "promote" the shift exponent to be too large for the -Comment: // promoted type. -Comment: /// @endcond -Comment: /// @cond undocumented -Comment: /// @endcond -Comment: // [bit.rot], rotating -Comment: /// Rotate `x` to the left by `s` bits. -Comment: /// Rotate `x` to the right by `s` bits. -Comment: // [bit.count], counting -Comment: /// The number of contiguous zero bits, starting from the highest bit. -Comment: /// The number of contiguous one bits, starting from the highest bit. -Comment: /// The number of contiguous zero bits, starting from the lowest bit. -Comment: /// The number of contiguous one bits, starting from the lowest bit. -Comment: /// The number of bits set in `x`. -Comment: // [bit.pow.two], integral powers of 2 -Comment: /// True if `x` is a power of two, false otherwise. -Comment: /// The smallest power-of-two not less than `x`. -Comment: /// The largest power-of-two not greater than `x`. -Comment: // _GLIBCXX_RESOLVE_LIB_DEFECTS -Comment: // 3656. Inconsistent bit operations returning a count -Comment: /// The smallest integer greater than the base-2 logarithm of `x`. -Comment: /// Byte order constants -Comment: /** - * The platform endianness can be checked by comparing `std::endian::native` - * to one of `std::endian::big` or `std::endian::little`. - * - * @since C++20 - */ -Comment: // C++2a -Comment: /// @} -Comment: // namespace std -Comment: // C++14 -Comment: // _GLIBCXX_BIT -Comment: /* - * A constexpr wrapper for __builtin_memcmp. - * @param __num The number of elements of type _Tp (not bytes). - */ -Comment: // C++03 -Comment: /** - * @brief Swaps the contents of two iterators. - * @ingroup mutating_algorithms - * @param __a An iterator. - * @param __b Another iterator. - * @return Nothing. - * - * This function swaps the values pointed to by two iterators, not the - * iterators themselves. - */ -Comment: // concept requirements -Comment: // _GLIBCXX_RESOLVE_LIB_DEFECTS -Comment: // 187. iter_swap underspecified -Comment: /** - * @brief Swap the elements of two sequences. - * @ingroup mutating_algorithms - * @param __first1 A forward iterator. - * @param __last1 A forward iterator. - * @param __first2 A forward iterator. - * @return An iterator equal to @p first2+(last1-first1). - * - * Swaps each element in the range @p [first1,last1) with the - * corresponding element in the range @p [first2,(last1-first1)). - * The ranges must not overlap. - */ -Comment: // concept requirements -Comment: /** - * @brief This does what you think it does. - * @ingroup sorting_algorithms - * @param __a A thing of arbitrary type. - * @param __b Another thing of arbitrary type. - * @return The lesser of the parameters. - * - * This is the simple classic generic implementation. It will work on - * temporary expressions, since they are only evaluated once, unlike a - * preprocessor macro. - */ -Comment: // concept requirements -Comment: //return __b < __a ? __b : __a; -Comment: /** - * @brief This does what you think it does. - * @ingroup sorting_algorithms - * @param __a A thing of arbitrary type. - * @param __b Another thing of arbitrary type. - * @return The greater of the parameters. - * - * This is the simple classic generic implementation. It will work on - * temporary expressions, since they are only evaluated once, unlike a - * preprocessor macro. - */ -Comment: // concept requirements -Comment: //return __a < __b ? __b : __a; -Comment: /** - * @brief This does what you think it does. - * @ingroup sorting_algorithms - * @param __a A thing of arbitrary type. - * @param __b Another thing of arbitrary type. - * @param __comp A @link comparison_functors comparison functor@endlink. - * @return The lesser of the parameters. - * - * This will work on temporary expressions, since they are only evaluated - * once, unlike a preprocessor macro. - */ -Comment: //return __comp(__b, __a) ? __b : __a; -Comment: /** - * @brief This does what you think it does. - * @ingroup sorting_algorithms - * @param __a A thing of arbitrary type. - * @param __b Another thing of arbitrary type. - * @param __comp A @link comparison_functors comparison functor@endlink. - * @return The greater of the parameters. - * - * This will work on temporary expressions, since they are only evaluated - * once, unlike a preprocessor macro. - */ -Comment: //return __comp(__a, __b) ? __b : __a; -Comment: // Fallback implementation of the function in bits/stl_iterator.h used to -Comment: // remove the __normal_iterator wrapper. See copy, fill, ... -Comment: // Reverse the __niter_base transformation to get a -Comment: // __normal_iterator back again (this assumes that __normal_iterator -Comment: // is only used to wrap random access iterators, like pointers). -Comment: // No need to wrap, iterator already has the right type. -Comment: // All of these auxiliary structs serve two purposes. (1) Replace -Comment: // calls to copy with memmove whenever possible. (Memmove, not memcpy, -Comment: // because the input and output ranges are permitted to overlap.) -Comment: // (2) If we're using random access iterators, then write the loop as -Comment: // a for loop with an explicit count. -Comment: // Helpers for streambuf iterators (either istream or ostream). -Comment: // NB: avoid including , relatively large. -Comment: // HOSTED -Comment: /** - * @brief Copies the range [first,last) into result. - * @ingroup mutating_algorithms - * @param __first An input iterator. - * @param __last An input iterator. - * @param __result An output iterator. - * @return result + (last - first) - * - * This inline function will boil down to a call to @c memmove whenever - * possible. Failing that, if random access iterators are passed, then the - * loop count will be known (and therefore a candidate for compiler - * optimizations such as unrolling). Result may not be contained within - * [first,last); the copy_backward function should be used instead. - * - * Note that the end of the output range is permitted to be contained - * within [first,last). - */ -Comment: // concept requirements -Comment: /** - * @brief Moves the range [first,last) into result. - * @ingroup mutating_algorithms - * @param __first An input iterator. - * @param __last An input iterator. - * @param __result An output iterator. - * @return result + (last - first) - * - * This inline function will boil down to a call to @c memmove whenever - * possible. Failing that, if random access iterators are passed, then the - * loop count will be known (and therefore a candidate for compiler - * optimizations such as unrolling). Result may not be contained within - * [first,last); the move_backward function should be used instead. - * - * Note that the end of the output range is permitted to be contained - * within [first,last). - */ -Comment: // concept requirements -Comment: /** - * @brief Copies the range [first,last) into result. - * @ingroup mutating_algorithms - * @param __first A bidirectional iterator. - * @param __last A bidirectional iterator. - * @param __result A bidirectional iterator. - * @return result - (last - first) - * - * The function has the same effect as copy, but starts at the end of the - * range and works its way to the start, returning the start of the result. - * This inline function will boil down to a call to @c memmove whenever - * possible. Failing that, if random access iterators are passed, then the - * loop count will be known (and therefore a candidate for compiler - * optimizations such as unrolling). - * - * Result may not be in the range (first,last]. Use copy instead. Note - * that the start of the output range may overlap [first,last). - */ -Comment: // concept requirements -Comment: /** - * @brief Moves the range [first,last) into result. - * @ingroup mutating_algorithms - * @param __first A bidirectional iterator. - * @param __last A bidirectional iterator. - * @param __result A bidirectional iterator. - * @return result - (last - first) - * - * The function has the same effect as move, but starts at the end of the - * range and works its way to the start, returning the start of the result. - * This inline function will boil down to a call to @c memmove whenever - * possible. Failing that, if random access iterators are passed, then the - * loop count will be known (and therefore a candidate for compiler - * optimizations such as unrolling). - * - * Result may not be in the range (first,last]. Use move instead. Note - * that the start of the output range may overlap [first,last). - */ -Comment: // concept requirements -Comment: // Specialization: for char types we can use memset. -Comment: /** - * @brief Fills the range [first,last) with copies of value. - * @ingroup mutating_algorithms - * @param __first A forward iterator. - * @param __last A forward iterator. - * @param __value A reference-to-const of arbitrary type. - * @return Nothing. - * - * This function fills a range with copies of the same value. For char - * types filling contiguous areas of memory, this becomes an inline call - * to @c memset or @c wmemset. - */ -Comment: // concept requirements -Comment: // Used by fill_n, generate_n, etc. to convert _Size to an integral type: -Comment: /** - * @brief Fills the range [first,first+n) with copies of value. - * @ingroup mutating_algorithms - * @param __first An output iterator. - * @param __n The count of copies to perform. - * @param __value A reference-to-const of arbitrary type. - * @return The iterator at first+n. - * - * This function fills a range with copies of the same value. For char - * types filling contiguous areas of memory, this becomes an inline call - * to @c memset or @c wmemset. - * - * If @p __n is negative, the function does nothing. - */ -Comment: // _GLIBCXX_RESOLVE_LIB_DEFECTS -Comment: // DR 865. More algorithms that throw away information -Comment: // DR 426. search_n(), fill_n(), and generate_n() with negative n -Comment: // concept requirements -Comment: // For C++20 iterator_traits::value_type is non-volatile -Comment: // so __is_byte could be true, but we can't use memcmp with -Comment: // volatile data. -Comment: /** - * @brief Finds the first position in which @a val could be inserted - * without changing the ordering. - * @param __first An iterator. - * @param __last Another iterator. - * @param __val The search term. - * @return An iterator pointing to the first element not less - * than @a val, or end() if every element is less than - * @a val. - * @ingroup binary_search_algorithms - */ -Comment: // concept requirements -Comment: /// This is a helper function for the sort routines and for random.tcc. -Comment: // Precondition: __n > 0. -Comment: /** - * @brief Tests a range for element-wise equality. - * @ingroup non_mutating_algorithms - * @param __first1 An input iterator. - * @param __last1 An input iterator. - * @param __first2 An input iterator. - * @return A boolean true or false. - * - * This compares the elements of two ranges using @c == and returns true or - * false depending on whether all of the corresponding elements of the - * ranges are equal. - */ -Comment: // concept requirements -Comment: /** - * @brief Tests a range for element-wise equality. - * @ingroup non_mutating_algorithms - * @param __first1 An input iterator. - * @param __last1 An input iterator. - * @param __first2 An input iterator. - * @param __binary_pred A binary predicate @link functors - * functor@endlink. - * @return A boolean true or false. - * - * This compares the elements of two ranges using the binary_pred - * parameter, and returns true or - * false depending on whether all of the corresponding elements of the - * ranges are equal. - */ -Comment: // concept requirements -Comment: // 4-iterator version of std::equal for use in C++11. -Comment: // 4-iterator version of std::equal for use in C++11. -Comment: // C++11 -Comment: /** - * @brief Tests a range for element-wise equality. - * @ingroup non_mutating_algorithms - * @param __first1 An input iterator. - * @param __last1 An input iterator. - * @param __first2 An input iterator. - * @param __last2 An input iterator. - * @return A boolean true or false. - * - * This compares the elements of two ranges using @c == and returns true or - * false depending on whether all of the corresponding elements of the - * ranges are equal. - */ -Comment: // concept requirements -Comment: /** - * @brief Tests a range for element-wise equality. - * @ingroup non_mutating_algorithms - * @param __first1 An input iterator. - * @param __last1 An input iterator. - * @param __first2 An input iterator. - * @param __last2 An input iterator. - * @param __binary_pred A binary predicate @link functors - * functor@endlink. - * @return A boolean true or false. - * - * This compares the elements of two ranges using the binary_pred - * parameter, and returns true or - * false depending on whether all of the corresponding elements of the - * ranges are equal. - */ -Comment: // concept requirements -Comment: // C++14 -Comment: /** - * @brief Performs @b dictionary comparison on ranges. - * @ingroup sorting_algorithms - * @param __first1 An input iterator. - * @param __last1 An input iterator. - * @param __first2 An input iterator. - * @param __last2 An input iterator. - * @return A boolean true or false. - * - * Returns true if the sequence of elements defined by the range - * [first1,last1) is lexicographically less than the sequence of elements - * defined by the range [first2,last2). Returns false otherwise. - * (Quoted from [25.3.8]/1.) If the iterators are all character pointers, - * then this is an inline call to @c memcmp. - */ -Comment: /** - * @brief Performs @b dictionary comparison on ranges. - * @ingroup sorting_algorithms - * @param __first1 An input iterator. - * @param __last1 An input iterator. - * @param __first2 An input iterator. - * @param __last2 An input iterator. - * @param __comp A @link comparison_functors comparison functor@endlink. - * @return A boolean true or false. - * - * The same as the four-parameter @c lexicographical_compare, but uses the - * comp parameter instead of @c <. - */ -Comment: // concept requirements -Comment: // Both iterators refer to contiguous ranges of unsigned narrow characters, -Comment: // or std::byte, or big-endian unsigned integers, suitable for comparison -Comment: // using memcmp. -Comment: // Return a struct with two members, initialized to the smaller of x and y -Comment: // (or x if they compare equal) and the result of the comparison x <=> y. -Comment: /** - * @brief Performs dictionary comparison on ranges. - * @ingroup sorting_algorithms - * @param __first1 An input iterator. - * @param __last1 An input iterator. - * @param __first2 An input iterator. - * @param __last2 An input iterator. - * @param __comp A @link comparison_functors comparison functor@endlink. - * @return The comparison category that `__comp(*__first1, *__first2)` - * returns. - */ -Comment: // concept requirements -Comment: // See PR 94006 -Comment: // three_way_comparison -Comment: /** - * @brief Finds the places in ranges which don't match. - * @ingroup non_mutating_algorithms - * @param __first1 An input iterator. - * @param __last1 An input iterator. - * @param __first2 An input iterator. - * @return A pair of iterators pointing to the first mismatch. - * - * This compares the elements of two ranges using @c == and returns a pair - * of iterators. The first iterator points into the first range, the - * second iterator points into the second range, and the elements pointed - * to by the iterators are not equal. - */ -Comment: // concept requirements -Comment: /** - * @brief Finds the places in ranges which don't match. - * @ingroup non_mutating_algorithms - * @param __first1 An input iterator. - * @param __last1 An input iterator. - * @param __first2 An input iterator. - * @param __binary_pred A binary predicate @link functors - * functor@endlink. - * @return A pair of iterators pointing to the first mismatch. - * - * This compares the elements of two ranges using the binary_pred - * parameter, and returns a pair - * of iterators. The first iterator points into the first range, the - * second iterator points into the second range, and the elements pointed - * to by the iterators are not equal. - */ -Comment: // concept requirements -Comment: /** - * @brief Finds the places in ranges which don't match. - * @ingroup non_mutating_algorithms - * @param __first1 An input iterator. - * @param __last1 An input iterator. - * @param __first2 An input iterator. - * @param __last2 An input iterator. - * @return A pair of iterators pointing to the first mismatch. - * - * This compares the elements of two ranges using @c == and returns a pair - * of iterators. The first iterator points into the first range, the - * second iterator points into the second range, and the elements pointed - * to by the iterators are not equal. - */ -Comment: // concept requirements -Comment: /** - * @brief Finds the places in ranges which don't match. - * @ingroup non_mutating_algorithms - * @param __first1 An input iterator. - * @param __last1 An input iterator. - * @param __first2 An input iterator. - * @param __last2 An input iterator. - * @param __binary_pred A binary predicate @link functors - * functor@endlink. - * @return A pair of iterators pointing to the first mismatch. - * - * This compares the elements of two ranges using the binary_pred - * parameter, and returns a pair - * of iterators. The first iterator points into the first range, the - * second iterator points into the second range, and the elements pointed - * to by the iterators are not equal. - */ -Comment: // concept requirements -Comment: /// This is an overload used by find algos for the Input Iterator case. -Comment: /// This is an overload used by find algos for the RAI case. -Comment: // FALLTHRU -Comment: // FALLTHRU -Comment: // FALLTHRU -Comment: // Efficiently compare identical prefixes: O(N) if sequences -Comment: // have the same elements in the same order. -Comment: // Establish __last2 assuming equal ranges by iterating over the -Comment: // rest of the list. -Comment: // We've seen this one before. -Comment: /** - * @brief Checks whether a permutation of the second sequence is equal - * to the first sequence. - * @ingroup non_mutating_algorithms - * @param __first1 Start of first range. - * @param __last1 End of first range. - * @param __first2 Start of second range. - * @return true if there exists a permutation of the elements in the range - * [__first2, __first2 + (__last1 - __first1)), beginning with - * ForwardIterator2 begin, such that equal(__first1, __last1, begin) - * returns true; otherwise, returns false. - */ -Comment: // concept requirements -Comment: // C++11 -Comment: // namespace std -Comment: // NB: This file is included within many other C++ includes, as a way -Comment: // of getting the base algorithms. So, make sure that parallel bits -Comment: // come in too if requested. -Comment: // Allocators -*- C++ -*- -Comment: // Copyright (C) 2001-2023 Free Software Foundation, Inc. -Comment: // -Comment: // This file is part of the GNU ISO C++ Library. This library is free -Comment: // software; you can redistribute it and/or modify it under the -Comment: // terms of the GNU General Public License as published by the -Comment: // Free Software Foundation; either version 3, or (at your option) -Comment: // any later version. -Comment: // This library is distributed in the hope that it will be useful, -Comment: // but WITHOUT ANY WARRANTY; without even the implied warranty of -Comment: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -Comment: // GNU General Public License for more details. -Comment: // Under Section 7 of GPL version 3, you are granted additional -Comment: // permissions described in the GCC Runtime Library Exception, version -Comment: // 3.1, as published by the Free Software Foundation. -Comment: // You should have received a copy of the GNU General Public License and -Comment: // a copy of the GCC Runtime Library Exception along with this program; -Comment: // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -Comment: // . -Comment: /* - * Copyright (c) 1996-1997 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ -Comment: /** @file bits/allocator.h - * This is an internal header file, included by other library headers. - * Do not attempt to use it directly. @headername{memory} - */ -Comment: // Define the base class to std::allocator. -Comment: // Base to std::allocator -*- C++ -*- -Comment: // Copyright (C) 2004-2023 Free Software Foundation, Inc. -Comment: // -Comment: // This file is part of the GNU ISO C++ Library. This library is free -Comment: // software; you can redistribute it and/or modify it under the -Comment: // terms of the GNU General Public License as published by the -Comment: // Free Software Foundation; either version 3, or (at your option) -Comment: // any later version. -Comment: // This library is distributed in the hope that it will be useful, -Comment: // but WITHOUT ANY WARRANTY; without even the implied warranty of -Comment: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -Comment: // GNU General Public License for more details. -Comment: // Under Section 7 of GPL version 3, you are granted additional -Comment: // permissions described in the GCC Runtime Library Exception, version -Comment: // 3.1, as published by the Free Software Foundation. -Comment: // You should have received a copy of the GNU General Public License and -Comment: // a copy of the GCC Runtime Library Exception along with this program; -Comment: // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -Comment: // . -Comment: /** @file bits/c++allocator.h - * This is an internal header file, included by other library headers. - * Do not attempt to use it directly. @headername{memory} - */ -Comment: // Allocator that wraps operator new -*- C++ -*- -Comment: // Copyright (C) 2001-2023 Free Software Foundation, Inc. -Comment: // -Comment: // This file is part of the GNU ISO C++ Library. This library is free -Comment: // software; you can redistribute it and/or modify it under the -Comment: // terms of the GNU General Public License as published by the -Comment: // Free Software Foundation; either version 3, or (at your option) -Comment: // any later version. -Comment: // This library is distributed in the hope that it will be useful, -Comment: // but WITHOUT ANY WARRANTY; without even the implied warranty of -Comment: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -Comment: // GNU General Public License for more details. -Comment: // Under Section 7 of GPL version 3, you are granted additional -Comment: // permissions described in the GCC Runtime Library Exception, version -Comment: // 3.1, as published by the Free Software Foundation. -Comment: // You should have received a copy of the GNU General Public License and -Comment: // a copy of the GCC Runtime Library Exception along with this program; -Comment: // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -Comment: // . -Comment: /** @file bits/new_allocator.h - * This is an internal header file, included by other library headers. - * Do not attempt to use it directly. @headername{memory} - */ -Comment: /** - * @brief An allocator that uses global `new`, as per C++03 [20.4.1]. - * @ingroup allocators - * - * This is precisely the allocator defined in the C++ Standard. - * - all allocation calls `operator new` - * - all deallocation calls `operator delete` - * - * This is the default base-class implementation of `std::allocator`, - * and is also the base-class of the `__gnu_cxx::new_allocator` extension. - * You should use either `std::allocator` or `__gnu_cxx::new_allocator` - * instead of using this directly. - * - * @tparam _Tp Type of allocated object. - * - * @headerfile memory - */ -Comment: // _GLIBCXX_RESOLVE_LIB_DEFECTS -Comment: // 2103. propagate_on_container_move_assignment -Comment: // NB: __n is permitted to be 0. The C++ standard says nothing -Comment: // about what the return value is when __n == 0. -Comment: // _GLIBCXX_RESOLVE_LIB_DEFECTS -Comment: // 3308. std::allocator().allocate(n) -Comment: // _GLIBCXX_RESOLVE_LIB_DEFECTS -Comment: // 3190. allocator::allocate sometimes returns too little storage -Comment: // __p is not permitted to be a null pointer. -Comment: // ! C++20 -Comment: // namespace -Comment: /** - * @brief An alias to the base class for std::allocator. - * - * Used to set the std::allocator base class to std::__new_allocator. - * - * @ingroup allocators - * @tparam _Tp Type of allocated object. - */ -Comment: // Forward declarations -*- C++ -*- -Comment: // Copyright (C) 2001-2023 Free Software Foundation, Inc. -Comment: // -Comment: // This file is part of the GNU ISO C++ Library. This library is free -Comment: // software; you can redistribute it and/or modify it under the -Comment: // terms of the GNU General Public License as published by the -Comment: // Free Software Foundation; either version 3, or (at your option) -Comment: // any later version. -Comment: // This library is distributed in the hope that it will be useful, -Comment: // but WITHOUT ANY WARRANTY; without even the implied warranty of -Comment: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -Comment: // GNU General Public License for more details. -Comment: // Under Section 7 of GPL version 3, you are granted additional -Comment: // permissions described in the GCC Runtime Library Exception, version -Comment: // 3.1, as published by the Free Software Foundation. -Comment: // You should have received a copy of the GNU General Public License and -Comment: // a copy of the GCC Runtime Library Exception along with this program; -Comment: // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -Comment: // . -Comment: /* - * Copyright (c) 1996-1997 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ -Comment: /** @file bits/memoryfwd.h - * This is an internal header file, included by other library headers. - * Do not attempt to use it directly. @headername{memory} - */ -Comment: /** - * @defgroup allocators Allocators - * @ingroup memory - * - * Classes encapsulating memory operations. - * - * @{ - */ -Comment: /// Declare uses_allocator so it can be specialized in `` etc. -Comment: /// @} group memory -Comment: // namespace std -Comment: /** - * @addtogroup allocators - * @{ - */ -Comment: // Since C++20 the primary template should be used for allocator, -Comment: // but then it would have a non-trivial default ctor and dtor for C++20, -Comment: // but trivial for C++98-17, which would be an ABI incompatibility between -Comment: // different standard dialects. So C++20 still uses the allocator -Comment: // explicit specialization, with the historical ABI properties, but with -Comment: // the same members that are present in the primary template. -Comment: /** std::allocator specialization. - * - * @headerfile memory - */ -Comment: // _GLIBCXX_RESOLVE_LIB_DEFECTS -Comment: // 2103. std::allocator propagate_on_container_move_assignment -Comment: // As noted above, these members are present for C++20 to provide the -Comment: // same API as the primary template, but still trivial as in pre-C++20. -Comment: // No allocate member because it's ill-formed by LWG 3307. -Comment: // No deallocate member because it would be undefined to call it -Comment: // with any pointer which wasn't obtained from allocate. -Comment: // C++20 -Comment: // C++11 -Comment: /** - * @brief The @a standard allocator, as per C++03 [20.4.1]. - * - * See https://gcc.gnu.org/onlinedocs/libstdc++/manual/memory.html#std.util.memory.allocator - * for further details. - * - * @tparam _Tp Type of allocated object. - * - * @headerfile memory - */ -Comment: // _GLIBCXX_RESOLVE_LIB_DEFECTS -Comment: // 2103. std::allocator propagate_on_container_move_assignment -Comment: // _GLIBCXX_RESOLVE_LIB_DEFECTS -Comment: // 3035. std::allocator's constructors should be constexpr -Comment: // Avoid implicit deprecation. -Comment: // C++20 -Comment: // Inherit everything else. -Comment: /** Equality comparison for std::allocator objects - * - * @return true, for all std::allocator objects. - * @relates std::allocator - */ -Comment: /// @cond undocumented -Comment: // Invalid allocator partial specializations. -Comment: // allocator_traits::rebind_alloc can be used to form a valid allocator type. -Comment: /// @endcond -Comment: /// @} group allocator -Comment: // Inhibit implicit instantiations for required instantiations, -Comment: // which are defined via explicit instantiations elsewhere. -Comment: // Undefine. -Comment: // namespace std -Comment: // Raw memory manipulators -*- C++ -*- -Comment: // Copyright (C) 2001-2023 Free Software Foundation, Inc. -Comment: // -Comment: // This file is part of the GNU ISO C++ Library. This library is free -Comment: // software; you can redistribute it and/or modify it under the -Comment: // terms of the GNU General Public License as published by the -Comment: // Free Software Foundation; either version 3, or (at your option) -Comment: // any later version. -Comment: // This library is distributed in the hope that it will be useful, -Comment: // but WITHOUT ANY WARRANTY; without even the implied warranty of -Comment: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -Comment: // GNU General Public License for more details. -Comment: // Under Section 7 of GPL version 3, you are granted additional -Comment: // permissions described in the GCC Runtime Library Exception, version -Comment: // 3.1, as published by the Free Software Foundation. -Comment: // You should have received a copy of the GNU General Public License and -Comment: // a copy of the GCC Runtime Library Exception along with this program; -Comment: // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -Comment: // . -Comment: /* - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1996,1997 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ -Comment: /** @file bits/stl_uninitialized.h - * This is an internal header file, included by other library headers. - * Do not attempt to use it directly. @headername{memory} - */ -Comment: // copy -Comment: // __alloc_traits -Comment: // Allocator traits -*- C++ -*- -Comment: // Copyright (C) 2011-2023 Free Software Foundation, Inc. -Comment: // -Comment: // This file is part of the GNU ISO C++ Library. This library is free -Comment: // software; you can redistribute it and/or modify it under the -Comment: // terms of the GNU General Public License as published by the -Comment: // Free Software Foundation; either version 3, or (at your option) -Comment: // any later version. -Comment: // This library is distributed in the hope that it will be useful, -Comment: // but WITHOUT ANY WARRANTY; without even the implied warranty of -Comment: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -Comment: // GNU General Public License for more details. -Comment: // Under Section 7 of GPL version 3, you are granted additional -Comment: // permissions described in the GCC Runtime Library Exception, version -Comment: // 3.1, as published by the Free Software Foundation. -Comment: // You should have received a copy of the GNU General Public License and -Comment: // a copy of the GCC Runtime Library Exception along with this program; -Comment: // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -Comment: // . -Comment: /** @file ext/alloc_traits.h - * This file is a GNU extension to the Standard C++ Library. - */ -Comment: // Allocator traits -*- C++ -*- -Comment: // Copyright (C) 2011-2023 Free Software Foundation, Inc. -Comment: // -Comment: // This file is part of the GNU ISO C++ Library. This library is free -Comment: // software; you can redistribute it and/or modify it under the -Comment: // terms of the GNU General Public License as published by the -Comment: // Free Software Foundation; either version 3, or (at your option) -Comment: // any later version. -Comment: // This library is distributed in the hope that it will be useful, -Comment: // but WITHOUT ANY WARRANTY; without even the implied warranty of -Comment: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -Comment: // GNU General Public License for more details. -Comment: // Under Section 7 of GPL version 3, you are granted additional -Comment: // permissions described in the GCC Runtime Library Exception, version -Comment: // 3.1, as published by the Free Software Foundation. -Comment: // You should have received a copy of the GNU General Public License and -Comment: // a copy of the GCC Runtime Library Exception along with this program; -Comment: // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -Comment: // . -Comment: /** @file bits/alloc_traits.h - * This is an internal header file, included by other library headers. - * Do not attempt to use it directly. @headername{memory} - */ -Comment: /// @cond undocumented -Comment: /// @endcond -Comment: /** - * @brief Uniform interface to all allocator types. - * @headerfile memory - * @ingroup allocators - * @since C++11 - */ -Comment: /// The allocator type -Comment: /// The allocated type -Comment: /** - * @brief The allocator's pointer type. - * - * @c Alloc::pointer if that type exists, otherwise @c value_type* - */ -Comment: // Select _Func<_Alloc> or pointer_traits::rebind<_Tp> -Comment: // Select _A2::difference_type or pointer_traits<_Ptr>::difference_type -Comment: // Select _A2::size_type or make_unsigned<_DiffT>::type -Comment: /** - * @brief The allocator's const pointer type. - * - * @c Alloc::const_pointer if that type exists, otherwise - * pointer_traits::rebind - */ -Comment: /** - * @brief The allocator's void pointer type. - * - * @c Alloc::void_pointer if that type exists, otherwise - * pointer_traits::rebind - */ -Comment: /** - * @brief The allocator's const void pointer type. - * - * @c Alloc::const_void_pointer if that type exists, otherwise - * pointer_traits::rebind - */ -Comment: /** - * @brief The allocator's difference type - * - * @c Alloc::difference_type if that type exists, otherwise - * pointer_traits::difference_type - */ -Comment: /** - * @brief The allocator's size type - * - * @c Alloc::size_type if that type exists, otherwise - * make_unsigned::type - */ -Comment: /** - * @brief How the allocator is propagated on copy assignment - * - * @c Alloc::propagate_on_container_copy_assignment if that type exists, - * otherwise @c false_type - */ -Comment: /** - * @brief How the allocator is propagated on move assignment - * - * @c Alloc::propagate_on_container_move_assignment if that type exists, - * otherwise @c false_type - */ -Comment: /** - * @brief How the allocator is propagated on swap - * - * @c Alloc::propagate_on_container_swap if that type exists, - * otherwise @c false_type - */ -Comment: /** - * @brief Whether all instances of the allocator type compare equal. - * - * @c Alloc::is_always_equal if that type exists, - * otherwise @c is_empty::type - */ -Comment: // _GLIBCXX_RESOLVE_LIB_DEFECTS -Comment: // 2466. allocator_traits::max_size() default behavior is incorrect -Comment: /** - * @brief Allocate memory. - * @param __a An allocator. - * @param __n The number of objects to allocate space for. - * - * Calls @c a.allocate(n) - */ -Comment: /** - * @brief Allocate memory. - * @param __a An allocator. - * @param __n The number of objects to allocate space for. - * @param __hint Aid to locality. - * @return Memory of suitable size and alignment for @a n objects - * of type @c value_type - * - * Returns a.allocate(n, hint) if that expression is - * well-formed, otherwise returns @c a.allocate(n) - */ -Comment: /** - * @brief Deallocate memory. - * @param __a An allocator. - * @param __p Pointer to the memory to deallocate. - * @param __n The number of objects space was allocated for. - * - * Calls a.deallocate(p, n) - */ -Comment: /** - * @brief Construct an object of type `_Tp` - * @param __a An allocator. - * @param __p Pointer to memory of suitable size and alignment for Tp - * @param __args Constructor arguments. - * - * Calls __a.construct(__p, std::forward(__args)...) - * if that expression is well-formed, otherwise uses placement-new - * to construct an object of type @a _Tp at location @a __p from the - * arguments @a __args... - */ -Comment: /** - * @brief Destroy an object of type @a _Tp - * @param __a An allocator. - * @param __p Pointer to the object to destroy - * - * Calls @c __a.destroy(__p) if that expression is well-formed, - * otherwise calls @c __p->~_Tp() - */ -Comment: /** - * @brief The maximum supported allocation size - * @param __a An allocator. - * @return @c __a.max_size() or @c numeric_limits::max() - * - * Returns @c __a.max_size() if that expression is well-formed, - * otherwise returns @c numeric_limits::max() - */ -Comment: /** - * @brief Obtain an allocator to use when copying a container. - * @param __rhs An allocator. - * @return @c __rhs.select_on_container_copy_construction() or @a __rhs - * - * Returns @c __rhs.select_on_container_copy_construction() if that - * expression is well-formed, otherwise returns @a __rhs - */ -Comment: /// Partial specialization for std::allocator. -Comment: /// The allocator type -Comment: /// The allocated type -Comment: /// The allocator's pointer type. -Comment: /// The allocator's const pointer type. -Comment: /// The allocator's void pointer type. -Comment: /// The allocator's const void pointer type. -Comment: /// The allocator's difference type -Comment: /// The allocator's size type -Comment: /// How the allocator is propagated on copy assignment -Comment: /// How the allocator is propagated on move assignment -Comment: /// How the allocator is propagated on swap -Comment: /// Whether all instances of the allocator type compare equal. -Comment: /** - * @brief Allocate memory. - * @param __a An allocator. - * @param __n The number of objects to allocate space for. - * - * Calls @c a.allocate(n) - */ -Comment: /** - * @brief Allocate memory. - * @param __a An allocator. - * @param __n The number of objects to allocate space for. - * @param __hint Aid to locality. - * @return Memory of suitable size and alignment for @a n objects - * of type @c value_type - * - * Returns a.allocate(n, hint) - */ -Comment: /** - * @brief Deallocate memory. - * @param __a An allocator. - * @param __p Pointer to the memory to deallocate. - * @param __n The number of objects space was allocated for. - * - * Calls a.deallocate(p, n) - */ -Comment: /** - * @brief Construct an object of type `_Up` - * @param __a An allocator. - * @param __p Pointer to memory of suitable size and alignment for - * an object of type `_Up`. - * @param __args Constructor arguments. - * - * Calls `__a.construct(__p, std::forward<_Args>(__args)...)` - * in C++11, C++14 and C++17. Changed in C++20 to call - * `std::construct_at(__p, std::forward<_Args>(__args)...)` instead. - */ -Comment: /** - * @brief Destroy an object of type @a _Up - * @param __a An allocator. - * @param __p Pointer to the object to destroy - * - * Calls @c __a.destroy(__p). - */ -Comment: /** - * @brief The maximum supported allocation size - * @param __a An allocator. - * @return @c __a.max_size() - */ -Comment: /** - * @brief Obtain an allocator to use when copying a container. - * @param __rhs An allocator. - * @return @c __rhs - */ -Comment: /// Explicit specialization for std::allocator. -Comment: /// The allocator type -Comment: /// The allocated type -Comment: /// The allocator's pointer type. -Comment: /// The allocator's const pointer type. -Comment: /// The allocator's void pointer type. -Comment: /// The allocator's const void pointer type. -Comment: /// The allocator's difference type -Comment: /// The allocator's size type -Comment: /// How the allocator is propagated on copy assignment -Comment: /// How the allocator is propagated on move assignment -Comment: /// How the allocator is propagated on swap -Comment: /// Whether all instances of the allocator type compare equal. -Comment: /// allocate is ill-formed for allocator -Comment: /// deallocate is ill-formed for allocator -Comment: /** - * @brief Construct an object of type `_Up` - * @param __a An allocator. - * @param __p Pointer to memory of suitable size and alignment for - * an object of type `_Up`. - * @param __args Constructor arguments. - * - * Calls `__a.construct(__p, std::forward<_Args>(__args)...)` - * in C++11, C++14 and C++17. Changed in C++20 to call - * `std::construct_at(__p, std::forward<_Args>(__args)...)` instead. - */ -Comment: /** - * @brief Destroy an object of type `_Up` - * @param __a An allocator. - * @param __p Pointer to the object to destroy - * - * Invokes the destructor for `*__p`. - */ -Comment: /// max_size is ill-formed for allocator -Comment: /** - * @brief Obtain an allocator to use when copying a container. - * @param __rhs An allocator. - * @return `__rhs` - */ -Comment: /// @cond undocumented -Comment: // true if _Alloc::value_type is CopyInsertable into containers using _Alloc -Comment: // (might be wrong if _Alloc::construct exists but is not constrained, -Comment: // i.e. actually trying to use it would still be invalid. Use with caution.) -Comment: // std::allocator<_Tp> just requires CopyConstructible -Comment: // true if _Alloc::value_type is MoveInsertable into containers using _Alloc -Comment: // (might be wrong if _Alloc::construct exists but is not constrained, -Comment: // i.e. actually trying to use it would still be invalid. Use with caution.) -Comment: // std::allocator<_Tp> just requires MoveConstructible -Comment: // Trait to detect Allocator-like types. -Comment: /// @endcond -Comment: // C++11 -Comment: /// @cond undocumented -Comment: // To implement Option 3 of DR 431. -Comment: // Precondition: swappable allocators. -Comment: /** - * Destroy a range of objects using the supplied allocator. For - * non-default allocators we do not optimize away invocation of - * destroy() even if _Tp has a trivial destructor. - */ -Comment: /// @endcond -Comment: // namespace std -Comment: // _ALLOC_TRAITS_H -Comment: /** - * @brief Uniform interface to C++98 and C++11 allocators. - * @ingroup allocators -*/ -Comment: // C++11 allocators do not define reference or const_reference -Comment: // overload construct for non-standard pointer types -Comment: // overload destroy for non-standard pointer types -Comment: // ! C++11 -Comment: // C++11 -Comment: // namespace __gnu_cxx -Comment: /** @addtogroup memory - * @{ - */ -Comment: /// @cond undocumented -Comment: // Trivial types can have deleted constructors, but std::copy etc. -Comment: // only use assignment (or memmove) not construction, so we need an -Comment: // explicit check that construction from _Tp is actually valid, -Comment: // otherwise some ill-formed uses of std::uninitialized_xxx would -Comment: // compile without errors. This gives a nice clear error message. -Comment: // If the type is trivial we don't need to construct it, just assign to it. -Comment: // But trivial types can still have deleted or inaccessible assignment, -Comment: // so don't try to use std::copy or std::fill etc. if we can't assign. -Comment: /// @endcond -Comment: /** - * @brief Copies the range [first,last) into result. - * @param __first An input iterator. - * @param __last An input iterator. - * @param __result An output iterator. - * @return __result + (__first - __last) - * - * Like copy(), but does not require an initialized output range. - */ -Comment: // _ValueType1 must be trivially-copyable to use memmove, so don't -Comment: // bother optimizing to std::copy if it isn't. -Comment: // XXX Unnecessary because std::copy would check it anyway? -Comment: /// @cond undocumented -Comment: /// @endcond -Comment: /** - * @brief Copies the value x into the range [first,last). - * @param __first An input iterator. - * @param __last An input iterator. - * @param __x The source value. - * @return Nothing. - * - * Like fill(), but does not require an initialized output range. - */ -Comment: // Trivial types do not need a constructor to begin their lifetime, -Comment: // so try to use std::fill to benefit from its memset optimization. -Comment: /// @cond undocumented -Comment: /// @endcond -Comment: // _GLIBCXX_RESOLVE_LIB_DEFECTS -Comment: // DR 1339. uninitialized_fill_n should return the end of its range -Comment: /** - * @brief Copies the value x into the range [first,first+n). - * @param __first An input iterator. - * @param __n The number of copies to make. - * @param __x The source value. - * @return Nothing. - * - * Like fill_n(), but does not require an initialized output range. - */ -Comment: // Trivial types do not need a constructor to begin their lifetime, -Comment: // so try to use std::fill_n to benefit from its optimizations. -Comment: // For arbitrary class types and floating point types we can't assume -Comment: // that __n > 0 and std::__size_to_integer(__n) > 0 are equivalent, -Comment: // so only use std::fill_n when _Size is already an integral type. -Comment: /// @cond undocumented -Comment: // Extensions: versions of uninitialized_copy, uninitialized_fill, -Comment: // and uninitialized_fill_n that take an allocator parameter. -Comment: // We dispatch back to the standard versions when we're given the -Comment: // default allocator. For nondefault allocators we do not use -Comment: // any of the POD optimizations. -Comment: // Extensions: __uninitialized_copy_move, __uninitialized_move_copy, -Comment: // __uninitialized_fill_move, __uninitialized_move_fill. -Comment: // All of these algorithms take a user-supplied allocator, which is used -Comment: // for construction and destruction. -Comment: // __uninitialized_copy_move -Comment: // Copies [first1, last1) into [result, result + (last1 - first1)), and -Comment: // move [first2, last2) into -Comment: // [result, result + (last1 - first1) + (last2 - first2)). -Comment: // __uninitialized_move_copy -Comment: // Moves [first1, last1) into [result, result + (last1 - first1)), and -Comment: // copies [first2, last2) into -Comment: // [result, result + (last1 - first1) + (last2 - first2)). -Comment: // __uninitialized_fill_move -Comment: // Fills [result, mid) with x, and moves [first, last) into -Comment: // [mid, mid + (last - first)). -Comment: // __uninitialized_move_fill -Comment: // Moves [first1, last1) into [first2, first2 + (last1 - first1)), and -Comment: // fills [first2 + (last1 - first1), last2) with x. -Comment: /// @endcond -Comment: /// @cond undocumented -Comment: // Extensions: __uninitialized_default, __uninitialized_default_n, -Comment: // __uninitialized_default_a, __uninitialized_default_n_a. -Comment: // __uninitialized_default -Comment: // Fills [first, last) with value-initialized value_types. -Comment: // trivial types can have deleted assignment -Comment: // __uninitialized_default_n -Comment: // Fills [first, first + n) with value-initialized value_types. -Comment: // See uninitialized_fill_n for the conditions for using std::fill_n. -Comment: // __uninitialized_default_a -Comment: // Fills [first, last) with value_types constructed by the allocator -Comment: // alloc, with no arguments passed to the construct call. -Comment: // __uninitialized_default_n_a -Comment: // Fills [first, first + n) with value_types constructed by the allocator -Comment: // alloc, with no arguments passed to the construct call. -Comment: // __uninitialized_default_n_a specialization for std::allocator, -Comment: // which ignores the allocator and value-initializes the elements. -Comment: // __uninitialized_default_novalue -Comment: // Fills [first, last) with default-initialized value_types. -Comment: // __uninitialized_default_novalue_n -Comment: // Fills [first, first + n) with default-initialized value_types. -Comment: /// @endcond -Comment: /** - * @brief Copies the range [first,first+n) into result. - * @param __first An input iterator. - * @param __n The number of elements to copy. - * @param __result An output iterator. - * @return __result + __n - * @since C++11 - * - * Like copy_n(), but does not require an initialized output range. - */ -Comment: /// @cond undocumented -Comment: /// @endcond -Comment: /** - * @brief Default-initializes objects in the range [first,last). - * @param __first A forward iterator. - * @param __last A forward iterator. - * @since C++17 - */ -Comment: /** - * @brief Default-initializes objects in the range [first,first+count). - * @param __first A forward iterator. - * @param __count The number of objects to construct. - * @return __first + __count - * @since C++17 - */ -Comment: /** - * @brief Value-initializes objects in the range [first,last). - * @param __first A forward iterator. - * @param __last A forward iterator. - * @since C++17 - */ -Comment: /** - * @brief Value-initializes objects in the range [first,first+count). - * @param __first A forward iterator. - * @param __count The number of objects to construct. - * @return __result + __count - * @since C++17 - */ -Comment: /** - * @brief Move-construct from the range [first,last) into result. - * @param __first An input iterator. - * @param __last An input iterator. - * @param __result An output iterator. - * @return __result + (__first - __last) - * @since C++17 - */ -Comment: /** - * @brief Move-construct from the range [first,first+count) into result. - * @param __first An input iterator. - * @param __count The number of objects to initialize. - * @param __result An output iterator. - * @return __result + __count - * @since C++17 - */ -Comment: // C++17 -Comment: /// @cond undocumented -Comment: // This class may be specialized for specific types. -Comment: // Also known as is_trivially_relocatable. -Comment: // Can't use memmove. Wrap the pointer so that __relocate_a_1 -Comment: // resolves to the non-trivial overload above. -Comment: /// @endcond -Comment: // C++11 -Comment: /// @} group memory -Comment: // namespace -Comment: /* _STL_UNINITIALIZED_H */ -Comment: // Vector implementation -*- C++ -*- -Comment: // Copyright (C) 2001-2023 Free Software Foundation, Inc. -Comment: // -Comment: // This file is part of the GNU ISO C++ Library. This library is free -Comment: // software; you can redistribute it and/or modify it under the -Comment: // terms of the GNU General Public License as published by the -Comment: // Free Software Foundation; either version 3, or (at your option) -Comment: // any later version. -Comment: // This library is distributed in the hope that it will be useful, -Comment: // but WITHOUT ANY WARRANTY; without even the implied warranty of -Comment: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -Comment: // GNU General Public License for more details. -Comment: // Under Section 7 of GPL version 3, you are granted additional -Comment: // permissions described in the GCC Runtime Library Exception, version -Comment: // 3.1, as published by the Free Software Foundation. -Comment: // You should have received a copy of the GNU General Public License and -Comment: // a copy of the GCC Runtime Library Exception along with this program; -Comment: // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -Comment: // . -Comment: /* - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1996 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ -Comment: /** @file bits/stl_vector.h - * This is an internal header file, included by other library headers. - * Do not attempt to use it directly. @headername{vector} - */ -Comment: // std::initializer_list support -*- C++ -*- -Comment: // Copyright (C) 2008-2023 Free Software Foundation, Inc. -Comment: // -Comment: // This file is part of GCC. -Comment: // -Comment: // GCC is free software; you can redistribute it and/or modify -Comment: // it under the terms of the GNU General Public License as published by -Comment: // the Free Software Foundation; either version 3, or (at your option) -Comment: // any later version. -Comment: // -Comment: // GCC is distributed in the hope that it will be useful, -Comment: // but WITHOUT ANY WARRANTY; without even the implied warranty of -Comment: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -Comment: // GNU General Public License for more details. -Comment: // -Comment: // Under Section 7 of GPL version 3, you are granted additional -Comment: // permissions described in the GCC Runtime Library Exception, version -Comment: // 3.1, as published by the Free Software Foundation. -Comment: // You should have received a copy of the GNU General Public License and -Comment: // a copy of the GCC Runtime Library Exception along with this program; -Comment: // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -Comment: // . -Comment: /** @file initializer_list - * This is a Standard C++ Library header. - */ -Comment: // C++0x -Comment: /// initializer_list -Comment: // The compiler can call a private constructor. -Comment: // Number of elements. -Comment: // First element. -Comment: // One past the last element. -Comment: /** - * @brief Return an iterator pointing to the first element of - * the initializer_list. - * @param __ils Initializer list. - * @relates initializer_list - */ -Comment: /** - * @brief Return an iterator pointing to one past the last element - * of the initializer_list. - * @param __ils Initializer list. - * @relates initializer_list - */ -Comment: // C++11 -Comment: // _INITIALIZER_LIST -Comment: /// See bits/stl_deque.h's _Deque_base for an explanation. -Comment: // Do not use std::swap(_M_start, __x._M_start), etc as it loses -Comment: // information used by TBAA. -Comment: // Not defaulted, to enforce noexcept(true) even when -Comment: // !is_nothrow_move_constructible<_Tp_alloc_type>. -Comment: // ! (_GLIBCXX_SANITIZE_STD_ALLOCATOR && _GLIBCXX_SANITIZE_VECTOR) -Comment: // _GLIBCXX_SANITIZE_STD_ALLOCATOR && _GLIBCXX_SANITIZE_VECTOR -Comment: // Kept for ABI compatibility. -Comment: // Kept for ABI compatibility. -Comment: /** - * @brief A standard container which offers fixed time access to - * individual elements in any order. - * - * @ingroup sequences - * @headerfile vector - * @since C++98 - * - * @tparam _Tp Type of element. - * @tparam _Alloc Allocator type, defaults to allocator<_Tp>. - * - * Meets the requirements of a container, a - * reversible container, and a - * sequence, including the - * optional sequence requirements with the - * %exception of @c push_front and @c pop_front. - * - * In some terminology a %vector can be described as a dynamic - * C-style array, it offers fast and efficient access to individual - * elements in any order and saves the user from worrying about - * memory and size allocation. Subscripting ( @c [] ) access is - * also provided as with C-style arrays. - */ -Comment: // Instantiating std::__relocate_a might cause an error outside the -Comment: // immediate context (in __relocate_object_a's noexcept-specifier), -Comment: // so only do it if we know the type can be move-inserted into *this. -Comment: // All callers have already checked _S_use_relocate() so just do it. -Comment: // C++11 -Comment: // [23.2.4.1] construct/copy/destroy -Comment: // (assign() and get_allocator() are also listed in this section) -Comment: /** - * @brief Creates a %vector with no elements. - */ -Comment: /** - * @brief Creates a %vector with no elements. - * @param __a An allocator object. - */ -Comment: /** - * @brief Creates a %vector with default constructed elements. - * @param __n The number of elements to initially create. - * @param __a An allocator. - * - * This constructor fills the %vector with @a __n default - * constructed elements. - */ -Comment: /** - * @brief Creates a %vector with copies of an exemplar element. - * @param __n The number of elements to initially create. - * @param __value An element to copy. - * @param __a An allocator. - * - * This constructor fills the %vector with @a __n copies of @a __value. - */ -Comment: /** - * @brief %Vector copy constructor. - * @param __x A %vector of identical element and allocator types. - * - * All the elements of @a __x are copied, but any unused capacity in - * @a __x will not be copied - * (i.e. capacity() == size() in the new %vector). - * - * The newly-created %vector uses a copy of the allocator object used - * by @a __x (unless the allocator traits dictate a different object). - */ -Comment: /** - * @brief %Vector move constructor. - * - * The newly-created %vector contains the exact contents of the - * moved instance. - * The contents of the moved instance are a valid, but unspecified - * %vector. - */ -Comment: /// Copy constructor with alternative allocator -Comment: /// Move constructor with alternative allocator -Comment: /** - * @brief Builds a %vector from an initializer list. - * @param __l An initializer_list. - * @param __a An allocator. - * - * Create a %vector consisting of copies of the elements in the - * initializer_list @a __l. - * - * This will call the element type's copy constructor N times - * (where N is @a __l.size()) and do no memory reallocation. - */ -Comment: /** - * @brief Builds a %vector from a range. - * @param __first An input iterator. - * @param __last An input iterator. - * @param __a An allocator. - * - * Create a %vector consisting of copies of the elements from - * [first,last). - * - * If the iterators are forward, bidirectional, or - * random-access, then this will call the elements' copy - * constructor N times (where N is distance(first,last)) and do - * no memory reallocation. But if only input iterators are - * used, then this will do at most 2N calls to the copy - * constructor, and logN memory reallocations. - */ -Comment: /** - * The dtor only erases the elements, and note that if the - * elements themselves are pointers, the pointed-to memory is - * not touched in any way. Managing the pointer is the user's - * responsibility. - */ -Comment: /** - * @brief %Vector assignment operator. - * @param __x A %vector of identical element and allocator types. - * - * All the elements of @a __x are copied, but any unused capacity in - * @a __x will not be copied. - * - * Whether the allocator is copied depends on the allocator traits. - */ -Comment: /** - * @brief %Vector move assignment operator. - * @param __x A %vector of identical element and allocator types. - * - * The contents of @a __x are moved into this %vector (without copying, - * if the allocators permit it). - * Afterwards @a __x is a valid, but unspecified %vector. - * - * Whether the allocator is moved depends on the allocator traits. - */ -Comment: /** - * @brief %Vector list assignment operator. - * @param __l An initializer_list. - * - * This function fills a %vector with copies of the elements in the - * initializer list @a __l. - * - * Note that the assignment completely changes the %vector and - * that the resulting %vector's size is the same as the number - * of elements assigned. - */ -Comment: /** - * @brief Assigns a given value to a %vector. - * @param __n Number of elements to be assigned. - * @param __val Value to be assigned. - * - * This function fills a %vector with @a __n copies of the given - * value. Note that the assignment completely changes the - * %vector and that the resulting %vector's size is the same as - * the number of elements assigned. - */ -Comment: /** - * @brief Assigns a range to a %vector. - * @param __first An input iterator. - * @param __last An input iterator. - * - * This function fills a %vector with copies of the elements in the - * range [__first,__last). - * - * Note that the assignment completely changes the %vector and - * that the resulting %vector's size is the same as the number - * of elements assigned. - */ -Comment: /** - * @brief Assigns an initializer list to a %vector. - * @param __l An initializer_list. - * - * This function fills a %vector with copies of the elements in the - * initializer list @a __l. - * - * Note that the assignment completely changes the %vector and - * that the resulting %vector's size is the same as the number - * of elements assigned. - */ -Comment: /// Get a copy of the memory allocation object. -Comment: // iterators -Comment: /** - * Returns a read/write iterator that points to the first - * element in the %vector. Iteration is done in ordinary - * element order. - */ -Comment: /** - * Returns a read-only (constant) iterator that points to the - * first element in the %vector. Iteration is done in ordinary - * element order. - */ -Comment: /** - * Returns a read/write iterator that points one past the last - * element in the %vector. Iteration is done in ordinary - * element order. - */ -Comment: /** - * Returns a read-only (constant) iterator that points one past - * the last element in the %vector. Iteration is done in - * ordinary element order. - */ -Comment: /** - * Returns a read/write reverse iterator that points to the - * last element in the %vector. Iteration is done in reverse - * element order. - */ -Comment: /** - * Returns a read-only (constant) reverse iterator that points - * to the last element in the %vector. Iteration is done in - * reverse element order. - */ -Comment: /** - * Returns a read/write reverse iterator that points to one - * before the first element in the %vector. Iteration is done - * in reverse element order. - */ -Comment: /** - * Returns a read-only (constant) reverse iterator that points - * to one before the first element in the %vector. Iteration - * is done in reverse element order. - */ -Comment: /** - * Returns a read-only (constant) iterator that points to the - * first element in the %vector. Iteration is done in ordinary - * element order. - */ -Comment: /** - * Returns a read-only (constant) iterator that points one past - * the last element in the %vector. Iteration is done in - * ordinary element order. - */ -Comment: /** - * Returns a read-only (constant) reverse iterator that points - * to the last element in the %vector. Iteration is done in - * reverse element order. - */ -Comment: /** - * Returns a read-only (constant) reverse iterator that points - * to one before the first element in the %vector. Iteration - * is done in reverse element order. - */ -Comment: // [23.2.4.2] capacity -Comment: /** Returns the number of elements in the %vector. */ -Comment: /** Returns the size() of the largest possible %vector. */ -Comment: /** - * @brief Resizes the %vector to the specified number of elements. - * @param __new_size Number of elements the %vector should contain. - * - * This function will %resize the %vector to the specified - * number of elements. If the number is smaller than the - * %vector's current size the %vector is truncated, otherwise - * default constructed elements are appended. - */ -Comment: /** - * @brief Resizes the %vector to the specified number of elements. - * @param __new_size Number of elements the %vector should contain. - * @param __x Data with which new elements should be populated. - * - * This function will %resize the %vector to the specified - * number of elements. If the number is smaller than the - * %vector's current size the %vector is truncated, otherwise - * the %vector is extended and new elements are populated with - * given data. - */ -Comment: /** A non-binding request to reduce capacity() to size(). */ -Comment: /** - * Returns the total number of elements that the %vector can - * hold before needing to allocate more memory. - */ -Comment: /** - * Returns true if the %vector is empty. (Thus begin() would - * equal end().) - */ -Comment: /** - * @brief Attempt to preallocate enough memory for specified number of - * elements. - * @param __n Number of elements required. - * @throw std::length_error If @a n exceeds @c max_size(). - * - * This function attempts to reserve enough memory for the - * %vector to hold the specified number of elements. If the - * number requested is more than max_size(), length_error is - * thrown. - * - * The advantage of this function is that if optimal code is a - * necessity and the user can determine the number of elements - * that will be required, the user can reserve the memory in - * %advance, and thus prevent a possible reallocation of memory - * and copying of %vector data. - */ -Comment: // element access -Comment: /** - * @brief Subscript access to the data contained in the %vector. - * @param __n The index of the element for which data should be - * accessed. - * @return Read/write reference to data. - * - * This operator allows for easy, array-style, data access. - * Note that data access with this operator is unchecked and - * out_of_range lookups are not defined. (For checked lookups - * see at().) - */ -Comment: /** - * @brief Subscript access to the data contained in the %vector. - * @param __n The index of the element for which data should be - * accessed. - * @return Read-only (constant) reference to data. - * - * This operator allows for easy, array-style, data access. - * Note that data access with this operator is unchecked and - * out_of_range lookups are not defined. (For checked lookups - * see at().) - */ -Comment: /// Safety check used only from at(). -Comment: /** - * @brief Provides access to the data contained in the %vector. - * @param __n The index of the element for which data should be - * accessed. - * @return Read/write reference to data. - * @throw std::out_of_range If @a __n is an invalid index. - * - * This function provides for safer data access. The parameter - * is first checked that it is in the range of the vector. The - * function throws out_of_range if the check fails. - */ -Comment: /** - * @brief Provides access to the data contained in the %vector. - * @param __n The index of the element for which data should be - * accessed. - * @return Read-only (constant) reference to data. - * @throw std::out_of_range If @a __n is an invalid index. - * - * This function provides for safer data access. The parameter - * is first checked that it is in the range of the vector. The - * function throws out_of_range if the check fails. - */ -Comment: /** - * Returns a read/write reference to the data at the first - * element of the %vector. - */ -Comment: /** - * Returns a read-only (constant) reference to the data at the first - * element of the %vector. - */ -Comment: /** - * Returns a read/write reference to the data at the last - * element of the %vector. - */ -Comment: /** - * Returns a read-only (constant) reference to the data at the - * last element of the %vector. - */ -Comment: // _GLIBCXX_RESOLVE_LIB_DEFECTS -Comment: // DR 464. Suggestion for new member functions in standard containers. -Comment: // data access -Comment: /** - * Returns a pointer such that [data(), data() + size()) is a valid - * range. For a non-empty %vector, data() == &front(). - */ -Comment: // [23.2.4.3] modifiers -Comment: /** - * @brief Add data to the end of the %vector. - * @param __x Data to be added. - * - * This is a typical stack operation. The function creates an - * element at the end of the %vector and assigns the given data - * to it. Due to the nature of a %vector this operation can be - * done in constant time if the %vector has preallocated space - * available. - */ -Comment: /** - * @brief Removes last element. - * - * This is a typical stack operation. It shrinks the %vector by one. - * - * Note that no data is returned, and if the last element's - * data is needed, it should be retrieved before pop_back() is - * called. - */ -Comment: /** - * @brief Inserts an object in %vector before specified iterator. - * @param __position A const_iterator into the %vector. - * @param __args Arguments. - * @return An iterator that points to the inserted data. - * - * This function will insert an object of type T constructed - * with T(std::forward(args)...) before the specified location. - * Note that this kind of operation could be expensive for a %vector - * and if it is frequently used the user should consider using - * std::list. - */ -Comment: /** - * @brief Inserts given value into %vector before specified iterator. - * @param __position A const_iterator into the %vector. - * @param __x Data to be inserted. - * @return An iterator that points to the inserted data. - * - * This function will insert a copy of the given value before - * the specified location. Note that this kind of operation - * could be expensive for a %vector and if it is frequently - * used the user should consider using std::list. - */ -Comment: /** - * @brief Inserts given rvalue into %vector before specified iterator. - * @param __position A const_iterator into the %vector. - * @param __x Data to be inserted. - * @return An iterator that points to the inserted data. - * - * This function will insert a copy of the given rvalue before - * the specified location. Note that this kind of operation - * could be expensive for a %vector and if it is frequently - * used the user should consider using std::list. - */ -Comment: /** - * @brief Inserts an initializer_list into the %vector. - * @param __position An iterator into the %vector. - * @param __l An initializer_list. - * - * This function will insert copies of the data in the - * initializer_list @a l into the %vector before the location - * specified by @a position. - * - * Note that this kind of operation could be expensive for a - * %vector and if it is frequently used the user should - * consider using std::list. - */ -Comment: /** - * @brief Inserts a number of copies of given data into the %vector. - * @param __position A const_iterator into the %vector. - * @param __n Number of elements to be inserted. - * @param __x Data to be inserted. - * @return An iterator that points to the inserted data. - * - * This function will insert a specified number of copies of - * the given data before the location specified by @a position. - * - * Note that this kind of operation could be expensive for a - * %vector and if it is frequently used the user should - * consider using std::list. - */ -Comment: /** - * @brief Inserts a range into the %vector. - * @param __position A const_iterator into the %vector. - * @param __first An input iterator. - * @param __last An input iterator. - * @return An iterator that points to the inserted data. - * - * This function will insert copies of the data in the range - * [__first,__last) into the %vector before the location specified - * by @a pos. - * - * Note that this kind of operation could be expensive for a - * %vector and if it is frequently used the user should - * consider using std::list. - */ -Comment: /** - * @brief Remove element at given position. - * @param __position Iterator pointing to element to be erased. - * @return An iterator pointing to the next element (or end()). - * - * This function will erase the element at the given position and thus - * shorten the %vector by one. - * - * Note This operation could be expensive and if it is - * frequently used the user should consider using std::list. - * The user is also cautioned that this function only erases - * the element, and that if the element is itself a pointer, - * the pointed-to memory is not touched in any way. Managing - * the pointer is the user's responsibility. - */ -Comment: /** - * @brief Remove a range of elements. - * @param __first Iterator pointing to the first element to be erased. - * @param __last Iterator pointing to one past the last element to be - * erased. - * @return An iterator pointing to the element pointed to by @a __last - * prior to erasing (or end()). - * - * This function will erase the elements in the range - * [__first,__last) and shorten the %vector accordingly. - * - * Note This operation could be expensive and if it is - * frequently used the user should consider using std::list. - * The user is also cautioned that this function only erases - * the elements, and that if the elements themselves are - * pointers, the pointed-to memory is not touched in any way. - * Managing the pointer is the user's responsibility. - */ -Comment: /** - * @brief Swaps data with another %vector. - * @param __x A %vector of the same element and allocator types. - * - * This exchanges the elements between two vectors in constant time. - * (Three pointers, so it should be quite fast.) - * Note that the global std::swap() function is specialized such that - * std::swap(v1,v2) will feed to this function. - * - * Whether the allocators are swapped depends on the allocator traits. - */ -Comment: /** - * Erases all the elements. Note that this function only erases the - * elements, and that if the elements themselves are pointers, the - * pointed-to memory is not touched in any way. Managing the pointer is - * the user's responsibility. - */ -Comment: /** - * Memory expansion handler. Uses the member allocation function to - * obtain @a n bytes of memory, and then copies [first,last) into it. - */ -Comment: // Internal constructor functions follow. -Comment: // Called by the range constructor to implement [23.1.1]/9 -Comment: // Called by the second initialize_dispatch above -Comment: // Called by the second initialize_dispatch above -Comment: // Called by the first initialize_dispatch above and by the -Comment: // vector(n,value,a) constructor. -Comment: // Called by the vector(n) constructor. -Comment: // Internal assign functions follow. The *_aux functions do the actual -Comment: // assignment work for the range versions. -Comment: // Called by the range assign to implement [23.1.1]/9 -Comment: // _GLIBCXX_RESOLVE_LIB_DEFECTS -Comment: // 438. Ambiguity in the "do the right thing" clause -Comment: // Called by the range assign to implement [23.1.1]/9 -Comment: // Called by the second assign_dispatch above -Comment: // Called by the second assign_dispatch above -Comment: // Called by assign(n,t), and the range assign when it turns out -Comment: // to be the same thing. -Comment: // Internal insert functions follow. -Comment: // Called by the range insert to implement [23.1.1]/9 -Comment: // _GLIBCXX_RESOLVE_LIB_DEFECTS -Comment: // 438. Ambiguity in the "do the right thing" clause -Comment: // Called by the range insert to implement [23.1.1]/9 -Comment: // Called by the second insert_dispatch above -Comment: // Called by the second insert_dispatch above -Comment: // Called by insert(p,n,x), and the range insert when it turns out to be -Comment: // the same thing. -Comment: // Called by resize(n). -Comment: // A value_type object constructed with _Alloc_traits::construct() -Comment: // and destroyed with _Alloc_traits::destroy(). -Comment: // Called by insert(p,x) and other functions when insertion needs to -Comment: // reallocate or move existing elements. _Arg is either _Tp& or _Tp. -Comment: // Either move-construct at the end, or forward to _M_insert_aux. -Comment: // Try to emplace at the end, otherwise forward to _M_insert_aux. -Comment: // Emplacing an rvalue of the correct type can use _M_insert_rval. -Comment: // Called by _M_fill_insert, _M_insert_aux etc. -Comment: // Called by constructors to check initial size. -Comment: // std::distance(begin(), end()) cannot be greater than PTRDIFF_MAX, -Comment: // and realistically we can't store more than PTRDIFF_MAX/sizeof(T) -Comment: // (even if std::allocator_traits::max_size says we can). -Comment: // Internal erase functions follow. -Comment: // Called by erase(q1,q2), clear(), resize(), _M_fill_assign, -Comment: // _M_assign_aux. -Comment: // Constant-time move assignment when source object's memory can be -Comment: // moved, either because the source's allocator will move too -Comment: // or because the allocators are equal. -Comment: // Do move assignment when it might not be possible to move source -Comment: // object's memory, resulting in a linear-time operation. -Comment: // The rvalue's allocator cannot be moved and is not equal, -Comment: // so we need to individually move each element. -Comment: /** - * @brief Vector equality comparison. - * @param __x A %vector. - * @param __y A %vector of the same type as @a __x. - * @return True iff the size and elements of the vectors are equal. - * - * This is an equivalence relation. It is linear in the size of the - * vectors. Vectors are considered equivalent if their sizes are equal, - * and if corresponding elements compare equal. - */ -Comment: /** - * @brief Vector ordering relation. - * @param __x A `vector`. - * @param __y A `vector` of the same type as `__x`. - * @return A value indicating whether `__x` is less than, equal to, - * greater than, or incomparable with `__y`. - * - * See `std::lexicographical_compare_three_way()` for how the determination - * is made. This operator is used to synthesize relational operators like - * `<` and `>=` etc. - */ -Comment: // three-way comparison -Comment: /// See std::vector::swap(). -Comment: // see -Comment: // Provide the strong exception-safety guarantee when emplacing a -Comment: // vector into a variant, but only if move assignment cannot throw. -Comment: // namespace __detail::__variant -Comment: // C++17 -Comment: // namespace std -Comment: /* _STL_VECTOR_H */ -Comment: // vector specialization -*- C++ -*- -Comment: // Copyright (C) 2001-2023 Free Software Foundation, Inc. -Comment: // -Comment: // This file is part of the GNU ISO C++ Library. This library is free -Comment: // software; you can redistribute it and/or modify it under the -Comment: // terms of the GNU General Public License as published by the -Comment: // Free Software Foundation; either version 3, or (at your option) -Comment: // any later version. -Comment: // This library is distributed in the hope that it will be useful, -Comment: // but WITHOUT ANY WARRANTY; without even the implied warranty of -Comment: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -Comment: // GNU General Public License for more details. -Comment: // Under Section 7 of GPL version 3, you are granted additional -Comment: // permissions described in the GCC Runtime Library Exception, version -Comment: // 3.1, as published by the Free Software Foundation. -Comment: // You should have received a copy of the GNU General Public License and -Comment: // a copy of the GCC Runtime Library Exception along with this program; -Comment: // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -Comment: // . -Comment: /* - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1996-1999 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ -Comment: /** @file bits/stl_bvector.h - * This is an internal header file, included by other library headers. - * Do not attempt to use it directly. @headername{vector} - */ -Comment: // functional_hash.h header -*- C++ -*- -Comment: // Copyright (C) 2007-2023 Free Software Foundation, Inc. -Comment: // -Comment: // This file is part of the GNU ISO C++ Library. This library is free -Comment: // software; you can redistribute it and/or modify it under the -Comment: // terms of the GNU General Public License as published by the -Comment: // Free Software Foundation; either version 3, or (at your option) -Comment: // any later version. -Comment: // This library is distributed in the hope that it will be useful, -Comment: // but WITHOUT ANY WARRANTY; without even the implied warranty of -Comment: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -Comment: // GNU General Public License for more details. -Comment: // Under Section 7 of GPL version 3, you are granted additional -Comment: // permissions described in the GCC Runtime Library Exception, version -Comment: // 3.1, as published by the Free Software Foundation. -Comment: // You should have received a copy of the GNU General Public License and -Comment: // a copy of the GCC Runtime Library Exception along with this program; -Comment: // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -Comment: // . -Comment: /** @file bits/functional_hash.h - * This is an internal header file, included by other library headers. - * Do not attempt to use it directly. @headername{functional} - */ -Comment: // Declarations for hash functions. -*- C++ -*- -Comment: // Copyright (C) 2010-2023 Free Software Foundation, Inc. -Comment: // -Comment: // This file is part of the GNU ISO C++ Library. This library is free -Comment: // software; you can redistribute it and/or modify it under the -Comment: // terms of the GNU General Public License as published by the -Comment: // Free Software Foundation; either version 3, or (at your option) -Comment: // any later version. -Comment: // This library is distributed in the hope that it will be useful, -Comment: // but WITHOUT ANY WARRANTY; without even the implied warranty of -Comment: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -Comment: // GNU General Public License for more details. -Comment: // Under Section 7 of GPL version 3, you are granted additional -Comment: // permissions described in the GCC Runtime Library Exception, version -Comment: // 3.1, as published by the Free Software Foundation. -Comment: // You should have received a copy of the GNU General Public License and -Comment: // a copy of the GCC Runtime Library Exception along with this program; -Comment: // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -Comment: // . -Comment: /** @file bits/hash_bytes.h - * This is an internal header file, included by other library headers. - * Do not attempt to use it directly. @headername{functional} - */ -Comment: // Hash function implementation for the nontrivial specialization. -Comment: // All of them are based on a primitive that hashes a pointer to a -Comment: // byte array. The actual hash algorithm is not guaranteed to stay -Comment: // the same from release to release -- it may be updated or tuned to -Comment: // improve hash quality or speed. -Comment: // A similar hash primitive, using the FNV hash algorithm. This -Comment: // algorithm is guaranteed to stay the same from release to release. -Comment: // (although it might not produce the same values on different -Comment: // machines.) -Comment: // namespace -Comment: /** @defgroup hashes Hashes - * @ingroup functors - * - * Hashing functors taking a variable type and returning a @c std::size_t. - * - * @{ - */ -Comment: /// Primary class template hash. -Comment: // Private rather than deleted to be non-trivially-copyable. -Comment: // Helper struct for SFINAE-poisoning non-enum types. -Comment: // Private rather than deleted to be non-trivially-copyable. -Comment: // Helper struct for hash with enum types. -Comment: /// Primary class template hash, usable for enum types only. -Comment: // Use with non-enum types still SFINAES. -Comment: /// Partial specializations for pointer types. -Comment: // Explicit specializations for integer types. -Comment: /// Explicit specialization for bool. -Comment: /// Explicit specialization for char. -Comment: /// Explicit specialization for signed char. -Comment: /// Explicit specialization for unsigned char. -Comment: /// Explicit specialization for wchar_t. -Comment: /// Explicit specialization for char8_t. -Comment: /// Explicit specialization for char16_t. -Comment: /// Explicit specialization for char32_t. -Comment: /// Explicit specialization for short. -Comment: /// Explicit specialization for int. -Comment: /// Explicit specialization for long. -Comment: /// Explicit specialization for long long. -Comment: /// Explicit specialization for unsigned short. -Comment: /// Explicit specialization for unsigned int. -Comment: /// Explicit specialization for unsigned long. -Comment: /// Explicit specialization for unsigned long long. -Comment: // A hash function similar to FNV-1a (see PR59406 for how it differs). -Comment: /// Specialization for float. -Comment: // 0 and -0 both hash to zero. -Comment: /// Specialization for double. -Comment: // 0 and -0 both hash to zero. -Comment: /// Specialization for long double. -Comment: /// @} group hashes -Comment: /** Hint about performance of hash functions. - * - * If a given hash function object is not fast, the hash-based containers - * will cache the hash code. - * The default behavior is to consider that hashers are fast unless specified - * otherwise. - * - * Users can specialize this for their own hash functions in order to force - * caching of hash codes in unordered containers. Specializing this trait - * affects the ABI of the unordered containers, so use it carefully. - */ -Comment: // namespace -Comment: // _FUNCTIONAL_HASH_H -Comment: // C++23 -Comment: // Ignore warnings about std::iterator. -Comment: // three-way comparison -Comment: // Do not use std::swap(_M_start, __x._M_start), etc as it loses -Comment: // information used by TBAA. -Comment: // Not defaulted, to enforce noexcept(true) even when -Comment: // !is_nothrow_move_constructible<_Bit_alloc_type>. -Comment: /** - * @brief A specialization of vector for booleans which offers fixed time - * access to individual elements in any order. - * - * @ingroup sequences - * @headerfile vector - * @since C++98 - * - * @tparam _Alloc Allocator type. - * - * Note that vector does not actually meet the requirements for being - * a container. This is because the reference and pointer types are not - * really references and pointers to bool. See DR96 for details. @see - * vector for function documentation. - * - * In some terminology a %vector can be described as a dynamic - * C-style array, it offers fast and efficient access to individual - * elements in any order and saves the user from worrying about - * memory and size allocation. Subscripting ( @c [] ) access is - * also provided as with C-style arrays. - */ -Comment: // assign(), a generalized assignment member function. Two -Comment: // versions: one that takes a count, and one that takes a range. -Comment: // The range version is a member template, so we dispatch on whether -Comment: // or not the type is an integer. -Comment: // [23.2.5]/1, third-to-last entry in synopsis listing -Comment: // Precondition: __first._M_offset == 0 && __result._M_offset == 0. -Comment: // _GLIBCXX_RESOLVE_LIB_DEFECTS -Comment: // DR 464. Suggestion for new member functions in standard containers. -Comment: // N.B. DR 464 says nothing about vector but we need something -Comment: // here due to the using-declaration in __gnu_debug::vector. -Comment: // vector class. -Comment: // Fill a partial word. -Comment: // Fill N full words, as if using memset, but usable in constant expressions. -Comment: // DR 1182. -Comment: /// std::hash specialization for vector. -Comment: // C++11 -Comment: // namespace std -Comment: // Implementation of std::reference_wrapper -*- C++ -*- -Comment: // Copyright (C) 2004-2023 Free Software Foundation, Inc. -Comment: // -Comment: // This file is part of the GNU ISO C++ Library. This library is free -Comment: // software; you can redistribute it and/or modify it under the -Comment: // terms of the GNU General Public License as published by the -Comment: // Free Software Foundation; either version 3, or (at your option) -Comment: // any later version. -Comment: // This library is distributed in the hope that it will be useful, -Comment: // but WITHOUT ANY WARRANTY; without even the implied warranty of -Comment: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -Comment: // GNU General Public License for more details. -Comment: // Under Section 7 of GPL version 3, you are granted additional -Comment: // permissions described in the GCC Runtime Library Exception, version -Comment: // 3.1, as published by the Free Software Foundation. -Comment: // You should have received a copy of the GNU General Public License and -Comment: // a copy of the GCC Runtime Library Exception along with this program; -Comment: // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -Comment: // . -Comment: /** @file include/bits/refwrap.h - * This is an internal header file, included by other library headers. - * Do not attempt to use it directly. @headername{functional} - */ -Comment: // Implementation of INVOKE -*- C++ -*- -Comment: // Copyright (C) 2016-2023 Free Software Foundation, Inc. -Comment: // -Comment: // This file is part of the GNU ISO C++ Library. This library is free -Comment: // software; you can redistribute it and/or modify it under the -Comment: // terms of the GNU General Public License as published by the -Comment: // Free Software Foundation; either version 3, or (at your option) -Comment: // any later version. -Comment: // This library is distributed in the hope that it will be useful, -Comment: // but WITHOUT ANY WARRANTY; without even the implied warranty of -Comment: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -Comment: // GNU General Public License for more details. -Comment: // Under Section 7 of GPL version 3, you are granted additional -Comment: // permissions described in the GCC Runtime Library Exception, version -Comment: // 3.1, as published by the Free Software Foundation. -Comment: // You should have received a copy of the GNU General Public License and -Comment: // a copy of the GCC Runtime Library Exception along with this program; -Comment: // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -Comment: // . -Comment: /** @file include/bits/invoke.h - * This is an internal header file, included by other library headers. - * Do not attempt to use it directly. @headername{functional} - */ -Comment: // forward -Comment: /** - * @addtogroup utilities - * @{ - */ -Comment: // Used by __invoke_impl instead of std::forward<_Tp> so that a -Comment: // reference_wrapper is converted to an lvalue-reference. -Comment: /// Invoke a callable object. -Comment: // INVOKE: Invoke a callable object and convert the result to R. -Comment: // C++11 or C++14 -Comment: // C++11 or C++14 -Comment: // namespace std -Comment: // C++11 -Comment: // _GLIBCXX_INVOKE_H -Comment: // for unary_function and binary_function -Comment: // Functor implementations -*- C++ -*- -Comment: // Copyright (C) 2001-2023 Free Software Foundation, Inc. -Comment: // -Comment: // This file is part of the GNU ISO C++ Library. This library is free -Comment: // software; you can redistribute it and/or modify it under the -Comment: // terms of the GNU General Public License as published by the -Comment: // Free Software Foundation; either version 3, or (at your option) -Comment: // any later version. -Comment: // This library is distributed in the hope that it will be useful, -Comment: // but WITHOUT ANY WARRANTY; without even the implied warranty of -Comment: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -Comment: // GNU General Public License for more details. -Comment: // Under Section 7 of GPL version 3, you are granted additional -Comment: // permissions described in the GCC Runtime Library Exception, version -Comment: // 3.1, as published by the Free Software Foundation. -Comment: // You should have received a copy of the GNU General Public License and -Comment: // a copy of the GCC Runtime Library Exception along with this program; -Comment: // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -Comment: // . -Comment: /* - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1996-1998 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ -Comment: /** @file bits/stl_function.h - * This is an internal header file, included by other library headers. - * Do not attempt to use it directly. @headername{functional} - */ -Comment: // 20.3.1 base classes -Comment: /** @defgroup functors Function Objects - * @ingroup utilities - * - * Function objects, or _functors_, are objects with an `operator()` - * defined and accessible. They can be passed as arguments to algorithm - * templates and used in place of a function pointer. Not only is the - * resulting expressiveness of the library increased, but the generated - * code can be more efficient than what you might write by hand. When we - * refer to _functors_, then, generally we include function pointers in - * the description as well. - * - * Often, functors are only created as temporaries passed to algorithm - * calls, rather than being created as named variables. - * - * Two examples taken from the standard itself follow. To perform a - * by-element addition of two vectors `a` and `b` containing `double`, - * and put the result in `a`, use - * \code - * transform (a.begin(), a.end(), b.begin(), a.begin(), plus()); - * \endcode - * To negate every element in `a`, use - * \code - * transform(a.begin(), a.end(), a.begin(), negate()); - * \endcode - * The addition and negation functions will usually be inlined directly. - * - * An _adaptable function object_ is one which provides nested typedefs - * `result_type` and either `argument_type` (for a unary function) or - * `first_argument_type` and `second_argument_type` (for a binary function). - * Those typedefs are used by function object adaptors such as `bind2nd`. - * The standard library provides two class templates, `unary_function` and - * `binary_function`, which define those typedefs and so can be used as - * base classes of adaptable function objects. - * - * Since C++11 the use of function object adaptors has been superseded by - * more powerful tools such as lambda expressions, `function<>`, and more - * powerful type deduction (using `auto` and `decltype`). The helpers for - * defining adaptable function objects are deprecated since C++11, and no - * longer part of the standard library since C++17. However, they are still - * defined and used by libstdc++ after C++17, as a conforming extension. - * - * @{ - */ -Comment: /** - * Helper for defining adaptable unary function objects. - * @deprecated Deprecated in C++11, no longer in the standard since C++17. - */ -Comment: /// @c argument_type is the type of the argument -Comment: /// @c result_type is the return type -Comment: /** - * Helper for defining adaptable binary function objects. - * @deprecated Deprecated in C++11, no longer in the standard since C++17. - */ -Comment: /// @c first_argument_type is the type of the first argument -Comment: /// @c second_argument_type is the type of the second argument -Comment: /// @c result_type is the return type -Comment: /** @} */ -Comment: // 20.3.2 arithmetic -Comment: /** @defgroup arithmetic_functors Arithmetic Function Object Classes - * @ingroup functors - * - * The library provides function objects for basic arithmetic operations. - * See the documentation for @link functors function objects @endlink - * for examples of their use. - * - * @{ - */ -Comment: // undefined -Comment: // Ignore warnings about unary_function and binary_function. -Comment: /// One of the @link arithmetic_functors math functors@endlink. -Comment: /// Returns the sum -Comment: /// One of the @link arithmetic_functors math functors@endlink. -Comment: /// One of the @link arithmetic_functors math functors@endlink. -Comment: /// One of the @link arithmetic_functors math functors@endlink. -Comment: /// One of the @link arithmetic_functors math functors@endlink. -Comment: /// One of the @link arithmetic_functors math functors@endlink. -Comment: /// One of the @link arithmetic_functors math functors@endlink. -Comment: /// One of the @link arithmetic_functors math functors@endlink. -Comment: /// One of the @link arithmetic_functors math functors@endlink. -Comment: /// One of the @link arithmetic_functors math functors@endlink. -Comment: /// One of the @link arithmetic_functors math functors@endlink. -Comment: /** @} */ -Comment: // 20.3.3 comparisons -Comment: /** @defgroup comparison_functors Comparison Classes - * @ingroup functors - * - * The library provides six wrapper functors for all the basic comparisons - * in C++, like @c <. - * - * @{ - */ -Comment: /// One of the @link comparison_functors comparison functors@endlink. -Comment: /// One of the @link comparison_functors comparison functors@endlink. -Comment: /// One of the @link comparison_functors comparison functors@endlink. -Comment: /// One of the @link comparison_functors comparison functors@endlink. -Comment: /// One of the @link comparison_functors comparison functors@endlink. -Comment: /// One of the @link comparison_functors comparison functors@endlink. -Comment: // Partial specialization of std::greater for pointers. -Comment: // Partial specialization of std::less for pointers. -Comment: // Partial specialization of std::greater_equal for pointers. -Comment: // Partial specialization of std::less_equal for pointers. -Comment: /// One of the @link comparison_functors comparison functors@endlink. -Comment: /// One of the @link comparison_functors comparison functors@endlink. -Comment: /// One of the @link comparison_functors comparison functors@endlink. -Comment: // True if there is no viable operator> member function. -Comment: // False if we can call T.operator>(U) -Comment: // True if there is no overloaded operator> for these operands. -Comment: // False if we can call operator>(T,U) -Comment: /// One of the @link comparison_functors comparison functors@endlink. -Comment: // True if there is no viable operator< member function. -Comment: // False if we can call T.operator<(U) -Comment: // True if there is no overloaded operator< for these operands. -Comment: // False if we can call operator<(T,U) -Comment: /// One of the @link comparison_functors comparison functors@endlink. -Comment: // True if there is no viable operator>= member function. -Comment: // False if we can call T.operator>=(U) -Comment: // True if there is no overloaded operator>= for these operands. -Comment: // False if we can call operator>=(T,U) -Comment: /// One of the @link comparison_functors comparison functors@endlink. -Comment: // True if there is no viable operator<= member function. -Comment: // False if we can call T.operator<=(U) -Comment: // True if there is no overloaded operator<= for these operands. -Comment: // False if we can call operator<=(T,U) -Comment: // C++14 -Comment: /** @} */ -Comment: // 20.3.4 logical operations -Comment: /** @defgroup logical_functors Boolean Operations Classes - * @ingroup functors - * - * The library provides function objects for the logical operations: - * `&&`, `||`, and `!`. - * - * @{ - */ -Comment: /// One of the @link logical_functors Boolean operations functors@endlink. -Comment: /// One of the @link logical_functors Boolean operations functors@endlink. -Comment: /// One of the @link logical_functors Boolean operations functors@endlink. -Comment: /// One of the @link logical_functors Boolean operations functors@endlink. -Comment: /// One of the @link logical_functors Boolean operations functors@endlink. -Comment: /// One of the @link logical_functors Boolean operations functors@endlink. -Comment: /** @} */ -Comment: // _GLIBCXX_RESOLVE_LIB_DEFECTS -Comment: // DR 660. Missing Bitwise Operations. -Comment: // C++14 -Comment: // 20.3.5 negators -Comment: /** @defgroup negators Negators - * @ingroup functors - * - * The function templates `not1` and `not2` are function object adaptors, - * which each take a predicate functor and wrap it in an instance of - * `unary_negate` or `binary_negate`, respectively. Those classes are - * functors whose `operator()` evaluates the wrapped predicate function - * and then returns the negation of the result. - * - * For example, given a vector of integers and a trivial predicate, - * \code - * struct IntGreaterThanThree - * : public std::unary_function - * { - * bool operator() (int x) const { return x > 3; } - * }; - * - * std::find_if (v.begin(), v.end(), not1(IntGreaterThanThree())); - * \endcode - * The call to `find_if` will locate the first index (i) of `v` for which - * `!(v[i] > 3)` is true. - * - * The not1/unary_negate combination works on predicates taking a single - * argument. The not2/binary_negate combination works on predicates taking - * two arguments. - * - * @deprecated Deprecated in C++17, no longer in the standard since C++20. - * Use `not_fn` instead. - * - * @{ - */ -Comment: /// One of the @link negators negation functors@endlink. -Comment: /// One of the @link negators negation functors@endlink. -Comment: /// One of the @link negators negation functors@endlink. -Comment: /// One of the @link negators negation functors@endlink. -Comment: /** @} */ -Comment: // 20.3.7 adaptors pointers functions -Comment: /** @defgroup pointer_adaptors Adaptors for pointers to functions - * @ingroup functors - * - * The advantage of function objects over pointers to functions is that - * the objects in the standard library declare nested typedefs describing - * their argument and result types with uniform names (e.g., `result_type` - * from the base classes `unary_function` and `binary_function`). - * Sometimes those typedefs are required, not just optional. - * - * Adaptors are provided to turn pointers to unary (single-argument) and - * binary (double-argument) functions into function objects. The - * long-winded functor `pointer_to_unary_function` is constructed with a - * function pointer `f`, and its `operator()` called with argument `x` - * returns `f(x)`. The functor `pointer_to_binary_function` does the same - * thing, but with a double-argument `f` and `operator()`. - * - * The function `ptr_fun` takes a pointer-to-function `f` and constructs - * an instance of the appropriate functor. - * - * @deprecated Deprecated in C++11, no longer in the standard since C++17. - * - * @{ - */ -Comment: /// One of the @link pointer_adaptors adaptors for function pointers@endlink. -Comment: /// One of the @link pointer_adaptors adaptors for function pointers@endlink. -Comment: /// One of the @link pointer_adaptors adaptors for function pointers@endlink. -Comment: /// One of the @link pointer_adaptors adaptors for function pointers@endlink. -Comment: /** @} */ -Comment: // Partial specialization, avoids confusing errors in e.g. std::set. -Comment: // 20.3.8 adaptors pointers members -Comment: /** @defgroup ptrmem_adaptors Adaptors for pointers to members - * @ingroup functors - * - * There are a total of 8 = 2^3 function objects in this family. - * (1) Member functions taking no arguments vs member functions taking - * one argument. - * (2) Call through pointer vs call through reference. - * (3) Const vs non-const member function. - * - * All of this complexity is in the function objects themselves. You can - * ignore it by using the helper function `mem_fun` and `mem_fun_ref`, - * which create whichever type of adaptor is appropriate. - * - * @deprecated Deprecated in C++11, no longer in the standard since C++17. - * Use `mem_fn` instead. - * - * @{ - */ -Comment: /// One of the @link ptrmem_adaptors adaptors for member pointers@endlink. -Comment: /// One of the @link ptrmem_adaptors adaptors for member pointers@endlink. -Comment: /// One of the @link ptrmem_adaptors adaptors for member pointers@endlink. -Comment: /// One of the @link ptrmem_adaptors adaptors for member pointers@endlink. -Comment: /// One of the @link ptrmem_adaptors adaptors for member pointers@endlink. -Comment: /// One of the @link ptrmem_adaptors adaptors for member pointers@endlink. -Comment: /// One of the @link ptrmem_adaptors adaptors for member pointers@endlink. -Comment: /// One of the @link ptrmem_adaptors adaptors for member pointers@endlink. -Comment: // Mem_fun adaptor helper functions. There are only two: -Comment: // mem_fun and mem_fun_ref. -Comment: /** @} */ -Comment: // namespace -Comment: // Functor implementations -*- C++ -*- -Comment: // Copyright (C) 2001-2023 Free Software Foundation, Inc. -Comment: // -Comment: // This file is part of the GNU ISO C++ Library. This library is free -Comment: // software; you can redistribute it and/or modify it under the -Comment: // terms of the GNU General Public License as published by the -Comment: // Free Software Foundation; either version 3, or (at your option) -Comment: // any later version. -Comment: // This library is distributed in the hope that it will be useful, -Comment: // but WITHOUT ANY WARRANTY; without even the implied warranty of -Comment: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -Comment: // GNU General Public License for more details. -Comment: // Under Section 7 of GPL version 3, you are granted additional -Comment: // permissions described in the GCC Runtime Library Exception, version -Comment: // 3.1, as published by the Free Software Foundation. -Comment: // You should have received a copy of the GNU General Public License and -Comment: // a copy of the GCC Runtime Library Exception along with this program; -Comment: // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -Comment: // . -Comment: /* - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1996-1998 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ -Comment: /** @file backward/binders.h - * This is an internal header file, included by other library headers. - * Do not attempt to use it directly. @headername{functional} - */ -Comment: // Suppress deprecated warning for this file. -Comment: // 20.3.6 binders -Comment: /** @defgroup binders Binder Classes - * @ingroup functors - * - * Binders turn functions/functors with two arguments into functors - * with a single argument, storing an argument to be applied later. - * For example, a variable @c B of type @c binder1st is constructed - * from a functor @c f and an argument @c x. Later, B's @c - * operator() is called with a single argument @c y. The return - * value is the value of @c f(x,y). @c B can be @a called with - * various arguments (y1, y2, ...) and will in turn call @c - * f(x,y1), @c f(x,y2), ... - * - * The function @c bind1st is provided to save some typing. It takes the - * function and an argument as parameters, and returns an instance of - * @c binder1st. - * - * The type @c binder2nd and its creator function @c bind2nd do the same - * thing, but the stored argument is passed as the second parameter instead - * of the first, e.g., @c bind2nd(std::minus(),1.3) will create a - * functor whose @c operator() accepts a floating-point number, subtracts - * 1.3 from it, and returns the result. (If @c bind1st had been used, - * the functor would perform 1.3 - x instead. - * - * Creator-wrapper functions like @c bind1st are intended to be used in - * calling algorithms. Their return values will be temporary objects. - * (The goal is to not require you to type names like - * @c std::binder1st> for declaring a variable to hold the - * return value from @c bind1st(std::plus(),5). - * - * These become more useful when combined with the composition functions. - * - * These functions are deprecated in C++11 and can be replaced by - * @c std::bind (or @c std::tr1::bind) which is more powerful and flexible, - * supporting functions with any number of arguments. Uses of @c bind1st - * can be replaced by @c std::bind(f, x, std::placeholders::_1) and - * @c bind2nd by @c std::bind(f, std::placeholders::_1, x). - * @{ - */ -Comment: /// One of the @link binders binder functors@endlink. -Comment: // _GLIBCXX_RESOLVE_LIB_DEFECTS -Comment: // 109. Missing binders for non-const sequence elements -Comment: /// One of the @link binders binder functors@endlink. -Comment: /// One of the @link binders binder functors@endlink. -Comment: // _GLIBCXX_RESOLVE_LIB_DEFECTS -Comment: // 109. Missing binders for non-const sequence elements -Comment: /// One of the @link binders binder functors@endlink. -Comment: /** @} */ -Comment: // namespace -Comment: /* _BACKWARD_BINDERS_H */ -Comment: /* _STL_FUNCTION_H */ -Comment: /// @cond undocumented -Comment: /** - * Derives from @c unary_function or @c binary_function, or perhaps - * nothing, depending on the number of arguments provided. The - * primary template is the basis case, which derives nothing. - */ -Comment: // Ignore warnings about unary_function and binary_function. -Comment: /// Derives from @c unary_function, as appropriate. -Comment: /// Derives from @c binary_function, as appropriate. -Comment: /// If we have found a result_type, extract it. -Comment: /** - * Base class for any function object that has a weak result type, as - * defined in 20.8.2 [func.require] of C++11. - */ -Comment: /// Retrieve the result type for a function type. -Comment: /// Retrieve the result type for a varargs function type. -Comment: /// Retrieve the result type for a function pointer. -Comment: /// Retrieve the result type for a varargs function pointer. -Comment: // Let _Weak_result_type_impl perform the real work. -Comment: // A pointer to member function has a weak result type. -Comment: // A pointer to data member doesn't have a weak result type. -Comment: /** - * Strip top-level cv-qualifiers from the function object and let - * _Weak_result_type_memfun perform the real work. - */ -Comment: // ! C++20 -Comment: /// @endcond -Comment: /** - * @brief Primary class template for reference_wrapper. - * @ingroup functors - */ -Comment: // _GLIBCXX_RESOLVE_LIB_DEFECTS -Comment: // 2993. reference_wrapper conversion from T&& -Comment: // 3041. Unnecessary decay in reference_wrapper -Comment: /// @relates reference_wrapper @{ -Comment: /// Denotes a reference should be taken to a variable. -Comment: /// Denotes a const reference should be taken to a variable. -Comment: /// std::ref overload to prevent wrapping a reference_wrapper -Comment: /// std::cref overload to prevent wrapping a reference_wrapper -Comment: /// @} -Comment: // namespace std -Comment: // C++11 -Comment: // _GLIBCXX_REFWRAP_H -Comment: // Range access functions for containers -*- C++ -*- -Comment: // Copyright (C) 2010-2023 Free Software Foundation, Inc. -Comment: // -Comment: // This file is part of the GNU ISO C++ Library. This library is free -Comment: // software; you can redistribute it and/or modify it under the -Comment: // terms of the GNU General Public License as published by the -Comment: // Free Software Foundation; either version 3, or (at your option) -Comment: // any later version. -Comment: // This library is distributed in the hope that it will be useful, -Comment: // but WITHOUT ANY WARRANTY; without even the implied warranty of -Comment: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -Comment: // GNU General Public License for more details. -Comment: // Under Section 7 of GPL version 3, you are granted additional -Comment: // permissions described in the GCC Runtime Library Exception, version -Comment: // 3.1, as published by the Free Software Foundation. -Comment: // You should have received a copy of the GNU General Public License and -Comment: // a copy of the GCC Runtime Library Exception along with this program; -Comment: // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -Comment: // . -Comment: /** @file bits/range_access.h - * This is an internal header file, included by other library headers. - * Do not attempt to use it directly. @headername{iterator} - */ -Comment: // common_type_t, make_signed_t -Comment: // reverse_iterator -Comment: /** - * @brief Return an iterator pointing to the first element of - * the container. - * @param __cont Container. - */ -Comment: /** - * @brief Return an iterator pointing to the first element of - * the const container. - * @param __cont Container. - */ -Comment: /** - * @brief Return an iterator pointing to one past the last element of - * the container. - * @param __cont Container. - */ -Comment: /** - * @brief Return an iterator pointing to one past the last element of - * the const container. - * @param __cont Container. - */ -Comment: /** - * @brief Return an iterator pointing to the first element of the array. - * @param __arr Array. - */ -Comment: /** - * @brief Return an iterator pointing to one past the last element - * of the array. - * @param __arr Array. - */ -Comment: // These overloads must be declared for cbegin and cend to use them. -Comment: /** - * @brief Return an iterator pointing to the first element of - * the const container. - * @param __cont Container. - */ -Comment: /** - * @brief Return an iterator pointing to one past the last element of - * the const container. - * @param __cont Container. - */ -Comment: /** - * @brief Return a reverse iterator pointing to the last element of - * the container. - * @param __cont Container. - */ -Comment: /** - * @brief Return a reverse iterator pointing to the last element of - * the const container. - * @param __cont Container. - */ -Comment: /** - * @brief Return a reverse iterator pointing one past the first element of - * the container. - * @param __cont Container. - */ -Comment: /** - * @brief Return a reverse iterator pointing one past the first element of - * the const container. - * @param __cont Container. - */ -Comment: /** - * @brief Return a reverse iterator pointing to the last element of - * the array. - * @param __arr Array. - */ -Comment: /** - * @brief Return a reverse iterator pointing one past the first element of - * the array. - * @param __arr Array. - */ -Comment: /** - * @brief Return a reverse iterator pointing to the last element of - * the initializer_list. - * @param __il initializer_list. - */ -Comment: /** - * @brief Return a reverse iterator pointing one past the first element of - * the initializer_list. - * @param __il initializer_list. - */ -Comment: /** - * @brief Return a reverse iterator pointing to the last element of - * the const container. - * @param __cont Container. - */ -Comment: /** - * @brief Return a reverse iterator pointing one past the first element of - * the const container. - * @param __cont Container. - */ -Comment: // C++14 -Comment: /** - * @brief Return the size of a container. - * @param __cont Container. - */ -Comment: /** - * @brief Return the size of an array. - */ -Comment: /** - * @brief Return whether a container is empty. - * @param __cont Container. - */ -Comment: /** - * @brief Return whether an array is empty (always false). - */ -Comment: /** - * @brief Return whether an initializer_list is empty. - * @param __il Initializer list. - */ -Comment: /** - * @brief Return the data pointer of a container. - * @param __cont Container. - */ -Comment: /** - * @brief Return the data pointer of a const container. - * @param __cont Container. - */ -Comment: /** - * @brief Return the data pointer of an array. - * @param __array Array. - */ -Comment: /** - * @brief Return the data pointer of an initializer list. - * @param __il Initializer list. - */ -Comment: // C++20 -Comment: // C++17 -Comment: // namespace -Comment: // C++11 -Comment: // _GLIBCXX_RANGE_ACCESS_H -Comment: // Vector implementation (out of line) -*- C++ -*- -Comment: // Copyright (C) 2001-2023 Free Software Foundation, Inc. -Comment: // -Comment: // This file is part of the GNU ISO C++ Library. This library is free -Comment: // software; you can redistribute it and/or modify it under the -Comment: // terms of the GNU General Public License as published by the -Comment: // Free Software Foundation; either version 3, or (at your option) -Comment: // any later version. -Comment: // This library is distributed in the hope that it will be useful, -Comment: // but WITHOUT ANY WARRANTY; without even the implied warranty of -Comment: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -Comment: // GNU General Public License for more details. -Comment: // Under Section 7 of GPL version 3, you are granted additional -Comment: // permissions described in the GCC Runtime Library Exception, version -Comment: // 3.1, as published by the Free Software Foundation. -Comment: // You should have received a copy of the GNU General Public License and -Comment: // a copy of the GCC Runtime Library Exception along with this program; -Comment: // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -Comment: // . -Comment: /* - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1996 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ -Comment: /** @file bits/vector.tcc - * This is an internal header file, included by other library headers. - * Do not attempt to use it directly. @headername{vector} - */ -Comment: // PR 106434 -Comment: // __x could be an existing element of this vector, so make a -Comment: // copy of it before _M_insert_aux moves elements around. -Comment: // replacement allocator cannot free existing storage -Comment: // We need to construct a temporary because something in __args... -Comment: // could alias one of the elements of the container and so we -Comment: // need to use it before _M_insert_aux moves elements around. -Comment: // The order of the three operations is dictated by the C++11 -Comment: // case, where the moves could alter a new element belonging -Comment: // to the existing vector. This is an issue only for callers -Comment: // taking the element by lvalue ref (see last bullet of C++11 -Comment: // [res.on.arguments]). -Comment: // Make local copies of these members because the compiler thinks -Comment: // the allocator can alter them if 'this' is globally reachable. -Comment: // See _M_realloc_insert above. -Comment: // Make local copies of these members because the compiler thinks -Comment: // the allocator can alter them if 'this' is globally reachable. -Comment: // Make local copies of these members because the compiler -Comment: // thinks the allocator can alter them if 'this' is globally -Comment: // reachable. -Comment: // vector -Comment: // namespace std -Comment: // namespace std -Comment: // C++11 -Comment: /* _VECTOR_TCC */ -Comment: // -*- C++ -*- -Comment: // Copyright (C) 2018-2023 Free Software Foundation, Inc. -Comment: // -Comment: // This file is part of the GNU ISO C++ Library. This library is free -Comment: // software; you can redistribute it and/or modify it under the -Comment: // terms of the GNU General Public License as published by the -Comment: // Free Software Foundation; either version 3, or (at your option) -Comment: // any later version. -Comment: // This library is distributed in the hope that it will be useful, -Comment: // but WITHOUT ANY WARRANTY; without even the implied warranty of -Comment: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -Comment: // GNU General Public License for more details. -Comment: // Under Section 7 of GPL version 3, you are granted additional -Comment: // permissions described in the GCC Runtime Library Exception, version -Comment: // 3.1, as published by the Free Software Foundation. -Comment: // You should have received a copy of the GNU General Public License and -Comment: // a copy of the GCC Runtime Library Exception along with this program; -Comment: // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -Comment: // . -Comment: /** @file include/bits/memory_resource.h - * This is an internal header file, included by other library headers. - * Do not attempt to use it directly. @headername{memory_resource} - */ -Comment: // operator new(size_t, void*) -Comment: // size_t, max_align_t, byte -Comment: // -*- C++ -*- forwarding header. -Comment: // Copyright (C) 1997-2023 Free Software Foundation, Inc. -Comment: // -Comment: // This file is part of the GNU ISO C++ Library. This library is free -Comment: // software; you can redistribute it and/or modify it under the -Comment: // terms of the GNU General Public License as published by the -Comment: // Free Software Foundation; either version 3, or (at your option) -Comment: // any later version. -Comment: // This library is distributed in the hope that it will be useful, -Comment: // but WITHOUT ANY WARRANTY; without even the implied warranty of -Comment: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -Comment: // GNU General Public License for more details. -Comment: // Under Section 7 of GPL version 3, you are granted additional -Comment: // permissions described in the GCC Runtime Library Exception, version -Comment: // 3.1, as published by the Free Software Foundation. -Comment: // You should have received a copy of the GNU General Public License and -Comment: // a copy of the GCC Runtime Library Exception along with this program; -Comment: // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -Comment: // . -Comment: /** @file cstddef - * This is a Standard C++ Library file. You should @c \#include this file - * in your programs, rather than any of the @a *.h implementation files. - * - * This is the C++ version of the Standard C Library header @c stddef.h, - * and its contents are (mostly) the same as that header, but are all - * contained in the namespace @c std (except for names which are defined - * as macros in C). - */ -Comment: // -Comment: // ISO C++ 14882: 18.1 Types -Comment: // -Comment: /*===---- stddef.h - Basic type definitions --------------------------------=== - * - * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. - * See https://llvm.org/LICENSE.txt for license information. - * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - * - *===-----------------------------------------------------------------------=== - */ -Comment: /* - * This header is designed to be included multiple times. If any of the __need_ - * macros are defined, then only that subset of interfaces are provided. This - * can be useful for POSIX headers that need to not expose all of stddef.h, but - * need to use some of its interfaces. Otherwise this header provides all of - * the expected interfaces. - * - * When clang modules are enabled, this header is a textual header to support - * the multiple include behavior. As such, it doesn't directly declare anything - * so that it doesn't add duplicate declarations to all of its includers' - * modules. - */ -Comment: /* ISO9899:2011 7.20 (C11 Annex K): Define rsize_t if __STDC_WANT_LIB_EXT1__ is - * enabled. */ -Comment: /* - * __stddef_null.h is special when building without modules: if __need_NULL is - * set, then it will unconditionally redefine NULL. To avoid stepping on client - * definitions of NULL, __need_NULL should only be set the first time this - * header is included, that is when __STDDEF_H is not defined. However, when - * building with modules, this header is a textual header and needs to - * unconditionally include __stdef_null.h to support multiple submodules - * exporting _Builtin_stddef.null. Take module SM with submodules A and B, whose - * headers both include stddef.h When SM.A builds, __STDDEF_H will be defined. - * When SM.B builds, the definition from SM.A will leak when building without - * local submodule visibility. stddef.h wouldn't include __stddef_null.h, and - * SM.B wouldn't import _Builtin_stddef.null, and SM.B's `export *` wouldn't - * export NULL as expected. When building with modules, always include - * __stddef_null.h so that everything works as expected. - */ -Comment: /* wint_t is provided by and not . It's here - * for compatibility, but must be explicitly requested. Therefore - * __need_wint_t is intentionally not defined here. */ -Comment: /*===---- __stddef_header_macro.h ------------------------------------------=== - * - * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. - * See https://llvm.org/LICENSE.txt for license information. - * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - * - *===-----------------------------------------------------------------------=== - */ -Comment: /*===---- __stddef_ptrdiff_t.h - Definition of ptrdiff_t -------------------=== - * - * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. - * See https://llvm.org/LICENSE.txt for license information. - * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - * - *===-----------------------------------------------------------------------=== - */ -Comment: /* - * When -fbuiltin-headers-in-system-modules is set this is a non-modular header - * and needs to behave as if it was textual. - */ -Comment: /* defined(__need_ptrdiff_t) */ -Comment: /*===---- __stddef_size_t.h - Definition of size_t -------------------------=== - * - * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. - * See https://llvm.org/LICENSE.txt for license information. - * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - * - *===-----------------------------------------------------------------------=== - */ -Comment: /* - * When -fbuiltin-headers-in-system-modules is set this is a non-modular header - * and needs to behave as if it was textual. - */ -Comment: /*defined(__need_size_t) */ -Comment: /* defined(__need_rsize_t) */ -Comment: /*===---- __stddef_wchar.h - Definition of wchar_t -------------------------=== - * - * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. - * See https://llvm.org/LICENSE.txt for license information. - * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - * - *===-----------------------------------------------------------------------=== - */ -Comment: /* defined(__need_wchar_t) */ -Comment: /*===---- __stddef_null.h - Definition of NULL -----------------------------=== - * - * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. - * See https://llvm.org/LICENSE.txt for license information. - * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - * - *===-----------------------------------------------------------------------=== - */ -Comment: /* linux/stddef.h will define NULL to 0. glibc (and other) headers then define - * __need_NULL and rely on stddef.h to redefine NULL to the correct value again. - * Modules don't support redefining macros like that, but support that pattern - * in the non-modules case. - */ -Comment: /* defined(__need_NULL) */ -Comment: /*===---- __stddef_nullptr_t.h - Definition of nullptr_t -------------------=== - * - * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. - * See https://llvm.org/LICENSE.txt for license information. - * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - * - *===-----------------------------------------------------------------------=== - */ -Comment: /* - * When -fbuiltin-headers-in-system-modules is set this is a non-modular header - * and needs to behave as if it was textual. - */ -Comment: /* defined(__need_nullptr_t) */ -Comment: /* defined(__need_unreachable) */ -Comment: /*===---- __stddef_max_align_t.h - Definition of max_align_t ---------------=== - * - * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. - * See https://llvm.org/LICENSE.txt for license information. - * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - * - *===-----------------------------------------------------------------------=== - */ -Comment: // Define 'max_align_t' to match the GCC definition. -Comment: /* defined(__need_max_align_t) */ -Comment: /*===---- __stddef_offsetof.h - Definition of offsetof ---------------------=== - * - * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. - * See https://llvm.org/LICENSE.txt for license information. - * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - * - *===-----------------------------------------------------------------------=== - */ -Comment: /* - * When -fbuiltin-headers-in-system-modules is set this is a non-modular header - * and needs to behave as if it was textual. - */ -Comment: /* defined(__need_offsetof) */ -Comment: /* Some C libraries expect to see a wint_t here. Others (notably MinGW) will use -__WINT_TYPE__ directly; accommodate both by requiring __need_wint_t */ -Comment: /* __need_wint_t */ -Comment: /* __MVS__ */ -Comment: // We handle size_t, ptrdiff_t, and nullptr_t in c++config.h. -Comment: // C++11 -Comment: /// std::byte -Comment: // namespace std -Comment: // C++17 -Comment: // extern "C++" -Comment: // _GLIBCXX_CSTDDEF -Comment: // __throw_bad_array_new_length -Comment: // allocator_arg_t, __use_alloc -Comment: // Uses-allocator Construction -*- C++ -*- -Comment: // Copyright (C) 2010-2023 Free Software Foundation, Inc. -Comment: // -Comment: // This file is part of the GNU ISO C++ Library. This library is free -Comment: // software; you can redistribute it and/or modify it under the -Comment: // terms of the GNU General Public License as published by the -Comment: // Free Software Foundation; either version 3, or (at your option) -Comment: // any later version. -Comment: // This library is distributed in the hope that it will be useful, -Comment: // but WITHOUT ANY WARRANTY; without even the implied warranty of -Comment: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -Comment: // GNU General Public License for more details. -Comment: // Under Section 7 of GPL version 3, you are granted additional -Comment: // permissions described in the GCC Runtime Library Exception, version -Comment: // 3.1, as published by the Free Software Foundation. -Comment: // You should have received a copy of the GNU General Public License and -Comment: // a copy of the GCC Runtime Library Exception along with this program; -Comment: // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -Comment: // . -Comment: /** @file include/bits/uses_allocator_args.h - * This is an internal header file, included by other library headers. - * Do not attempt to use it directly. @headername{memory} - */ -Comment: /// @cond undocumented -Comment: // This is used for std::experimental::erased_type from Library Fundamentals. -Comment: // This also supports the "type-erased allocator" protocol from the -Comment: // Library Fundamentals TS, where allocator_type is erased_type. -Comment: // The second condition will always be false for types not using the TS. -Comment: /// [allocator.tag] -Comment: /// [allocator.uses.trait] -Comment: // _GLIBCXX_RESOLVE_LIB_DEFECTS -Comment: // 2586. Wrong value category used in scoped_allocator_adaptor::construct -Comment: // C++17 -Comment: // C++14 -Comment: // C++14 -Comment: /// @endcond -Comment: // namespace std -Comment: // uninitialized_construct_using_alloc -Comment: // Utility functions for uses-allocator construction -*- C++ -*- -Comment: // Copyright (C) 2019-2023 Free Software Foundation, Inc. -Comment: // -Comment: // This file is part of the GNU ISO C++ Library. This library is free -Comment: // software; you can redistribute it and/or modify it under the -Comment: // terms of the GNU General Public License as published by the -Comment: // Free Software Foundation; either version 3, or (at your option) -Comment: // any later version. -Comment: // This library is distributed in the hope that it will be useful, -Comment: // but WITHOUT ANY WARRANTY; without even the implied warranty of -Comment: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -Comment: // GNU General Public License for more details. -Comment: // Under Section 7 of GPL version 3, you are granted additional -Comment: // permissions described in the GCC Runtime Library Exception, version -Comment: // 3.1, as published by the Free Software Foundation. -Comment: // You should have received a copy of the GNU General Public License and -Comment: // a copy of the GCC Runtime Library Exception along with this program; -Comment: // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -Comment: // . -Comment: /** @file include/bits/uses_allocator_args.h - * This is an internal header file, included by other library headers. - * Do not attempt to use it directly. @headername{memory} - */ -Comment: // for placement operator new -Comment: // for tuple, make_tuple, make_from_tuple -Comment: // -*- C++ -*- -Comment: // Copyright (C) 2007-2023 Free Software Foundation, Inc. -Comment: // -Comment: // This file is part of the GNU ISO C++ Library. This library is free -Comment: // software; you can redistribute it and/or modify it under the -Comment: // terms of the GNU General Public License as published by the -Comment: // Free Software Foundation; either version 3, or (at your option) -Comment: // any later version. -Comment: // This library is distributed in the hope that it will be useful, -Comment: // but WITHOUT ANY WARRANTY; without even the implied warranty of -Comment: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -Comment: // GNU General Public License for more details. -Comment: // Under Section 7 of GPL version 3, you are granted additional -Comment: // permissions described in the GCC Runtime Library Exception, version -Comment: // 3.1, as published by the Free Software Foundation. -Comment: // You should have received a copy of the GNU General Public License and -Comment: // a copy of the GCC Runtime Library Exception along with this program; -Comment: // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -Comment: // . -Comment: /** @file include/tuple - * This is a Standard C++ Library header. - */ -Comment: // for std::pair -Comment: // for std::allocator_arg_t -Comment: // for std::tuple_size etc. -Comment: // for std::__invoke -Comment: // for std::ranges::subrange -Comment: // Utilities for representing and manipulating ranges -*- C++ -*- -Comment: // Copyright (C) 2019-2023 Free Software Foundation, Inc. -Comment: // -Comment: // This file is part of the GNU ISO C++ Library. This library is free -Comment: // software; you can redistribute it and/or modify it under the -Comment: // terms of the GNU General Public License as published by the -Comment: // Free Software Foundation; either version 3, or (at your option) -Comment: // any later version. -Comment: // This library is distributed in the hope that it will be useful, -Comment: // but WITHOUT ANY WARRANTY; without even the implied warranty of -Comment: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -Comment: // GNU General Public License for more details. -Comment: // Under Section 7 of GPL version 3, you are granted additional -Comment: // permissions described in the GCC Runtime Library Exception, version -Comment: // 3.1, as published by the Free Software Foundation. -Comment: // You should have received a copy of the GNU General Public License and -Comment: // a copy of the GCC Runtime Library Exception along with this program; -Comment: // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -Comment: // . -Comment: /** @file bits/ranges_util.h - * This is an internal header file, included by other library headers. - * Do not attempt to use it directly. @headername{ranges} - */ -Comment: // Core concepts and definitions for -*- C++ -*- -Comment: // Copyright (C) 2019-2023 Free Software Foundation, Inc. -Comment: // -Comment: // This file is part of the GNU ISO C++ Library. This library is free -Comment: // software; you can redistribute it and/or modify it under the -Comment: // terms of the GNU General Public License as published by the -Comment: // Free Software Foundation; either version 3, or (at your option) -Comment: // any later version. -Comment: // This library is distributed in the hope that it will be useful, -Comment: // but WITHOUT ANY WARRANTY; without even the implied warranty of -Comment: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -Comment: // GNU General Public License for more details. -Comment: // Under Section 7 of GPL version 3, you are granted additional -Comment: // permissions described in the GCC Runtime Library Exception, version -Comment: // 3.1, as published by the Free Software Foundation. -Comment: // You should have received a copy of the GNU General Public License and -Comment: // a copy of the GCC Runtime Library Exception along with this program; -Comment: // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -Comment: // . -Comment: /** @file bits/ranges_base.h - * This is an internal header file, included by other library headers. - * Do not attempt to use it directly. @headername{ranges} - */ -Comment: // -*- C++ -*- -Comment: // Copyright (C) 2019-2023 Free Software Foundation, Inc. -Comment: // -Comment: // This file is part of the GNU ISO C++ Library. This library is free -Comment: // software; you can redistribute it and/or modify it under the -Comment: // terms of the GNU General Public License as published by the -Comment: // Free Software Foundation; either version 3, or (at your option) -Comment: // any later version. -Comment: // This library is distributed in the hope that it will be useful, -Comment: // but WITHOUT ANY WARRANTY; without even the implied warranty of -Comment: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -Comment: // GNU General Public License for more details. -Comment: // Under Section 7 of GPL version 3, you are granted additional -Comment: // permissions described in the GCC Runtime Library Exception, version -Comment: // 3.1, as published by the Free Software Foundation. -Comment: // You should have received a copy of the GNU General Public License and -Comment: // a copy of the GCC Runtime Library Exception along with this program; -Comment: // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -Comment: // . -Comment: /** @file bits/max_size_type.h - * This is an internal header file, included by other library headers. - * Do not attempt to use it directly. @headername{iterator} - */ -Comment: // -*- C++ -*- -Comment: // Copyright (C) 2019-2023 Free Software Foundation, Inc. -Comment: // -Comment: // This file is part of the GNU ISO C++ Library. This library is free -Comment: // software; you can redistribute it and/or modify it under the -Comment: // terms of the GNU General Public License as published by the -Comment: // Free Software Foundation; either version 3, or (at your option) -Comment: // any later version. -Comment: // This library is distributed in the hope that it will be useful, -Comment: // but WITHOUT ANY WARRANTY; without even the implied warranty of -Comment: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -Comment: // GNU General Public License for more details. -Comment: // Under Section 7 of GPL version 3, you are granted additional -Comment: // permissions described in the GCC Runtime Library Exception, version -Comment: // 3.1, as published by the Free Software Foundation. -Comment: // You should have received a copy of the GNU General Public License and -Comment: // a copy of the GCC Runtime Library Exception along with this program; -Comment: // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -Comment: // . -Comment: /** @file include/numbers - * This is a Standard C++ Library header. - */ -Comment: /** @defgroup math_constants Mathematical constants - * @ingroup numerics - * @{ - */ -Comment: /// Namespace for mathematical constants -Comment: /// @cond undocumented -Comment: /// @endcond -Comment: /// e -Comment: /// log_2 e -Comment: /// log_10 e -Comment: /// pi -Comment: /// 1/pi -Comment: /// 1/sqrt(pi) -Comment: /// log_e 2 -Comment: /// log_e 10 -Comment: /// sqrt(2) -Comment: /// sqrt(3) -Comment: /// 1/sqrt(3) -Comment: /// The Euler-Mascheroni constant -Comment: /// The golden ratio, (1+sqrt(5))/2 -Comment: /* e */ -Comment: /* log_2 e */ -Comment: /* log_10 e */ -Comment: /* pi */ -Comment: /* 1/pi */ -Comment: /* 1/sqrt(pi) */ -Comment: /* log_e 2 */ -Comment: /* log_e 10 */ -Comment: /* sqrt(2) */ -Comment: /* sqrt(3) */ -Comment: /* 1/sqrt(3) */ -Comment: /* The Euler-Mascheroni constant */ -Comment: /* The golden ratio, (1+sqrt(5))/2 */ -Comment: // USE_FLOAT128 -Comment: // namespace numbers -Comment: /// @} -Comment: // namespace std -Comment: // C++20 -Comment: // _GLIBCXX_NUMBERS -Comment: // This header implements unsigned and signed integer-class types (as per -Comment: // [iterator.concept.winc]) that are one bit wider than the widest supported -Comment: // integer type. -Comment: // -Comment: // The set of integer types we consider includes __int128 and unsigned __int128 -Comment: // (when they exist), even though they are really integer types only in GNU -Comment: // mode. This is to obtain a consistent ABI for these integer-class types -Comment: // across strict mode and GNU mode. -Comment: // When both operands are below this threshold then the -Comment: // multiplication can be safely computed in the base precision. -Comment: // Otherwise, perform the multiplication in four steps, by -Comment: // decomposing the LHS and the RHS into 2*x+a and 2*y+b, -Comment: // respectively, and computing 4*x*y + 2*x*b + 2*y*a + a*b. -Comment: // The non-trivial case: the dividend has its MSB set and the -Comment: // divisor doesn't. In this case we compute ((LHS/2)/RHS)*2 -Comment: // in the base precision. This quantity is either the true -Comment: // quotient or one less than the true quotient. -Comment: // Arithmetic right shift. -Comment: // namespace __detail -Comment: // namespace ranges -Comment: // namespace -Comment: // C++20 && library concepts -Comment: // _GLIBCXX_MAX_SIZE_TYPE_H -Comment: // Part of the constraints of ranges::borrowed_range -Comment: // namespace __detail -Comment: // Poison pills so that unqualified lookup doesn't find std::end. -Comment: // std::reverse_iterator copy-initializes its member. -Comment: // std::reverse_iterator copy-initializes its member. -Comment: // _GLIBCXX_RESOLVE_LIB_DEFECTS -Comment: // 3403. Domain of ranges::ssize(E) doesn't match ranges::size(E) -Comment: // Return the wider of ptrdiff_t and make-signed-like-t<__size_type>. -Comment: // For strict-ansi modes integral<__int128> is false -Comment: // Must be one of __max_diff_type or __max_size_type. -Comment: // namespace __cust_access -Comment: /// [range.range] The range concept. -Comment: /// [range.range] The borrowed_range concept. -Comment: /// [range.sized] The sized_range concept. -Comment: // defined in -Comment: // not defined -Comment: // Returns true iff _Tp has exactly one public base class that's a -Comment: // specialization of view_interface. -Comment: // namespace __detail -Comment: /// [range.view] The ranges::view_base type. -Comment: /// [range.view] The ranges::enable_view boolean. -Comment: /// [range.view] The ranges::view concept. -Comment: // [range.refinements] -Comment: /// A range for which ranges::begin returns an output iterator. -Comment: /// A range for which ranges::begin returns an input iterator. -Comment: /// A range for which ranges::begin returns a forward iterator. -Comment: /// A range for which ranges::begin returns a bidirectional iterator. -Comment: /// A range for which ranges::begin returns a random access iterator. -Comment: /// A range for which ranges::begin returns a contiguous iterator. -Comment: /// A range for which ranges::begin and ranges::end return the same type. -Comment: // If _To is an lvalue-reference, return const _Tp&, otherwise const _Tp&&. -Comment: // namespace __cust_access -Comment: // namespace __detail -Comment: /// A range which can be safely converted to a view. -Comment: // [range.iter.ops] range iterator operations -Comment: // cannot decrement a non-bidirectional iterator -Comment: // n and bound must not lead in opposite directions: -Comment: // cannot decrement a non-bidirectional iterator -Comment: /// Type returned by algorithms instead of a dangling iterator or subrange. -Comment: // namespace ranges -Comment: // namespace std -Comment: // library concepts -Comment: // C++20 -Comment: // _GLIBCXX_RANGES_BASE_H -Comment: // C++20 24.5 [range.utility] Range utilities -Comment: // namespace __detail -Comment: /// The ranges::view_interface class template -Comment: // not defined -Comment: // namespace __detail -Comment: // defined in -Comment: /// The ranges::subrange class template -Comment: // Needs to inspect _S_store_size. -Comment: // _GLIBCXX_RESOLVE_LIB_DEFECTS -Comment: // 3433. subrange::advance(n) has UB when n < 0 -Comment: // namespace ranges -Comment: // The following ranges algorithms are used by , and are defined here -Comment: // so that can avoid including all of . -Comment: // namespace ranges -Comment: // namespace std -Comment: // library concepts -Comment: // C++20 -Comment: // _RANGES_UTIL_H -Comment: /** - * @addtogroup utilities - * @{ - */ -Comment: // Using EBO for elements that are tuples causes ambiguous base errors. -Comment: // Use the Empty Base-class Optimization for empty, non-final types. -Comment: /** - * Contains the actual implementation of the @c tuple template, stored - * as a recursive inheritance hierarchy from the first element (most - * derived class) to the last (least derived class). The @c Idx - * parameter gives the 0-based index of the element stored at this - * point in the hierarchy; we use it to implement a constant-time - * get() operation. - */ -Comment: /** - * Recursive tuple implementation. Here we store the @c Head element - * and derive from a @c Tuple_impl containing the remaining elements - * (which contains the @c Tail). - */ -Comment: // _GLIBCXX_RESOLVE_LIB_DEFECTS -Comment: // 2729. Missing SFINAE on std::pair::operator= -Comment: // C++23 -Comment: // C++23 -Comment: // C++23 -Comment: // C++23 -Comment: // Basis case of inheritance recursion. -Comment: // _GLIBCXX_RESOLVE_LIB_DEFECTS -Comment: // 2729. Missing SFINAE on std::pair::operator= -Comment: // C++23 -Comment: // C++23 -Comment: // C++23 -Comment: // C++23 -Comment: // Concept utility functions, reused in conditionally-explicit -Comment: // constructors. -Comment: // Constraint for a non-explicit constructor. -Comment: // True iff each Ti in _Types... can be constructed from Ui in _UTypes... -Comment: // and every Ui is implicitly convertible to Ti. -Comment: // Constraint for a non-explicit constructor. -Comment: // True iff each Ti in _Types... can be constructed from Ui in _UTypes... -Comment: // but not every Ui is implicitly convertible to Ti. -Comment: // Partial specialization used when a required precondition isn't met, -Comment: // e.g. when sizeof...(_Types) != sizeof...(_UTypes). -Comment: /// Primary class template, tuple -Comment: // Constraint for non-explicit default constructor -Comment: // Constraint for explicit default constructor -Comment: // Constraint for non-explicit constructors -Comment: // Constraint for non-explicit constructors -Comment: // Condition for noexcept-specifier of an assignment operator. -Comment: // Condition for noexcept-specifier of a constructor. -Comment: // Constraint for tuple(_UTypes&&...) where sizeof...(_UTypes) == 1. -Comment: // Constraint for tuple(_UTypes&&...) where sizeof...(_UTypes) > 1. -Comment: /* Constraint for constructors with a tuple parameter ensures - * that the constructor is only viable when it would not interfere with - * tuple(UTypes&&...) or tuple(const tuple&) or tuple(tuple&&). - * Such constructors are only viable if: - * either sizeof...(Types) != 1, - * or (when Types... expands to T and UTypes... expands to U) - * is_convertible_v, is_constructible_v, - * and is_same_v are all false. - */ -Comment: // If TUPLE is convertible to the single element in *this, -Comment: // then TUPLE should match tuple(UTypes&&...) instead. -Comment: // If TUPLE and *this each have a single element of the same type, -Comment: // then TUPLE should match a copy/move constructor instead. -Comment: // Return true iff sizeof...(Types) == 1 && tuple_size_v == 1 -Comment: // and the single element in Types can be initialized from TUPLE, -Comment: // or is the same type as tuple_element_t<0, TUPLE>. -Comment: // C++23 -Comment: // C++23 -Comment: // Allocator-extended constructors. -Comment: // C++23 -Comment: // tuple assignment -Comment: // C++23 -Comment: // tuple swap -Comment: // C++23 -Comment: // Explicit specialization, zero-element tuple. -Comment: /* no-op */ -Comment: // We need the default since we're going to define no-op -Comment: // allocator constructors. -Comment: // No-op allocator constructors. -Comment: /// Partial specialization, 2-element tuple. -Comment: /// Includes construction and assignment from a pair. -Comment: // Constraint for non-explicit default constructor -Comment: // Constraint for explicit default constructor -Comment: // Constraint for non-explicit constructors -Comment: // Constraint for non-explicit constructors -Comment: // C++23 -Comment: // C++23 -Comment: // C++23 -Comment: // Allocator-extended constructors. -Comment: // C++23 -Comment: // C++23 -Comment: // Tuple assignment. -Comment: // C++23 -Comment: // C++23 -Comment: // C++23 -Comment: /// class tuple_size -Comment: /// Trait to get the Ith element type from a tuple. -Comment: // Deleted overload to improve diagnostics for invalid indices -Comment: /// Return a reference to the ith element of a tuple. -Comment: /// Return a const reference to the ith element of a const tuple. -Comment: /// Return an rvalue reference to the ith element of a tuple rvalue. -Comment: /// Return a const rvalue reference to the ith element of a const tuple rvalue. -Comment: /// @cond undocumented -Comment: // Deleted overload chosen for invalid indices. -Comment: /// @endcond -Comment: /// Return a reference to the unique element of type _Tp of a tuple. -Comment: /// Return a reference to the unique element of type _Tp of a tuple rvalue. -Comment: /// Return a const reference to the unique element of type _Tp of a tuple. -Comment: /// Return a const reference to the unique element of type _Tp of -Comment: /// a const tuple rvalue. -Comment: // This class performs the comparison operations on tuples -Comment: // three_way_comparison -Comment: // NB: DR 705. -Comment: /// Create a tuple containing copies of the arguments -Comment: // _GLIBCXX_RESOLVE_LIB_DEFECTS -Comment: // 2275. Why is forward_as_tuple not constexpr? -Comment: /// Create a tuple of lvalue or rvalue references to the arguments -Comment: // Declarations of std::array and its std::get overloads, so that -Comment: // std::tuple_cat can use them if is included before . -Comment: /// @cond undocumented -Comment: // Returns the std::tuple equivalent of a tuple-like type. -Comment: // Combines several std::tuple's into a single one. -Comment: // Computes the result type of tuple_cat given a set of tuple-like types. -Comment: // Helper to determine the index set for the first tuple-like -Comment: // type of a given set. -Comment: // Performs the actual concatenation by step-wise expanding tuple-like -Comment: // objects into the elements, which are finally forwarded into the -Comment: // result tuple. -Comment: /// @endcond -Comment: /// Create a `tuple` containing all elements from multiple tuple-like objects -Comment: // _GLIBCXX_RESOLVE_LIB_DEFECTS -Comment: // 2301. Why is tie not constexpr? -Comment: /// Return a tuple of lvalue references bound to the arguments -Comment: /// Exchange the values of two tuples -Comment: // c++1z or gnu++11 -Comment: // Constrained free swap overload, see p0185r1 -Comment: // C++23 -Comment: // c++1z or gnu++11 -Comment: /// Exchange the values of two const tuples (if const elements can be swapped) -Comment: // A class (and instance) which can be used in 'tie' when an element -Comment: // of a tuple is not required. -Comment: // _GLIBCXX14_CONSTEXPR -Comment: // 2933. PR for LWG 2773 could be clearer -Comment: // _GLIBCXX_RESOLVE_LIB_DEFECTS -Comment: // 2773. Making std::ignore constexpr -Comment: /** Used with `std::tie` to ignore an element of a tuple - * - * When using `std::tie` to assign the elements of a tuple to variables, - * unwanted elements can be ignored by using `std::ignore`. For example: - * - * ``` - * int x, y; - * std::tie(x, std::ignore, y) = std::make_tuple(1, 2, 3); - * ``` - * - * This assignment will perform `x=1; std::ignore=2; y=3;` which results - * in the second element being ignored. - * - * @since C++11 - */ -Comment: /// Partial specialization for tuples -Comment: // See stl_pair.h... -Comment: /** "piecewise construction" using a tuple of arguments for each member. - * - * @param __first Arguments for the first member of the pair. - * @param __second Arguments for the second member of the pair. - * - * The elements of each tuple will be used as the constructor arguments - * for the data members of the pair. - */ -Comment: // Unpack a std::tuple into a type trait and use its value. -Comment: // For cv std::tuple<_Up> the result is _Trait<_Tp, cv _Up...>::value. -Comment: // For cv std::tuple<_Up>& the result is _Trait<_Tp, cv _Up&...>::value. -Comment: // Otherwise the result is false (because we don't know if std::get throws). -Comment: // C++17 -Comment: // C++23 -Comment: /// @} -Comment: // namespace std -Comment: // C++11 -Comment: // _GLIBCXX_TUPLE -Comment: // construct_at -Comment: // pair -Comment: /** @addtogroup allocators - * @{ - */ -Comment: // Not specified by C++20, used internally -Comment: // C++23 -Comment: // _GLIBCXX_RESOLVE_LIB_DEFECTS -Comment: // 3527. uses_allocator_construction_args handles rvalue pairs -Comment: // of rvalue references incorrectly -Comment: // C++23 -Comment: /// @} -Comment: // namespace std -Comment: // C++20 -Comment: // _USES_ALLOCATOR_ARGS -Comment: // __int_traits -Comment: /// Class memory_resource -Comment: /** - * @ingroup pmr - * @headerfile memory_resource - * @since C++17 - */ -Comment: // key function -Comment: // C++17 23.12.3 Class template polymorphic_allocator -Comment: /// Class template polymorphic_allocator -Comment: /** - * @ingroup pmr - * @headerfile memory_resource - * @since C++17 - */ -Comment: // _GLIBCXX_RESOLVE_LIB_DEFECTS -Comment: // 2975. Missing case for pair construction in polymorphic allocators -Comment: // C++2a -Comment: // make_obj_using_allocator -Comment: // _GLIBCXX_RESOLVE_LIB_DEFECTS -Comment: // 3683. operator== for polymorphic_allocator cannot deduce template arg -Comment: // namespace pmr -Comment: /// Partial specialization for std::pmr::polymorphic_allocator -Comment: /// The allocator type -Comment: /// The allocated type -Comment: /// The allocator's pointer type. -Comment: /// The allocator's const pointer type. -Comment: /// The allocator's void pointer type. -Comment: /// The allocator's const void pointer type. -Comment: /// The allocator's difference type -Comment: /// The allocator's size type -Comment: /** @{ - * A `polymorphic_allocator` does not propagate when a - * container is copied, moved, or swapped. - */ -Comment: /// @} -Comment: /// Whether all instances of the allocator type compare equal. -Comment: /** - * @brief Allocate memory. - * @param __a An allocator. - * @param __n The number of objects to allocate space for. - * - * Calls `a.allocate(n)`. - */ -Comment: /** - * @brief Allocate memory. - * @param __a An allocator. - * @param __n The number of objects to allocate space for. - * @return Memory of suitable size and alignment for `n` objects - * of type `value_type`. - * - * The third parameter is ignored.. - * - * Returns `a.allocate(n)`. - */ -Comment: /** - * @brief Deallocate memory. - * @param __a An allocator. - * @param __p Pointer to the memory to deallocate. - * @param __n The number of objects space was allocated for. - * - * Calls `a.deallocate(p, n)`. - */ -Comment: /** - * @brief Construct an object of type `_Up` - * @param __a An allocator. - * @param __p Pointer to memory of suitable size and alignment for - * an object of type `_Up`. - * @param __args Constructor arguments. - * - * Calls `__a.construct(__p, std::forward<_Args>(__args)...)` - * in C++11, C++14 and C++17. Changed in C++20 to call - * `std::construct_at(__p, std::forward<_Args>(__args)...)` instead. - */ -Comment: /** - * @brief Destroy an object of type `_Up` - * @param __a An allocator. - * @param __p Pointer to the object to destroy - * - * Calls `p->_Up()`. - */ -Comment: /** - * @brief The maximum supported allocation size - * @return `numeric_limits::max() / sizeof(value_type)` - */ -Comment: // namespace std -Comment: // C++17 -Comment: // _GLIBCXX_MEMORY_RESOURCE_H -Comment: // namespace pmr -Comment: // namespace std -Comment: // C++17 -Comment: // namespace std -Comment: // C++20 -Comment: /* _GLIBCXX_VECTOR */ -# ifndef _GLIBCXX_VECTOR # define _GLIBCXX_VECTOR 1 # pragma GCC system_header # include < bits / requires_hosted . h > # include < bits / stl_algobase . h > # include < bits / allocator . h > # include < bits / stl_construct . h > # include < bits / stl_uninitialized . h > # include < bits / stl_vector . h > # include < bits / stl_bvector . h > # include < bits / refwrap . h > # include < bits / range_access . h > # ifndef _GLIBCXX_EXPORT_TEMPLATE # include < bits / vector . tcc > # endif # ifdef _GLIBCXX_DEBUG # include < debug / vector > # endif # if __cplusplus >= 201703L # include < bits / memory_resource . h > namespace std _GLIBCXX_VISIBILITY ( default ) { _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace pmr { template < typename _Tp > using vector = std :: vector < _Tp , polymorphic_allocator < _Tp >> ; } # ifdef _GLIBCXX_DEBUG namespace _GLIBCXX_STD_C :: pmr { template < typename _Tp > using vector = _GLIBCXX_STD_C :: vector < _Tp , std :: pmr :: polymorphic_allocator < _Tp >> ; } # endif _GLIBCXX_END_NAMESPACE_VERSION } # endif # if __cplusplus > 201703L namespace std _GLIBCXX_VISIBILITY ( default ) { _GLIBCXX_BEGIN_NAMESPACE_VERSION # define __cpp_lib_erase_if 202002L template < typename _Tp , typename _Alloc , typename _Predicate > _GLIBCXX20_CONSTEXPR inline typename vector < _Tp , _Alloc > :: size_type erase_if ( vector < _Tp , _Alloc > & __cont , _Predicate __pred ) { using namespace __gnu_cxx ; _GLIBCXX_STD_C :: vector < _Tp , _Alloc > & __ucont = __cont ; const auto __osz = __cont . size ( ) ; const auto __end = __ucont . end ( ) ; auto __removed = std :: __remove_if ( __ucont . begin ( ) , __end , __ops :: __pred_iter ( std :: ref ( __pred ) ) ) ; if ( __removed != __end ) { __cont . erase ( __niter_wrap ( __cont . begin ( ) , __removed ) , __cont . end ( ) ) ; return __osz - __cont . size ( ) ; } return 0 ; } template < typename _Tp , typename _Alloc , typename _Up > _GLIBCXX20_CONSTEXPR inline typename vector < _Tp , _Alloc > :: size_type erase ( vector < _Tp , _Alloc > & __cont , const _Up & __value ) { using namespace __gnu_cxx ; _GLIBCXX_STD_C :: vector < _Tp , _Alloc > & __ucont = __cont ; const auto __osz = __cont . size ( ) ; const auto __end = __ucont . end ( ) ; auto __removed = std :: __remove_if ( __ucont . begin ( ) , __end , __ops :: __iter_equals_val ( __value ) ) ; if ( __removed != __end ) { __cont . erase ( __niter_wrap ( __cont . begin ( ) , __removed ) , __cont . end ( ) ) ; return __osz - __cont . size ( ) ; } return 0 ; } _GLIBCXX_END_NAMESPACE_VERSION } # endif # endif \ No newline at end of file diff --git a/docs/clang/Diagnostic.md b/docs/clang/Diagnostic.md deleted file mode 100644 index e69de29b..00000000 diff --git a/docs/clang/Preprocessor.md b/docs/clang/Preprocessor.md deleted file mode 100644 index 2bc83554..00000000 --- a/docs/clang/Preprocessor.md +++ /dev/null @@ -1,59 +0,0 @@ - - - -`Preprocessor`就是负责处理 C++ 预处理过程的类。 - - -```cpp -using namespace clang; -class Callback : public clang::PPCallbacks { -public: - Preprocessor& pp; - SourceRange last; - Callback(Preprocessor& pp) : pp(pp) {} - /// Called by Preprocessor::HandleMacroExpandedIdentifier when a - /// macro invocation is found. - void MacroExpands(const Token& MacroNameTok, - const MacroDefinition& MD, - SourceRange Range, - const MacroArgs* Args) override { - auto name = MacroNameTok.getIdentifierInfo()->getName(); - if(name.starts_with("__")) - return; - llvm::outs() << "MacroExpands: " << name; - if(MD.getMacroInfo()->isFunctionLike()) { - llvm::outs() << "("; - int len = Args->getNumMacroArguments(); - for(auto i = 0; i < len; i++) { - auto arg = Args->getUnexpArgument(i); - auto len2 = Args->getArgLength(arg); - for(auto j = 0; j < len2; j++) { - llvm::outs() << pp.getSpelling(*(arg + j)); - } - if(i < len - 1) - llvm::outs() << ", "; - } - llvm::outs() << ")"; - } - llvm::outs() << "\n"; - auto& m = pp.getSourceManager(); - auto x = m.getExpansionRange(Range); - // auto z = m.getImmediateExpansionRange(x.getBegin()); - auto text = Lexer::getSourceText(x, m, pp.getLangOpts()); - llvm::outs() << text << "\n"; - } - /// Hook called whenever a macro definition is seen. - void MacroDefined(const Token& MacroNameTok, const MacroDirective* MD) override { - auto name = MacroNameTok.getIdentifierInfo()->getName(); - if(name.starts_with("__")) - return; - // llvm::outs() << "MacroDefined: " << name << "\n"; - } -} -``` - -```cpp -// must be after BeginSourceFile -auto& preprocessor = instance->getPreprocessor(); -preprocessor.addPPCallbacks(std::make_unique(preprocessor)); -``` \ No newline at end of file diff --git a/docs/clang/README.md b/docs/clang/README.md deleted file mode 100644 index 8b7223dc..00000000 --- a/docs/clang/README.md +++ /dev/null @@ -1,202 +0,0 @@ -在编写 clice 这个项目的时候,很大一个挑战就是和 clang 的源码进行交互。尽管 clang 一开始就被设计为模块化的项目,但是由于文档的匮乏,以及其本身就是一个生命周期非常长的项目了,不可避免的导致不同模块间的耦合程度加重,导致基于它编写相关的代码的时候较为困难。本文的旨在为 clice 项目中使用到的 clang 源码部分提供详细的介绍,方便阅读。 - -# Overview - -TODO: - -我们的目标是,基于 clang 的代码,自己编译出一个编译器前端程序出来,可以产生 AST 以便于我们使用,中端和后端这里就省略了。 - -# CompilerInstance - -```cpp -class CompilerInstance { /* ... */ } -``` - -这个类其实就代表一个 C++ 编译器实例,通过它我们就能完成实际代码的编译工作。它是个可默认构造的类型 - -```cpp -auto instance = std::make_unique(); -``` - -但是不要被表象迷惑了,这样默认构造出来的`instance`其实是不能直接用,如果你在 Debug 模式下构建,你会得到一大堆断言失败的错误。`CompilerInstance`有非常多的`set*`方法,只有在这些方法都正确的调用之后,才能执行最后的编译。下面就一步步让我们看看有哪些成员要被正确设置。 - -# Diagnostic - -编译器如何处理错误?各种错误,比如解析命令行可能出错,预处理阶段可能出错,语法分析语义分析阶段也可能出错,如何呈现报错信息呢?这就是本小结要讨论的问题。 - -核心的类型主要有四个 - -`DiagnosticsEngine`用于管理所有和诊断相关的对象。 - -```cpp -class DiagnosticOptions{ /* ... */ } -``` - -`DiagnosticOptions`用于设置诊断选项。 - -```cpp -class DiagnosticConsumer{ /* ... */ } -``` - -`DiagnosticConsumer`用于处理诊断信息。可以重写这个类的方法来自定义诊断信息的处理方式。有一个默认的实现`TextDiagnosticPrinter`,它会将诊断信息输出到指定的流中。 - -```cpp -class DiagnosticIDs { /* ... */ } -``` - -`DiagnosticIDs` 负责管理诊断消息的唯一标识符。每个诊断消息都有一个唯一的 ID,用于在代码中引用特定的诊断消息。 - -```cpp -class DiagnosticsEngine{ /* ... */ } -``` - -`DiagnosticsEngine`是一个诊断引擎,用于生成和管理诊断消息。 - -创建 - -```cpp -clang::DiagnosticIDs* ids = new clang::DiagnosticIDs(); -clang::DiagnosticOptions* diag_opts = new clang::DiagnosticOptions(); -clang::DiagnosticConsumer* consumer = new clang::TextDiagnosticPrinter(llvm::errs(), diag_opts); -clang::DiagnosticsEngine* engine = new clang::DiagnosticsEngine(ids, diag_opts, consumer); -``` - -准备好`DiagnosticsEngine`之后,就可以设置给`instance`了,注意参数是一个裸指针,`instance`会获取它的所有权。 - -```cpp -instance->setDiagnostics(engine); -``` - -# CompilerInvocation - -```cpp -class CompilerInvocation { /* ... */ } -``` - -这个类型用于向编译器传递一些信息,比如编译选项,输入文件等等,它同样是一个可默认构造的类型 - -```cpp -auto invocation = std::make_shared(); -``` - -同样,这样构造出来的对象是不能直接用的。可以使用`CompilerInvocation::CreateFromArgs`从一组命令行选项来初始化它。 - -```cpp -std::vector args = {"-Xclang", "-c", "main.cpp"}; -clang::CompilerInvocation::CreateFromArgs(*invocation, args, instance->getDiagnostics()); -``` - -通过它的`getFrontendOpts`方法,我们可以获取到解析过的编译选项。 - -```cpp -auto& opts = invocation->getFrontendOpts(); -``` - -clang 提供了代码补全的接口,如果想使用的话需要设置相应的`getFrontendOpts` - -```cpp -auto& codeCompletionAt = opts.CodeCompletionAt; -codeCompletionAt.FileName = "main.cpp"; -codeCompletionAt.Line = 10; -codeCompletionAt.Column = 4; -``` - -效果上和使用这个编译选项是类似的 - -```shell -clang++ -cc1 -fsyntax-only -code-completion-at main.cpp:10:4 main.cpp -``` - -准备好`invocation`之后就可以设置给`instance`了 - -```cpp -instance->setInvocation(std::move(invocation)); -``` - -# Target - -target 也就是我们常说的目标,这会影响最终生成的代码,例如不同平台的类型大小和对齐等等因素不同,那么`sizeof`等运算符求值得到的结果也就不同。不过由于往往在编译选项中就会默认指定 target 了,我们不需要再去自己创建,只需要 - -```cpp -if(!instance->createTarget()) { - llvm::errs() << "Failed to create target\n"; - std::terminate(); -} -``` - -就会自动根据当前的编译选项来创建对应的 target 了。 - -# FileManager and SourceManager - -```cpp -if(auto manager = instance->createFileManager()) { - instance->createSourceManager(*manager); -} else { - llvm::errs() << "Failed to create file manager\n"; - std::terminate(); -} -``` - -# Preprocessor - -```cpp -class Preprocessor { /* ... */ } -``` - -Preprocessor 就是预处理器,负责源文件的预处理工作,比如宏展开,条件编译等等。同样,基于先前的设置,我们可以方便的使用`createPreprocessor`来创建一个预处理器,而不需要自己用 Preprocessor 来构造,省去了一些不必要的麻烦。 - -```cpp -instance->createPreprocessor(clang::TranslationUnitKind::TU_Complete); -auto& preprocessor = instance->getPreprocessor(); -``` - -clang 暴露给了我们一些钩子在预处理的过程中获取一些信息。例如可以重写 PPCallbacks 里面的一些方法来获取一些信息。例如下面这个示例就是在打印每次宏展开的时候输出一些信息。clice 就通过这种方式来获取一个源文件中的头文件信息。 - -```cpp -using namespace clang; - -class Callback : public PPCallbacks { -public: - /// Called by Preprocessor::HandleMacroExpandedIdentifier when a - /// macro invocation is found. - void MacroExpands(const Token& MacroNameTok, - const MacroDefinition& MD, - SourceRange Range, - const MacroArgs* Args) override { - llvm::outs() << "MacroExpands: " << MacroNameTok.getIdentifierInfo()->getName() << "\n"; - } - - /// Hook called whenever a macro definition is seen. - void MacroDefined(const Token& MacroNameTok, const MacroDirective* MD) override { - llvm::outs() << "MacroDefined: " << MacroNameTok.getIdentifierInfo()->getName() << "\n"; - } -}; -``` - -之后只需要将这个 Callback 设置给 Preprocessor 就可以了 - -```cpp -preprocessor.addPPCallbacks(std::make_unique()); -``` - - - -This class is used to simplify a dependent type, so that we can do more things on it. e.g. code -completion. Dependent type is a type that depends on a template parameter. - -For example: - -```cpp -template -void foo(std::vector vec); -``` - -`std::vector` is a dependent type, because it depends on the template parameter `T`. Beacuse it has not been instantiated yet, we can't determine which specialization it will use(if have), even can't not determine whether the instantiation is valid or not. Beacuse of this, we can't not provide **precise** code completion for it. - -Note that I emphasis the word **precise**. In fact, in most of the cases, not very precise is tolerable. It's better than nothing. We can only consider the main template and provide code completion for it. - - - - - - diff --git a/docs/clang/SourceLocation.md b/docs/clang/SourceLocation.md deleted file mode 100644 index e69de29b..00000000 diff --git a/docs/clangd.md b/docs/clangd.md deleted file mode 100644 index 76b66c98..00000000 --- a/docs/clangd.md +++ /dev/null @@ -1,113 +0,0 @@ -首先分析一下项目架构,clice 本身是一个非常简单的模型,就是一个 client,实现了 [Language Server Protocol](https://microsoft.github.io/language-server-protocol/) 的 client。比如在 vscode 里面用的时候,对方发消息,然后我们回复指定内容即可。 - -那这个项目的难点主要在哪? - -## 和庞大的 Clang 源码进行交互 - -目前进度: -- 成功基于 CompilerInstance 创建了简单的 CodeCompletionConsumer,可以进行简单的代码补全查询 -- 了解到进行语义高亮的原理,先把所有 Tokens 记录下来,然后遍历 AST 的时候再根据语义信息(可以用 Location 作为 Key 来索引)去高亮,语义分析的时候 Tokens 肯定全有了,但是暂时不知道如何拿到 Tokens -- 成功拿到 Tokens,原来是 CodeCompletion 和 Tokens 不能同时用。在使用 Action 进行 Execute 后,可以从 CompilerInstance 里面拿到整个编译单元的 AST,遍历 AST(使用 RecursiveASTVisitor),然后再根据这个反向去渲染 Token 即可。 -- 已经知道是由 PrecompiledPreamble 负责构建预编译头文件,clangd 里面的 Preamble(Preamble.cpp) 也都是指这个,但是。一个源文件编译最多依赖一个 pch,依赖关系是线性的,但是一个 module 可以依赖多个其它的 module,依赖关系是有向无环图。 - - -TODO: -- 了解是什么 Preamble -- 了解 module 的工作机制 -- 了解 FrontendAction 的使用 -- 详细了解 Clang 前端的工作流程 -- 了解启发式代码补全的原理 -- 了解 AST 是如何被加载到内存中的 - -FIXME: -- 为每个 Token 都提供语义高亮: https://github.com/clangd/clangd/issues/1115 -- no-self-contained: https://github.com/clangd/clangd/issues/45 -- 提供更好的模板代码补全(需要在索引文件里面记录模板实例化),https://github.com/clangd/clangd/issues/443,然后补全的时候获取`.`号前面的表达式类型,之后再这里查找 -- 支持模块:https://github.com/clangd/clangd/issues/1293 -- https://github.com/clangd/clangd/issues/123 优化头文查找 -- 折叠预处理 https://github.com/clangd/clangd/issues/1661 -## 性能优化 - -TODO: 寻找核心优化点 -- 尽可能减少对 LLVM 源码的依赖,比如 json,hashmap 这种,提供方便换成第三方容器的接口,方便测试性能 - -一些讨论: -- 使用 LRU 缓存来优化语法树的查找与储存,参考 [Rust analyzer](https://github.com/rust-lang/rust-analyzer/pull/1382),目前 clangd 使用嵌套 vector 来处理这个问题 [ASTNode](https://github.com/llvm/llvm-project/blob/main/clang-tools-extra/clangd/Protocol.h#L2017). -- [持久化储存](https://github.com/rust-lang/rust-analyzer/issues/4712),指定缓存目录 -- 做加法而不是做减法,默认只提供非常少的功能,以减轻内存使用负担,通过主动开启选项来提供更多功能 - -## 编制索引与缓存查询 - -TODO: -- 了解索引工作的实际调度过程 -- 了解 AST 是以何种形式被储存到磁盘中的 - -一些讨论: -- [支持离线索引](https://github.com/clangd/clangd/issues/587) -- 另外请见 https://discourse.llvm.org/t/using-background-and-static-indexes-simultaneously-for-large-codebases/3706/7 - - -## 详细的支持功能列表 - -需要具体到哪些功能要做 - -比较大的特色是支持 module,这个需要重点支持,同时需要进一步阅读 LSProtocol 的文档,看看还有哪些功能需要支持。PCH 相关 ...。 - -一些可能有帮助的内容: -- 内联类型提示: https://github.com/clangd/clangd/issues/1535 -- 生成函数实现(补全父类虚函数和未实现的成员函数): https://github.com/clangd/clangd/issues/445 -- 更详细的 Token 语义提示:https://github.com/clangd/clangd/issues/1115 -- module support: https://github.com/clangd/clangd/issues/1293 - -一些必须要做的选项: -- 支持补全的时候不补全函数模板的<> -- 支持补全的时候不补全函数变量,模板变量,concept的占位符 -- 支持 markdown 注释渲染 -- 修复 quick fix 的位置问题 -- 启发式模版补全(可选) -- 控制代码补全的时机,只有光标后面没有字母的时候才补全,不要改中间的词弹补全框,烦死了(可选) -- 如果可变参数类型名太长了,比如`tuple`之类的,则显式成`tuple<...>`然后可以点击展开 - -希望支持的一些功能: -- 可视化宏展开(类似 VS 里面那个功能) -- 插件系统,支持用户编写一些简单的脚步来扩展功能(代码生成 .etc) - -# clangd 源码阅读(从 ClangMain 开始一点一点阅读) - - -## 第一阶段 - -`ClangMain(tool/ClangMain.cpp)` 里面没什么重要的内容,主要是 LLVM 的初始化和设置一些命令行 Option,主要调用了 `ClangServerLSP(ClangServerLSP.h)` 的 `run` 函数,这个 `run` 函数本身主要调用了 `Transport` 的 `loop` 函数,即开启服务器的事件循环 - -`Transport(Transport.h)` 本身是一个抽象类,通过不同的子类来实现,可以发送不同格式的消息。在 `ClangMain` 里面根据不同的情况使用不同的 `Transport` 子类,默认是 `JSONTransport(JSONTransport.cpp)`,大部分方法都没什么好看的,就是设置一些协议格式,然后发送消息(似乎是通过标准输入输出流进行通信,不过这个不重要),我们主要看 `loop` 函数。 - -`loop` 函数主要调用 `handleMessage` 这个私有方法来处理消息,这个私有方法则主要是把最后的处理交给 `MessageHandler`,`MessageHandler` 是 `Transport` 的一个成员抽象类,`ClangServerLSP` 实现了一个 `MessageHandler(ClangServerLSP.cpp-176)` 用于处理消息,对应的成员是 `MsgHandler`,在构造函数中初始化。下面主要看这个 `MsgHandler` 的处理逻辑。 - -`MsgHandler` 主要有三个函数 `onNotify`,`onCall` 和 `onReply`。分别表示 响应通知,响应请求和响应回复。三个函数的逻辑大体是相似的,都是 RPC 调用,根据函数名调用对应的函数,然后返回执行结果(找不到就报错)。接下来就主要看 `Handlers` 这个成员,他负责储存所有的处理函数。 - -`Handlers` 的类型是 `LSPBinder::RawHandlers`,在 `ClangServerLSP` 的构造函数中把 `Handlers` 这个成员绑定给了 `Bind`(`LSPBinder` 类型),`LSPBinder` 的 `method`,`notification` 和 `command` 成员函数的作用是,分别往对应的 `handler` 里面注册函数。在 `ClangServerLSP` 的构造函数中注册了 `ClangdLSPServer::onInitialize` 这个函数,可以猜测,实际的初始化工作都是在这里完成的,接下来我们主要看 `onInitialize` 这个函数的逻辑。 - -这里执行了很多初始化的逻辑,暂时没有细看,不知道都是干嘛用的。注册成员函数是在 `ClangdLSPServer` 的 `bindMethods` 方法中完成的,它注册了所有需要用到的方法,第一阶段的阅读到这里暂时结束,接下来要针对每一个模块看了。 - -## 第二阶段 - -接下来主要看`ClangServer(ClangServer.h)`这个类型,`ClangServerLSP`里面的绝大多数触发函数,只是对这个类对应函数的简单包装。先重点看一下它的`BackgroundIdx`和`TUScheduler`这两个成员。前者负责对文件进行索引,把结果储存到磁盘上。后者负责管理和加载 AST 到内存中,便于后续的操作。 - -一切的一切都从`ClangServer::addDocument`这个函数开始,处理客户端发过来的数据,然后调用`TUScheduler`的`update`函数,来加载到内存中。之后再调用`BackgroundIdx`的`boostRelated`函数,储存对应的索引文件。接下来先分析`TUScheduler`这个类。所有的 AST 都储存在 Files 这个成员变量里,它的类型是`llvm::StringMap>`,它同时有一个`ASTCache`类型的成员变量`IdleASTs`,LRU 储存一些 AST,用于快速查找。 - -`TUScheduler`的`update`函数主要创建了一个`ASTWorkerHandle`,然后调用它的`update`函数来处理这个事情。其实就是发起一个异步任务,更新对应的 AST 内容。值得注意的是 update 函数似乎都只是更新相关文件的状态,而具体的 AST 或者 Preamble 的创建则都是在第一次使用的时候,即 runWithAST 和 runWithPreamble 中。 - -TODO: 查看 runWithAST 和 runWithPreamble 的具体实现,PreambleThread 负责构建 PCH - -Clang 的 AST 的实际解析发生在 ParsedAST.cpp 的 build 函数,ParsedAST 本身会储存一个 CompilerInstance 实例。 - -!!! 原来 CodeCompletion 和 TokenCollector 不能同时获取,这也就意味着如果需要完成代码补全和语义高亮似乎需要多次遍历 AST ...... - -## 注意事项 - -注意:FeatureModule 这个东西没啥用,感觉是个废弃的功能,之后记得扔了。 - -## 一些已经解决的问题 - -SemanticHighlight:通过 SynatxOnlyAction 和 TokenCollector 可以拿到所有 Tokens,之后再遍历一遍语法树,分别处理每个语法树元素的高亮即可(可以通过 Location 查询 Token)。另外要注意,关键字高亮优先级最大,记得处理遍历语法树时候未处理完的 Token。 - diff --git a/docs/clangd2.md b/docs/clangd2.md deleted file mode 100644 index 59478c19..00000000 --- a/docs/clangd2.md +++ /dev/null @@ -1,64 +0,0 @@ -"architectural issue" here actually means the issue which can be solved but need to make a lot of modification to clangd. Currently, such big modification can be hard to push because of lack resource in clangd as mentioned [here](https://github.com/clangd/clangd/issues/1690#issuecomment-1619735578). I am a university student, also a c++ enthusiast and a vscode user. So I have a lot of time that I can dedicate to things I am interested in.. At first, I just want to wonder whether I can make some efforts to clangd. But gradually, I found it could be better to rewrite a new LSP. After evaluating the project scale, I think it's possible to complete for just one person (about 4w~ lines and ccls is also written by one person). Then I start to dive into clangd source code and learn the clang base. So far, I have known how to build preamble, how to build AST, how to traverse AST and so on. All of them are done with clang's C++ API. Next step is putting them together into final program. However, before the actual implementation, I need to plan out its structure. - -At first, how to manage message? LSP is also a type of server, and the common event-driven model is sufficient. I plan to use libuv as the event library, with the main thread handling requests and distributing tasks, while the thread pool executes the actual tasks. This is slightly different from clangd's current model; clangd doesn't use a thread pool, but rather creates a new thread for each file and uses semaphore to limit the number of active threads. - -Then we need to handle TU. I decided to use a different policy with clangd, which is not to build the preamble for the file until the first edit, and headers will reuse the AST in the source file by default, also until first edit. In this way, we can reduce a lot of memory usage, speed up the loading (building preamble always needs more time compared to normal AST building) and support non self contained header. This can be very useful, people actually only need to modify a few files in big projects like LLVM. And today I found Sam also reported this [issue](https://github.com/clangd/clangd/issues/391). Another important problem is how to interact with C++20 modules, I am still exploring this. - -Next is about indexing, current indexer in clangd seems to be efficient enough, so I think I would reuse it and make only some small modifications to record more information. Also, I am wondering whether we can modify the absolute path to relative path in the index, so issue like [support offline background index preparation](https://github.com/clangd/clangd/issues/587)。It shouldn't be hard to implement. - -Following is discussion on some specific LSP features: - -## Semantic Highlight - -There are several issues around it. - -- [provide semantic information for each token](https://github.com/clangd/clangd/issues/1115) -- [no AST node for explicit template instantiations](https://github.com/clangd/clangd/issues/358) -- [class name does not get a coloring in constructor call ](https://github.com/clangd/clangd/issues/501) -- [store implicit specializations as distinct symbols in the index, with their own refs](https://github.com/clangd/clangd/issues/536) -- [distinguish between type template parameter and non-type template parameter highlightings](https://github.com/clangd/clangd/issues/787) -- [modifiers are wrong in semantic token for destructor](https://github.com/clangd/clangd/issues/872) - -Mainly about wrong or not enough information in the semantic highlight. I would like to support detail information for each token, then we can solve all of them. - -## Hint - -- [simplify inlay hints](https://github.com/clangd/clangd/issues/824) -- [make the type hint length limit configurable](https://github.com/clangd/clangd/issues/1357) -- [support go-to-definition on type names in inlay hints](https://github.com/clangd/clangd/issues/1535) -- [use namespace alias but not original namespace name](https://github.com/clangd/clangd/issues/542) -- [support folding range on directive](https://github.com/clangd/clangd/issues/1661) -- [documentation for struct member fields not working correctly](https://github.com/clangd/clangd/issues/564) -- [make the hover box more compact](https://github.com/clangd/clangd/issues/747) -- [padding inlay hints](https://github.com/clangd/clangd/issues/923) -- [struct members and enum values are not shown on type hover](https://github.com/clangd/clangd/issues/959) -- [show length of string literal in hover](https://github.com/clangd/clangd/issues/1016) -- [show type hints for init-captures](https://github.com/clangd/clangd/issues/1163) - -Most of these problems are about hint. Providing options to allow users to configure them will be fine. - -## Action - -- [add implementation](https://github.com/clangd/clangd/issues/445) -- [revert if](https://github.com/clangd/clangd/issues/466) -- [move constructor argument into member](https://github.com/clangd/clangd/issues/454) -- [modify function parameters](https://github.com/clangd/clangd/issues/460) -- [expand macro one level](https://github.com/clangd/clangd/issues/820) - -Providing more actions will be helpful. - -## Code Completion - -- [improve code completion inside template](https://github.com/clangd/clangd/issues/443) -- [resolve the type of lambda auto parameters](https://github.com/clangd/clangd/issues/493) -- [don't include template completion when inside the template class](https://github.com/clangd/clangd/issues/678) -- [can I disable snippet](https://github.com/clangd/clangd/issues/727) -- [no completion for definition of non-public member functions](https://github.com/clangd/clangd/issues/880) -- [outside function definition won't complete default arguments](https://github.com/clangd/clangd/issues/753) -- [postfix completions](https://github.com/clangd/clangd/issues/850) -- [list free functions alongside methods in autocompletion](https://github.com/clangd/clangd/issues/893) -- [type information lost during auto deduction in templates](https://github.com/clangd/clangd/issues/897) -- [completion member field listing order w.r.t. C++20 designated initializers](https://github.com/clangd/clangd/issues/965) -- [completion of pointers to functions and function objects](https://github.com/clangd/clangd/issues/968) - -These issues around code completion could be hardest to resolve. We need to modify the `Parser` and `SemaComplete` in clang to support them. Some are about templates, improving `HeuristicResolver` will resolve them. \ No newline at end of file diff --git a/docs/clice.md b/docs/clice.md deleted file mode 100644 index 3697a1ab..00000000 --- a/docs/clice.md +++ /dev/null @@ -1,65 +0,0 @@ -# clice - -这个文件详细描述了 clice 的项目架构以及诸多实现细节。 - -# Overview - -clice 是一个 C++ 的 [LSP](https://microsoft.github.io/language-server-protocol/),旨在解决 clangd 中现存的诸多问题。下面是我认为 clangd 中一些现存的需要迫切去解决的问题: - -## Index - -- [preamble-less first build](https://github.com/clangd/clangd/issues/391) -- [C++20 module support](https://github.com/clangd/clangd/issues/1293) -- [support non self contained header](https://github.com/clangd/clangd/issues/45) -- [add an option to build ASTs for files in the CDB on startup](https://github.com/clangd/clangd/issues/589) -- [support offline background index preparation](https://github.com/clangd/clangd/issues/587) -- [give the user some way to control the order in which files are indexed](https://github.com/clangd/clangd/issues/523) -- [improve template instantiation and dependent types](https://github.com/clangd/clangd/issues/1095) - -## Completion - -- [improve code completion inside template](https://github.com/clangd/clangd/issues/443) -- [resolve the type of lambda auto parameters](https://github.com/clangd/clangd/issues/493) -- [don't include template completion when inside the template class](https://github.com/clangd/clangd/issues/678) -- [can I disable snippet](https://github.com/clangd/clangd/issues/727) -- [no completion for definition of non-public member functions](https://github.com/clangd/clangd/issues/880) -- [outside function definition won't complete default arguments](https://github.com/clangd/clangd/issues/753) -- [postfix completions](https://github.com/clangd/clangd/issues/850) -- [list free functions alongside methods in autocompletion](https://github.com/clangd/clangd/issues/893) -- [type information lost during auto deduction in templates](https://github.com/clangd/clangd/issues/897) -- [completion member field listing order w.r.t. C++20 designated initializers](https://github.com/clangd/clangd/issues/965) -- [completion of pointers to functions and function objects](https://github.com/clangd/clangd/issues/968) - -## Hint - -- [simplify inlay hints](https://github.com/clangd/clangd/issues/824) -- [make the type hint length limit configurable](https://github.com/clangd/clangd/issues/1357) -- [support go-to-definition on type names in inlay hints](https://github.com/clangd/clangd/issues/1535) -- [use namespace alias but not original namespace name](https://github.com/clangd/clangd/issues/542) -- [support folding range on directive](https://github.com/clangd/clangd/issues/1661) -- [documentation for struct member fields not working correctly](https://github.com/clangd/clangd/issues/564) -- [make the hover box more compact](https://github.com/clangd/clangd/issues/747) -- [padding inlay hints](https://github.com/clangd/clangd/issues/923) -- [struct members and enum values are not shown on type hover](https://github.com/clangd/clangd/issues/959) -- [show length of string literal in hover](https://github.com/clangd/clangd/issues/1016) -- [show type hints for init-captures](https://github.com/clangd/clangd/issues/1163) - - -## Semantic Highlight - -- [provide semantic information for each token](https://github.com/clangd/clangd/issues/1115) -- [no AST node for explicit template instantiations](https://github.com/clangd/clangd/issues/358) -- [class name does not get a coloring in constructor call ](https://github.com/clangd/clangd/issues/501) -- [store implicit specializations as distinct symbols in the index, with their own refs](https://github.com/clangd/clangd/issues/536) -- [distinguish between type template parameter and non-type template parameter highlightings](https://github.com/clangd/clangd/issues/787) -- [modifiers are wrong in semantic token for destructor](https://github.com/clangd/clangd/issues/872) - -## Action - -- [add implementation](https://github.com/clangd/clangd/issues/445) -- [revert if](https://github.com/clangd/clangd/issues/466) -- [move constructor argument into member](https://github.com/clangd/clangd/issues/454) -- [modify function parameters](https://github.com/clangd/clangd/issues/460) -- [expand macro one level](https://github.com/clangd/clangd/issues/820) - -## \ No newline at end of file diff --git a/docs/examples/ASTVisitor.cpp b/docs/examples/ASTVisitor.cpp deleted file mode 100644 index 3b80a8bf..00000000 --- a/docs/examples/ASTVisitor.cpp +++ /dev/null @@ -1,742 +0,0 @@ -#include -#include -#include - -class DependentShaper { - clang::ASTContext& context; - clang::Sema& sema; - -public: - DependentShaper(clang::ASTContext& context, clang::Sema& sema) : context(context), sema(sema) {} - - /// replace template arguments in a dependent type - /// e.g. - /// ```cpp - /// template - /// struct A { - /// using reference = T1&; - /// }; - /// - /// template - /// struct B { - /// using type = A::reference; - /// }; - /// ``` - /// we want to simplify `A::reference` to `U1&`, then we need to call - /// `replace(, )` to get `U1&`. - clang::QualType replace(clang::QualType input, - llvm::ArrayRef originalArguments) { - assert(type->isDependentType() && "type is not dependent"); - - // if the input is still a dependent name type, we need to simplify it recursively - while(auto type = llvm::dyn_cast(input)) { - input = simplify(type); - } - - clang::ElaboratedType* elaboratedType = nullptr; - clang::MultiLevelTemplateArgumentList list; - list.addOuterTemplateArguments(originalArguments); - llvm::outs() << "-------------------------------------------------\n"; - clang::Sema::CodeSynthesisContext InstContext; - // InstContext.Kind = clang::Sema::CodeSynthesisContext::TemplateInstantiation; - // InstContext.Entity = nullptr; - // InstContext.TemplateArgs = TemplateArgs; - // sema.CodeSynthesisContexts.back().dump(); - auto result = sema.SubstType(input, list, {}, {}); - - if(auto type = llvm::dyn_cast(input)) { - auto pointee = type->getPointeeType(); - - while(auto elaboratedType = llvm::dyn_cast(pointee)) { - pointee = elaboratedType->desugar(); - } - - // get the position of the dependent type in the template parameter list - // e.g `T1` in , the index is 0 - if(auto paramType = llvm::dyn_cast(pointee)) { - auto index = paramType->getIndex(); - auto argument = originalArguments[index]; - - // create a new type that fit the replacement - return context.getLValueReferenceType(argument.getAsType()); - - } else if(auto defType = llvm::dyn_cast(pointee)) { - return replace(defType->getDecl()->getUnderlyingType(), originalArguments); - } else { - pointee->dump(); - std::terminate(); - } - } - // TODO: handle other kinds - - return input; - } - - clang::NamedDecl* lookup(const clang::ClassTemplateDecl* classTemplateDecl, - const clang::IdentifierInfo* identifier) { - clang::CXXRecordDecl* recordDecl = classTemplateDecl->getTemplatedDecl(); - auto result = recordDecl->lookup(identifier); - return result.front(); - } - - /// for a complex dependent type: `X<...>::name::name2::...::nameN`, we can resolve it - /// recursively. so we only need to handle the `X<...>::name`, whose prefix is a template - /// specialization type. - clang::QualType simplify(const clang::TemplateSpecializationType* templateType, - const clang::IdentifierInfo* identifier) { - // X is a class template or a type alias template - auto templateDecl = templateType->getTemplateName().getAsTemplateDecl(); - if(auto classTemplateDecl = llvm::dyn_cast(templateDecl)) { - // lookup the identifier in the record decl - auto namedDecl = lookup(classTemplateDecl, identifier); - - if(auto decl = llvm::dyn_cast(namedDecl)) { - return replace(decl->getUnderlyingType(), templateType->template_arguments()); - } else if(auto decl = llvm::dyn_cast(namedDecl)) { - return replace(decl->getUnderlyingType(), templateType->template_arguments()); - } else { - namedDecl->dump(); - } - - } else if(auto aliasTemplateDecl = - llvm::dyn_cast(templateDecl)) { - // TODO: - } else { - templateDecl->dump(); - } - } - - const clang::QualType simplify(const clang::NestedNameSpecifier* specifier, - const clang::IdentifierInfo* identifier) { - auto kind = specifier->getKind(); - switch(specifier->getKind()) { - case clang::NestedNameSpecifier::Identifier: { - const auto prefix = simplify(specifier->getPrefix(), specifier->getAsIdentifier()); - - if(auto type = llvm::dyn_cast(prefix)) { - return simplify(type, identifier); - } else { - prefix->dump(); - } - - break; - } - - case clang::NestedNameSpecifier::TypeSpec: { - auto node = specifier->getAsType(); - - if(auto type = llvm::dyn_cast(node)) { - // represent a direct dependent name, e.g. typename T::^ name - // and can not be further simplified - // node->dump(); - type->dump(); - } else if(auto type = node->getAs()) { - // represent a dependent name that is a template specialization - // e.g. typename vector::^ name, and can be further simplified - return simplify(type, identifier); - } else { - node->dump(); - } - - break; - } - - case clang::NestedNameSpecifier::TypeSpecWithTemplate: { - llvm::outs() << "unsupported kind: " << kind << "\n"; - break; - } - - default: { - llvm::outs() << "unsupported kind: " << kind << "\n"; - } - } - } - - const clang::QualType simplify(const clang::DependentNameType* type) { - // llvm::outs() << "-----------------------------------------------------------" << "\n"; - // type->dump(); - return simplify(type->getQualifier(), type->getIdentifier()); - } -}; - -namespace clang { -class DependentNameResolver { -public: - Sema& S; - ASTContext& Ctx; - clang::NamedDecl* CurrentDecl; - -public: - DependentNameResolver(ASTContext& Ctx, Sema& S) : Ctx(Ctx), S(S) {} - - std::vector resolve(llvm::ArrayRef arguments) { - std::vector result; - for(auto arg: arguments) { - if(arg.getKind() == TemplateArgument::ArgKind::Type) { - if(auto type = llvm::dyn_cast(arg.getAsType())) { - const TemplateTypeParmDecl* param = type->getDecl(); - if(param->hasDefaultArgument()) { - result.push_back(param->getDefaultArgument().getArgument()); - continue; - } - } - } - result.push_back(arg); - } - return result; - } - - QualType resolve(QualType T) { - if(!T->isDependentType()) { - return T; - } - - while(true) { - if(auto DNT = T->getAs()) { - T = resolve(DNT); - } else if(auto DTST = T->getAs()) { - T = resolve(DTST); - } else if(auto LRT = T->getAs()) { - return Ctx.getLValueReferenceType(resolve(LRT->getPointeeType())); - } else { - return T; - } - } - } - - /// resolve a dependent name type, e.g. `typename std::vector::reference` - QualType resolve(const DependentNameType* DNT) { - // e.g. when DNT is `typename std::vector::reference` - // - qualifier: std::vector - // - identifier: reference - return resolve(DNT->getQualifier(), DNT->getIdentifier()); - } - - /// resolve a dependent template specialization type. - QualType resolve(const DependentTemplateSpecializationType* DTST) { - // e.g. when DTST is `typename std::allocator_traits::template rebind_alloc`. - // - qualifier: std::allocator_traits - // - identifier: rebind_alloc - // - template_arguments: - return resolve(DTST->getQualifier(), DTST->getIdentifier(), DTST->template_arguments()); - } - - QualType resolve(const NestedNameSpecifier* TST, - const IdentifierInfo* II, - ArrayRef arguments = {}) { - - switch(TST->getKind()) { - case NestedNameSpecifier::SpecifierKind::Identifier: { - llvm::outs() << "\n------------------ Identifier -----------------------\n"; - // when the kind of TST is Identifier - // e.g. std::vector>::value_type:: - // resolve it recursively - return resolve(resolve(TST->getPrefix(), TST->getAsIdentifier()), II, arguments); - } - - case NestedNameSpecifier::SpecifierKind::TypeSpec: { - llvm::outs() << "\n------------------ TypeSpec -----------------------\n"; - TST->dump(); - llvm::outs() << " " << II->getName() << "\n"; - // when the kind of TST is TypeSpec, e.g. std::vector:: - return resolve(QualType(TST->getAsType(), 0), II, arguments); - } - - case NestedNameSpecifier::SpecifierKind::TypeSpecWithTemplate: { - llvm::outs() << "------------------ TypeSpecWithTemplate -----------------------\n"; - // when the kind of TST is TypeSpecWithTemplate, e.g. std::vector::template - // name:: - TST->dump(); - return resolve(QualType(TST->getAsType(), 0), II, arguments); - } - - default: { - llvm::outs() << "\n------------------ Unknown -----------------------\n"; - TST->dump(); - std::terminate(); - } - } - } - - QualType substitute(ClassTemplateDecl* CTD, - const IdentifierInfo* II, - ArrayRef arguments = {}) { - Sema::CodeSynthesisContext context; - - auto args = resolve(arguments); - - context.Entity = CTD; - context.TemplateArgs = args.data(); - context.Kind = Sema::CodeSynthesisContext::TemplateInstantiation; - S.pushCodeSynthesisContext(context); - - MultiLevelTemplateArgumentList list; - - auto recordDecl = CTD->getTemplatedDecl(); - auto member = recordDecl->lookup(II).front(); - - QualType type; - - if(auto TAD = llvm::dyn_cast(member)) { - type = TAD->getUnderlyingType(); - } else if(auto TD = llvm::dyn_cast(member)) { - type = TD->getUnderlyingType(); - } else if(auto TATD = llvm::dyn_cast(member)) { - auto args2 = resolve(arguments); - - context.Entity = TATD; - context.TemplateArgs = args2.data(); - context.Kind = Sema::CodeSynthesisContext::TypeAliasTemplateInstantiation; - S.pushCodeSynthesisContext(context); - - MultiLevelTemplateArgumentList list; - list.addOuterTemplateArguments(TATD, args2, false); - - auto TAD = TATD->getTemplatedDecl(); - - type = TAD->getUnderlyingType(); - } else if(auto CTD = llvm::dyn_cast(member)) { - return substitute(CTD, II, arguments); - } else { - member->dump(); - std::terminate(); - } - - list.addOuterTemplateArguments(CTD, args, true); - return S.SubstType(type, list, {}, {}); - } - - /// typename A::template B::template C::type:: - QualType resolve(const DependentTemplateSpecializationType* DTST, const IdentifierInfo* II) { - // auto prefix; - MultiLevelTemplateArgumentList list; - while(true) { - // list.addOuterTemplateArguments() - } - } - - QualType - resolve(QualType T, const IdentifierInfo* II, ArrayRef arguments = {}) { - if(!T->isDependentType() && arguments.size() == 0) { - // TODO: - } - llvm::outs() << "\n"; - T.dump(); - Sema::CodeSynthesisContext context; - - if(auto TTPT = T->getAs()) { - llvm::outs() << "\n-------------------------------------------------\n"; - T->dump(); - llvm::outs() << " \n" << II->getName(); - - // e.g. when T is `T` - // - index: 0 - } else if(auto TST = T->getAs()) { - auto TemplateName = TST->getTemplateName(); - auto TemplateDecl = TemplateName.getAsTemplateDecl(); - auto TemplatedDecl = TemplateDecl->getTemplatedDecl(); - - if(auto CTD = llvm::dyn_cast(TemplateDecl)) { - return substitute(CTD, II, TST->template_arguments()); - } else { - TemplateDecl->dump(); - std::terminate(); - } - auto TemplateArgs = TST->template_arguments(); - } else if(auto DTST = T->getAs()) { - auto TST = DTST->getQualifier()->getAsType()->getAs(); - auto TemplateName = TST->getTemplateName(); - auto TemplateDecl = TemplateName.getAsTemplateDecl(); - auto TemplatedDecl = TemplateDecl->getTemplatedDecl(); - - if(auto CTD = llvm::dyn_cast(TemplateDecl)) { - auto args = resolve(TST->template_arguments()); - - context.Entity = CTD; - context.TemplateArgs = args.data(); - context.Kind = Sema::CodeSynthesisContext::TemplateInstantiation; - S.pushCodeSynthesisContext(context); - - MultiLevelTemplateArgumentList list; - list.addOuterTemplateArguments(CTD, args, true); - - auto recordDecl = CTD->getTemplatedDecl(); - auto member = recordDecl->lookup(DTST->getIdentifier()).front(); - - if(auto CTD2 = llvm::dyn_cast(member)) { - auto args2 = resolve(DTST->template_arguments()); - - context.Entity = CTD2; - context.TemplateArgs = args2.data(); - context.Kind = Sema::CodeSynthesisContext::TemplateInstantiation; - S.pushCodeSynthesisContext(context); - - MultiLevelTemplateArgumentList list; - list.addOuterTemplateArguments(CTD2, args2, true); - list.addOuterTemplateArguments(CTD, args, true); - - auto CRD = CTD2->getTemplatedDecl(); - return S.SubstType( - llvm::dyn_cast(CRD->lookup(II).front())->getUnderlyingType(), - list, - {}, - {}); - - } else if(auto TATD = llvm::dyn_cast(member)) { - auto args2 = resolve(arguments); - - context.Entity = TATD; - context.TemplateArgs = args2.data(); - context.Kind = Sema::CodeSynthesisContext::TypeAliasTemplateInstantiation; - S.pushCodeSynthesisContext(context); - - MultiLevelTemplateArgumentList list; - list.addOuterTemplateArguments(TATD, args2, false); - list.addOuterTemplateArguments(CTD, args, true); - - auto TAD = TATD->getTemplatedDecl(); - return S.SubstType(TAD->getUnderlyingType(), list, {}, {}); - } else { - member->dump(); - std::terminate(); - } - } else { - T->dump(); - std::terminate(); - } - - // S.SubstType() - } - } -}; - -class DependentNameResolverV2 { -public: - Sema& S; - ASTContext& Ctx; - - std::vector>*> arguments; - -public: - DependentNameResolverV2(ASTContext& Ctx, Sema& S) : Ctx(Ctx), S(S) {} - - std::vector resolve(llvm::ArrayRef arguments) { - std::vector result; - for(auto arg: arguments) { - if(arg.getKind() == TemplateArgument::ArgKind::Type) { - // check whether it is a TemplateTypeParmType. - if(auto type = llvm::dyn_cast(arg.getAsType())) { - const TemplateTypeParmDecl* param = type->getDecl(); - if(param && param->hasDefaultArgument()) { - result.push_back(param->getDefaultArgument().getArgument()); - continue; - } - } - } - result.push_back(arg); - } - return result; - } - - QualType dealias(QualType type) { - if(auto DNT = type->getAs()) { - return QualType(DNT, 0); - } else if(auto DTST = type->getAs()) { - auto NNS = NestedNameSpecifier::Create( - Ctx, - nullptr, - false, - dealias(QualType(DTST->getQualifier()->getAsType(), 0)).getTypePtr()); - return Ctx.getDependentTemplateSpecializationType(DTST->getKeyword(), - NNS, - DTST->getIdentifier(), - resolve(DTST->template_arguments())); - } else { - return type; - } - } - - QualType resolve(QualType type) { - - while(true) { - // llvm::outs() << - // "--------------------------------------------------------------------\n"; - // type.dump(); - - MultiLevelTemplateArgumentList list; - if(auto DNT = type->getAs()) { - type = resolve(resolve(DNT->getQualifier(), DNT->getIdentifier())); - for(auto begin = arguments.rbegin(), end = arguments.rend(); begin != end; - ++begin) { - list.addOuterTemplateArguments((*begin)->first, (*begin)->second, true); - } - type = S.SubstType(dealias(type), list, {}, {}); - arguments.clear(); - - } else if(auto DTST = type->getAs()) { - auto ND = resolve(DTST->getQualifier(), DTST->getIdentifier()); - if(auto TATD = llvm::dyn_cast(ND)) { - auto args = resolve(DTST->template_arguments()); - - Sema::CodeSynthesisContext context; - context.Entity = TATD; - context.Kind = Sema::CodeSynthesisContext::TypeAliasTemplateInstantiation; - context.TemplateArgs = args.data(); - S.pushCodeSynthesisContext(context); - - list.addOuterTemplateArguments(TATD, args, true); - for(auto begin = arguments.rbegin(), end = arguments.rend(); begin != end; - ++begin) { - list.addOuterTemplateArguments((*begin)->first, (*begin)->second, true); - } - - // llvm::outs() << "before: - // ----------------------------------------------------------------\n"; - // TATD->getTemplatedDecl()->getUnderlyingType().dump(); - type = dealias(TATD->getTemplatedDecl()->getUnderlyingType()); - // llvm::outs() << "arguments: - // -------------------------------------------------------------\n"; - // list.dump(); - type = S.SubstType(type, list, {}, {}); - // type.dump(); - arguments.clear(); - - } else { - ND->dump(); - std::terminate(); - } - // return resolve(DTST); - } else if(auto LRT = type->getAs()) { - type = Ctx.getLValueReferenceType(resolve(LRT->getPointeeType())); - } else { - return type; - } - } - } - - QualType resolve(NamedDecl* ND) { - if(auto TD = llvm::dyn_cast(ND)) { - return TD->getUnderlyingType(); - } else if(auto TAD = llvm::dyn_cast(ND)) { - return TAD->getUnderlyingType(); - } else { - ND->dump(); - std::terminate(); - } - } - - NamedDecl* resolve(const NestedNameSpecifier* NNS, const IdentifierInfo* II) { - switch(NNS->getKind()) { - // prefix is an identifier, e.g. <...>::name:: - case NestedNameSpecifier::SpecifierKind::Identifier: { - return lookup(resolve(resolve(NNS->getPrefix(), NNS->getAsIdentifier())), II); - } - - // prefix is a type, e.g. <...>::typename name:: - case NestedNameSpecifier::SpecifierKind::TypeSpec: - case NestedNameSpecifier::SpecifierKind::TypeSpecWithTemplate: { - return lookup(QualType(NNS->getAsType(), 0), II); - } - - default: { - NNS->dump(); - std::terminate(); - } - } - } - - NamedDecl* lookup(QualType Type, const IdentifierInfo* Name) { - NamedDecl* TemplateDecl; - ArrayRef arguments; - - llvm::outs() << "--------------------------------------------------------------------\n"; - Type.dump(); - Type->getCanonicalTypeInternal(); - if(auto TTPT = Type->getAs()) { - Type->dump(); - std::terminate(); - } else if(auto TST = Type->getAs()) { - auto TemplateName = TST->getTemplateName(); - TemplateDecl = TemplateName.getAsTemplateDecl(); - arguments = TST->template_arguments(); - } else if(auto DTST = Type->getAs()) { - TemplateDecl = resolve(DTST->getQualifier(), DTST->getIdentifier()); - arguments = DTST->template_arguments(); - } else if(auto RT = Type->getAs()) { - return RT->getDecl()->lookup(Name).front(); - } else { - Type->dump(); - std::terminate(); - } - - this->arguments.push_back( - new std::pair>{TemplateDecl, resolve(arguments)}); - - NamedDecl* result; - - Sema::CodeSynthesisContext context; - context.Entity = TemplateDecl; - context.Kind = Sema::CodeSynthesisContext::TemplateInstantiation; - context.TemplateArgs = this->arguments.back()->second.data(); - S.pushCodeSynthesisContext(context); - - if(auto CTD = llvm::dyn_cast(TemplateDecl)) { - llvm::outs() - << "--------------------------------------------------------------------\n"; - llvm::SmallVector paritals; - CTD->getPartialSpecializations(paritals); - - for(auto partial: paritals) { - partial->getInjectedSpecializationType().dump(); - } - llvm::outs() - << "--------------------------------------------------------------------\n"; - // CTD->findPartialSpecialization() - auto partial = CTD->findPartialSpecialization(Type); - if(partial) { - result = partial->lookup(Name).front(); - } - - if(!result) { - result = CTD->getTemplatedDecl()->lookup(Name).front(); - } - } else if(auto TATD = llvm::dyn_cast(TemplateDecl)) { - result = lookup(TATD->getTemplatedDecl()->getUnderlyingType(), Name); - } - - if(result == nullptr) { - Type.dump(); - std::terminate(); - } - - return result; - } -}; - -} // namespace clang - -#define Traverse(NAME) bool Traverse##NAME(clang::NAME* node) -#define WalkUpFrom(NAME) bool WalkUpFrom##NAME(clang::NAME* node) -#define VISIT(NAME) bool Visit##NAME(clang::NAME* node) -#define VISIT_TYPE(NAME) bool Visit##NAME(clang::NAME node) - -class ASTVistor : public clang::RecursiveASTVisitor { -private: - clang::Preprocessor& preprocessor; - clang::SourceManager& sourceManager; - clang::syntax::TokenBuffer& buffer; - clang::ASTContext& context; - clang::Sema& sema; - clang::syntax::TokenBuffer& TB; - -public: - ASTVistor(clang::Preprocessor& preprocessor, - clang::syntax::TokenBuffer& buffer, - clang::ASTContext& context, - clang::Sema& sema, - clang::syntax::TokenBuffer& TB) : - preprocessor(preprocessor), sourceManager(preprocessor.getSourceManager()), buffer(buffer), - context(context), sema(sema), TB(TB) {} - - bool TraverseTranslationUnitDecl(clang::TranslationUnitDecl* decl) { - for(auto it = decl->decls_begin(), end = decl->decls_end(); it != end; ++it) { - TraverseDecl(*it); - if(sourceManager.getFilename(sourceManager.getSpellingLoc(it->getLocation())) == - "/usr/include/c++/13/bits/stl_vector.h") {} - } - return true; - } - - VISIT(ClassTemplateDecl) { - clang::DeclRefExpr* node2; - if(node->getName() == "vector") { - node->getLocation().dump(sourceManager); - } - return true; - } -}; - -class CommentHandler : public clang::CommentHandler { - - bool HandleComment(clang::Preprocessor& PP, clang::SourceRange Comment) override { - auto& sm = PP.getSourceManager(); - std::string CommentText = std::string(sm.getCharacterData(Comment.getBegin()), - sm.getCharacterData(Comment.getEnd()) - - sm.getCharacterData(Comment.getBegin())); - llvm::outs() << "Comment: " << CommentText << "\n"; - return false; - } -}; - -int main(int argc, const char** argv) { - assert(argc == 2 && "Usage: Preprocessor "); - llvm::outs() << "running ASTVisitor...\n"; - - auto instance = std::make_unique(); - - clang::DiagnosticIDs* ids = new clang::DiagnosticIDs(); - clang::DiagnosticOptions* diag_opts = new clang::DiagnosticOptions(); - clang::DiagnosticConsumer* consumer = new clang::IgnoringDiagConsumer(); - clang::DiagnosticsEngine* engine = new clang::DiagnosticsEngine(ids, diag_opts, consumer); - instance->setDiagnostics(engine); - - auto invocation = std::make_shared(); - std::vector args = { - "/usr/local/bin/clang++", - "-Xclang", - "-no-round-trip-args", - "-std=c++20", - argv[1], - }; - - invocation = clang::createInvocation(args, {}); - // clang::CompilerInvocation::CreateFromArgs(*invocation, args, instance->getDiagnostics()); - instance->setInvocation(std::move(invocation)); - - if(!instance->createTarget()) { - llvm::errs() << "Failed to create target\n"; - std::terminate(); - } - - clang::SyntaxOnlyAction action; - - if(!action.BeginSourceFile(*instance, instance->getFrontendOpts().Inputs[0])) { - llvm::errs() << "Failed to begin source file\n"; - std::terminate(); - } - - auto& pp = instance->getPreprocessor(); - pp.addCommentHandler(new CommentHandler()); - clang::syntax::TokenCollector collector{pp}; - // pp.addCommentHandler(new CommentHandler()); - - if(auto error = action.Execute()) { - llvm::errs() << "Failed to execute action: " << error << "\n"; - std::terminate(); - } - - clang::syntax::TokenBuffer buffer = std::move(collector).consume(); - buffer.indexExpandedTokens(); - - auto& sm = instance->getSourceManager(); - auto& fm = instance->getFileManager(); - - auto entry = fm.getFileRef("/usr/include/c++/13/vector"); - auto id = sm.translateFile(*entry); - auto tokens = buffer.spelledTokens(id); - - for(auto token: tokens) { - llvm::outs() << token.text(sm) << " "; - token.location().dump(sm); - } - - auto tu = instance->getASTContext().getTranslationUnitDecl(); - ASTVistor visitor{instance->getPreprocessor(), - buffer, - instance->getASTContext(), - instance->getSema(), - buffer}; - // visitor.TraverseDecl(tu); - - action.EndSourceFile(); -}; diff --git a/docs/examples/CodeCompletion.cpp b/docs/examples/CodeCompletion.cpp deleted file mode 100644 index d9eade4e..00000000 --- a/docs/examples/CodeCompletion.cpp +++ /dev/null @@ -1,175 +0,0 @@ -#include -#include - -// clang 的 CodeCompletion 提供的功能非常有限,无法获取当前 Completion 的 scope -// 而获取 scope 是非常重要的一个功能,有了它我们可以做更多事情,比如只把 ...sizeof 显示在可变模板参数的语境下 -// 又或者根据函数名的语境不同(定义和调用)执行不同的补全逻辑,定义的时候就自动补全参数,调用的时候就不补全 -// 我们只能通过一些 hack 的手段来做这个事情了,首先使用 TokenWatcher 可以获取到所有的 Token -// 同样我们可以获取到最终的 tu, - -// TODO: 检查 SemaCodeCompletion.cpp,看看能不能把当前代码补全的 scope 拿到,当然在这之前,先尝试前面那种 hack -// 的 方式,看看能不能同样拿到这些信息,反正 token 位置和最后的语法树都是有的 由于要改 clang -// 源码,所以这不是一个高优先级的任务 ... - -class CodeCompleteConsumer : public clang::CodeCompleteConsumer { -private: - std::shared_ptr Allocator; - clang::CodeCompletionTUInfo CCTUInfo; - -public: - CodeCompleteConsumer() : - clang::CodeCompleteConsumer(clang::CodeCompleteOptions{}), - Allocator(std::make_shared()), CCTUInfo(Allocator) {} - - clang::CodeCompletionAllocator& getAllocator() override { return *Allocator; } - - clang::CodeCompletionTUInfo& getCodeCompletionTUInfo() override { return CCTUInfo; } - - void ProcessCodeCompleteResults(clang::Sema& S, - clang::CodeCompletionContext Context, - clang::CodeCompletionResult* Results, - unsigned NumResults) override { - llvm::outs() << NumResults << " code completion results\n"; - auto kind = Context.getKind(); - if(kind == clang::CodeCompletionContext::CCC_DotMemberAccess) { - auto type = Context.getBaseType(); - type->dump(); - } - // auto contexts = Context.getVisitedContexts(); - // for(auto c: contexts) { - // // llvm::outs() << " Kind: " << c->getDeclKindName() << "\n"; - // // for(auto d: c->decls()) { - // // // d->dump(); - // // } - // } - // - // llvm::outs() << "code completion results:\n"; - // switch(Context.getKind()) { - // case clang::CodeCompletionContext::CCC_Attribute: { - // } - // case clang::CodeCompletionContext::CCC_DotMemberAccess: { - // const auto type = Context.getBaseType(); - // if(type->isDependentType()) { - // - // if(const auto dependentType = type->getAs()) { - // auto qualifers = dependentType->getQualifier(); - // // qualifers->getKind() -> clang::NestedNameSpecifier::SpecifierKind; - // // auto t = qualifers->getAsType(); - // // TODO: 看是否能根据主模板一路把依赖名替换下去,直到变成非依赖名 - // } else if(const auto dependentType = type->getAs()) { - // } - // } - // break; - // } - // /* ... */ - // default: { - // llvm::outs() << " Kind: " << Context.getKind() << "\n"; - // } - //} - // - // for(unsigned i = 0; i < NumResults; ++i) { - // clang::CodeCompletionResult& Result = Results[i]; - // - // switch(Result.Kind) { - // case clang::CodeCompletionResult::RK_Declaration: { - // llvm::outs() << " Declaration: "; - // llvm::outs() << Result.Declaration->getNameAsString() << "\n"; - // break; - // } - // - // case clang::CodeCompletionResult::RK_Keyword: { - // llvm::outs() << " Keyword: "; - // llvm::outs() << Result.Keyword << "\n"; - // break; - // } - // - // case clang::CodeCompletionResult::RK_Macro: { - // llvm::outs() << " Macro: "; - // llvm::outs() << Result.Macro->getName() << "\n"; - // break; - // } - // - // case clang::CodeCompletionResult::RK_Pattern: { - // llvm::outs() << " Pattern: "; - // llvm::outs() << Result.Pattern->getAsString() << "\n"; - // break; - // } - // } - //} - } - - void ProcessOverloadCandidates(clang::Sema& S, - unsigned CurrentArg, - OverloadCandidate* Candidates, - unsigned NumCandidates, - clang::SourceLocation OpenParLoc, - bool Braced) override {} -}; - -int main(int argc, const char** argv) { - assert(argc == 4 && "Usage: CodeCompletion "); - llvm::outs() << "running CodeCompletion...\n"; - - auto instance = std::make_unique(); - - clang::DiagnosticIDs* ids = new clang::DiagnosticIDs(); - clang::DiagnosticOptions* diag_opts = new clang::DiagnosticOptions(); - diag_opts->IgnoreWarnings = true; - clang::DiagnosticConsumer* consumer = new clang::IgnoringDiagConsumer(); - clang::DiagnosticsEngine* engine = new clang::DiagnosticsEngine(ids, diag_opts, consumer); - instance->setDiagnostics(engine); - - auto invocation = std::make_shared(); - std::vector args = { - "/usr/local/bin/clang++", - "-Xclang", - "-no-round-trip-args", - "-std=c++20", - argv[1], - }; - - invocation = clang::createInvocation(args, {}); - - /// NOTICE: - auto& codeCompletionAt = invocation->getFrontendOpts().CodeCompletionAt; - codeCompletionAt.FileName = argv[1]; - codeCompletionAt.Line = std::stoi(argv[2]); - codeCompletionAt.Column = std::stoi(argv[3]); - - clang::PreprocessorOptions& popts = invocation->getPreprocessorOpts(); - popts.DetailedRecord = true; - - instance->setInvocation(std::move(invocation)); - - if(!instance->createTarget()) { - llvm::errs() << "Failed to create target\n"; - std::terminate(); - } - - /// NOTICE: - instance->setCodeCompletionConsumer(new CodeCompleteConsumer()); - - clang::SyntaxOnlyAction action; - - if(!action.BeginSourceFile(*instance, instance->getFrontendOpts().Inputs[0])) { - llvm::errs() << "Failed to begin source file\n"; - std::terminate(); - } - - auto& pp = instance->getPreprocessor(); - pp.setTokenWatcher([&pp](const clang::Token& token) { - if(!token.isAnnotation()) { - // llvm::outs() << "token: " << pp.getSpelling(token) << " kind: " << token.getName() << "\n"; - } - }); - - if(auto error = action.Execute()) { - llvm::errs() << "Failed to execute action: " << error << "\n"; - std::terminate(); - } - - auto tu = instance->getASTContext().getTranslationUnitDecl(); - // tu->dump(); - - action.EndSourceFile(); -} diff --git a/docs/examples/Module.cpp b/docs/examples/Module.cpp deleted file mode 100644 index f439d115..00000000 --- a/docs/examples/Module.cpp +++ /dev/null @@ -1,203 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -class CodeCompleteConsumer : public clang::CodeCompleteConsumer { -private: - std::shared_ptr Allocator; - clang::CodeCompletionTUInfo CCTUInfo; - -public: - CodeCompleteConsumer() : - clang::CodeCompleteConsumer(clang::CodeCompleteOptions{}), - Allocator(std::make_shared()), CCTUInfo(Allocator) {} - - clang::CodeCompletionAllocator& getAllocator() override { return *Allocator; } - - clang::CodeCompletionTUInfo& getCodeCompletionTUInfo() override { return CCTUInfo; } - - void ProcessCodeCompleteResults(clang::Sema& S, - clang::CodeCompletionContext Context, - clang::CodeCompletionResult* Results, - unsigned NumResults) override { - llvm::outs() << NumResults << " code completion results\n"; - auto kind = Context.getKind(); - if(kind == clang::CodeCompletionContext::CCC_DotMemberAccess) { - auto type = Context.getBaseType(); - type->dump(); - } - // auto contexts = Context.getVisitedContexts(); - // for(auto c: contexts) { - // // llvm::outs() << " Kind: " << c->getDeclKindName() << "\n"; - // // for(auto d: c->decls()) { - // // // d->dump(); - // // } - // } - // - llvm::outs() << "code completion results:\n"; - // switch(Context.getKind()) { - // case clang::CodeCompletionContext::CCC_Attribute: { - // } - // case clang::CodeCompletionContext::CCC_DotMemberAccess: { - // const auto type = Context.getBaseType(); - // if(type->isDependentType()) { - // - // if(const auto dependentType = type->getAs()) { - // auto qualifers = dependentType->getQualifier(); - // // qualifers->getKind() -> clang::NestedNameSpecifier::SpecifierKind; - // // auto t = qualifers->getAsType(); - // // TODO: 看是否能根据主模板一路把依赖名替换下去,直到变成非依赖名 - // } else if(const auto dependentType = - // type->getAs()) { - // } - // } - // break; - // } - // /* ... */ - // default: { - // llvm::outs() << " Kind: " << Context.getKind() << "\n"; - // } - //} - - for(unsigned i = 0; i < NumResults; ++i) { - clang::CodeCompletionResult& Result = Results[i]; - - switch(Result.Kind) { - case clang::CodeCompletionResult::RK_Declaration: { - llvm::outs() << " Declaration: "; - llvm::outs() << Result.Declaration->getNameAsString() << "\n"; - break; - } - - case clang::CodeCompletionResult::RK_Keyword: { - llvm::outs() << " Keyword: "; - llvm::outs() << Result.Keyword << "\n"; - break; - } - - case clang::CodeCompletionResult::RK_Macro: { - llvm::outs() << " Macro: "; - llvm::outs() << Result.Macro->getName() << "\n"; - break; - } - - case clang::CodeCompletionResult::RK_Pattern: { - llvm::outs() << " Pattern: "; - llvm::outs() << Result.Pattern->getAsString() << "\n"; - break; - } - } - } - } - - void ProcessOverloadCandidates(clang::Sema& S, - unsigned CurrentArg, - OverloadCandidate* Candidates, - unsigned NumCandidates, - clang::SourceLocation OpenParLoc, - bool Braced) override {} -}; - -int main(int argc, const char** argv) { - assert(argc == 2 && "Usage: Preprocessor "); - llvm::outs() << "running ASTVisitor...\n"; - - std::string err; - auto CDB = clang::tooling::CompilationDatabase::loadFromDirectory( - "/home/ykiko/C++/clice/docs/examples/temp/build", - err); - - if(!CDB) { - llvm::errs() << "Failed to load compilation database: " << err << "\n"; - std::terminate(); - } - - using namespace clang::tooling::dependencies; - DependencyScanningService service{ScanningMode::DependencyDirectivesScan, - ScanningOutputFormat::P1689}; - DependencyScanningTool tool{service}; - auto cmd = CDB->getCompileCommands("/home/ykiko/C++/clice/docs/examples/temp/src/D.cppm")[0]; - auto dep = tool.getP1689ModuleDependencyFile(cmd, cmd.Directory); - if(auto error = dep.takeError()) { - llvm::errs() << "Failed to get module dependency file: " << error << "\n"; - std::terminate(); - } - for(auto& file: dep->Requires) { - llvm::outs() << "Module Name: " << file.ModuleName << "\n"; - } - - auto instance = std::make_unique(); - - clang::DiagnosticIDs* ids = new clang::DiagnosticIDs(); - clang::DiagnosticOptions* diag_opts = new clang::DiagnosticOptions(); - clang::DiagnosticConsumer* consumer = new clang::TextDiagnosticPrinter(llvm::errs(), diag_opts); - clang::DiagnosticsEngine* engine = new clang::DiagnosticsEngine(ids, diag_opts, consumer); - instance->setDiagnostics(engine); - - auto invocation = std::make_shared(); - std::vector args{ - "/usr/local/bin/clang++", - "-std=gnu++20", - "-x", - "c++-module", - "-fmodule-output=/home/ykiko/C++/clice/docs/examples/temp/build/CMakeFiles/test_modules.dir/D.pcm", - "-fmodule-file=B=/home/ykiko/C++/clice/docs/examples/temp/build/CMakeFiles/test_modules.dir/B.pcm", - "-fmodule-file=C=/home/ykiko/C++/clice/docs/examples/temp/build/CMakeFiles/test_modules.dir/C.pcm", - "-fmodule-file=A=/home/ykiko/C++/clice/docs/examples/temp/build/CMakeFiles/test_modules.dir/A.pcm", - "/home/ykiko/C++/clice/docs/examples/temp/src/D.cppm", - "-Xclang", - "-no-round-trip-args", - }; - - invocation = clang::createInvocation(args, {}); - - auto& codeCompletionAt = invocation->getFrontendOpts().CodeCompletionAt; - codeCompletionAt.FileName = "/home/ykiko/C++/clice/docs/examples/temp/src/D.cppm"; - codeCompletionAt.Line = std::stoi(argv[1]); - codeCompletionAt.Column = std::stoi(argv[2]); - - // clang::CompilerInvocation::CreateFromArgs(*invocation, args, instance->getDiagnostics()); - instance->setInvocation(std::move(invocation)); - - instance->setCodeCompletionConsumer(new CodeCompleteConsumer()); - - if(!instance->createTarget()) { - llvm::errs() << "Failed to create target\n"; - std::terminate(); - } - - clang::SyntaxOnlyAction action; - - if(!action.BeginSourceFile(*instance, instance->getFrontendOpts().Inputs[0])) { - llvm::errs() << "Failed to begin source file\n"; - std::terminate(); - } - - clang::syntax::TokenCollector collector{instance->getPreprocessor()}; - - if(auto error = action.Execute()) { - llvm::errs() << "Failed to execute action: " << error << "\n"; - std::terminate(); - } - - clang::syntax::TokenBuffer buffer = std::move(collector).consume(); - buffer.indexExpandedTokens(); - - auto tu = instance->getASTContext().getTranslationUnitDecl(); - // tu->dump(); - // ASTVistor visitor{instance->getPreprocessor(), - // buffer, - // instance->getASTContext(), - // instance->getSema(), - // buffer}; - // visitor.TraverseDecl(tu); - - action.EndSourceFile(); -}; - diff --git a/docs/examples/Preamble.cpp b/docs/examples/Preamble.cpp deleted file mode 100644 index 7eb2baea..00000000 --- a/docs/examples/Preamble.cpp +++ /dev/null @@ -1,136 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace fs = std::filesystem; - -auto buildPreamble(std::vector args, const char* path) { - auto invocation = clang::createInvocation(args, {}); - - // from filepath: llvm::MemoryBuffer::getFile - // from content: llvm::MemoryBuffer::getMemBuffer(content); - auto tmp = llvm::MemoryBuffer::getFile(path); - if(auto error = tmp.getError()) { - llvm::errs() << "Failed to get file: " << error.message() << "\n"; - std::terminate(); - } - llvm::MemoryBuffer* buffer = tmp->release(); - - // compute preamble bounds, if MaxLines set to false(0), it means not to limit the number of lines - auto bounds = clang::ComputePreambleBounds(invocation->getLangOpts(), *buffer, false); - - // create diagnostic engine - clang::DiagnosticsEngine* engine = new clang::DiagnosticsEngine( - new clang::DiagnosticIDs(), - new clang::DiagnosticOptions(), - new clang::TextDiagnosticPrinter(llvm::errs(), new clang::DiagnosticOptions())); - - // if store the preamble in memory, if not, store it in a file(storagePath) - bool storeInMemory = false; - std::string storagePath = (fs::path(path).parent_path() / "build").string(); - - auto VFS = llvm::vfs::getRealFileSystem(); - // if(auto error = VFS->setCurrentWorkingDirectory(storagePath)) { - // llvm::errs() << error.message() << "\n"; - // } - - // use to collect information in the process of building preamble, such as include files and macros - // TODO: inherit from clang::PreambleCallbacks and collect the information - clang::PreambleCallbacks callbacks = {}; - - // build preamble - auto preamble = clang::PrecompiledPreamble::Build(*invocation, - buffer, - bounds, - *engine, - llvm::vfs::getRealFileSystem(), - std::make_shared(), - storeInMemory, - storeInMemory ? "" : storagePath, - callbacks); - - if(auto error = preamble.getError()) { - llvm::errs() << "Failed to build preamble: " << error.message() << "\n"; - std::terminate(); - } - - return preamble; -} - -int main(int argc, const char** argv) { - assert(argc == 2 && "Usage: Preamble "); - llvm::outs() << "running Preamble...\n"; - - std::vector args = { - "/home/ykiko/Project/C++/clice/external/llvm/bin/clang++", - "-Xclang", - "-no-round-trip-args", - "-std=c++20", - argv[1], - "-c", - }; - - auto preamble = buildPreamble(args, argv[1]); - - auto instance = std::make_unique(); - - auto invocation = std::make_shared(); - invocation = clang::createInvocation(args, {}); - - auto tmp = llvm::MemoryBuffer::getFile(argv[1]); - if(auto error = tmp.getError()) { - llvm::errs() << "Failed to get file: " << error.message() << "\n"; - std::terminate(); - } - llvm::MemoryBuffer* buffer = tmp->release(); - - auto VFS = llvm::vfs::getRealFileSystem(); - auto bounds = clang::ComputePreambleBounds(invocation->getLangOpts(), *buffer, false); - - // check if the preamble can be reused - if(preamble->CanReuse(*invocation, *buffer, bounds, *VFS)) { - llvm::outs() << "Resued preamble\n"; - // reuse preamble - preamble->AddImplicitPreamble(*invocation, VFS, buffer); - } - - instance->setInvocation(std::move(invocation)); - - instance->createDiagnostics( - new clang::TextDiagnosticPrinter(llvm::errs(), new clang::DiagnosticOptions()), - true); - - /// NOTICE: if preamble is stored in memory, the code below is necessary - if(auto VFSWithRemapping = - createVFSFromCompilerInvocation(instance->getInvocation(), instance->getDiagnostics(), VFS)) - VFS = VFSWithRemapping; - instance->createFileManager(VFS); - - if(!instance->createTarget()) { - llvm::errs() << "Failed to create target\n"; - std::terminate(); - } - - clang::SyntaxOnlyAction action; - - auto& mainInput = instance->getFrontendOpts().Inputs[0]; - if(!action.BeginSourceFile(*instance, mainInput)) { - llvm::errs() << "Failed to begin source file\n"; - std::terminate(); - } - - if(auto error = action.Execute()) { - llvm::errs() << "Failed to execute action: " << error << "\n"; - std::terminate(); - } - - instance->getASTContext().getTranslationUnitDecl()->dump(); - - action.EndSourceFile(); -} diff --git a/docs/examples/Preprocessor.cpp b/docs/examples/Preprocessor.cpp deleted file mode 100644 index 6339f747..00000000 --- a/docs/examples/Preprocessor.cpp +++ /dev/null @@ -1,192 +0,0 @@ -#include -#include -#include - -using namespace clang; - -struct IfBlock { - SourceLocation If; - std::vector Elifs; - SourceLocation Else; - SourceLocation End; -}; - -struct IfdefBlock { - SourceLocation If; - std::vector Elifs; - SourceLocation Else; - SourceLocation End; -}; - -class DirectiveCollector : public clang::PPCallbacks { -private: - clang::Preprocessor& pp; - clang::SourceManager& sm; - -public: - DirectiveCollector(clang::Preprocessor& pp) : pp(pp), sm(pp.getSourceManager()) {} - - virtual ~DirectiveCollector() = default; - - void InclusionDirective(clang::SourceLocation HashLoc, - const clang::Token& IncludeTok, - StringRef FileName, - bool IsAngled, - clang::CharSourceRange FilenameRange, - clang::OptionalFileEntryRef File, - StringRef SearchPath, - StringRef RelativePath, - const clang::Module* SuggestedModule, - bool ModuleImported, - clang::SrcMgr::CharacteristicKind FileType) override {} - - void moduleImport(clang::SourceLocation ImportLoc, - clang::ModuleIdPath Path, - const clang::Module* Imported) override {} - - void PragmaDirective(clang::SourceLocation Loc, - clang::PragmaIntroducerKind Introducer) override {} - - void MacroExpands(const clang::Token& MacroNameTok, - const clang::MacroDefinition& MD, - clang::SourceRange Range, - const clang::MacroArgs* Args) override {} - - void MacroDefined(const clang::Token& MacroNameTok, const clang::MacroDirective* MD) override {} - - void MacroUndefined(const clang::Token& MacroNameTok, - const clang::MacroDefinition& MD, - const clang::MacroDirective* Undef) override {} - - void If(clang::SourceLocation Loc, - clang::SourceRange ConditionRange, - ConditionValueKind ConditionValue) override { - llvm::outs() << "If\n"; - Loc.dump(sm); - ConditionRange.dump(sm); - } - - void Elif(clang::SourceLocation Loc, - clang::SourceRange ConditionRange, - ConditionValueKind ConditionValue, - clang::SourceLocation IfLoc) override {} - - void Else(clang::SourceLocation Loc, clang::SourceLocation IfLoc) override {} - - void Ifdef(clang::SourceLocation Loc, - const clang::Token& MacroNameTok, - const clang::MacroDefinition& MD) override { - llvm::outs() << "Ifdef\n"; - Loc.dump(sm); - - llvm::outs() << "MacroName: " << pp.getSpelling(MacroNameTok) << "\n"; - auto info = MD.getMacroInfo(); - if(info) { - info->dump(); - } - } - - void Elifdef(clang::SourceLocation Loc, - const clang::Token& MacroNameTok, - const clang::MacroDefinition& MD) override {} - - void Ifndef(clang::SourceLocation Loc, - const clang::Token& MacroNameTok, - const clang::MacroDefinition& MD) override {} - - void Elifndef(clang::SourceLocation Loc, - const clang::Token& MacroNameTok, - const clang::MacroDefinition& MD) override {} - - void Endif(clang::SourceLocation Loc, clang::SourceLocation IfLoc) override { - llvm::outs() << "Endif\n"; - Loc.dump(sm); - IfLoc.dump(sm); - } -}; - -int main(int argc, const char** argv) { - assert(argc == 2 && "Usage: Preprocessor "); - llvm::outs() << "running Preprocessor...\n"; - - auto instance = std::make_unique(); - - clang::DiagnosticIDs* ids = new clang::DiagnosticIDs(); - clang::DiagnosticOptions* diag_opts = new clang::DiagnosticOptions(); - clang::DiagnosticConsumer* consumer = new clang::TextDiagnosticPrinter(llvm::errs(), diag_opts); - clang::DiagnosticsEngine* engine = new clang::DiagnosticsEngine(ids, diag_opts, consumer); - instance->setDiagnostics(engine); - - auto invocation = std::make_shared(); - std::vector args = { - "/usr/local/bin/clang++", - "-Xclang", - "-no-round-trip-args", - "-std=c++20", - argv[1], - }; - - invocation = clang::createInvocation(args, {}); - - instance->setInvocation(std::move(invocation)); - - if(!instance->createTarget()) { - llvm::errs() << "Failed to create target\n"; - std::terminate(); - } - - clang::PreprocessOnlyAction action; - - if(!action.BeginSourceFile(*instance, instance->getFrontendOpts().Inputs[0])) { - llvm::errs() << "Failed to begin source file\n"; - std::terminate(); - } - - clang::Preprocessor& pp = instance->getPreprocessor(); - auto& sm = pp.getSourceManager(); - // pp.setTokenWatcher([&](const clang::Token& token) { - // llvm::outs() << "Token: " << pp.getSpelling(token); - // auto loc = sm.getSpellingLoc(token.getLocation()); - // - // //llvm::outs() << " at " << pp.get << "\n"; - // // if(!token.isAnnotation()) { - // // if(auto II = token.getIdentifierInfo()) { - // // if(II->isKeyword(pp.getLangOpts())) { - // // auto name = clang::Lexer::getSpelling(token, pp.getSourceManager(), - // pp.getLangOpts()); - // // llvm::outs() << "Keyword: " << name << "\n"; - // // } - // // } - // // } else { - // // // TODO: split annoated token - // // } - // }); - - pp.addPPCallbacks(std::make_unique(pp)); - clang::syntax::TokenCollector collector{pp}; - - if(auto error = action.Execute()) { - llvm::errs() << "Failed to execute action: " << error << "\n"; - std::terminate(); - } - - auto buffer = std::move(collector).consume(); - buffer.dumpForTests(); - auto tokens = buffer.spelledTokens(sm.getMainFileID()); - // for(auto& token: tokens) { - // - // llvm::outs() << "Token: " << token.text(sm) << " " << - // clang::tok::getTokenName(token.kind()) - // << "\n"; - //} - - // auto tokens2 = buffer.expandedTokens(); - // for(auto& token: tokens2) { - // token.dumpForTests(sm); - // } - // auto buffer = sm.getBufferData(sm.getMainFileID()); - // llvm::outs() << buffer << "\n"; - // buffer.spelledTokenContaining() - // all operations should before action end - action.EndSourceFile(); -} diff --git a/docs/examples/TreeTransform.cpp b/docs/examples/TreeTransform.cpp deleted file mode 100644 index 8e84e880..00000000 --- a/docs/examples/TreeTransform.cpp +++ /dev/null @@ -1,130 +0,0 @@ -#include -#include -#include -#include -#include - -namespace clang { -class MyTreeTransform : public TreeTransform { - ASTContext& Context; - -public: - MyTreeTransform(Sema& SemaRef, clang::ASTContext& Context) : - TreeTransform(SemaRef), Context(Context) {} - - ExprResult TransformBinaryOperator(BinaryOperator* E) { - llvm::outs() << "Transforming BinaryOperator\n"; - E->dump(); - auto LHS = TransformExpr(E->getLHS()); - auto RHS = TransformExpr(E->getRHS()); - return SemaRef.BuildBinOp(SemaRef.getCurScope(), - E->getOperatorLoc(), - E->getOpcode(), - RHS.get(), - LHS.get()); - } - - ExprResult RebuildBinaryOperator(SourceLocation OpLoc, BinaryOperatorKind Opc, Expr* LHS, Expr* RHS) { - llvm::outs() << "-----------------------------" << "\n"; - return SemaRef.BuildBinOp(SemaRef.getCurScope(), OpLoc, Opc, RHS, LHS); - } -}; - -class ASTVisitor : public RecursiveASTVisitor { - clang::ASTContext& Context; - clang::Sema& SemaRef; - -public: - -public: - ASTVisitor(clang::ASTContext& Context, clang::Sema& SemaRef) : Context(Context), SemaRef(SemaRef) {} - - bool VisitVarDecl(VarDecl* decl) { - llvm::outs() << "Visiting BinaryOperator\n"; - clang::MyTreeTransform transformer{SemaRef, Context}; - decl->dump(); - auto result = transformer.TransformExpr(decl->getInit()); - decl->setInit(result.get()); - decl->dump(); - return true; - } -}; - -class MySemaConsumer : public clang::SemaConsumer { - clang::CompilerInstance& CI; - -public: - MySemaConsumer(clang::CompilerInstance& CI) : CI(CI) {} - - void HandleTranslationUnit(clang::ASTContext& Context) override { - clang::Sema& SemaRef = CI.getSema(); - clang::MyTreeTransform Transformer(SemaRef, Context); - llvm::outs() << "------------------------------\n"; - auto TU = Context.getTranslationUnitDecl(); - clang::ASTVisitor visitor{Context, SemaRef}; - visitor.TraverseDecl(TU); - } -}; - -class MyFrontendAction : public clang::ASTFrontendAction { -public: - std::unique_ptr CreateASTConsumer(clang::CompilerInstance& CI, - llvm::StringRef) override { - return std::make_unique(CI); - } -}; - -} // namespace clang - -int main(int argc, const char** argv) { - assert(argc == 2 && "Usage: Preprocessor "); - llvm::outs() << "running ASTVisitor...\n"; - - auto instance = std::make_unique(); - - clang::DiagnosticIDs* ids = new clang::DiagnosticIDs(); - clang::DiagnosticOptions* diag_opts = new clang::DiagnosticOptions(); - clang::DiagnosticConsumer* consumer = new clang::IgnoringDiagConsumer(); - clang::DiagnosticsEngine* engine = new clang::DiagnosticsEngine(ids, diag_opts, consumer); - instance->setDiagnostics(engine); - - auto invocation = std::make_shared(); - std::vector args = { - "/usr/local/bin/clang++", - "-Xclang", - "-no-round-trip-args", - "-std=c++20", - argv[1], - }; - - invocation = clang::createInvocation(args, {}); - // clang::CompilerInvocation::CreateFromArgs(*invocation, args, instance->getDiagnostics()); - instance->setInvocation(std::move(invocation)); - - if(!instance->createTarget()) { - llvm::errs() << "Failed to create target\n"; - std::terminate(); - } - - // instance->setASTConsumer(std::make_unique(*instance)); - - clang::MyFrontendAction action; - - if(!action.BeginSourceFile(*instance, instance->getFrontendOpts().Inputs[0])) { - llvm::errs() << "Failed to begin source file\n"; - std::terminate(); - } - - if(auto error = action.Execute()) { - llvm::errs() << "Failed to execute action: " << error << "\n"; - std::terminate(); - } - - auto tu = instance->getASTContext().getTranslationUnitDecl(); - - // tu->dump(); - // ASTVistor visitor{instance->getPreprocessor(), buffer, instance->getASTContext(), - // instance->getSema()}; visitor.TraverseDecl(tu); - - action.EndSourceFile(); -}; diff --git a/include/Clang/Clang.h b/include/Clang/Clang.h deleted file mode 100644 index 53011e48..00000000 --- a/include/Clang/Clang.h +++ /dev/null @@ -1,25 +0,0 @@ -#pragma once - -#include "clang/AST/RecursiveASTVisitor.h" -#include -#include -#include -#include -#include -#include -#include -#include - -namespace clice { - -using llvm::StringRef; -using PathRef = StringRef; -using clang::CompilerInstance; -using clang::CompilerInvocation; - -using clang::SourceLocation; -using clang::SourceRange; -using clang::PPCallbacks; -using clang::Token; - -} // namespace clice diff --git a/include/Clang/CompileDatabase.h b/include/Clang/CompileDatabase.h deleted file mode 100644 index 2e294566..00000000 --- a/include/Clang/CompileDatabase.h +++ /dev/null @@ -1,30 +0,0 @@ -#pragma once - -#include - -namespace clice { - -class CompileDatabase { -private: - std::unique_ptr database; - -public: - static auto& instance() { - static CompileDatabase instance; - return instance; - } - - void load(std::string_view path); - - auto lookup(std::string_view path) { - auto commands = database->getCompileCommands(path); - llvm::ArrayRef command = commands[0].CommandLine; - std::vector args = {command.front().c_str(), "-Xclang", "-no-round-trip-args"}; - for(auto& arg: command.drop_front()) { - args.push_back(arg.c_str()); - } - return args; - } -}; - -} // namespace clice diff --git a/include/Clang/Compiler.h b/include/Clang/Compiler.h deleted file mode 100644 index 5df44468..00000000 --- a/include/Clang/Compiler.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once - -#include "Clang.h" - -namespace clice { - -auto createCompilerInvocation(clang::tooling::CompileCommand& command, - std::vector* extraArgs, - llvm::IntrusiveRefCntPtr vfs, - clang::DiagnosticConsumer& consumer) -> std::unique_ptr; - -auto createCompilerInstance(std::unique_ptr invocation, - const clang::PrecompiledPreamble* preamble, - std::unique_ptr content, - llvm::IntrusiveRefCntPtr vfs, - clang::DiagnosticConsumer& consumer) -> std::unique_ptr; - -} // namespace clice diff --git a/include/Clang/Diagnostic.h b/include/Clang/Diagnostic.h deleted file mode 100644 index ed5686f4..00000000 --- a/include/Clang/Diagnostic.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include "Clang.h" - -namespace clice { - -class Diagnostic { - -}; - -class DiagnosticConsumer : clang::DiagnosticConsumer { - -}; - -} // namespace clice diff --git a/include/Clang/Directive.h b/include/Clang/Directive.h deleted file mode 100644 index 142cda41..00000000 --- a/include/Clang/Directive.h +++ /dev/null @@ -1,142 +0,0 @@ -#include - -namespace clice { - -// note that `#` is not part of the directive token. it is a separate token. -class Directive { - friend class DirectiveCollector; - -private: - /// represent a `#include` directive. - struct Header { - SourceLocation hashLoc; - Token includeTok; - StringRef fileName; - bool isAngled; - clang::CharSourceRange filenameRange; - clang::OptionalFileEntryRef file; - StringRef searchPath; - StringRef relativePath; - const clang::Module* suggestedModule; - bool moduleImported; - clang::SrcMgr::CharacteristicKind fileType; - }; - - /// represent a `#define` directive. - struct Define { - Token name; - const clang::MacroDirective* directive; - }; - - /// represent a `#undef` directive. - struct Undef { - Token name; - const clang::MacroDefinition* definition; - const clang::MacroDirective* directive; - }; - - /// represent a `#pragma` directive. - struct Pragma { - /// the location of `pragma` directive. - SourceLocation location; - /// the kind of the pragma directive. - clang::PragmaIntroducerKind kind; - }; - - /// represent a condition in `#if` or `#elif` directive. - struct Condition { - /// the source range of the condition. - SourceRange range; - /// the evaluated value of the condition. - PPCallbacks::ConditionValueKind value; - }; - - /// represent a `#if` directive - struct If { - /// the location of `if` directive. - SourceLocation location; - Condition condition; - }; - - /// represent a `#elif` directive - struct Elif { - /// the location of `elif` directive. - SourceLocation location; - Condition condition; - }; - - /// represent a macro condition in `#ifdef` or `#elifdef` directive. - struct MacroCondition { - /// the source range of the macro name. - Token token; - /// the corresponding macro definition(may be null). - clang::MacroDefinition definition; - }; - - /// represent a `#ifdef` directive - struct Ifdef { - /// the location of `ifdef` directive. - SourceLocation location; - MacroCondition condition; - }; - - /// represent a `#elifdef` directive - struct Elifdef { - /// the location of `elifdef` directive. - SourceLocation location; - MacroCondition condition; - }; - - struct Else { - /// the location of `else` directive. - SourceLocation location; - }; - - struct Endif { - /// the location of `endif` directive. - SourceLocation location; - }; - - struct IfBlock { - If if_; - std::vector elifs; - std::optional else_; - Endif endif; - }; - - struct IfdefBlock { - Ifdef ifdef; - std::vector elifdefs; - std::optional else_; - Endif endif; - }; - -private: - std::vector

headers; - std::vector defines; - std::vector undefs; - std::vector pragmas; - std::vector ifBlocks; - std::vector ifdefBlocks; - -public: - Directive(clang::Preprocessor& pp); - - auto& Headers() { return headers; } - - auto& Defines() { return defines; } - - auto& Undefs() { return undefs; } - - auto& Pragmas() { return pragmas; } - - auto& IfBlocks() { return ifBlocks; } - - auto& IfdefBlocks() { return ifdefBlocks; } -}; - -#if 1111 - -#endif - -} // namespace clice diff --git a/include/Clang/Module.h b/include/Clang/Module.h deleted file mode 100644 index e69de29b..00000000 diff --git a/include/Clang/ParsedAST.h b/include/Clang/ParsedAST.h deleted file mode 100644 index 49cd24c0..00000000 --- a/include/Clang/ParsedAST.h +++ /dev/null @@ -1,54 +0,0 @@ -#pragma once - -#include "Diagnostic.h" -#include "Preamble.h" -#include "CompileDatabase.h" - -namespace clice { - -class ParsedAST { -private: - using Decl = clang::Decl*; - using ASTConsumer = std::unique_ptr; - - struct FrontendAction : public clang::ASTFrontendAction { - ASTConsumer CreateASTConsumer(CompilerInstance& instance, PathRef file) override; - }; - -private: - /// path of translation unit - PathRef path; - /// llvm version - std::string version; - /// headers part of the tu, when a file is loaded, we will build the preamble, the reuse it. - Preamble preamble; - /// some extra info - std::vector topLevelDecls; - std::vector diagnostics; - /// core members for clang frontend - // uninitialized tokens; - clang::SyntaxOnlyAction action; - CompilerInstance instance; - clang::syntax::TokenBuffer buffer; - -public: - static std::unique_ptr build(std::string_view path, std::string_view content); - - static std::unique_ptr build(std::string_view path, - const std::shared_ptr& invocation, - const Preamble& preamble); - - auto& Diagnostics() { return diagnostics; } - - auto& ASTContext() { return instance.getASTContext(); } - - auto& Preprocessor() { return instance.getPreprocessor(); } - - auto& SourceManager() { return instance.getSourceManager(); } - - auto& TokenBuffer() { return buffer; } - - auto& TranslationUnit() { return *instance.getASTContext().getTranslationUnitDecl(); } -}; - -} // namespace clice diff --git a/include/Clang/Preamble.h b/include/Clang/Preamble.h deleted file mode 100644 index c8bb38a9..00000000 --- a/include/Clang/Preamble.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once - -#include "Directive.h" - -namespace clice { - -class Preamble { -private: - Directive directive; - clang::PrecompiledPreamble data; - - // Preamble(clang::PrecompiledPreamble&& preamble) : data(std::move(preamble)) {} - -public: - static std::unique_ptr - build(PathRef path, StringRef content, const CompilerInvocation& invocation); -}; - -} // namespace clice diff --git a/include/Clang/SelectionTree.h b/include/Clang/SelectionTree.h deleted file mode 100644 index e69de29b..00000000 diff --git a/include/Feature/SemanticToken.h b/include/Feature/SemanticToken.h deleted file mode 100644 index 4f091678..00000000 --- a/include/Feature/SemanticToken.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once - -#include - -namespace clice { - -class ParsedAST; - -namespace feature { - -protocol::SemanticTokens semanticTokens(const ParsedAST& ast); - -} - -} // namespace clice - diff --git a/include/Protocol/Basic.h b/include/Protocol/Basic.h deleted file mode 100644 index eb3afef1..00000000 --- a/include/Protocol/Basic.h +++ /dev/null @@ -1,187 +0,0 @@ -#pragma once - -#include -#include -#include -#include - -namespace clice::protocol { - -using Integer = int; -using UInteger = unsigned int; -using String = std::string; -using StringRef = std::string_view; - -template -struct Combine : Ts... {}; - -class URI { -private: - String scheme; - String authority; - String body; - -public: -}; - -using DocumentUri = String; - -/// Position in a text document expressed as zero-based line and zero-based character offset. -struct Position { - /// line position in a document (zero-based). - UInteger line; - - /// character offset on a line in a document (zero-based). - /// The meaning of this offset is determined by the negotiated `PositionEncodingKind`. - UInteger character; -}; - -/// A range in a text document expressed as (zero-based) start and end positions. -struct Range { - /// The range's start position. - Position start; - - /// The range's end position. - Position end; -}; - -/// An item to transfer a text document from the client to the server. -struct TextDocumentItem { - /// The text document's URI. - DocumentUri uri; - - /// The text document's language identifier. - String languageId; - - /// The version number of this document (it will strictly increase after each change, including - /// undo/redo). - Integer version; - - /// The content of the opened text document. - String text; -}; - -/// Text documents are identified using a URI. -struct TextDocumentIdentifier { - /// The text document's URI. - DocumentUri uri; -}; - -/// A parameter literal used in requests to pass a text document and a position inside that document. -struct TextDocumentPositionParams { - /// The text document. - TextDocumentIdentifier textDocument; - - /// The position inside the text document. - Position position; -}; - -/// A textual edit applicable to a text document. -struct TextEdit { - /// The range of the text document to be manipulated. To insert text into a document create a - /// range where start === end. - Range range; - - /// The string to be inserted. For delete operations use an empty string. - String newText; -}; - -/// Represents a location inside a resource, such as a line inside a text file. -struct Location { - URI uri; - Range range; -}; - -/// Represents a link between a source and a target location. -struct LocationLink { - /// Span of the origin of this link. - Range originSelectionRange; - - /// The target resource identifier of this link. - URI targetUri; - - /// The full target range of this link. If the target for example is a symbol then target range is the - /// range enclosing this symbol not including leading/trailing whitespace but everything else - /// like comments. This information is typically used to highlight the range in the editor. - Range targetRange; - - /// The range that should be selected and revealed when this link is being followed, e.g the name of a - /// function. Must be contained by the the `targetRange`. See also `DocumentSymbol#range` - Range targetSelectionRange; -}; - -/// Represents a diagnostic, such as a compiler error or warning. -/// Diagnostic objects are only valid in the scope of a resource. -struct Diagnostic { - - /// Represents a related message and source code location for a diagnostic. - /// This should be used to point to code locations that cause or are related to - /// a diagnostics, e.g when duplicating a symbol in a scope. - struct DiagnosticRelatedInformation { - /// The location of this related diagnostic information. - Location location; - - /// The message of this related diagnostic information. - String message; - }; - - /// Structure to capture a description for an error code. - struct CodeDescription { - /// An URI where the code is described. - URI href; - }; - - /// The range at which the message applies. - Range range; - - /// The diagnostic's severity. Can be omitted. If omitted it is up to the - /// client to interpret diagnostics as error, warning, info or hint. - Integer severity; - - /// The diagnostic's code. Can be omitted. - Integer code; - - /// A human-readable string describing the source of this diagnostic, e.g. 'typescript' or 'super lint'. - String source; - - /// The diagnostic's message. - String message; - - /// An array of related diagnostic information, e.g. when symbol-names within a scope collide all - /// definitions can be marked via this property. - // TODO: std::vector relatedInformation; -}; - -/// Represents a reference to a command. -struct Command { - /// Title of the command, like `save`. - String title; - - /// The identifier of the actual command handler. - String command; - - /// Arguments that the command handler should be invoked with. - /// arguments?: LSPAny[]; -}; - -struct MarkupKind { - StringRef m_Value; - - MarkupKind(StringRef value) : m_Value(value) {} - - /// Plain text is supported as a content format - constexpr inline static StringRef PlainText = "plaintext"; - - /// Markdown is supported as a content format - constexpr inline static StringRef Markdown = "markdown"; -}; - -struct MarkupContent { - /// The type of the Markup - MarkupKind kind; - - /// The content itself - String value; -}; - -} // namespace clice::protocol diff --git a/include/Protocol/Document/DidChange.h b/include/Protocol/Document/DidChange.h deleted file mode 100644 index e69de29b..00000000 diff --git a/include/Protocol/Document/DidClose.h b/include/Protocol/Document/DidClose.h deleted file mode 100644 index e69de29b..00000000 diff --git a/include/Protocol/Document/DidOpen.h b/include/Protocol/Document/DidOpen.h deleted file mode 100644 index e69de29b..00000000 diff --git a/include/Protocol/Document/DidSave.h b/include/Protocol/Document/DidSave.h deleted file mode 100644 index e69de29b..00000000 diff --git a/include/Protocol/Language/CallHierarchy.h b/include/Protocol/Language/CallHierarchy.h deleted file mode 100644 index 7927dce7..00000000 --- a/include/Protocol/Language/CallHierarchy.h +++ /dev/null @@ -1,92 +0,0 @@ -#pragma once - -#include "DocumentSymbol.h" - -namespace clice::protocol { - -/*=========================================================================/ -/ / -/============================= CallHierarchy ==============================/ -/ / -/=========================================================================*/ - -struct CallHierarchyItem { - /// The name of this item. - String name; - - /// The kind of this item. - SymbolKind kind; - - /// Tags for this item. - std::vector tags; - - /// More detail for this item, e.g. the signature of a function. - std::string detail; - - /// The resource identifier of this item. - URI uri; - - /// The range enclosing this symbol not including leading/trailing whitespace but everything else, e.g. - /// comments and code. - Range range; - - /// The range that should be selected and revealed when this symbol is being picked, e.g. the name of a - /// function. - Range selectionRange; - - /// A data entry field that is preserved between a call hierarchy prepare and incoming calls or outgoing - /// calls requests. std::any data; - /// data?: LSPAny; -}; - -/// Client Capability: -/// - property name (optional): `textDocument.callHierarchy` -/// - property type: `CallHierarchyClientCapabilities` defined as follows: -struct CallHierarchyClientCapabilities { - - /// Whether callHierarchy supports dynamic registration. - bool dynamicRegistration = false; -}; - -/// Request: -/// - method: 'textDocument/prepareCallHierarchy' -/// - params: `PrepareCallHierarchyParams` defined follows: -using CallHierarchyPrepareParams = Combine; - -/// Response: -/// - result: `CallHierarchyItem[]` -using CallHierarchyPrepareResult = std::vector; - -/*=========================================================================/ -/ / -/====================== Call Hierarchy Incoming Calls =====================/ -/ / -/=========================================================================*/ - -struct CallHierarchyIncomingCallsParamsBody { - /// The item for which incoming calls are to be computed. - CallHierarchyItem item; -}; - -/// Request: -/// - method: 'textDocument/callHierarchy/incomingCalls' -/// - params: `CallHierarchyIncomingCallsParams` defined follows: -using CallHierarchyIncomingCallsParams = Combine; - -struct CallHierarchyIncomingCall { - /// The item that was called. - CallHierarchyItem from; - /// The range at which at which the calls were made. - Range fromRanges; -}; - -/// Response: -/// - result: `CallHierarchyIncomingCall[]` -using CallHierarchyIncomingCallsResult = std::vector; - -} // namespace clice::protocol diff --git a/include/Protocol/Language/CodeAction.h b/include/Protocol/Language/CodeAction.h deleted file mode 100644 index 6f70f09b..00000000 --- a/include/Protocol/Language/CodeAction.h +++ /dev/null @@ -1 +0,0 @@ -#pragma once diff --git a/include/Protocol/Language/CodeLens.h b/include/Protocol/Language/CodeLens.h deleted file mode 100644 index a02f815b..00000000 --- a/include/Protocol/Language/CodeLens.h +++ /dev/null @@ -1,38 +0,0 @@ -#pragma once - -#include "../Basic.h" - -namespace clice::protocol { - -/// Client Capability: -/// - property name (optional): `textDocument/codeLens` -/// - property type: `CodeLensClientCapabilities` defined as follows: -struct CodeLensClientCapabilities { - /// Whether codeLens supports dynamic registration. - bool dynamicRegistration = false; -}; - -struct CodeLensParamsBody { - /// The document to request code lens for. - TextDocumentIdentifier textDocument; -}; - -/// Request: -/// - method: 'textDocument/codeLens' -/// - params: `CodeLensParams` defined follows: -using CodeLensParams = Combine< - // WorkDoneProgressParams, - // PartialResultParams, - CodeLensParamsBody>; - -struct CodeLens { - /// The range in which this code lens is valid. Should only span a single line. - Range range; - - /// The command this code lens represents. - /// TODO: Command command; - - /// data?: LSPAny; -}; - -} // namespace clice::protocol diff --git a/include/Protocol/Language/Completion.h b/include/Protocol/Language/Completion.h deleted file mode 100644 index 6f70f09b..00000000 --- a/include/Protocol/Language/Completion.h +++ /dev/null @@ -1 +0,0 @@ -#pragma once diff --git a/include/Protocol/Language/Declaration.h b/include/Protocol/Language/Declaration.h deleted file mode 100644 index 4db65aa5..00000000 --- a/include/Protocol/Language/Declaration.h +++ /dev/null @@ -1,32 +0,0 @@ -#pragma once - -#include "../Basic.h" - -namespace clice::protocol { - -/// Client Capability: -/// - property name (optional): `textDocument.declaration` -/// - property type: `DeclarationClientCapabilities` defined as follows: -struct DeclarationClientCapabilities { - /// Whether declaration supports dynamic registration. If this is set to - ///`true` the client supports the new `DeclarationRegistrationOptions` - /// return value for the corresponding server capability as well. - bool dynamicRegistration = false; - - /// The client supports additional metadata in the form of declaration links. - bool linkSupport = false; -}; - -/// Request: -/// - method: 'textDocument/declaration' -/// - params: `DeclarationParams` defined follows: -using DeclarationParams = Combine; - -/// Response: -/// result: Location -using DeclarationResult = Location; - -} // namespace clice::protocol diff --git a/include/Protocol/Language/Definition.h b/include/Protocol/Language/Definition.h deleted file mode 100644 index cde410c7..00000000 --- a/include/Protocol/Language/Definition.h +++ /dev/null @@ -1,31 +0,0 @@ -#pragma once - -#include "../Basic.h" - -namespace clice::protocol { - -/// Client Capability: -/// - property name (optional): `textDocument.definition` -/// - property type: `DefinitionClientCapabilities` defined as follows: -struct DefinitionClientCapabilities { - - /// Whether definition supports dynamic registration. - bool dynamicRegistration = false; - - /// The client supports additional metadata in the form of definition links. - bool linkSupport = false; -}; - -/// Request: -/// - method: 'textDocument/definition' -/// - params: `DefinitionParams` defined follows: -using DefinitionParams = Combine; - -/// Response: -/// result: Location -using DefinitionResult = Location; - -} // namespace clice::protocol diff --git a/include/Protocol/Language/DocumentColor.h b/include/Protocol/Language/DocumentColor.h deleted file mode 100644 index 6f70f09b..00000000 --- a/include/Protocol/Language/DocumentColor.h +++ /dev/null @@ -1 +0,0 @@ -#pragma once diff --git a/include/Protocol/Language/DocumentHighlight.h b/include/Protocol/Language/DocumentHighlight.h deleted file mode 100644 index 6821daf6..00000000 --- a/include/Protocol/Language/DocumentHighlight.h +++ /dev/null @@ -1,48 +0,0 @@ -#pragma once - -#include "../Basic.h" - -namespace clice::protocol { - -/// Client Capability: -/// - property name (optional): `textDocument.documentHighlight` -/// - property type: `DocumentHighlightClientCapabilities` defined as follows: -struct DocumentHighlightClientCapabilities { - - /// Whether documentHighlight supports dynamic registration. - bool dynamicRegistration = false; -}; - -/// Request: -/// - method: 'textDocument/documentHighlight' -/// - params: `DocumentHighlightParams` defined follows: -using DocumentHighlightParams = Combine; -/// A document highlight kind. -enum class DocumentHighlightKind { - /// A textual occurrence. - Text = 1, - /// Read-access of a symbol, like reading a variable. - Read = 2, - /// Write-access of a symbol, like writing to a variable. - Write = 3, -}; - -/// A document highlight is a range inside a text document which deserves -/// special attention. Usually a document highlight is visualized by changing -/// the background color of its range. -struct DocumentHighlight { - /// The range this highlight applies to. - Range range; - - /// The highlight kind, default is DocumentHighlightKind.Text. - DocumentHighlightKind kind = DocumentHighlightKind::Text; -}; - -/// Response: -/// result: DocumentHighlight[] -using DocumentHighlightResult = std::vector; - -} // namespace clice::protocol diff --git a/include/Protocol/Language/DocumentLink.h b/include/Protocol/Language/DocumentLink.h deleted file mode 100644 index 13293b18..00000000 --- a/include/Protocol/Language/DocumentLink.h +++ /dev/null @@ -1,52 +0,0 @@ -#pragma once - -#include "../Basic.h" - -namespace clice::protocol { - -/// Client Capability: -/// - property name (optional): `textDocument.documentLink` -/// - property type: `DocumentLinkClientCapabilities` defined as follows: -struct DocumentLinkClientCapabilities { - - /// Whether documentLink supports dynamic registration. - bool dynamicRegistration = false; - - /// Whether the client support the `tooltip` property on `DocumentLink`. - bool tooltipSupport = false; -}; - -struct DocumentLinkParamsBody { - /// The document to provide document links for. - TextDocumentIdentifier textDocument; -}; - -/// Request: -/// - method: 'textDocument/documentLink' -/// - params: `DocumentLinkParams` defined follows: -using DocumentLinkParams = Combine< - // WorkDoneProgressParams, - // PartialResultParams, - DocumentLinkParamsBody>; - -/// A document link is a range in a text document that links to an internal or -/// external resource, like another text document or a web site. -struct DocumentLink { - /// The range this link applies to. - Range range; - - /// The uri this link points to. If missing a resolve request is sent later. - std::string target; - - /// The tooltip text when you hover over this link. - std::string tooltip; - - // data?: LSPAny; -}; - -/// Response: -/// - result: `DocumentLink[]` -using DocumentLinkResult = std::vector; - -} // namespace clice::protocol - diff --git a/include/Protocol/Language/DocumentSymbol.h b/include/Protocol/Language/DocumentSymbol.h deleted file mode 100644 index d2518b6f..00000000 --- a/include/Protocol/Language/DocumentSymbol.h +++ /dev/null @@ -1,72 +0,0 @@ -#pragma once - -#include "../Basic.h" - -namespace clice::protocol { - -/// A symbol kind. -enum class SymbolKind : uint8_t { - File = 1, - Module, - Namespace, - Package, - Class, - Method, - Property, - Field, - Constructor, - Enum, - Interface, - Function, - Variable, - Constant, - String, - Number, - Boolean, - Array, - Object, - Key, - Null, - EnumMember, - Struct, - Event, - Operator, - TypeParameter -}; - -/// Symbol tags are extra annotations that tweak the rendering of a symbol. -enum class SymbolTag : uint8_t { - /// Render a symbol as obsolete, usually using a strike-out. - Deprecated = 1, -}; - -/// Represents programming constructs like variables, classes, interfaces etc. -/// that appear in a document. Document symbols can be hierarchical and they -/// have two ranges: one that encloses its definition and one that points to its -/// most interesting range, e.g. the range of an identifier. -struct DocumentSymbol { - /// The name of this symbol. - String name; - - /// More detail for this symbol, e.g the signature of a function. - String detail; - - /// The kind of this symbol. - SymbolKind kind; - - /// Tags for this symbol. - std::vector tags; - - /// The range enclosing this symbol not including leading/trailing whitespace but everything else, e.g. - /// comments and code. - Range range; - - /// The range that should be selected and revealed when this symbol is being picked, e.g. the name of a - /// function. Must be contained by the `range`. - Range selectionRange; - - /// Children of this symbol, e.g. properties of a class. - std::vector children; -}; - -} // namespace clice::protocol diff --git a/include/Protocol/Language/FoldingRange.h b/include/Protocol/Language/FoldingRange.h deleted file mode 100644 index 6f70f09b..00000000 --- a/include/Protocol/Language/FoldingRange.h +++ /dev/null @@ -1 +0,0 @@ -#pragma once diff --git a/include/Protocol/Language/Formatting.h b/include/Protocol/Language/Formatting.h deleted file mode 100644 index 6f70f09b..00000000 --- a/include/Protocol/Language/Formatting.h +++ /dev/null @@ -1 +0,0 @@ -#pragma once diff --git a/include/Protocol/Language/Hover.h b/include/Protocol/Language/Hover.h deleted file mode 100644 index 48d71a00..00000000 --- a/include/Protocol/Language/Hover.h +++ /dev/null @@ -1,41 +0,0 @@ -#pragma once - -#include "../Basic.h" - -namespace clice::protocol { - -/// Client Capability: -/// - property name (optional): `textDocument/hover` -/// - property type: `HoverClientCapabilities` defined as follows: -struct HoverClientCapabilities { - - /// Whether hover supports dynamic registration. - bool dynamicRegistration = false; - - /// Client supports the follow content formats for the content property. The order describes the preferred - /// format of the client. - std::vector contentFormat; -}; - -/// Request: -/// - method: 'textDocument/hover' -/// - params: `HoverParams` defined follows: -using HoverParams = Combine; - -/// The result of a hover request. -struct Hover { - /// The hover's content - MarkupContent contents; - - /// An optional range is a range inside a text document that is used to visualize a hover, e.g. by - /// changing the background color. - Range range; -}; - -/// Response: -/// result: Hover -using HoverResult = Hover; - -} // namespace clice::protocol diff --git a/include/Protocol/Language/Implementation.h b/include/Protocol/Language/Implementation.h deleted file mode 100644 index 8c382828..00000000 --- a/include/Protocol/Language/Implementation.h +++ /dev/null @@ -1,31 +0,0 @@ -#pragma once - -#include "../Basic.h" - -namespace clice::protocol { - -/// Client Capability: -/// - property name (optional): `textDocument.implementation` -/// - property type: `ImplementationClientCapabilities` defined as follows: -struct ImplementationClientCapabilities { - - /// Whether implementation supports dynamic registration. - bool dynamicRegistration = false; - - /// The client supports additional metadata in the form of implementation links. - bool linkSupport = false; -}; - -/// Request: -/// - method: 'textDocument/implementation' -/// - params: `ImplementationParams` defined follows: -using ImplementationParams = Combine; - -/// Response: -/// result: Location -using ImplementationResult = Location; - -} // namespace clice::protocol diff --git a/include/Protocol/Language/InlayHint.h b/include/Protocol/Language/InlayHint.h deleted file mode 100644 index 6f70f09b..00000000 --- a/include/Protocol/Language/InlayHint.h +++ /dev/null @@ -1 +0,0 @@ -#pragma once diff --git a/include/Protocol/Language/InlineValue.h b/include/Protocol/Language/InlineValue.h deleted file mode 100644 index 6f70f09b..00000000 --- a/include/Protocol/Language/InlineValue.h +++ /dev/null @@ -1 +0,0 @@ -#pragma once diff --git a/include/Protocol/Language/OnTypeFormatting.h b/include/Protocol/Language/OnTypeFormatting.h deleted file mode 100644 index 6f70f09b..00000000 --- a/include/Protocol/Language/OnTypeFormatting.h +++ /dev/null @@ -1 +0,0 @@ -#pragma once diff --git a/include/Protocol/Language/RangeFormatting.h b/include/Protocol/Language/RangeFormatting.h deleted file mode 100644 index 6f70f09b..00000000 --- a/include/Protocol/Language/RangeFormatting.h +++ /dev/null @@ -1 +0,0 @@ -#pragma once diff --git a/include/Protocol/Language/Reference.h b/include/Protocol/Language/Reference.h deleted file mode 100644 index a6ef2154..00000000 --- a/include/Protocol/Language/Reference.h +++ /dev/null @@ -1,37 +0,0 @@ -#pragma once - -#include "../Basic.h" - -namespace clice::protocol { - -/// Client Capability: -/// - property name (optional): `textDocument.references` -/// - property type: `ReferenceClientCapabilities` defined as follows: -struct ReferenceClientCapabilities { - - /// Whether references supports dynamic registration. - bool dynamicRegistration = false; -}; - -struct ReferenceContext { - /// Include the declaration of the current symbol. - bool includeDeclaration = false; -}; - -struct ReferenceParamsBody { - ReferenceContext context; -}; - -/// Request: -/// - method: 'textDocument/references' -/// - params: `ReferenceParams` defined follows: -using ReferenceParams = Combine; - -/// Response: -/// result: Location[] -using ReferenceResult = std::vector; - -} // namespace clice::protocol diff --git a/include/Protocol/Language/Rename.h b/include/Protocol/Language/Rename.h deleted file mode 100644 index 6f70f09b..00000000 --- a/include/Protocol/Language/Rename.h +++ /dev/null @@ -1 +0,0 @@ -#pragma once diff --git a/include/Protocol/Language/SelectionRange.h b/include/Protocol/Language/SelectionRange.h deleted file mode 100644 index 6f70f09b..00000000 --- a/include/Protocol/Language/SelectionRange.h +++ /dev/null @@ -1 +0,0 @@ -#pragma once diff --git a/include/Protocol/Language/SemanticToken.h b/include/Protocol/Language/SemanticToken.h deleted file mode 100644 index 0bc2307f..00000000 --- a/include/Protocol/Language/SemanticToken.h +++ /dev/null @@ -1,195 +0,0 @@ -#pragma once - -#include "../Basic.h" - -namespace clice::protocol { - -enum class SemanticTokenType : uint8_t { - /// Represents a comment. - Comment, - /// Represents a number literal. - Number, - /// Represents a character literal. - Char, - /// Represents a string literal. - String, - /// Represents a C/C++ keyword (e.g., `int`, `class`, `struct`). - Keyword, - /// Represents a compiler built-in macro, function, or keyword (e.g., `__stdcall`, - /// `__attribute__`, `__FUNCSIG__`). - Builtin, - /// Represents a preprocessor directive (e.g., `#include`, `#define`, `#if`). - Directive, - /// Represents a header file path (e.g., ``). - HeaderPath, - /// Represents a C/C++ macro name, both in definition and invocation. - Macro, - /// Represents a C/C++ macro parameter, both in definition and invocation. - MacroParameter, - /// Represents a C++ namespace name. - Namespace, - /// Represents a C/C++ type name. - Type, - /// Represents a C/C++ struct name. - Struct, - /// Represents a C/C++ union name. - Union, - /// Represents a C/C++ class name. - Class, - /// Represents a C/C++ field name. - Field, - /// Represents a C/C++ enum name. - Enum, - /// Represents a C/C++ enum field (member) name. - EnumMember, - /// Represents a C/C++ variable name. - Variable, - /// Represents a C/C++ function name. - Function, - /// Represents a C++ method name. - Method, - /// Represents a C/C++ function/method parameter name. - Parameter, - /// Represents a C++ dependent name in a template context (e.g., `name` in `auto y = T::name` - /// where T is a template parameter). - /// Note: This includes `T::template name(...)`; it's not possible to distinguish whether a name - /// is a function or a functor in a dependent context. - DependentName, - /// Represents a C++ dependent type name (e.g., `type` in `typename std::vector::type` where - /// T is a template parameter). - /// Note: This includes `typename T::template type<...>`. - DependentType, - /// Represents a C++20 concept name. - Concept, - /// Represents a C++11 attribute name. - Attribute, - /// Represents parentheses `()`. - Paren, - /// Represents curly braces `{}`. - Brace, - /// Represents square brackets `[]`. - Bracket, - /// Represents angle brackets `<>`. - Angle, - /// Represents the scope resolution operator `::`. - Scope, - /// Represents built-in operators (e.g., `+` in `1 + 2`). - Operator, - /// Represents punctuation in non-expression contexts (e.g., `;`, `,` in enum declaration, `=` - /// and `&` in lambda capture). - Delimiter, - Unknown, - Invalid -}; - -enum class SemanticTokenModifier : uint32_t { - /// emit for a name in declaration. - /// e.g. function declaration, variable declaration, class declaration. - Declaration, - /// emit for a name in definition. - /// e.g. function definition, variable definition, class definition. - Definition, - /// emit for a name in reference(not declaration or definition). - /// e.g. `x` in `x + 1`, `X` in `X::type` - Reference, - Const, - Constexpr, - Consteval, - Virtual, - PureVirtual, - Inline, - Static, - Deprecated, - Local, - /// emit for left bracket. - Left, - /// emit for right bracket. - Right, - /// emit for operators which are part of type. - /// e.g. `*` in `int*`, `&` in `int&`. - Intype, - /// emit for operators which are overloaded. - /// e.g. `+` in `std::string("123") + c;` - Overloaded, - None, -}; - -/// Client Capability: -/// - property name(optional): `textDocument.semanticTokens` -/// - property type: `SemanticTokensClientCapabilities` defined as follows: -struct SemanticTokensClientCapabilities { - /// Whether implementation supports dynamic registration. If this is set to `true` the client - bool dynamicRegistration = false; - - struct Requests { - // FIXME: - }; - - /// The token types that the client supports. - std::vector tokenTypes; - - /// The token modifiers that the client supports. - std::vector tokenModifiers; - - /// The formats the client supports. - /// formats: TokenFormat[]; - - /// Whether the client supports tokens that can overlap each other. - bool overlappingTokenSupport = false; - - /// Whether the client supports tokens that can span multiple lines. - bool multilineTokenSupport = false; - - /// Whether the client allows the server to actively cancel a semantic token request. - bool serverCancelSupport = false; - - /// Whether the client uses semantic tokens to augment existing syntax tokens. - bool serverCancelSupports = false; -}; - -struct SemanticTokensLegend { - /// The token types a server uses. - std::vector tokenTypes; - - /// The token modifiers a server uses. - std::vector tokenModifiers; -}; - -/// Server Capability: -/// - property name(optional): `textDocument.semanticTokens` -/// - property type: `SemanticTokensOptionss` defined as follows: -struct SemanticTokensOptions { - /// The legend used by the server. - SemanticTokensLegend legend; - - /// Server supports providing semantic tokens for a specific range. - bool range = false; - - /// Server supports providing semantic tokens for a full document. - bool full = false; -}; - -/// Request: -/// - method: `textDocument/semanticTokens/full` -/// - params: `SemanticTokensParams` defined as follows: -struct SemanticTokensParamsBody { - /// The text document. - TextDocumentIdentifier textDocument; -}; - -using SemanticTokensParams = Combine< - // WorkDoneProgressParams, - // PartialResultParams, - SemanticTokensParamsBody>; - -/// Response: -/// - result: `SemanticTokens` defined as follows: -struct SemanticTokens { - /// An optional result id. - String resultId; - - /// The actual tokens. - std::vector data; -}; - -} // namespace clice::protocol diff --git a/include/Protocol/Language/SignatureHelp.h b/include/Protocol/Language/SignatureHelp.h deleted file mode 100644 index 6f70f09b..00000000 --- a/include/Protocol/Language/SignatureHelp.h +++ /dev/null @@ -1 +0,0 @@ -#pragma once diff --git a/include/Protocol/Language/TypeDefinition.h b/include/Protocol/Language/TypeDefinition.h deleted file mode 100644 index 47f6f438..00000000 --- a/include/Protocol/Language/TypeDefinition.h +++ /dev/null @@ -1,31 +0,0 @@ -#pragma once - -#include "../Basic.h" - -namespace clice::protocol { - -/// Client Capability: -/// - property name (optional): `textDocument/typeDefinition` -/// - property type: `TypeDefinitionClientCapabilities` defined as follows: -struct TypeDefinitionClientCapabilities { - - /// Whether typeDefinition supports dynamic registration. - bool dynamicRegistration = false; - - /// The client supports additional metadata in the form of typeDefinition links. - bool linkSupport = false; -}; - -/// Request: -/// - method: 'textDocument/typeDefinition' -/// - params: `TypeDefinitionParams` defined follows: -using TypeDefinitionParams = Combine; - -/// Response: -/// result: Location -using TypeDefinitionResult = Location; - -} // namespace clice::protocol diff --git a/include/Protocol/Language/TypeHierarchy.h b/include/Protocol/Language/TypeHierarchy.h deleted file mode 100644 index 3695c0d4..00000000 --- a/include/Protocol/Language/TypeHierarchy.h +++ /dev/null @@ -1,63 +0,0 @@ -#pragma once - -#include "DocumentSymbol.h" - -namespace clice::protocol { - -struct TypeHierarchyItem { - - /// The name of this item. - String name; - - /// The kind of this item. - SymbolKind kind; - - /// Tags for this item. - std::vector tags; - - /// More detail for this item, e.g. the signature of a function. - std::string detail; - - /// The resource identifier of this item. - DocumentUri uri; - - /// The range enclosing this symbol not including leading/trailing whitespace but everything else, e.g. - /// comments and code. - Range range; - - /// The range that should be selected and revealed when this symbol is being picked, e.g. the name of a - /// function. - Range selectionRange; - - /// A data entry field that is preserved between a call hierarchy prepare and incoming calls or outgoing - /// calls requests. - /// data?: LSPAny; -}; - -/// Client Capability: -/// - property name (optional): `textDocument/typeHierarchy` -/// - property type: `TypeHierarchyClientCapabilities` defined as follows: -struct TypeHierarchyClientCapabilities { - /// Whether typeHierarchy supports dynamic registration. - bool dynamicRegistration = false; -}; - -/// Request: -/// - method: 'textDocument/prepareTypeHierarchy' -/// - params: `TypeHierarchyParams` defined follows: -using TypeHierarchyParams = Combine; - -/// Response: -/// - result: `TypeHierarchyItem[]` -using TypeHierarchyResult = std::vector; - -/*=========================================================================/ -/ / -/======================== Type Hierarchy Supertypes =======================/ -/ / -/=========================================================================*/ - -// TODO: -} // namespace clice::protocol diff --git a/include/Protocol/Lifecycle/Exit.h b/include/Protocol/Lifecycle/Exit.h deleted file mode 100644 index e69de29b..00000000 diff --git a/include/Protocol/Lifecycle/Initialize.h b/include/Protocol/Lifecycle/Initialize.h deleted file mode 100644 index e69de29b..00000000 diff --git a/include/Protocol/Lifecycle/Initialized.h b/include/Protocol/Lifecycle/Initialized.h deleted file mode 100644 index e69de29b..00000000 diff --git a/include/Protocol/Lifecycle/Shutdown.h b/include/Protocol/Lifecycle/Shutdown.h deleted file mode 100644 index e69de29b..00000000 diff --git a/include/Protocol/Message.h b/include/Protocol/Message.h deleted file mode 100644 index 94b0db47..00000000 --- a/include/Protocol/Message.h +++ /dev/null @@ -1,73 +0,0 @@ -#include - -namespace clice::protocol { - -/// A request message to describe a request between the client and the server. -/// Every processed request must send a response back to the sender of the request. -template -struct Request { - String jsonrpc = "2.0"; - - /// The request id. - Integer id; - - /// The method to be invoked. - String method; - - /// The method's params. - Params params; -}; - -enum class ErrorCode : Integer { - ParseError = -32700, - InvalidRequest = -32600, - MethodNotFound = -32601, - InvalidParams = -32602, - InternalError = -32603, -}; - -struct ResponseError { - /// A number indicating the error type that occurred. - ErrorCode code; - - /// A string providing a short description of the error. - String message; - - /// A Primitive or Structured value that contains additional information about the error. - // TODO: std::optional data; -}; - -/// A Response Message sent as a result of a request. If a request doesn’t provide a result value -/// the receiver of a request still needs to return a response message to conform to the JSON-RPC -/// specification. The result property of the ResponseMessage should be set to null in this case to signal a -/// successful request. -template -struct Response { - String jsonrpc = "2.0"; - - /// The request id. - Integer id; - - /// The result of the request. - std::optional result; - - /// The error of the request. - std::optional error; -}; - -/// A notification message to inform the server that the client has successfully registered itself. -template -struct Registration { - String jsonrpc = "2.0"; - - /// The method to be invoked. - String method; - - /// The registration's id. - Integer id; - - /// The registration's options. - RegistrationOptions registerOptions; -}; - -} // namespace clice::protocol diff --git a/include/Protocol/Protocol.h b/include/Protocol/Protocol.h deleted file mode 100644 index 4eae7d5a..00000000 --- a/include/Protocol/Protocol.h +++ /dev/null @@ -1,709 +0,0 @@ -#pragma once - -#include -#include -#include -#include - -#include "Language/SemanticToken.h" - -namespace clice { - -// Defined by JSON RPC. -enum class ErrorCode { - ParseError = -32700, - InvalidRequest = -32600, - MethodNotFound = -32601, - InvalidParams = -32602, - InternalError = -32603, - - ServerNotInitialized = -32002, - UnknownErrorCode = -32001, - - // Defined by the protocol. - RequestCancelled = -32800, - ContentModified = -32801, -}; - -struct ResourceOperationKind { - /// Supports creating new files and folders. - constexpr inline static std::string_view Create = "create"; - - /// Supports renaming existing files and folders. - constexpr inline static std::string_view Rename = "rename"; - - /// Supports deleting existing files and folders. - constexpr inline static std::string_view Delete = "delete"; -}; - -struct FailureHandlingKind { - /// Applying the workspace change is simply aborted if one of the changes - /// provided fails. All operations executed before the failing operation stay - /// executed. - constexpr inline static std::string_view Abort = "abort"; - - /// All operations are executed transactionally. That is they either all - /// succeed or no changes at all are applied to the workspace. - constexpr inline static std::string_view Transactional = "transactional"; - - /// If the workspace edit contains only textual file changes they are executed - /// transactionally. If resource changes (create, rename or delete file) are - /// part of the change the failure handling strategy is abort. - constexpr inline static std::string_view TextOnlyTransactional = "textOnlyTransactional"; - - /// The client tries to undo the operations already executed. But there is no - /// guarantee that this is succeeding. - constexpr inline static std::string_view Undo = "undo"; -}; - -/// A symbol kind. -enum class SymbolKind { - File = 1, - Module = 2, - Namespace = 3, - Package = 4, - Class = 5, - Method = 6, - Property = 7, - Field = 8, - Constructor = 9, - Enum = 10, - Interface = 11, - Function = 12, - Variable = 13, - Constant = 14, - String = 15, - Number = 16, - Boolean = 17, - Array = 18, - Object = 19, - Key = 20, - Null = 21, - EnumMember = 22, - Struct = 23, - Event = 24, - Operator = 25, - TypeParameter = 26, -}; - -struct WorkspaceEditClientCapabilities { - /// The client supports versioned document changes in `WorkspaceEdit`s - std::optional documentChanges; - - /// The resource operations the client supports. Clients should at least - /// support 'create', 'rename' and 'delete' files and folders. - /// possible values are in ResourceOperationKind - std::optional> resourceOperations; - - /// The failure handling strategy of a client if applying the workspace edit - /// fails. - /// possible values are in FailureHandlingKind - std::optional failureHandling; - - /// Whether the client normalizes line endings to the client specific - /// setting. - /// If set to `true` the client will normalize line ending characters - /// in a workspace edit to the client specific new line character(s). - std::optional normalizesLineEndings; - - struct ChangeAnnotationSupport { - /// Whether the client groups edits with equal labels into tree nodes, - /// for instance all edits labelled with "Changes in Strings" would - /// be a tree node. - std::optional groupsOnLabel; - }; - - /// Whether the client in general supports change annotations on text edits, - /// create file, rename file and delete file changes. - std::optional changeAnnotationSupport; -}; - -struct DidChangeConfigurationClientCapabilities { - /// Did change configuration notification supports dynamic registration. - std::optional dynamicRegistration; -}; - -struct DidChangeWatchedFilesClientCapabilities { - /// Did change watched files notification supports dynamic registration. - /// Please note that the current protocol doesn't support static - /// configuration for file changes from the server side. - std::optional dynamicRegistration; - - /// Whether the client has support for relative patterns or not. - std::optional supportsRelativePattern; -}; - -struct WorkspaceSymbolClientCapabilities { - /// Symbol request supports dynamic registration. - std::optional dynamicRegistration; - - struct SymbolKind_ { - /// The symbol kind values the client supports. When this - /// property exists the client also guarantees that it will - /// handle values outside its set gracefully and falls back - /// to a default value when unknown. - /// - /// If this property is not present the client only supports - /// the symbol kinds from `File` to `Array` as defined in - /// the initial version of the protocol. - std::vector valueSet; - }; - - /// Specific capabilities for the `SymbolKind` in the `workspace/symbol` request. - std::optional symbolKind; - - struct TagSupport { - /// The tags supported by the client. - std::vector valueSet; - }; - - /// The client supports tags on `SymbolInformation` and `WorkspaceSymbol`. - /// Clients supporting tags have to handle unknown tags gracefully. - std::optional tagSupport; - - struct ResolveSupport { - /// The properties that a client can resolve lazily. Usually `location.range`. - std::vector properties; - }; - - /// The client support partial workspace symbols. The client will send the - /// request `workspaceSymbol/resolve` to the server to resolve additional - /// properties. - std::optional resolveSupport; -}; - -struct ExecuteCommandClientCapabilities { - /// Execute command supports dynamic registration. - std::optional dynamicRegistration; -}; - -struct SemanticTokensWorkspaceClientCapabilities { - /// Whether the client implementation supports a refresh request sent from - /// the server to the client. - /// - /// Note that this event is global and will force the client to refresh all - /// semantic tokens currently shown. It should be used with absolute care - /// and is useful for situation where a server for example detect a project - /// wide change that requires such a calculation. - std::optional refreshSupport; -}; - -struct CodeLensWorkspaceClientCapabilities { - /** - * Whether the client implementation supports a refresh request sent from the - * server to the client. - * - * Note that this event is global and will force the client to refresh all - * code lenses currently shown. It should be used with absolute care and is - * useful for situation where a server for example detect a project wide - * change that requires such a calculation. - */ - std::optional refreshSupport; -}; - -/// Client workspace capabilities specific to inline values. -struct InlineValueWorkspaceClientCapabilities { - /// Whether the client implementation supports a refresh request sent from - /// the server to the client. - /// - /// Note that this event is global and will force the client to refresh all - /// inline values currently shown. It should be used with absolute care and - /// is useful for situation where a server for example detect a project wide - /// change that requires such a calculation. - std::optional refreshSupport; -}; - -/// Client workspace capabilities specific to inlay hints. -struct InlayHintWorkspaceClientCapabilities { - /// Whether the client implementation supports a refresh request sent from - /// the server to the client. - /// - /// Note that this event is global and will force the client to refresh all - /// inlay hints currently shown. It should be used with absolute care and - /// is useful for situation where a server for example detects a project wide - /// change that requires such a calculation. - std::optional refreshSupport; -}; - -/// Workspace client capabilities specific to diagnostic pull requests. -struct DiagnosticWorkspaceClientCapabilities { - /// Whether the client implementation supports a refresh request sent from - /// the server to the client. - /// - /// Note that this event is global and will force the client to refresh all - /// pulled diagnostics currently shown. It should be used with absolute care - /// and is useful for situation where a server for example detects a project - /// wide change that requires such a calculation. - std::optional refreshSupport; -}; - -struct ClientCapabilities { - struct Workplace { - /// The client supports applying batch edits - /// to the workspace by supporting the request - /// 'workspace/applyEdit' - std::optional applyEdit; - - /// Capabilities specific to `WorkspaceEdit`s - std::optional workspaceEdit; - - /// Capabilities specific to the `workspace/didChangeConfiguration` notification. - std::optional didChangeConfiguration; - - /// Capabilities specific to the `workspace/didChangeWatchedFiles` notification. - std::optional didChangeWatchedFiles; - - /// Capabilities specific to the `workspace/symbol` request. - std::optional symbol; - - /// Capabilities specific to the `workspace/executeCommand` request. - std::optional executeCommand; - - /// The client has support for workspace folders. - std::optional workspaceFolders; - - /// The client supports `workspace/configuration` requests. - std::optional configuration; - - /// Capabilities specific to the semantic token requests scoped to the workspace. - std::optional semanticTokens; - - /// Capabilities specific to the code lens requests scoped to the workspace. - std::optional codeLens; - - struct FileOperations { - /// Whether the client supports dynamic registration for file requests/notifications. - std::optional dynamicRegistration; - - /// The client has support for sending didCreateFiles notifications. - std::optional didCreate; - - /// The client has support for sending willCreateFiles requests. - std::optional willCreate; - - /// The client has support for sending didRenameFiles notifications. - std::optional didRename; - - /// The client has support for sending willRenameFiles requests. - std::optional willRename; - - /// The client has support for sending didDeleteFiles notifications. - std::optional didDelete; - - /// The client has support for sending willDeleteFiles requests. - std::optional willDelete; - }; - - /// The client has support for file requests/notifications. - std::optional fileOperations; - - /// Client workspace capabilities specific to inline values. - std::optional inlineValue; - - /// Client workspace capabilities specific to inlay hints. - std::optional inlayHint; - - /// Client workspace capabilities specific to diagnostics. - std::optional diagnostic; - }; - - /// Workspace specific client capabilities. - std::optional workspace; - - /// Text document specific client capabilities. - /// TODO: textDocument?: TextDocumentClientCapabilities; - - /// Capabilities specific to the notebook document support. - /// TODO: notebookDocument?: NotebookDocumentClientCapabilities; - - /// Window specific client capabilities. - /// TODO: window: {...} - - /// General client capabilities. - /// TODO: general: {...} - - /// Experimental client capabilities. - /// experimental?: LSPAny; -}; - -/// TODO: -struct URI {}; - -struct WorkspaceFolder { - /// The associated URI for this workspace folder. - URI uri; - - /// The name of the workspace folder. Used to refer to this - /// workspace folder in the user interface. - std::string name; -}; - -struct InitializeParams { - /// The process Id of the parent process that started the server. Is null if - /// the process has not been started by another process. If the parent - /// process is not alive then the server should exit (see exit notification) - /// its process. - std::optional processId; - - struct ClientInfo { - std::string_view name; - std::optional version; - }; - - /// Information about the client - std::optional clientInfo; - - /// The locale the client is currently showing the user interface - /// in. This must not necessarily be the locale of the operating - /// system. - /// - /// Uses IETF language tags as the value's syntax - /// (See https://en.wikipedia.org/wiki/IETF_language_tag) - /// - /// @since 3.16.0 - std::optional locale; - - /// User provided initialization options. - /// TODO: initializationOptions?: LSPAny; - - /// The capabilities provided by the client (editor or tool). - ClientCapabilities capabilities; - - /// The initial trace setting. If omitted trace is disabled ('off'). - /// TODO: trace?: TraceValue; - - /// The workspace folders configured in the client when the server starts. - /// This property is only available if the client supports workspace folders. - /// It can be `null` if the client supports workspace folders but none are - /// configured. - std::optional> workspaceFolders; -}; - -/*===========================================================================// -// RESPONSES // -//===========================================================================*/ - -struct PositionEncodingKind { - /// Character offsets count UTF-8 code units (e.g bytes). - constexpr inline static std::string_view UTF8 = "utf-8"; - - /// Character offsets count UTF-16 code units. - /// This is the default and must always be supported by servers. - constexpr inline static std::string_view UTF16 = "utf-16"; - - /// Character offsets count UTF-32 code units. - /// Implementation note: these are the same as Unicode code points, - /// so this `PositionEncodingKind` may also be used for an - /// encoding-agnostic representation of character offsets. - constexpr inline static std::string_view UTF32 = "utf-32"; -}; - -/// Defines how the host (editor) should sync document changes to the language server. -enum class TextDocumentSyncKind { - /// Documents should not be synced at all. - None = 0, - - /// Documents are synced by always sending the full content of the document. - Full = 1, - - /// Documents are synced by sending the full content on open. After that only - /// incremental updates to the document are sent. - Incremental = 2, -}; - -/// Completion options. -struct CompletionOptions { - /// - /// The additional characters, beyond the defaults provided by the client (typically - ///[a-zA-Z]), that should automatically trigger a completion request. For example - ///`.` in JavaScript represents the beginning of an object property or method and is - /// thus a good candidate for triggering a completion request. - /// - /// Most tools trigger a completion request automatically without explicitly - /// requesting it using a keyboard shortcut (e.g. Ctrl+Space). Typically they - /// do so when the user starts to type an identifier. For example if the user - /// types `c` in a JavaScript file code complete will automatically pop up - /// present `console` besides others as a completion item. Characters that - /// make up identifiers don't need to be listed here. - std::array triggerCharacters = {".", "<", ">", ":", "\"", "/", "*"}; - - /// The list of all possible characters that commit a completion. This field - /// can be used if clients don't support individual commit characters per - /// completion item. See client capability `completion.completionItem.commitCharactersSupport`. - /// - /// If a server provides both `allCommitCharacters` and commit characters on - /// an individual completion item the ones on the completion item win. - /// - /// allCommitCharacters?: string[]; - /// NOTICE: We don't set `(` etc as allCommitCharacters as they interact poorly with snippet results. - /// See https://github.com/clangd/vscode-clangd/issues/357 - /// Hopefully we can use them one day without this side-effect: - /// https://github.com/microsoft/vscode/issues/42544 - - /// The server provides support to resolve additional information for a completion item. - bool resolveProvider = false; - - /// The server supports the following `CompletionItem` specific capabilities. - /// TODO: completionItem?: {...} -}; - -struct SignatureHelpOptions { - /// The characters that trigger signature help automatically. - std::array triggerCharacters = {"(", ")", "{", "}", "<", ">", ","}; - - /// List of characters that re-trigger signature help. - /// These trigger characters are only active when signature help is already showing. - /// All trigger characters are also counted as re-trigger characters. - std::array retriggerCharacters = {","}; -}; - -struct CodeLensOptions { - /// Code lens has a resolve provider as well. - bool resolveProvider = false; -}; - -struct DocumentLinkOptions { - /// Document links have a resolve provider as well. - bool resolveProvider = false; -}; - -struct DocumentOnTypeFormattingOptions { - /// A character on which formatting should be triggered, like `{`. - std::string_view firstTriggerCharacter = "\n"; - - /// More trigger characters. - /// moreTriggerCharacter?: string[]; -}; - -struct SemanticTokensOptions { - /// The legend used by the server - protocol::SemanticTokensLegend legend; - - /// Server supports providing semantic tokens for a specific range of a document. - bool range = false; // TODO: further check - - struct Full { - /// Server supports providing semantic tokens for a full document. - bool delta = true; - }; - - /// Server supports providing semantic tokens for a full document. - Full full; -}; - -struct ServerCapabilities { - /// The position encoding the server picked from the encodings offered - /// by the client via the client capability `general.positionEncodings`. - /// - /// If the client didn't provide any position encodings the only valid - /// value that a server can return is 'utf-16'. - /// - /// If omitted it defaults to 'utf-16'. - /// - /// possible values: ['utf-8', 'utf-16', 'utf-32'] in PositionEncodingKind - std::string_view positionEncoding = PositionEncodingKind::UTF16; - - /// Defines how text documents are synced. Is either a detailed structure - /// defining each notification or for backwards compatibility the - /// TextDocumentSyncKind number. If omitted it defaults to `TextDocumentSyncKind.None`. - TextDocumentSyncKind textDocumentSync = TextDocumentSyncKind::Incremental; - - /// Defines how notebook documents are synced. - /// TODO: notebookDocumentSync?: NotebookDocumentSyncOptions | NotebookDocumentSyncRegistrationOptions; - - /// The server provides completion support. - CompletionOptions completionProvider; - - /// The server provides hover support. - bool hoverProvider = true; - - /// The server provides signature help support. - SignatureHelpOptions signatureHelpProvider; - - /// The server provides go to declaration support. - bool declarationProvider = true; - - /// The server provides goto definition support. - bool definitionProvider = true; - - /// The server provides goto type definition support. - bool typeDefinitionProvider = true; - - /// The server provides goto implementation support. - bool implementationProvider = true; - - /// The server provides find references support. - bool referencesProvider = true; - - /// The server provides document highlight support. - bool documentHighlightProvider = true; - - /// The server provides document symbol support. - bool documentSymbolProvider = true; - - /// The server provides code actions. The `CodeActionOptions` return type is - /// only valid if the client signals code action literal support via the - /// client capability `textDocument.codeAction.codeActionLiteralSupport`. - bool codeActionProvider = true; // TODO: provide CodeActionOptions - - /// The server provides code lens. - CodeLensOptions codeLensProvider; - - /// The server provides document link support. - DocumentLinkOptions documentLinkProvider; - - /// The server provides color provider support. - bool colorProvider = false; // TODO: check what is colorProvider - - /// The server provides document formatting. - bool documentFormattingProvider = true; - - /// The server provides document range formatting. - bool documentRangeFormattingProvider = true; - - /// The server provides document formatting on typing. - DocumentOnTypeFormattingOptions documentOnTypeFormattingProvider; - - /// The server provides rename support. RenameOptions may only be - /// specified if the client states that it supports - /// `prepareSupport` in its initial `initialize` request. - bool renameProvider = true; - - /// The server provides folding provider support. - bool foldingRangeProvider = true; - - /// The server provides execute command support. - /// executeCommandProvider?: ExecuteCommandOptions; - - /// The server provides selection range support. - bool selectionRangeProvider = true; - - /// The server provides linked editing range support. - bool linkedEditingRangeProvider = true; - - /// The server provides call hierarchy support. - bool callHierarchyProvider = true; - - /// The server provides semantic tokens support. - SemanticTokensOptions semanticTokensProvider; - - /// Whether server provides moniker support. - bool monikerProvider = false; // TODO: further discussion - - /// The server provides type hierarchy support. - bool typeHierarchyProvider = true; - - /// The server provides inline values. - bool inlineValueProvider = true; - - /// The server provides inlay hints. - bool inlayHintProvider = true; - - /// The server has support for pull model diagnostics. - /// TODO: diagnosticProvider?: DiagnosticOptions - - /// The server provides workspace symbol support. - bool workspaceSymbolProvider = true; - - /// The server is interested in file notifications/requests. - /// TODO: fileOperations?: {...} -}; - -struct InitializeResult { - /// The capabilities the language server provides. - ServerCapabilities capabilities; - - struct ServerInfo { - /// The name of the server as defined by the server. - std::string_view name = "clice"; - - /// The server's version as defined by the server. - std::string_view version = "0.0.1"; - }; - - /// Information about the server. - ServerInfo serverInfo; -}; - -/*===================================================/ -/ / -/======= Text Document Synchronization ==========/ -/ / -/===================================================*/ - -/// An item to transfer a text document from the client to the server. -struct TextDocumentItem { - /// The text document's URI. - std::string_view uri; - - /// The text document's language identifier. - std::string_view languageId; - - /// he version number of this document (it will increase after each change, including undo/redo). - int version; - - /// The content of the opened text document. - std::string_view text; -}; - -/// Text documents are identified using a URI. On the protocol level, URIs are passed as strings. -struct TextDocumentIdentifier { - /// The text document's URI. - std::string_view uri; -}; - -struct VersionedTextDocumentIdentifier { - /// The text document's URI. - std::string_view uri; - - /// The version number of this document. - /// - /// The version number of a document will increase after each change, - /// including undo/redo. The number doesn't need to be consecutive. - int version; -}; - -struct DidOpenTextDocumentParams { - /// The document that was opened. - TextDocumentItem textDocument; -}; - -struct TextDocumentContentChangeEvent { - // TODO: -}; - -struct DidChangeTextDocumentParams { - /// The document that did change. The version number points - /// to the version after all provided content changes have - /// been applied. - VersionedTextDocumentIdentifier textDocument; - - /// The actual content changes. The content changes describe single state - /// changes to the document. So if there are two content changes c1 (at - /// array index 0) and c2 (at array index 1) for a document in state S then - /// c1 moves the document from S to S' and c2 from S' to S''. So c1 is - /// computed on the state S and c2 is computed on the state S'. - /// - /// To mirror the content of a document using change events use the following - /// approach: - /// - start with the same initial content - /// - apply the 'textDocument/didChange' notifications in the order you receive them. - /// - apply the `TextDocumentContentChangeEvent`s in a single notification in the order you receive them. - std::vector contentChanges; -}; - -struct DidCloseTextDocumentParams { - /// The document that was closed. - TextDocumentIdentifier textDocument; -}; - -struct DidSaveTextDocumentParams { - /// The document that was saved. - TextDocumentIdentifier textDocument; - - /// Optional the content when saved. Depends on the includeText value - /// when the save notification was requested. - std::optional text; -}; - -} // namespace clice diff --git a/include/Protocol/README.md b/include/Protocol/README.md deleted file mode 100644 index 85045c48..00000000 --- a/include/Protocol/README.md +++ /dev/null @@ -1,93 +0,0 @@ -This file dictionary mainly describes the [Language Server Protocol Specification](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/). Every interface in the protocol is defined as corresponding struct. - -For example, [Position](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#position) has the following definition in the protocol: - -```typescript -interface Position { - line: uinteger; - character: uinteger; -} -``` - -then the corresponding representation in C++ is: - -```cpp -struct Position { - uinteger line; - uinteger character; -}; -``` - -We use template meta programming to reflect the protocol type so that the serialization and deserialization can be done automatically. The trick is only suitable for type which is aggregate and default constructible and does not have base classes. But there are many types in the protocol which are defined through inheritance. For example, [DeclarationParams](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#declarationParams) is defined as: - -```typescript -export interface DeclarationParams extends TextDocumentPositionParams, - WorkDoneProgressParams, PartialResultParams { -} -``` - -We use `Combine` to resolve the problem. `Combine` is defined as: - -```cpp -template -struct Combine : Ts... {}; -``` - -Then `DeclarationParams` can be defined as: - -```cpp -using DeclarationParams = Combine< - TextDocumentPositionParams, - WorkDoneProgressParams, - PartialResultParams ->; -``` - -Compared to direct inheritance, this way allows us to get the base class types of `DeclarationParams`. If the interface also has data members, you should define a struct to hold the data members separately and add it to `Combine` list. - -For example, we have [ReferenceParams](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#referenceParams) definition as follow: - -```typescript -export interface ReferenceParams extends TextDocumentPositionParams, - WorkDoneProgressParams, PartialResultParams { - context: ReferenceContext; -} -``` - -Then we can define `ReferenceParams` as: - -```cpp -struct ReferenceParamsBody { - ReferenceContext context; -}; - -using ReferenceParams = Combine< - TextDocumentPositionParams, - WorkDoneProgressParams, - PartialResultParams, - ReferenceParamsBody ->; -``` - -For number enum in TypeScript, it can define as corresponding `enum` in C++ directly, for string enum, we define it as `struct` with `static` members. - -```typescript -export namespace MarkupKind { - export const PlainText: 'plaintext' = 'plaintext'; - export const Markdown: 'markdown' = 'markdown'; -} -export type MarkupKind = 'plaintext' | 'markdown'; -``` - -```cpp -struct MarkupKind { - std::string_view m_value; - - constexpr MarkupKind(std::string_view value) : m_value(value) {} - - constexpr inline static std::string_view PlainText = "plaintext"; - constexpr inline static std::string_view Markdown = "markdown"; -}; -``` - - diff --git a/include/Server/Scheduler.h b/include/Server/Scheduler.h deleted file mode 100644 index 66b3b9cb..00000000 --- a/include/Server/Scheduler.h +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once - -#include -#include - -namespace clice { - -struct TranslationUnit { - std::string path; - std::deque messages; - std::unique_ptr ast; -}; - -/// a class used to manage all resources for the LSP server -class Scheduler { -private: - llvm::StringMap> parsedASTs; - -public: - // update the AST for a given file - Task update(std::string_view path, std::string_view content); -}; - -} // namespace clice diff --git a/include/Server/Server.h b/include/Server/Server.h deleted file mode 100644 index 1fec494e..00000000 --- a/include/Server/Server.h +++ /dev/null @@ -1,68 +0,0 @@ -#pragma once - -#include -#include "Scheduler.h" -#include "Transport.h" - -namespace clice { - -// global server instance -extern class Server server; - -/// core class responsible for starting the server -class Server { - std::unique_ptr transport; - std::unique_ptr scheduler; - std::map methods; - -public: - int run(int argc, char** argv); - int exit(); - void handle_message(std::string_view message); - - template - void register_method(std::string_view name) { - methods[name] = [](R (*)(Args...)) { - return [](std::string_view message) { - // auto input = json::parse(message); - // auto params = deserialize(input["params"]); - // ptr(params); - }; - }(ptr); - } - -private: - /*===================================================/ - / / - /==================== LSP methods ===================/ - / / - /===================================================*/ - - // Server lifecycle - void initialize(const InitializeParams& params); - - // Text Document Synchronization - Task didOpen(const DidOpenTextDocumentParams& params); - Task didChange(const DidChangeTextDocumentParams& params); - Task didClose(const DidCloseTextDocumentParams& params); - Task didSave(const DidSaveTextDocumentParams& params); - - // Language Features - Task declaration(); - Task definition(); - Task typeDefinition(); - Task implementation(); - Task references(); - Task callHierarchy(); - /* ... */ - Task hover(); - Task codeLens(); - /* ... */ - Task foldingRange(); - Task selectionRange(); - Task documentSymbol(); - Task semanticTokens(); - Task inlineValue(); -}; - -} // namespace clice diff --git a/include/Server/Setting.h b/include/Server/Setting.h deleted file mode 100644 index 95045f10..00000000 --- a/include/Server/Setting.h +++ /dev/null @@ -1,16 +0,0 @@ -#include - -namespace clice { - -/// Settings for the LSP server -struct Setting { - /// compile_commands.json file path - std::string compile_commands_dictionary = "/build"; - /// mode of the server: ["pipe", "socket", "index"] - std::string mode = "pipe"; -}; - -/// global setting instance -inline Setting setting = {}; - -} // namespace clice diff --git a/include/Server/Transport.h b/include/Server/Transport.h deleted file mode 100644 index 91e53985..00000000 --- a/include/Server/Transport.h +++ /dev/null @@ -1,57 +0,0 @@ -#pragma once - -#include - -namespace clice { - -class Transport { -public: - virtual void send(std::string_view) = 0; - virtual ~Transport() = default; -}; - -class Pipe : public Transport { -private: - uv_pipe_t stdin_pipe; - uv_pipe_t stdout_pipe; - -private: - static void alloc_buffer(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf); - static void on_read(uv_stream_t* stream, ssize_t nread, const uv_buf_t* buf); - -public: - Pipe() { - // initialize the pipe - uv_loop_t* loop = uv_default_loop(); - uv_pipe_init(loop, &stdin_pipe, 0); - uv_pipe_init(loop, &stdout_pipe, 0); - - // bind to stdin and stdout - uv_pipe_open(&stdin_pipe, 0); - uv_pipe_open(&stdout_pipe, 1); - - // set callback for reading from stdin - uv_read_start((uv_stream_t*)&stdin_pipe, alloc_buffer, on_read); - } - - void send(std::string_view message) override; - - ~Pipe() override { - uv_close((uv_handle_t*)&stdin_pipe, nullptr); - uv_close((uv_handle_t*)&stdout_pipe, nullptr); - } -}; - -class Socket : public Transport { -private: - uv_tcp_t socket; - -public: - Socket(std::string_view address, int port); - - void send(std::string_view message) override; - - ~Socket() override { uv_close((uv_handle_t*)&socket, nullptr); } -}; - -} // namespace clice diff --git a/include/Support/Async.h b/include/Support/Async.h deleted file mode 100644 index f191ee20..00000000 --- a/include/Support/Async.h +++ /dev/null @@ -1,152 +0,0 @@ -#pragma once - -#include -#include -#include - -namespace clice { - -/// An async coroutine that runs a callback on a worker thread. -template -class async { -private: - Callback callback; - std::optional result; - uv_work_t req; - std::coroutine_handle<> handle; - -public: - template - requires std::is_invocable_v - async(Fn&& fn) : callback(std::forward(fn)) {} - - bool await_ready() noexcept { return false; } - - void await_suspend(std::coroutine_handle<> handle) noexcept { - handle = handle; - req.data = this; - uv_queue_work( - uv_default_loop(), - &this->req, - [](uv_work_t* req) { - auto& self = *static_cast(req->data); - self.result = self.callback(); - }, - [](uv_work_t* req, int status) { - if(status != 0) { - // TODO: handle error - } - auto& self = *static_cast(req->data); - self.handle.resume(); - }); - } - - decltype(auto) await_resume() noexcept { - // assert(self.result.has_value()); - return std::move(*this->result); - } -}; - -template -async(T) -> async>; - -template -class Task { -public: - struct promise_type; - using handle_type = std::coroutine_handle; - - struct promise_type { - std::optional value; - std::coroutine_handle<> caller; - - Task get_return_object() { return Task(handle_type::from_promise(*this)); } - - std::suspend_always initial_suspend() { return {}; } - - std::suspend_always final_suspend() noexcept { - if(caller) { - caller.resume(); - } - return {}; - } - - void return_value(T&& val) { value = std::move(val); } - - void return_value(const T& val) { value = val; } - - void unhandled_exception() { std::terminate(); } - }; - - Task(handle_type handle) : handle(handle) {} - - ~Task() { - if(handle && !handle.done()) { - handle.destroy(); - } - } - - void resume() { handle.resume(); } - - bool await_ready() const noexcept { return false; } - - void await_suspend(std::coroutine_handle<> caller) noexcept { - handle.promise().caller = caller; - handle.resume(); - } - - T await_resume() { return std::move(*handle.promise().value); } - -private: - handle_type handle; -}; - -template <> -class Task { -public: - struct promise_type; - using handle_type = std::coroutine_handle; - - struct promise_type { - std::coroutine_handle<> caller; - - Task get_return_object() { return Task(handle_type::from_promise(*this)); } - - std::suspend_always initial_suspend() { return {}; } - - std::suspend_always final_suspend() noexcept { - if(caller) { - caller.resume(); - } - return {}; - } - - void return_void() {} - - void unhandled_exception() { std::terminate(); } - }; - - Task(handle_type handle) : handle(handle) {} - - //~Task() { - // if(handle && !handle.done()) { - // handle.destroy(); - // } - //} - - void resume() { handle.resume(); } - - bool await_ready() const noexcept { return false; } - - void await_suspend(std::coroutine_handle<> caller) noexcept { - handle.promise().caller = caller; - handle.resume(); - } - - void await_resume() {} - -private: - handle_type handle; -}; - -} // namespace clice diff --git a/include/Support/Filesystem.h b/include/Support/Filesystem.h deleted file mode 100644 index 30ef37d7..00000000 --- a/include/Support/Filesystem.h +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once - -#include -#include - -namespace clice { - -namespace fs = std::filesystem; - -inline std::string readAll(std::string_view path) { - std::string result; - FILE* file = fopen(path.data(), "r"); - if(file) { - fseek(file, 0, SEEK_END); - size_t size = ftell(file); - result.resize(size); - fseek(file, 0, SEEK_SET); - fread(result.data(), 1, size, file); - fclose(file); - } - return result; -} - -} // namespace clice diff --git a/include/Support/Logger.h b/include/Support/Logger.h deleted file mode 100644 index 5ac11a03..00000000 --- a/include/Support/Logger.h +++ /dev/null @@ -1,35 +0,0 @@ -#pragma once - -#include - -namespace clice::logger { - -extern void* instance; - -void init(std::string_view path); - -inline void info(std::string_view message) { - spdlog::info(message); - spdlog::default_logger()->flush(); -} - -template -inline void info(spdlog::format_string_t message, Args&&... args) { - spdlog::info(message, std::forward(args)...); - spdlog::default_logger()->flush(); -} - -inline void error [[noreturn]] (std::string_view message) { - spdlog::error(message); - spdlog::default_logger()->flush(); - std::terminate(); -} - -template -inline void error [[noreturn]] (spdlog::format_string_t message, Args&&... args) { - spdlog::error(message, std::forward(args)...); - spdlog::default_logger()->flush(); - std::terminate(); -} - -} // namespace clice::logger diff --git a/include/Support/Reflection.h b/include/Support/Reflection.h deleted file mode 100644 index 099d5db0..00000000 --- a/include/Support/Reflection.h +++ /dev/null @@ -1,183 +0,0 @@ -#pragma once - -// support basic reflection through template meta programming -#include -#include -#include - -namespace clice::impl { - -struct Any { - consteval Any(std::size_t); - - template - consteval operator T () const; -}; - -template -consteval auto test() { - return [](std::index_sequence) { - return requires { T{Any(I)...}; }; - }(std::make_index_sequence{}); -} - -template -consteval auto member_count() { - if constexpr(test() && !test()) { - return N; - } else { - return member_count(); - } -} - -template -struct Wrapper { - T value; - - constexpr Wrapper(T value) : value(value) {} -}; - -template -constexpr auto member_name() { - std::string_view name = std::source_location::current().function_name(); -#if __GNUC__ && (!__clang__) && (!_MSC_VER) - std::size_t start = name.rfind("::") + 2; - std::size_t end = name.rfind(')'); - return name.substr(start, end - start); -#elif __clang__ - std::size_t start = name.rfind(".") + 1; - std::size_t end = name.rfind('}'); - return name.substr(start, end - start); -#elif _MSC_VER - std::size_t start = name.rfind("->") + 2; - std::size_t end = name.rfind('}'); - return name.substr(start, end - start); -#else - static_assert(false, "Not supported compiler"); -#endif -} - -template -constexpr auto collcet_members(Object&& object) { - // clang-format off - if constexpr(count == 1) { - auto&& [a] = object; - return std::tuple{&a}; - } else if constexpr(count == 2) { - auto&& [a, b] = object; - return std::tuple{&a, &b}; - } else if constexpr(count == 3) { - auto&& [a, b, c] = object; - return std::tuple{&a, &b, &c}; - } else if constexpr(count == 4) { - auto&& [a, b, c, d] = object; - return std::tuple{&a, &b, &c, &d}; - } else if constexpr(count == 5) { - auto&& [a, b, c, d, e] = object; - return std::tuple{&a, &b, &c, &d, &e}; - } else if constexpr(count == 6) { - auto&& [a, b, c, d, e, f] = object; - return std::tuple{&a, &b, &c, &d, &e, &f}; - } else if constexpr(count == 7) { - auto&& [a, b, c, d, e, f, g] = object; - return std::tuple{&a, &b, &c, &d, &e, &f, &g}; - } else if constexpr(count == 8) { - auto&& [a, b, c, d, e, f, g, h] = object; - return std::tuple{&a, &b, &c, &d, &e, &f, &g, &h}; - } else if constexpr(count == 9) { - auto&& [a, b, c, d, e, f, g, h, i] = object; - return std::tuple{&a, &b, &c, &d, &e, &f, &g, &h, &i}; - } else if constexpr(count == 10) { - auto&& [a, b, c, d, e, f, g, h, i, j] = object; - return std::tuple{&a, &b, &c, &d, &e, &f, &g, &h, &i, &j}; - } else if constexpr(count == 11) { - auto&& [a, b, c, d, e, f, g, h, i, j, k] = object; - return std::tuple{&a, &b, &c, &d, &e, &f, &g, &h, &i, &j, &k}; - } else if constexpr(count == 12) { - auto&& [a, b, c, d, e, f, g, h, i, j, k, l] = object; - return std::tuple{&a, &b, &c, &d, &e, &f, &g, &h, &i, &j, &k, &l}; - } else if constexpr(count == 13) { - auto&& [a, b, c, d, e, f, g, h, i, j, k, l, m] = object; - return std::tuple{&a, &b, &c, &d, &e, &f, &g, &h, &i, &j, &k, &l, &m}; - } else if constexpr(count == 14) { - auto&& [a, b, c, d, e, f, g, h, i, j, k, l, m, n] = object; - return std::tuple{&a, &b, &c, &d, &e, &f, &g, &h, &i, &j, &k, &l, &m, &n}; - } else if constexpr(count == 15) { - auto&& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o] = object; - return std::tuple{&a, &b, &c, &d, &e, &f, &g, &h, &i, &j, &k, &l, &m, &n, &o}; - } else if constexpr(count == 16) { - auto&& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p] = object; - return std::tuple{&a, &b, &c, &d, &e, &f, &g, &h, &i, &j, &k, &l, &m, &n, &o, &p}; - } else if constexpr(count == 17) { - auto&& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q] = object; - return std::tuple{&a, &b, &c, &d, &e, &f, &g, &h, &i, &j, &k, &l, &m, &n, &o, &p, &q}; - } else if constexpr(count == 18) { - auto&& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r] = object; - return std::tuple{&a, &b, &c, &d, &e, &f, &g, &h, &i, &j, &k, &l, &m, &n, &o, &p, &q, &r}; - } else if constexpr(count == 19) { - auto&& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s] = object; - return std::tuple{&a, &b, &c, &d, &e, &f, &g, &h, &i, &j, &k, &l, &m, &n, &o, &p, &q, &r, &s}; - } else if constexpr(count == 20) { - auto&& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t] = object; - return std::tuple{&a, &b, &c, &d, &e, &f, &g, &h, &i, &j, &k, &l, &m, &n, &o, &p, &q, &r, &s, &t}; - } else if constexpr(count == 21) { - auto&& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u] = object; - return std::tuple{&a, &b, &c, &d, &e, &f, &g, &h, &i, &j, &k, &l, &m, &n, &o, &p, &q, &r, &s, &t, &u}; - } else if constexpr(count == 22) { - auto&& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v] = object; - return std::tuple{&a, &b, &c, &d, &e, &f, &g, &h, &i, &j, &k, &l, &m, &n, &o, &p, &q, &r, &s, &t, &u, &v}; - } else if constexpr(count == 23) { - auto&& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w] = object; - return std::tuple{&a, &b, &c, &d, &e, &f, &g, &h, &i, &j, &k, &l, &m, &n, &o, &p, &q, &r, &s, &t, &u, &v, &w}; - } else if constexpr(count == 24) { - auto&& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x] = object; - return std::tuple{&a, &b, &c, &d, &e, &f, &g, &h, &i, &j, &k, &l, &m, &n, &o, &p, &q, &r, &s, &t, &u, &v, &w, &x}; - } else if constexpr(count == 25) { - auto&& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y] = object; - return std::tuple{&a, &b, &c, &d, &e, &f, &g, &h, &i, &j, &k, &l, &m, &n, &o, &p, &q, &r, &s, &t, &u, &v, &w, &x, &y}; - } else if constexpr(count == 26) { - auto&& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z] = object; - return std::tuple{&a, &b, &c, &d, &e, &f, &g, &h, &i, &j, &k, &l, &m, &n, &o, &p, &q, &r, &s, &t, &u, &v, &w, &x, &y, &z}; - } else if constexpr(count == 27) { - auto&& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, _0] = object; - return std::tuple{&a, &b, &c, &d, &e, &f, &g, &h, &i, &j, &k, &l, &m, &n, &o, &p, &q, &r, &s, &t, &u, &v, &w, &x, &y, &z, &_0}; - } else if constexpr(count == 28) { - auto&& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, _0, _1] = object; - return std::tuple{&a, &b, &c, &d, &e, &f, &g, &h, &i, &j, &k, &l, &m, &n, &o, &p, &q, &r, &s, &t, &u, &v, &w, &x, &y, &z, &_0, &_1}; - } else if constexpr(count == 29) { - auto&& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, _0, _1, _2] = object; - return std::tuple{&a, &b, &c, &d, &e, &f, &g, &h, &i, &j, &k, &l, &m, &n, &o, &p, &q, &r, &s, &t, &u, &v, &w, &x, &y, &z, &_0, &_1, &_2}; - } else if constexpr(count == 30) { - auto&& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, _0, _1, _2, _3] = object; - return std::tuple{&a, &b, &c, &d, &e, &f, &g, &h, &i, &j, &k, &l, &m, &n, &o, &p, &q, &r, &s, &t, &u, &v, &w, &x, &y, &z, &_0, &_1, &_2, &_3}; - } else { - static_assert(count <= 30, "Not supported member count"); - } - // clang-format on -} - -template -struct Storage { - inline static T value; -}; - -} // namespace clice::impl - -namespace clice { - -template -concept Reflectable = - std::is_aggregate_v> && std::is_default_constructible_v>; - -template -constexpr void for_each(Object&& object, const Callback& callback) { - using T = std::decay_t; - constexpr auto count = impl::member_count(); - auto members = impl::collcet_members(object); - constexpr auto static_members = impl::collcet_members(impl::Storage::value); - [&](std::index_sequence) { - (callback(impl::member_name(static_members)>(), *std::get(members)), ...); - }(std::make_index_sequence{}); -} - -}; // namespace clice diff --git a/include/Support/Serialize.h b/include/Support/Serialize.h deleted file mode 100644 index bc2d7f20..00000000 --- a/include/Support/Serialize.h +++ /dev/null @@ -1,81 +0,0 @@ -#pragma once - -#include - -#include - -namespace clice::impl { - -template -constexpr inline bool is_optional_v = false; - -template -constexpr inline bool is_optional_v> = true; - -template -constexpr inline bool is_vector_like_v = false; - -template -constexpr inline bool is_vector_like_v> = true; - -template -constexpr inline bool is_vector_like_v> = true; - -} // namespace clice::impl - -namespace clice { - -using nlohmann::json; - -template -auto serialize(const Object& object) { - if constexpr(std::is_fundamental_v || std::is_same_v || - std::is_same_v) { - return json(object); - } else if constexpr(impl::is_vector_like_v) { - return json(object); - } else if constexpr(std::is_enum_v) { - return static_cast>(object); - } else { - json json; - for_each(object, [&json](std::string_view name, auto& member) { - using Member = std::remove_cvref_t; - if constexpr(impl::is_optional_v) { - if(member.has_value()) { - json.emplace(name, serialize(member.value())); - } - } else { - json.emplace(name, serialize(member)); - } - }); - return std::move(json); - } -} - -template -Object deserialize(const json& json) { - if constexpr(std::is_fundamental_v || std::is_same_v || - std::is_same_v) { - return json.get(); - } else if constexpr(impl::is_vector_like_v) { - return json.get(); - } else if constexpr(std::is_enum_v) { - return static_cast(json.get>()); - } else { - Object object; - for_each(object, [&json](std::string_view name, auto& member) { - using Member = std::remove_cvref_t; - if constexpr(impl::is_optional_v) { - if(json.contains(name)) { - member = deserialize(json[name]); - } - } else { - member = deserialize(json[name]); - } - }); - return std::move(object); - } -} - -} // namespace clice - diff --git a/main.cpp b/main.cpp deleted file mode 100644 index 8c555dd0..00000000 --- a/main.cpp +++ /dev/null @@ -1,174 +0,0 @@ -int x = 1; -static_assert(__is_same(int, int)); -auto y = new int(1); -#if 0 -template -struct A { - template - struct B { - template - struct C { - using type = type_list; - }; - }; -}; - -template -struct Test { - using result = typename A::template B::template C::type; -}; - -#elif 0 -template -struct A { - using type = type_list; -}; - -template -struct B { - using type = typename A::type; -}; - -template -struct C { - using type = typename B::type; -}; - -template -struct Test { - using result = typename C::type; -}; - -#elif 0 -template -struct A { - using type = type_list; -}; - -template -struct B { - using type = typename U::type; -}; - -template > -struct Test { - using result = typename B::type; -}; - -#elif 0 -// #include - -template -struct A { - template - using type = type_list; -}; - -template -struct B { - using base = A; - - template - struct rebind { - using other = typename base::template type; - }; -}; - -template -struct Test { - using result = typename B::template rebind::other; -}; - -// #include -template -struct Test { - // using result = typename std::_Vector_base>::_Tp_alloc_type; - // using result = typename __gnu_cxx::__alloc_traits>::template - // rebind::other; - using result = typename B::template rebind::other; -}; - -#elif 0 - -// #include - -template -struct X { - using type = type_list; -}; - -template typename List> -struct X> { - using type = type_list; -}; - -template -struct Result { - using result = typename X>::type; -}; - -X>::type x; - -#elif 1 - -#include -#include - -// For a specialization `SomeTemplate` and a type `U` the member -// `type` is `SomeTemplate`, otherwise there is no member `type`. -template -struct replace_first_arg {}; - -template