Skip to content

Commit

Permalink
[0023] Add proposal to adopt C++11 as the base language (#314)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
llvm-beanz authored Sep 18, 2024
1 parent 68c2ff0 commit 6aff17f
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions proposals/0023-cxx11-base.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<!-- {% raw %} -->

# Adopt C++11 Base

* Proposal: [NNNN](NNNN-cxx11-base.md)
* Author(s): [Chris Bieneman](https://github.com/llvm-beanz)
* Sponsor: TBD
* Status: **Under Consideration**
* Planned Version: 202y

## Introduction

In DXC HLSL is a set of feature extensions on top of a subset of C++98. C++98
is now over 20 years old and most modern C++ users have adopted newer language
constructs. This proposal suggests taking the small step of updating HLSL 202y's
base C++ language to C++11.

## Motivation

C++11 is over a decade old and introduced widely adopted features, many of which
have been frequently requested additions for HLSL.

## Proposed solution

Adopt a C++11 base language and include the following C++11 features in HLSL 202y:
* auto
* decltype
* constexpr
* C++11 scoped enumerations
* variadic templates
* user-defined literals
* [C++11 attributes](/proposals/0002-cxx-attributes.md)
* Lambda expressions
* Static assert
* Range-based for loops

## Alternatives considered

### C++20

We could instead adopt an even more recent C++, like C++20. The main drawback of
that is that it significantly increases the rapid divergence from DXC, and it
gives us a longer list of features that we need to rectify against HLSL's
language features. Adopting a C++11 base for 202y does not prevent later
versions from adopting newer C++ base standards, but it does allow us to phase
the changes in iteratively as HLSL evolves.

### Target HLSL 202x

While the original Clang 3.7 release did support C++11 fully, the intrusive
changes to support HLSL broke many of the basic features Clang uses for
configuring language features and supporting language modes. To restore those
parts of clang sufficiently to support a C++11 base in DXC would be non-trivial.
For that reason this is proposed as a Clang-only HLSL 202y feature.

<!-- {% endraw %} -->

0 comments on commit 6aff17f

Please sign in to comment.