forked from OSchip/llvm-project
[flang] Small edits to C++17 usage notes
Original-commit: flang-compiler/f18@bdf62ac900 Reviewed-on: https://github.com/flang-compiler/f18/pull/306
This commit is contained in:
parent
340ecc8765
commit
9c45b0d369
|
@ -4,10 +4,10 @@ Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
|
|||
|
||||
## C++14/17 features used in f18
|
||||
|
||||
The C++ dialect used in this project is a subset of the
|
||||
The C++ dialect used in this project constitutes a subset of the
|
||||
standard C++ programming language and library features.
|
||||
We want it to be compatible with the LLVM C++ language
|
||||
subset in use at the time that we integrate with that
|
||||
We want our dialect to be compatible with the LLVM C++ language
|
||||
subset that will be in use at the time that we integrate with that
|
||||
project.
|
||||
We also want to maximize portability, future-proofing,
|
||||
compile-time error checking, and use of best practices.
|
||||
|
@ -20,11 +20,19 @@ We have chosen to use some features of the recent C++17
|
|||
language standard in f18.
|
||||
The most important of these are:
|
||||
* sum types (discriminated unions) in the form of `std::variant`
|
||||
* `using` template parameter packs
|
||||
* generic lambdas with `auto` argument types
|
||||
* product types in the form of `std::tuple`
|
||||
* `std::optional`
|
||||
|
||||
(`std::tuple` is actually a C++11 feature, but I include it
|
||||
in this list because it's not particularly well known.)
|
||||
|
||||
### Sum types
|
||||
|
||||
First, some background information to explain the need for sum types
|
||||
in f18.
|
||||
|
||||
Fortran is notoriously problematic to lex and parse, as tokenization
|
||||
depends on the state of the partial parse;
|
||||
the language has no reserved words in the sense that C++ does.
|
||||
|
@ -85,7 +93,8 @@ of the possibilities, and f18 will fail to build if one is missing.
|
|||
|
||||
Were we unable to use `std::variant` directly, we would likely
|
||||
have chosen to implement a local `SumType` replacement; in the
|
||||
absence of C++17's ability of `using` a template parameter pack,
|
||||
absence of C++17's abilities of `using` a template parameter pack
|
||||
and allowing `auto` arguments in anonymous lambda functions,
|
||||
it would be less convenient to use.
|
||||
|
||||
The other options for polymorphism in C++ at the level of C++11
|
||||
|
|
Loading…
Reference in New Issue