Browse Source

add NiklasRosenstein/type_traits.hpp

master
Niklas Rosenstein 2 years ago
parent
commit
0e59dbfc39
Signed by: NiklasRosenstein GPG Key ID: 06D269B33D25F6C6
1 changed files with 17 additions and 0 deletions
  1. + 17
    - 0
      include/NiklasRosenstein/type_traits.hpp

+ 17
- 0
include/NiklasRosenstein/type_traits.hpp

@ -0,0 +1,17 @@
/**
* Copyright (c) 2018 Niklas Rosenstein
* MIT licensed.
*
* @description Some useful type traits.
*/
#pragma once
namespace niklasrosenstein {
/* Adds "const" to a type only if the other type is const. */
template <typename SRC, typename DST> struct add_const_from { using type = DST; };
template <typename SRC, typename DST> struct add_const_from<const SRC, DST> { using type = typename std::add_const<DST>::type; };
template <typename SRC, typename DST> using add_const_from_t = typename add_const_from<SRC, DST>::type;
} // namespace niklasrosenstein

Loading…
Cancel
Save