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
5733b77b
Commit
5733b77b
authored
Sep 16, 2009
by
Jesse Beder
Browse files
Patched for gcc version <= 3.3 (just fall back to original version of Node::Read)
parent
98bebfb6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
4 deletions
+16
-4
include/nodeimpl.h
include/nodeimpl.h
+4
-4
include/nodereadimpl.h
include/nodereadimpl.h
+12
-0
No files found.
include/nodeimpl.h
View file @
5733b77b
...
@@ -79,22 +79,22 @@ namespace YAML
...
@@ -79,22 +79,22 @@ namespace YAML
template
<
typename
T
>
template
<
typename
T
>
inline
bool
operator
==
(
const
T
&
value
,
const
Node
&
node
)
{
inline
bool
operator
==
(
const
T
&
value
,
const
Node
&
node
)
{
return
value
==
node
.
Read
<
T
>
();
return
value
==
node
.
operator
T
();
}
}
template
<
typename
T
>
template
<
typename
T
>
inline
bool
operator
==
(
const
Node
&
node
,
const
T
&
value
)
{
inline
bool
operator
==
(
const
Node
&
node
,
const
T
&
value
)
{
return
value
==
node
.
Read
<
T
>
();
return
value
==
node
.
operator
T
();
}
}
template
<
typename
T
>
template
<
typename
T
>
inline
bool
operator
!=
(
const
T
&
value
,
const
Node
&
node
)
{
inline
bool
operator
!=
(
const
T
&
value
,
const
Node
&
node
)
{
return
value
!=
node
.
Read
<
T
>
();
return
value
!=
node
.
operator
T
();
}
}
template
<
typename
T
>
template
<
typename
T
>
inline
bool
operator
!=
(
const
Node
&
node
,
const
T
&
value
)
{
inline
bool
operator
!=
(
const
Node
&
node
,
const
T
&
value
)
{
return
value
!=
node
.
Read
<
T
>
();
return
value
!=
node
.
operator
T
();
}
}
inline
bool
operator
==
(
const
char
*
value
,
const
Node
&
node
)
{
inline
bool
operator
==
(
const
char
*
value
,
const
Node
&
node
)
{
...
...
include/nodereadimpl.h
View file @
5733b77b
...
@@ -6,7 +6,18 @@ namespace YAML
...
@@ -6,7 +6,18 @@ namespace YAML
// (the goal is to call ConvertScalar if we can, and fall back to operator >> if not)
// (the goal is to call ConvertScalar if we can, and fall back to operator >> if not)
// thanks to litb from stackoverflow.com
// thanks to litb from stackoverflow.com
// http://stackoverflow.com/questions/1386183/how-to-call-a-templated-function-if-it-exists-and-something-else-otherwise/1386390#1386390
// http://stackoverflow.com/questions/1386183/how-to-call-a-templated-function-if-it-exists-and-something-else-otherwise/1386390#1386390
// Note: this doesn't work on gcc 3.2, but does on gcc 3.4 and above. I'm not sure about 3.3.
#if (__GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ <= 3))
// trick doesn't work? Just fall back to ConvertScalar.
// This means that we can't use any user-defined types as keys in a map
template
<
typename
T
>
inline
bool
Node
::
Read
(
T
&
value
)
const
{
return
ConvertScalar
(
*
this
,
value
);
}
#else
// usual case: the trick!
template
<
bool
>
template
<
bool
>
struct
read_impl
;
struct
read_impl
;
...
@@ -52,6 +63,7 @@ namespace YAML
...
@@ -52,6 +63,7 @@ namespace YAML
return
read_impl
<
sizeof
(
fallback
::
flag
(),
Convert
(
std
::
string
(),
value
),
fallback
::
flag
())
!=
1
>::
read
(
*
this
,
value
);
return
read_impl
<
sizeof
(
fallback
::
flag
(),
Convert
(
std
::
string
(),
value
),
fallback
::
flag
())
!=
1
>::
read
(
*
this
,
value
);
}
}
#endif // done with trick
// the main conversion function
// the main conversion function
template
<
typename
T
>
template
<
typename
T
>
...
...
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