Thrill  0.1
static_index.hpp
Go to the documentation of this file.
1 /*******************************************************************************
2  * tlx/meta/static_index.hpp
3  *
4  * Part of tlx - http://panthema.net/tlx
5  *
6  * Copyright (C) 2016-2017 Timo Bingmann <[email protected]>
7  *
8  * All rights reserved. Published under the Boost Software License, Version 1.0
9  ******************************************************************************/
10 
11 #ifndef TLX_META_STATIC_INDEX_HEADER
12 #define TLX_META_STATIC_INDEX_HEADER
13 
14 #include <cstddef>
15 
16 namespace tlx {
17 
18 //! \addtogroup tlx_meta
19 //! \{
20 
21 //! Helper for call_foreach_with_index() to save the index as a compile-time
22 //! index
23 template <size_t Index>
24 struct StaticIndex {
25  //! compile-time index
26  static constexpr size_t index = Index;
27 
28  //! implicit conversion to a run-time index.
29  operator size_t () const { return index; }
30 };
31 
32 //! \}
33 
34 } // namespace tlx
35 
36 #endif // !TLX_META_STATIC_INDEX_HEADER
37 
38 /******************************************************************************/
static constexpr size_t index
compile-time index