Skip to content

Commit 21966e0

Browse files
committed
Use C++14 way of using type traits
1 parent 2f8e971 commit 21966e0

14 files changed

Lines changed: 29 additions & 29 deletions

File tree

include/osmium/builder/attr.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ namespace osmium {
182182

183183
#define OSMIUM_ATTRIBUTE_WITH_CONSTRUCTOR(_handler, _name, _type) \
184184
OSMIUM_ATTRIBUTE(_handler, _name, _type) \
185-
constexpr explicit _name(std::add_const<_type>::type& value) : \
185+
constexpr explicit _name(std::add_const_t<_type>& value) : \
186186
type_wrapper(value) {} \
187187
}
188188

@@ -658,7 +658,7 @@ namespace osmium {
658658
}
659659

660660
template <typename TFirst, typename... TRest>
661-
constexpr typename std::enable_if<!std::is_same<attr::_user, TFirst>::value, const char*>::type
661+
constexpr std::enable_if_t<!std::is_same<attr::_user, TFirst>::value, const char*>
662662
get_user(const TFirst& /*first*/, const TRest&... args) noexcept {
663663
return get_user(args...);
664664
}
@@ -802,12 +802,12 @@ namespace osmium {
802802
// ==============================================================
803803

804804
template <typename TBuilder, typename THandler, typename... TArgs>
805-
inline typename std::enable_if<!is_handled_by<THandler, TArgs...>::value>::type
805+
inline std::enable_if_t<!is_handled_by<THandler, TArgs...>::value>
806806
add_list(osmium::builder::Builder& /*parent*/, const TArgs&... /*args*/) noexcept {
807807
}
808808

809809
template <typename TBuilder, typename THandler, typename... TArgs>
810-
inline typename std::enable_if<is_handled_by<THandler, TArgs...>::value>::type
810+
inline std::enable_if_t<is_handled_by<THandler, TArgs...>::value>
811811
add_list(osmium::builder::Builder& parent, const TArgs&... args) {
812812
TBuilder builder{parent.buffer(), &parent};
813813
(void)std::initializer_list<int>{

include/osmium/index/relations_map.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ namespace osmium {
9595
m_map.emplace_back(key, value);
9696
}
9797

98-
typename std::enable_if<std::is_same<TKey, TValue>::value>::type flip_in_place() {
98+
std::enable_if_t<std::is_same<TKey, TValue>::value> flip_in_place() {
9999
for (auto& p : m_map) {
100100
using std::swap;
101101
swap(p.key, p.value);

include/osmium/memory/collection.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ namespace osmium {
4949
// This data_type is either 'unsigned char*' or 'const unsigned
5050
// char*' depending on whether TMember is const. This allows this
5151
// class to be used as an iterator and as a const_iterator.
52-
using data_type = typename std::conditional<std::is_const<TMember>::value, const unsigned char*, unsigned char*>::type;
52+
using data_type = std::conditional_t<std::is_const<TMember>::value, const unsigned char*, unsigned char*>;
5353

5454
data_type m_data;
5555

include/osmium/memory/item_iterator.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ namespace osmium {
6363
// This data_type is either 'unsigned char*' or 'const unsigned char*' depending
6464
// on whether TMember is const. This allows this class to be used as an iterator and
6565
// as a const_iterator.
66-
using data_type = typename std::conditional<std::is_const<TMember>::value, const unsigned char*, unsigned char*>::type;
66+
using data_type = std::conditional_t<std::is_const<TMember>::value, const unsigned char*, unsigned char*>;
6767

6868
data_type m_data;
6969
data_type m_end;
@@ -179,7 +179,7 @@ namespace osmium {
179179

180180
// This data_type is either 'unsigned char*' or
181181
// 'const unsigned char*' depending on whether T is const.
182-
using data_type = typename std::conditional<std::is_const<T>::value, const unsigned char*, unsigned char*>::type;
182+
using data_type = std::conditional_t<std::is_const<T>::value, const unsigned char*, unsigned char*>;
183183

184184
data_type m_begin;
185185
data_type m_end;

include/osmium/osm/entity_bits.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ namespace osmium {
115115
* changeset.
116116
*/
117117
inline type from_item_type(osmium::item_type item_type) noexcept {
118-
const auto ut = static_cast<std::underlying_type<osmium::item_type>::type>(item_type);
118+
const auto ut = static_cast<std::underlying_type_t<osmium::item_type>>(item_type);
119119
assert(ut <= 0x05);
120120
if (ut == 0) {
121121
return nothing;

include/osmium/osm/timestamp.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ namespace osmium {
220220
* The constructor is not declared "explicit" so that conversions
221221
* like @code node.set_timestamp(123); @endcode work.
222222
*/
223-
template <typename T, typename std::enable_if<std::is_integral<T>::value, int>::type = 0>
223+
template <typename T, typename std::enable_if_t<std::is_integral<T>::value, int> = 0>
224224
constexpr Timestamp(T timestamp) noexcept : // NOLINT(google-explicit-constructor, hicpp-explicit-conversions)
225225
m_timestamp(static_cast<uint32_t>(timestamp)) {
226226
}

include/osmium/relations/relations_manager.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ namespace osmium {
304304
template <typename TManager, bool TNodes, bool TWays, bool TRelations, bool TCheckOrder = true>
305305
class RelationsManager : public RelationsManagerBase {
306306

307-
using check_order_handler = typename std::conditional<TCheckOrder, osmium::handler::CheckOrder, osmium::handler::Handler>::type;
307+
using check_order_handler = std::conditional_t<TCheckOrder, osmium::handler::CheckOrder, osmium::handler::Handler>;
308308

309309
check_order_handler m_check_order_handler;
310310

include/osmium/tags/filter.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ namespace osmium {
9292
class Filter {
9393

9494
using key_type = TKey;
95-
using value_type = typename std::conditional<std::is_void<TValue>::value, bool, TValue>::type;
95+
using value_type = std::conditional_t<std::is_void<TValue>::value, bool, TValue>;
9696

9797
struct Rule {
9898
key_type key;
@@ -130,7 +130,7 @@ namespace osmium {
130130
m_default_result(default_result) {
131131
}
132132

133-
template <typename V = TValue, typename std::enable_if<!std::is_void<V>::value, int>::type = 0>
133+
template <typename V = TValue, typename std::enable_if_t<!std::is_void<V>::value, int> = 0>
134134
Filter& add(bool result, const key_type& key, const value_type& value) {
135135
m_rules.emplace_back(result, false, key, value);
136136
return *this;

include/osmium/tags/matcher.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ namespace osmium {
7272
*
7373
* @param key_matcher StringMatcher for matching the key.
7474
*/
75-
template <typename TKey, typename X = typename std::enable_if<
76-
std::is_convertible<TKey, osmium::StringMatcher>::value, void>::type>
75+
template <typename TKey, typename X = std::enable_if_t<
76+
std::is_convertible<TKey, osmium::StringMatcher>::value, void>>
7777
explicit TagMatcher(TKey&& key_matcher) :
7878
m_key_matcher(std::forward<TKey>(key_matcher)),
7979
m_value_matcher(osmium::StringMatcher::always_true{}) {
@@ -88,8 +88,8 @@ namespace osmium {
8888
* @param invert If set to true, invert the result of the value_matcher.
8989
*/
9090
template <typename TKey, typename TValue,
91-
typename std::enable_if<std::is_convertible<TKey, osmium::StringMatcher>::value, int>::type = 0,
92-
typename std::enable_if<std::is_convertible<TValue, osmium::StringMatcher>::value, int>::type = 0>
91+
typename std::enable_if_t<std::is_convertible<TKey, osmium::StringMatcher>::value, int> = 0,
92+
typename std::enable_if_t<std::is_convertible<TValue, osmium::StringMatcher>::value, int> = 0>
9393
TagMatcher(TKey&& key_matcher, TValue&& value_matcher, bool invert = false) :
9494
m_key_matcher(std::forward<TKey>(key_matcher)),
9595
m_value_matcher(std::forward<TValue>(value_matcher)),

include/osmium/thread/function_wrapper.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ namespace osmium {
8787

8888
// Constructor must not be "explicit" for wrapper
8989
// to work seemlessly.
90-
template <typename TFunction, typename X = typename std::enable_if<
91-
!std::is_same<TFunction, function_wrapper>::value, void>::type>
90+
template <typename TFunction, typename X = std::enable_if_t<
91+
!std::is_same<TFunction, function_wrapper>::value, void>>
9292
// cppcheck-suppress noExplicitConstructor
9393
function_wrapper(TFunction&& f) : // NOLINT(google-explicit-constructor, hicpp-explicit-conversions)
9494
impl(new impl_type<TFunction>(std::forward<TFunction>(f))) {

0 commit comments

Comments
 (0)