Author: wyoung
Date: Fri Dec 28 10:06:34 2007
New Revision: 2032
URL: http://svn.gna.org/viewcvs/mysqlpp?rev=2032&view=rev
Log:
Added an assert() suggested by Jonathan Wakely for detecting bad type
lookups in mapping C++ to SQL types.
Modified:
trunk/lib/type_info.h
Modified: trunk/lib/type_info.h
URL:
http://svn.gna.org/viewcvs/mysqlpp/trunk/lib/type_info.h?rev=2032&r1=2031&r2=2032&view=diff
==============================================================================
--- trunk/lib/type_info.h (original)
+++ trunk/lib/type_info.h Fri Dec 28 10:06:34 2007
@@ -35,6 +35,8 @@
#include <map>
#include <typeinfo>
+
+#include <assert.h>
namespace mysqlpp {
@@ -106,6 +108,8 @@
friend class mysql_type_info;
typedef mysql_ti_sql_type_info sql_type_info;
+ typedef std::map<const std::type_info*, unsigned char, type_info_cmp>
+ map_type;
mysql_ti_sql_type_info_lookup(const sql_type_info types[],
const int size);
@@ -113,10 +117,12 @@
const unsigned char& operator [](
const std::type_info& ti) const
{
- return map_.find(&ti)->second;
- }
-
- std::map<const std::type_info*, unsigned char, type_info_cmp> map_;
+ map_type::const_iterator it = map_.find(&ti);
+ assert(it != map_.end());
+ return it->second;
+ }
+
+ map_type map_;
};
#endif // !defined(DOXYGEN_IGNORE)
_______________________________________________
Mysqlpp-commits mailing list
[email protected]
https://mail.gna.org/listinfo/mysqlpp-commits