C++ Logo

std-proposals

Advanced search

[std-proposals] Lakos rule

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Thu, 21 Dec 2023 12:39:01 +0000
I see people arguing that the Lakos rule should be kept, and others saying
it should be abolished.

For everyone to meet half way, what if the Standard library could do:

    namespace std {
        int SomeFunc(int,int) noexcept_Lakos;
    }

A function marked as 'noexcept_Lakos' is said to be a 'Lakos function'.

So then if you want a Lakos function to be 'noexcept', you do something
like:

    void MyFunc(int const a, int const b) noexcept
    {
        using noexcept_Lakos;
        // The above line ensures that all
        // Lakos functions called in this
        // function won't throw
        return 2 * std::SomeFunc(a,b);
    }

Or if you just want to single-out one function call:

    void MyFunc(int const a, int const b) noexcept
    {
        return 2 * _Lakos(std::SomeFunc(a,b));
    }

Received on 2023-12-21 12:39:04