Commit 407e633f authored by Yiding Jia's avatar Yiding Jia Committed by Jordan DeLong

folly/dynamic fix use of incomplete type in template definition

Summary:
the old code is ill-formed per spec (section 14.6.8):

> If a type used in a non-dependent name is incomplete at the point at which a
> template is defined but is complete at the point at which an instantiation is
> done, and if the completeness of that type affects whether or not the program
> is well-formed or affects the semantics of the program, the program is
> ill-formed; no diagnostic is required.

GCC is lax and allows this, clang gives an error.

Test Plan: compiles.

Reviewed By: delong.j@fb.com

FB internal diff: D643431
parent 35a186fe
......@@ -58,6 +58,22 @@ struct hash< ::folly::dynamic> {
namespace folly {
struct TypeError : std::runtime_error {
explicit TypeError(const std::string& expected, dynamic::Type actual)
: std::runtime_error(to<std::string>("TypeError: expected dynamic "
"type `", expected, '\'', ", but had type `",
dynamic::typeName(actual), '\''))
{}
explicit TypeError(const std::string& expected,
dynamic::Type actual1, dynamic::Type actual2)
: std::runtime_error(to<std::string>("TypeError: expected dynamic "
"types `", expected, '\'', ", but had types `",
dynamic::typeName(actual1), "' and `", dynamic::typeName(actual2),
'\''))
{}
};
//////////////////////////////////////////////////////////////////////
namespace detail {
......@@ -128,21 +144,6 @@ namespace detail {
//////////////////////////////////////////////////////////////////////
struct TypeError : std::runtime_error {
explicit TypeError(const std::string& expected, dynamic::Type actual)
: std::runtime_error(to<std::string>("TypeError: expected dynamic "
"type `", expected, '\'', ", but had type `",
dynamic::typeName(actual), '\''))
{}
explicit TypeError(const std::string& expected,
dynamic::Type actual1, dynamic::Type actual2)
: std::runtime_error(to<std::string>("TypeError: expected dynamic "
"types `", expected, '\'', ", but had types `",
dynamic::typeName(actual1), "' and `", dynamic::typeName(actual2),
'\''))
{}
};
/*
* We're doing this instead of a simple member typedef to avoid the
* undefined behavior of parameterizing std::unordered_map<> with an
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment