Modernize: Use "using" instead of "typedef" (#754)

This commit is contained in:
Andy Maloney
2019-10-02 12:14:49 -04:00
committed by Jesse Beder
parent 0fddd1e5bd
commit 6e87b37034
18 changed files with 44 additions and 44 deletions

View File

@@ -10,7 +10,7 @@
#include <cstddef>
namespace YAML {
typedef std::size_t anchor_t;
using anchor_t = std::size_t;
const anchor_t NullAnchor = 0;
}

View File

@@ -13,7 +13,7 @@ struct unspecified_bool {
struct NOT_ALLOWED;
static void true_value(NOT_ALLOWED*) {}
};
typedef void (*unspecified_bool_type)(unspecified_bool::NOT_ALLOWED*);
using unspecified_bool_type = void (*)(unspecified_bool::NOT_ALLOWED *);
}
}

View File

@@ -26,7 +26,7 @@ class iterator_base {
template <typename>
friend class iterator_base;
struct enabler {};
typedef node_iterator base_type;
using base_type = node_iterator;
struct proxy {
explicit proxy(const V& x) : m_ref(x) {}

View File

@@ -20,8 +20,8 @@ template <typename V>
class iterator_base;
}
typedef detail::iterator_base<detail::iterator_value> iterator;
typedef detail::iterator_base<const detail::iterator_value> const_iterator;
using iterator = detail::iterator_base<detail::iterator_value>;
using const_iterator = detail::iterator_base<const detail::iterator_value>;
}
#endif // VALUE_DETAIL_ITERATOR_FWD_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@@ -27,7 +27,7 @@ class YAML_CPP_API memory {
void merge(const memory& rhs);
private:
typedef std::set<shared_node> Nodes;
using Nodes = std::set<shared_node>;
Nodes m_nodes;
};

View File

@@ -160,7 +160,7 @@ class node {
private:
shared_node_ref m_pRef;
typedef std::set<node*> nodes;
using nodes = std::set<node *>;
nodes m_dependencies;
};
} // namespace detail

View File

@@ -108,17 +108,17 @@ class YAML_CPP_API node_data {
std::string m_scalar;
// sequence
typedef std::vector<node*> node_seq;
using node_seq = std::vector<node *>;
node_seq m_sequence;
mutable std::size_t m_seqSize;
// map
typedef std::vector<std::pair<node*, node*>> node_map;
using node_map = std::vector<std::pair<node*, node*>>;
node_map m_map;
typedef std::pair<node*, node*> kv_pair;
typedef std::list<kv_pair> kv_pairs;
using kv_pair = std::pair<node*, node*>;
using kv_pairs = std::list<kv_pair>;
mutable kv_pairs m_undefinedPairs;
};
}

View File

@@ -24,7 +24,7 @@ struct iterator_type {
template <typename V>
struct node_iterator_value : public std::pair<V*, V*> {
typedef std::pair<V*, V*> kv;
using kv = std::pair<V*, V*>;
node_iterator_value() : kv(), pNode(nullptr) {}
explicit node_iterator_value(V& rhs) : kv(), pNode(&rhs) {}
@@ -36,19 +36,19 @@ struct node_iterator_value : public std::pair<V*, V*> {
V* pNode;
};
typedef std::vector<node*> node_seq;
typedef std::vector<std::pair<node*, node*>> node_map;
using node_seq = std::vector<node *>;
using node_map = std::vector<std::pair<node*, node*>>;
template <typename V>
struct node_iterator_type {
typedef node_seq::iterator seq;
typedef node_map::iterator map;
using seq = node_seq::iterator;
using map = node_map::iterator;
};
template <typename V>
struct node_iterator_type<const V> {
typedef node_seq::const_iterator seq;
typedef node_map::const_iterator map;
using seq = node_seq::const_iterator;
using map = node_map::const_iterator;
};
template <typename V>
@@ -68,9 +68,9 @@ class node_iterator_base
};
public:
typedef typename node_iterator_type<V>::seq SeqIter;
typedef typename node_iterator_type<V>::map MapIter;
typedef node_iterator_value<V> value_type;
using SeqIter = typename node_iterator_type<V>::seq;
using MapIter = typename node_iterator_type<V>::map;
using value_type = node_iterator_value<V>;
node_iterator_base()
: m_type(iterator_type::NoneType), m_seqIt(), m_mapIt(), m_mapEnd() {}
@@ -172,8 +172,8 @@ class node_iterator_base
MapIter m_mapIt, m_mapEnd;
};
typedef node_iterator_base<node> node_iterator;
typedef node_iterator_base<const node> const_node_iterator;
using node_iterator = node_iterator_base<node>;
using const_node_iterator = node_iterator_base<const node>;
}
}

View File

@@ -335,7 +335,7 @@ template <typename T>
struct to_value_t {
explicit to_value_t(const T& t_) : t(t_) {}
const T& t;
typedef const T& return_type;
using return_type = const T &;
const T& operator()() const { return t; }
};
@@ -344,7 +344,7 @@ template <>
struct to_value_t<const char*> {
explicit to_value_t(const char* t_) : t(t_) {}
const char* t;
typedef std::string return_type;
using return_type = std::string;
const std::string operator()() const { return t; }
};
@@ -353,7 +353,7 @@ template <>
struct to_value_t<char*> {
explicit to_value_t(char* t_) : t(t_) {}
const char* t;
typedef std::string return_type;
using return_type = std::string;
const std::string operator()() const { return t; }
};
@@ -362,7 +362,7 @@ template <std::size_t N>
struct to_value_t<char[N]> {
explicit to_value_t(const char* t_) : t(t_) {}
const char* t;
typedef std::string return_type;
using return_type = std::string;
const std::string operator()() const { return t; }
};

View File

@@ -39,8 +39,8 @@ class YAML_CPP_API Node {
template <typename T, typename S>
friend struct as_if;
typedef YAML::iterator iterator;
typedef YAML::const_iterator const_iterator;
using iterator = YAML::iterator;
using const_iterator = YAML::const_iterator;
Node();
explicit Node(NodeType::value type);

View File

@@ -18,11 +18,11 @@ class node_data;
class memory;
class memory_holder;
typedef std::shared_ptr<node> shared_node;
typedef std::shared_ptr<node_ref> shared_node_ref;
typedef std::shared_ptr<node_data> shared_node_data;
typedef std::shared_ptr<memory_holder> shared_memory_holder;
typedef std::shared_ptr<memory> shared_memory;
using shared_node = std::shared_ptr<node>;
using shared_node_ref = std::shared_ptr<node_ref>;
using shared_node_data = std::shared_ptr<node_data>;
using shared_memory_holder = std::shared_ptr<memory_holder>;
using shared_memory = std::shared_ptr<memory>;
}
}

View File

@@ -84,7 +84,7 @@ struct is_numeric<long double> {
template <bool, class T = void>
struct enable_if_c {
typedef T type;
using type = T;
};
template <class T>
@@ -95,7 +95,7 @@ struct enable_if : public enable_if_c<Cond::value, T> {};
template <bool, class T = void>
struct disable_if_c {
typedef T type;
using type = T;
};
template <class T>

View File

@@ -66,7 +66,7 @@ static const unsigned char decoding[] = {
};
std::vector<unsigned char> DecodeBase64(const std::string &input) {
typedef std::vector<unsigned char> ret_type;
using ret_type = std::vector<unsigned char>;
if (input.empty())
return ret_type();

View File

@@ -61,11 +61,11 @@ class NodeBuilder : public EventHandler {
detail::shared_memory_holder m_pMemory;
detail::node* m_pRoot;
typedef std::vector<detail::node*> Nodes;
using Nodes = std::vector<detail::node *>;
Nodes m_stack;
Nodes m_anchors;
typedef std::pair<detail::node*, bool> PushedKey;
using PushedKey = std::pair<detail::node*, bool>;
std::vector<PushedKey> m_keys;
std::size_t m_mapDepth;
};

View File

@@ -45,7 +45,7 @@ class NodeEvents {
anchor_t _CreateNewAnchor() { return ++m_curAnchor; }
private:
typedef std::map<const detail::node_ref*, anchor_t> AnchorByIdentity;
using AnchorByIdentity = std::map<const detail::node_ref*, anchor_t>;
AnchorByIdentity m_anchorByIdentity;
anchor_t m_curAnchor;
@@ -60,7 +60,7 @@ class NodeEvents {
detail::shared_memory_holder m_pMemory;
detail::node* m_root;
typedef std::map<const detail::node_ref*, int> RefCount;
using RefCount = std::map<const detail::node_ref*, int>;
RefCount m_refCount;
};
} // namespace YAML

View File

@@ -95,7 +95,7 @@ class SettingChanges {
}
private:
typedef std::vector<std::unique_ptr<SettingChangeBase>> setting_changes;
using setting_changes = std::vector<std::unique_ptr<SettingChangeBase> >;
setting_changes m_settingChanges;
};
} // namespace YAML

View File

@@ -59,7 +59,7 @@ class SingleDocParser {
const Directives& m_directives;
std::unique_ptr<CollectionStack> m_pCollectionStack;
typedef std::map<std::string, anchor_t> Anchors;
using Anchors = std::map<std::string, anchor_t>;
Anchors m_anchors;
anchor_t m_curAnchor;

View File

@@ -189,7 +189,7 @@ Stream::Stream(std::istream& input)
m_pPrefetched(new unsigned char[YAML_PREFETCH_SIZE]),
m_nPrefetchedAvailable(0),
m_nPrefetchedUsed(0) {
typedef std::istream::traits_type char_traits;
using char_traits = std::istream::traits_type;
if (!input)
return;