/* * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * Copyright 2011-2018 Danny Robson */ #pragma once #include /////////////////////////////////////////////////////////////////////////////// /// Forwards the supplied `value` and annotates the result as likely to be the /// value `typical`. /// /// Must be an integral type. template >> constexpr inline T expect (T val, T typical) { return __builtin_expect (val, typical); } /// Coerces the argument into a bool and annotates the result as likely to be /// true. template constexpr inline bool likely (T &&t) { return __builtin_expect (!!t, true); } /// Coerces the argument into a bool and annotates the result as likely to be /// false. template constexpr inline bool unlikely (T &&t) { return __builtin_expect (!!t, false); }