[exec.sync.wait.var]

# 33 Execution control library [[exec]](./#exec)

## 33.9 Senders [[exec.snd]](exec.snd#exec.sync.wait.var)

### 33.9.13 Sender consumers [[exec.consumers]](exec.consumers#exec.sync.wait.var)

#### 33.9.13.2 this_thread​::​sync_wait_with_variant [exec.sync.wait.var]

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/exec.tex#L5781)

The name this_thread​::​sync_wait_with_variant denotes
a customization point object[.](#1.sentence-1)

For a subexpression sndr,
let Sndr be decltype(into_variant(sndr))[.](#1.sentence-2)

The expression this_thread​::​sync_wait_with_variant(sndr) is expression-equivalent to the following,
except sndr is evaluated only once:apply_sender(*get-domain-early*(sndr), sync_wait_with_variant, sndr)*Mandates*: 

- [(1.1)](#1.1)

  [sender_in](exec.snd.concepts#concept:sender_in "33.9.3 Sender concepts [exec.snd.concepts]")<Sndr, *sync-wait-env*> is true[.](#1.1.sentence-1)

- [(1.2)](#1.2)

  The type *sync-wait-with-variant-result-type*<Sndr> is well-formed[.](#1.2.sentence-1)

- [(1.3)](#1.3)

  [same_as](concept.same#concept:same_as "18.4.2 Concept same_­as [concept.same]")<decltype(e), *sync-wait-with-variant-result-type*<Sndr>> is true, where e is the apply_sender expression above[.](#1.3.sentence-1)

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/exec.tex#L5804)

The expression sync_wait_with_variant.apply_sender(sndr) is equivalent to:using result_type = *sync-wait-with-variant-result-type*<Sndr>;if (auto opt_value = sync_wait(into_variant(sndr))) {return result_type(std::move(get<0>(*opt_value)));}return result_type(nullopt);

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/exec.tex#L5814)

The behavior of this_thread​::​sync_wait_with_variant(sndr) is undefined unless:

- [(3.1)](#3.1)

  It blocks the current thread of execution ([[defns.block]](defns.block "3.6 block"))
with forward progress guarantee delegation ([[intro.progress]](intro.progress "6.10.2.3 Forward progress"))
until the specified sender completes[.](#3.1.sentence-1)
  [*Note [1](#note-1)*:
  The default implementation of sync_wait_with_variant achieves
forward progress guarantee delegation by relying on
the forward progress guarantee delegation provided by sync_wait[.](#3.1.sentence-2)
 â *end note*]

- [(3.2)](#3.2)

  It returns the specified sender's async results as follows:
  * [(3.2.1)](#3.2.1)

      For a value completion,
the result datums are returned in an engaged optional object
that contains a variant of tuples[.](#3.2.1.sentence-1)

  * [(3.2.2)](#3.2.2)

      For an error completion, an exception is thrown[.](#3.2.2.sentence-1)

  * [(3.2.3)](#3.2.3)

      For a stopped completion, a disengaged optional object is returned[.](#3.2.3.sentence-1)
