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:
> >
> > https://tinyurl.com/ybxwlewh
>
> FWIW, Niall, I convinced my variant implementation to work in Compiler
> Explorer:
>
> https://godbolt.org/g/juh4WB
>
> 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:

https://godbolt.org/g/EG6Kht

g++ 7.1 turns this:

#include <iostream>

result<int> function()
{
    return 14;
}

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

into this:

function():
        mov rax, rdi
        mov DWORD PTR [rdi], 1
        mov DWORD PTR [rdi+8], 14
        ret
main:
        sub rsp, 8
        mov esi, 14
        mov edi, OFFSET FLAT:std::cout
        call std::basic_ostream<char, std::char_traits<char>
>::operator<<(int)
        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
        ret
_GLOBAL__sub_I__Z8functionv:
        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 acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk