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> #include <cstddef>
namespace YAML { namespace YAML {
typedef std::size_t anchor_t; using anchor_t = std::size_t;
const anchor_t NullAnchor = 0; const anchor_t NullAnchor = 0;
} }

View File

@@ -13,7 +13,7 @@ struct unspecified_bool {
struct NOT_ALLOWED; struct NOT_ALLOWED;
static void true_value(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> template <typename>
friend class iterator_base; friend class iterator_base;
struct enabler {}; struct enabler {};
typedef node_iterator base_type; using base_type = node_iterator;
struct proxy { struct proxy {
explicit proxy(const V& x) : m_ref(x) {} explicit proxy(const V& x) : m_ref(x) {}

View File

@@ -20,8 +20,8 @@ template <typename V>
class iterator_base; class iterator_base;
} }
typedef detail::iterator_base<detail::iterator_value> iterator; using iterator = detail::iterator_base<detail::iterator_value>;
typedef detail::iterator_base<const detail::iterator_value> const_iterator; using const_iterator = detail::iterator_base<const detail::iterator_value>;
} }
#endif // VALUE_DETAIL_ITERATOR_FWD_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #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); void merge(const memory& rhs);
private: private:
typedef std::set<shared_node> Nodes; using Nodes = std::set<shared_node>;
Nodes m_nodes; Nodes m_nodes;
}; };

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -59,7 +59,7 @@ class SingleDocParser {
const Directives& m_directives; const Directives& m_directives;
std::unique_ptr<CollectionStack> m_pCollectionStack; 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; Anchors m_anchors;
anchor_t m_curAnchor; anchor_t m_curAnchor;

View File

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