Boost logo

Boost :

Subject: Re: [boost] [outcome] High level summary of review feedback accepted so far
From: Peter Dimov (lists_at_[hidden])
Date: 2017-06-01 14:51:38

> Niall Douglas wrote:
> > See what you make of my toy std::variant<> based Outcome at:
> >
> >
> FWIW, Niall, I convinced my variant implementation to work in Compiler
> Explorer:
> so you can try it for a spin. It's never-valueless, ever, so you can
> dispense with the "safe assign" workarounds.

Here's a simplistic result<> based on that:

g++ 7.1 turns this:

#include <iostream>

result<int> function()
    return 14;

int main()
    std::cout << function().value() << std::endl;

into this:

        mov rax, rdi
        mov DWORD PTR [rdi], 1
        mov DWORD PTR [rdi+8], 14
        sub rsp, 8
        mov esi, 14
        mov edi, OFFSET FLAT:std::cout
        call std::basic_ostream<char, std::char_traits<char>
        mov rdi, rax
        call std::basic_ostream<char, std::char_traits<char> >&
std::endl<char, std::char_traits<char> >(std::basic_ostream<char,
std::char_traits<char> >&)
        xor eax, eax
        add rsp, 8
        sub rsp, 8
        mov edi, OFFSET FLAT:std::__ioinit
        call std::ios_base::Init::Init()
        mov edx, OFFSET FLAT:__dso_handle
        mov esi, OFFSET FLAT:std::__ioinit
        mov edi, OFFSET FLAT:std::ios_base::Init::~Init()
        add rsp, 8
        jmp __cxa_atexit

Boost list run by bdawes at, gregod at, cpdaniel at, john at