libjmmcg  release_579_6_g8cffd
A C++ library containing an eclectic mix of useful, advanced components.
unordered_tuple_impl.hpp
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright © 2017 by J.M.McGuiness, libjmmcg@hussar.me.uk
3 **
4 ** This library is free software; you can redistribute it and/or
5 ** modify it under the terms of the GNU Lesser General Public
6 ** License as published by the Free Software Foundation; either
7 ** version 2.1 of the License, or (at your option) any later version.
8 **
9 ** This library is distributed in the hope that it will be useful,
10 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 ** Lesser General Public License for more details.
13 **
14 ** You should have received a copy of the GNU Lesser General Public
15 ** License along with this library; if not, write to the Free Software
16 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18 
19 namespace jmmcg { namespace LIBJMMCG_VER_NAMESPACE {
20 
21 template<class KeyType, class MappedType, class Hasher, template<class> class ExtractHash, class ... MappedTypes>
22 inline
24 : mapped_cont{{}} {
25  if constexpr (noexcept(default_ctors_t<MappedTypes...>::result(mapped_cont.data()))) {
27  } else {
28  try {
30  } catch (...) {
32  throw;
33  }
34  }
35 }
36 
37 template<class KeyType, class MappedType, class Hasher, template<class> class ExtractHash, class ... MappedTypes>
38 template<class MappedCtorArg, class... MappedCtorArgs, class> inline
40 : mapped_cont{{}} {
41  BOOST_MPL_ASSERT_RELATION(size, ==, sizeof...(MappedCtorArgs)+1);
42  if constexpr (noexcept(ctors_t<MappedTypes...>::result(mapped_cont.data(), std::forward<MappedCtorArg>(arg), std::forward<MappedCtorArgs>(args)...))) {
44  } else {
45  try {
47  } catch (...) {
49  throw;
50  }
51  }
52 }
53 
54 template<class KeyType, class MappedType, class Hasher, template<class> class ExtractHash, class ... MappedTypes> inline
57 }
58 
59 template<class KeyType, class MappedType, class Hasher, template<class> class ExtractHash, class ... MappedTypes> inline
63  mapped_type const &ret=reinterpret_cast<mapped_type const &>(mapped_cont[i]);
64  return ret;
65 }
66 
67 template<class KeyType, class MappedType, class Hasher, template<class> class ExtractHash, class ... MappedTypes> inline
71  mapped_type &ret=reinterpret_cast<mapped_type &>(mapped_cont[i]);
72  return ret;
73 }
74 
75 } }