OpenMS
3.6.0
Main Page
Related Pages
Topics
Namespaces
Concepts
Classes
Files
File List
File Members
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
11
#include <
OpenMS/CONCEPT/Types.h
>
12
#include <
OpenMS/CONCEPT/Exception.h
>
13
14
#include <algorithm>
15
16
namespace
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
Exception.h
Types.h
OpenMS::Exception::ElementNotFound
Element could not be found exception.
Definition
Exception.h:657
OpenMS::Size
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition
Types.h:97
OpenMS::Helpers::indexOf
Size indexOf(const ContainerType &cont, const typename ContainerType::value_type &val)
Definition
EnumHelpers.h:23
OpenMS
Main OpenMS namespace.
Definition
openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
OpenMS
CONCEPT
EnumHelpers.h
Generated on Sun Jun 28 2026 01:56:23 for OpenMS by
1.9.8