Skip to content

Commit eef3d7f

Browse files
committed
replace std::shared_ptr<T>(new T) with std::make_shared<T>
1 parent 28f93bd commit eef3d7f

File tree

6 files changed

+7
-7
lines changed

6 files changed

+7
-7
lines changed

include/yaml-cpp/node/detail/memory.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class YAML_CPP_API memory {
3333

3434
class YAML_CPP_API memory_holder {
3535
public:
36-
memory_holder() : m_pMemory(new memory) {}
36+
memory_holder() : m_pMemory(std::make_shared<memory>()) {}
3737

3838
node& create_node() { return m_pMemory->create_node(); }
3939
void merge(memory_holder& rhs);

include/yaml-cpp/node/detail/node.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class node {
2424
};
2525

2626
public:
27-
node() : m_pRef(new node_ref), m_dependencies{}, m_index{} {}
27+
node() : m_pRef(std::make_shared<node_ref>()), m_dependencies{}, m_index{} {}
2828
node(const node&) = delete;
2929
node& operator=(const node&) = delete;
3030

include/yaml-cpp/node/detail/node_ref.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace YAML {
1616
namespace detail {
1717
class node_ref {
1818
public:
19-
node_ref() : m_pData(new node_data) {}
19+
node_ref() : m_pData(std::make_shared<node_data>()) {}
2020
node_ref(const node_ref&) = delete;
2121
node_ref& operator=(const node_ref&) = delete;
2222

include/yaml-cpp/node/impl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ inline Node::Node()
2222
inline Node::Node(NodeType::value type)
2323
: m_isValid(true),
2424
m_invalidKey{},
25-
m_pMemory(new detail::memory_holder),
25+
m_pMemory(std::make_shared<detail::memory_holder>()),
2626
m_pNode(&m_pMemory->create_node()) {
2727
m_pNode->set_type(type);
2828
}
@@ -31,7 +31,7 @@ template <typename T>
3131
inline Node::Node(const T& rhs)
3232
: m_isValid(true),
3333
m_invalidKey{},
34-
m_pMemory(new detail::memory_holder),
34+
m_pMemory(std::make_shared<detail::memory_holder>()),
3535
m_pNode(&m_pMemory->create_node()) {
3636
Assign(rhs);
3737
}

src/memory.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ void memory_holder::merge(memory_holder& rhs) {
1414
}
1515

1616
node& memory::create_node() {
17-
shared_node pNode(new node);
17+
shared_node pNode(std::make_shared<node>());
1818
m_nodes.insert(pNode);
1919
return *pNode;
2020
}

src/nodebuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace YAML {
1010
struct Mark;
1111

1212
NodeBuilder::NodeBuilder()
13-
: m_pMemory(new detail::memory_holder),
13+
: m_pMemory(std::make_shared<detail::memory_holder>()),
1414
m_pRoot(nullptr),
1515
m_stack{},
1616
m_anchors{},

0 commit comments

Comments
 (0)