Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
yaml-cpp
Commits
97d56c3f
Commit
97d56c3f
authored
Nov 22, 2015
by
Jesse Beder
Browse files
Remove 'const' modifier on return of Node::as.
This enables the return value to be moved, rather than copied.
parent
320b02b1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
5 deletions
+5
-5
include/yaml-cpp/node/impl.h
include/yaml-cpp/node/impl.h
+3
-3
include/yaml-cpp/node/node.h
include/yaml-cpp/node/node.h
+2
-2
No files found.
include/yaml-cpp/node/impl.h
View file @
97d56c3f
...
@@ -87,7 +87,7 @@ struct as_if {
...
@@ -87,7 +87,7 @@ struct as_if {
explicit
as_if
(
const
Node
&
node_
)
:
node
(
node_
)
{}
explicit
as_if
(
const
Node
&
node_
)
:
node
(
node_
)
{}
const
Node
&
node
;
const
Node
&
node
;
const
T
operator
()(
const
S
&
fallback
)
const
{
T
operator
()(
const
S
&
fallback
)
const
{
if
(
!
node
.
m_pNode
)
if
(
!
node
.
m_pNode
)
return
fallback
;
return
fallback
;
...
@@ -140,14 +140,14 @@ struct as_if<std::string, void> {
...
@@ -140,14 +140,14 @@ struct as_if<std::string, void> {
// access functions
// access functions
template
<
typename
T
>
template
<
typename
T
>
inline
const
T
Node
::
as
()
const
{
inline
T
Node
::
as
()
const
{
if
(
!
m_isValid
)
if
(
!
m_isValid
)
throw
InvalidNode
();
throw
InvalidNode
();
return
as_if
<
T
,
void
>
(
*
this
)();
return
as_if
<
T
,
void
>
(
*
this
)();
}
}
template
<
typename
T
,
typename
S
>
template
<
typename
T
,
typename
S
>
inline
const
T
Node
::
as
(
const
S
&
fallback
)
const
{
inline
T
Node
::
as
(
const
S
&
fallback
)
const
{
if
(
!
m_isValid
)
if
(
!
m_isValid
)
return
fallback
;
return
fallback
;
return
as_if
<
T
,
S
>
(
*
this
)(
fallback
);
return
as_if
<
T
,
S
>
(
*
this
)(
fallback
);
...
...
include/yaml-cpp/node/node.h
View file @
97d56c3f
...
@@ -63,9 +63,9 @@ class YAML_CPP_API Node {
...
@@ -63,9 +63,9 @@ class YAML_CPP_API Node {
// access
// access
template
<
typename
T
>
template
<
typename
T
>
const
T
as
()
const
;
T
as
()
const
;
template
<
typename
T
,
typename
S
>
template
<
typename
T
,
typename
S
>
const
T
as
(
const
S
&
fallback
)
const
;
T
as
(
const
S
&
fallback
)
const
;
const
std
::
string
&
Scalar
()
const
;
const
std
::
string
&
Scalar
()
const
;
const
std
::
string
&
Tag
()
const
;
const
std
::
string
&
Tag
()
const
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment