---
title: either neither
document: P3625R1
date: 2026-04-07
audience: LWG
reply-to:
  - "Michael Florian Hava  < <mfh.cpp@gmail.com>"
  - "1"
paper-type: proposal
---

Document number: P3625R1 Date: 2026-04-07 Project: Programming Language C++ Audience: LWG Reply-to: Michael Florian Hava [<mfh.cpp@gmail.com>](mailto:mfh.cpp@gmail.com) 1

# `either neither`

**Design Space** Given these facilities are simple wrappers around foldings of `same_as`, the only design decisions pertain to naming. We’ve considered the following alternative names and discarded them for the given reasons.

• `oneof`/`noneof` … only partially correct as one could assume that `oneof` expresses matching exactly one given type.

• `anyof`/`noneof` … express the basic idea, but are unusual spellings to circumvent collisions with the respective algorithms.

**Before** **Proposed** `template``<``typename` `T``>` `requires``(``same_as``<``T``,` `char``>` `or` `same_as``<``T``,` `short``>)` `void` `func``(``T``) { … }` `template``<``either``<``char``,` `short``>` `T``>` `void` `func``(``T``) { … }`

:::wording-add

<ins>// or just:</ins> void func(either<char, short> auto) { … } template<typename T> requires(not same_as<T, short> and not same_as<T, int>) void func(T) { … } template<neither<short, int> T> void func(T) { … } <ins>// or just:</ins> void func(neither<short, int> auto) { … }

:::

[RISC Software GmbH, Softwarepark 32a, 4232 Hagenberg, Austria, michael.hava@risc-software.at](mailto:michael.hava@risc-software.at) 1

### 1

The best names we could come up with after excluding the above have been `either`/`neither`, which admittedly look funky when used directly (`either<T, U...>`) but look fine when using the 2 “terse notation” (`template<either<U...> T>`, `void f(either<U...> auto)`).

## Impact on the Standard

## Proposed Wording

### [version.syn]

### [concepts]

## Acknowledgements

:::wording-add

<ins>#define __cpp_lib_either_neither YYYYMML // freestanding, also in</ins> <concepts>

:::

**[DRAFTING NOTE: Adjust the placeholder value as needed to denote the proposal’s date of adoption.]**

**??.? Header <concepts> synopsis** **[concepts.syn]**

:::wording-add

// all freestanding namespace std { // [concepts.lang], language-related concepts // [concept.same], concept same_as template<class T, class U> concept same_as = see below; <ins>template<class T, class... U></ins> <ins>concept either = (same_as<T, U> || ...);</ins> <ins>template<class T, class... U></ins> <ins>concept neither = !either<T, U...>;</ins>

:::

*//* `[concept.derived]`*, concept* `derived_from` `}`

Not more funky then already existing concepts (e.g. `derived_from<Derived, Base>`) though… 2

### 2
