OpenMS
Loading...
Searching...
No Matches
EnumHelpers.h
Go to the documentation of this file.
1// Copyright (c) 2002-present, OpenMS Inc. -- EKU Tuebingen, ETH Zurich, and FU Berlin
2// SPDX-License-Identifier: BSD-3-Clause
3//
4// --------------------------------------------------------------------------
5// $Maintainer: Chris Bielow $
6// $Authors: Chris Bielow $
7// --------------------------------------------------------------------------
8
9#pragma once
10
13
14#include <algorithm>
15
16namespace OpenMS
17{
18 namespace Helpers
19 {
22 template <class ContainerType>
23 Size indexOf(const ContainerType& cont, const typename ContainerType::value_type& val)
24 {
25 auto it = std::find(cont.begin(), cont.end(), val);
26 if (it == cont.end())
27 {
28 throw Exception::ElementNotFound(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, val);
29 }
30 return std::distance(cont.begin(), it);
31 }
32
33 }
34}
35
36
Element could not be found exception.
Definition Exception.h:657
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition Types.h:97
Size indexOf(const ContainerType &cont, const typename ContainerType::value_type &val)
Definition EnumHelpers.h:23
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19