OSVR-Core
If.h
Go to the documentation of this file.
1 
14 // Copyright 2015 Sensics, Inc.
15 // TypePack is part of OSVR-Core.
16 //
17 // Incorporates code from "meta":
18 // Copyright Eric Niebler 2014-2015
19 //
20 // Use, modification and distribution is subject to the
21 // Boost Software License, Version 1.0. (See accompanying
22 // file LICENSE_1_0.txt or copy at
23 // http://www.boost.org/LICENSE_1_0.txt)
24 //
25 // Project home: https://github.com/ericniebler/meta
26 //
27 
28 #ifndef INCLUDED_If_h_GUID_F34A2E21_4328_478B_E11B_2E8FBD606BF8
29 #define INCLUDED_If_h_GUID_F34A2E21_4328_478B_E11B_2E8FBD606BF8
30 
31 // Internal Includes
32 #include "Bool.h"
33 #include "T.h"
34 
35 // Library/third-party includes
36 // - none
37 
38 // Standard includes
39 #include <type_traits>
40 
41 namespace osvr {
42 namespace typepack {
44  namespace detail {
45  template <typename...> struct if_impl {};
46 
47  template <typename If>
48  struct if_impl<If> : std::enable_if<If::type::value> {};
49 
50  template <typename If, typename Then>
51  struct if_impl<If, Then> : std::enable_if<If::type::value, Then> {};
52 
53  template <typename If, typename Then, typename Else>
54  struct if_impl<If, Then, Else>
55  : std::conditional<If::type::value, Then, Else> {};
56  } // namespace detail
58 
61  template <typename... Args> using if_ = t_<detail::if_impl<Args...>>;
62 
64  template <bool If, typename... Args>
65  using if_c = t_<detail::if_impl<bool_<If>, Args...>>;
66 } // namespace typepack
67 } // namespace osvr
68 #endif // INCLUDED_If_h_GUID_F34A2E21_4328_478B_E11B_2E8FBD606BF8
The main namespace for all C++ elements of the framework, internal and external.
Definition: namespace_osvr.dox:3
Definition: newuoa.h:1888
Header.
t_< detail::if_impl< Args... >> if_
Select one type or another depending on a compile-time Boolean integral constant type.
Definition: If.h:61
typename T::type t_
A convenience alias template to extract the nested type within the supplied T.
Definition: T.h:52
Header.
t_< detail::if_impl< bool_< If >, Args... >> if_c
Select one type or another depending on a compile-time Boolean value.
Definition: If.h:65