LCOV - code coverage report
Current view: top level - common/include/scipp/common - index.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 2 2 100.0 %
Date: 2024-04-28 01:25:40 Functions: 80 149 53.7 %

          Line data    Source code
       1             : // SPDX-License-Identifier: BSD-3-Clause
       2             : // Copyright (c) 2023 Scipp contributors (https://github.com/scipp)
       3             : /// @file
       4             : /// @author Simon Heybrock
       5             : #pragma once
       6             : 
       7             : #include <cstdint>
       8             : 
       9             : namespace scipp {
      10             : /// Type to use for all container/array sizes and indices.
      11             : ///
      12             : /// As recommended by the C++ core guidelines, this is signed, i.e., not size_t.
      13             : using index = int64_t;
      14             : 
      15             : /// Return the size of a container as a signed index type.
      16             : ///
      17             : /// The purpose of this is to improve interoperability with std containers,
      18             : /// where, e.g., std::vector::size return size_t. Use of this free function
      19             : /// reduces the need for manual casting, which would otherwise be required to
      20             : /// avoid compiler warnings.
      21   125220422 : template <class T> index size(const T &container) {
      22   125220422 :   return static_cast<index>(container.size());
      23             : }
      24             : } // namespace scipp

Generated by: LCOV version 1.14