From 9c45b0d3693f91d9b7839bab33e255e8be476e04 Mon Sep 17 00:00:00 2001 From: peter klausler Date: Wed, 27 Feb 2019 16:00:37 -0800 Subject: [PATCH] [flang] Small edits to C++17 usage notes Original-commit: flang-compiler/f18@bdf62ac90020c84516400085b75109979d599dd7 Reviewed-on: https://github.com/flang-compiler/f18/pull/306 --- flang/documentation/C++17.md | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/flang/documentation/C++17.md b/flang/documentation/C++17.md index 7c26c9e..607ab55 100644 --- a/flang/documentation/C++17.md +++ b/flang/documentation/C++17.md @@ -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 -- 2.7.4