/* * 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 2017 Danny Robson */ #include "typeidx.hpp" #include /////////////////////////////////////////////////////////////////////////////// static std::atomic counter; //----------------------------------------------------------------------------- int cruft::detail::typeidx_next () { // We can't return zero, but we want to optimise access to the static // (which means we can't have it locally due to initialisation locking). // // Ensure we use pre-increment so that we can utilise zero static // initialisation instead. return ++counter; }