Permalink
Browse files

amend eaa53b0 and #1232 to compile with clang++ by avoiding first pas…

…s instanciation of intentionally invalid templates - refs #985
  • Loading branch information...
1 parent eaa53b0 commit 5feb9750e5aa5e17d39328ce8bde5c1f5113a892 Dane Springmeyer committed May 29, 2012
Showing with 10 additions and 12 deletions.
  1. +10 −12 include/mapnik/expression_string.hpp
@@ -34,29 +34,27 @@ namespace mapnik
{
MAPNIK_DECL std::string to_expression_string(expr_node const& node);
-// Dummy types that are used to trigger nice (with gcc at least)
-// compilation error when to_expression_string is misused.
-enum expr_node_ref_ {};
-enum expr_node_ptr_ {};
-
-// The following two templates should prevent accidentally passing
-// a pointer (either raw or shared) as the argument. Without them,
-// the compiler would construct a temporary expr_node(bool) using
-// implicit pointer-to-bool conversion, thus any non-null pointer
-// would yield "true".
+/*
+The following two templates are intentionally invalid and will prompt
+a compile error if ever instanciated. This should prevent accidentally
+passing a pointer (either raw or shared) as the argument. Without them,
+the compiler could construct a temporary expr_node(bool) using
+implicit pointer-to-bool conversion, thus any non-null pointer
+would yield "true".
+*/
template <typename T>
std::string to_expression_string(T const* x)
{
- expr_node_ref_ invalid_argument_type = expr_node_ptr_();
+ x = 0;
throw std::logic_error("to_expression_string() called with pointer argument");
return std::string();
}
template <typename T>
std::string to_expression_string(boost::shared_ptr<T> const& x)
{
- expr_node_ref_ invalid_argument_type = expr_node_ptr_();
+ x = 0;
throw std::logic_error("to_expression_string() called with pointer argument");
return std::string();
}

0 comments on commit 5feb975

Please sign in to comment.