Skip to content

Commit 6aff17f

Browse files
authored
[0023] Add proposal to adopt C++11 as the base language (#314)
This proposal is for HLSL 202y to adopt C++ 11 as its base C++ language version and encorporate as many of C++ 11's features as reasonably fit within HLSL's language design.
1 parent 68c2ff0 commit 6aff17f

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

proposals/0023-cxx11-base.md

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<!-- {% raw %} -->
2+
3+
# Adopt C++11 Base
4+
5+
* Proposal: [NNNN](NNNN-cxx11-base.md)
6+
* Author(s): [Chris Bieneman](https://github.com/llvm-beanz)
7+
* Sponsor: TBD
8+
* Status: **Under Consideration**
9+
* Planned Version: 202y
10+
11+
## Introduction
12+
13+
In DXC HLSL is a set of feature extensions on top of a subset of C++98. C++98
14+
is now over 20 years old and most modern C++ users have adopted newer language
15+
constructs. This proposal suggests taking the small step of updating HLSL 202y's
16+
base C++ language to C++11.
17+
18+
## Motivation
19+
20+
C++11 is over a decade old and introduced widely adopted features, many of which
21+
have been frequently requested additions for HLSL.
22+
23+
## Proposed solution
24+
25+
Adopt a C++11 base language and include the following C++11 features in HLSL 202y:
26+
* auto
27+
* decltype
28+
* constexpr
29+
* C++11 scoped enumerations
30+
* variadic templates
31+
* user-defined literals
32+
* [C++11 attributes](/proposals/0002-cxx-attributes.md)
33+
* Lambda expressions
34+
* Static assert
35+
* Range-based for loops
36+
37+
## Alternatives considered
38+
39+
### C++20
40+
41+
We could instead adopt an even more recent C++, like C++20. The main drawback of
42+
that is that it significantly increases the rapid divergence from DXC, and it
43+
gives us a longer list of features that we need to rectify against HLSL's
44+
language features. Adopting a C++11 base for 202y does not prevent later
45+
versions from adopting newer C++ base standards, but it does allow us to phase
46+
the changes in iteratively as HLSL evolves.
47+
48+
### Target HLSL 202x
49+
50+
While the original Clang 3.7 release did support C++11 fully, the intrusive
51+
changes to support HLSL broke many of the basic features Clang uses for
52+
configuring language features and supporting language modes. To restore those
53+
parts of clang sufficiently to support a C++11 base in DXC would be non-trivial.
54+
For that reason this is proposed as a Clang-only HLSL 202y feature.
55+
56+
<!-- {% endraw %} -->

0 commit comments

Comments
 (0)