Re: [Cppcms-users] Cppdb: How to fetch a column of unknown type at compile time?
Brought to you by:
artyom-beilis
|
From: Klaim <mj...@gm...> - 2011-01-04 10:19:05
|
Hi,
reading this example
try {
> int x = r.get<int>(v);
> }
> catch(cppdb::bad_value_cast const &e) {
> // ok it can't be integer
> }
>
I'm thinking : could it be possible to provide a way to make it return a
specific value instead of throwing when the conversion can't be done?
I'm not sure that would be useful in this case but it have been when using
boost::property_tree for example.
Something like
int x = r.get<int>( v , -1 ); // return -1 if something gone wrong
Alllowing the two syntaxes help avoiding unnecessary try/catch when you just
want an obviously wrong result instead of a potential exception you'll have
to remember to catch to stop crashing.
|