rippled
maybe_const.h
1 //------------------------------------------------------------------------------
2 /*
3  This file is part of Beast: https://github.com/vinniefalco/Beast
4  Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
5 
6  Permission to use, copy, modify, and/or distribute this software for any
7  purpose with or without fee is hereby granted, provided that the above
8  copyright notice and this permission notice appear in all copies.
9 
10  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18 //==============================================================================
19 
20 #ifndef BEAST_UTILITY_MAYBE_CONST_H_INCLUDED
21 #define BEAST_UTILITY_MAYBE_CONST_H_INCLUDED
22 
23 #include <type_traits>
24 
25 namespace beast {
26 
28 template <bool IsConst, class T>
30 {
31  explicit maybe_const() = default;
32  using type = typename std::conditional<
33  IsConst,
34  typename std::remove_const<T>::type const,
36 };
37 
39 template <bool IsConst, class T>
41 
42 } // namespace beast
43 
44 #endif
beast::maybe_const::maybe_const
maybe_const()=default
beast::maybe_const_t
typename maybe_const< IsConst, T >::type maybe_const_t
Alias for omitting typename.
Definition: maybe_const.h:40
beast::maybe_const
Makes T const or non const depending on a bool.
Definition: maybe_const.h:29
beast::maybe_const::type
typename std::conditional< IsConst, typename std::remove_const< T >::type const, typename std::remove_const< T >::type >::type type
Definition: maybe_const.h:35
std::remove_const
std::conditional
type_traits
beast
Definition: base_uint.h:641