dbTalk Databases Forums  

[patch] row::operator[](int)

mailing.database.mysql-plusplus mailing.database.mysql-plusplus


Discuss [patch] row::operator[](int) in the mailing.database.mysql-plusplus forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Chris Frey
 
Posts: n/a

Default [patch] row::operator[](int) - 09-17-2005 , 08:12 PM






Here's the int style patch to row.h, for evaluation. It's not as clean
as the template solution, but there is less chance of weird error
messages.

Applies against CVS.

- Chris


Index: lib/row.h
================================================== =================
--- lib/row.h (revision 1119)
+++ lib/row.h (working copy)
@@ -130,6 +130,18 @@

/// \brief Get the value of a field given its index.
///
+ /// If the index value is bad, the underlying std::vector is
+ /// supposed to throw an exception, according to the Standard.
+ ///
+ /// This function provides the int overload so row[0] is not
+ /// ambiguous.
+ const ColData operator [](int i) const
+ {
+ return at(i);
+ }
+
+ /// \brief Get the value of a field given its index.
+ ///
/// If the index is out-of-bounds, the underlying vector is supposed
/// to throw an exception according to the C++ Standard. Whether it
/// actually does this is implementation-dependent.


--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw


Reply With Quote
  #2  
Old   
Chris Frey
 
Posts: n/a

Default Re: [patch] row::operator[](int) - 09-17-2005 , 08:22 PM






On Sat, Sep 17, 2005 at 09:12:07PM -0400, Chris Frey wrote:
Quote:
Applies against CVS.
Ahem, that should be SVN of course. :-) Old habits die hard.

- Chris


--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
  #3  
Old   
Warren Young
 
Posts: n/a

Default Re: [patch] row::operator[](int) - 09-19-2005 , 12:17 PM



Chris Frey wrote:
Quote:
+ const ColData operator [](int i) const
It happens to work, but it makes me nervous.

The problem is that const_subscript_container requires
operator[](SizeType), where SizeType is an unsigned int. That's
reasonable, since these containers should never be indexed with a
negative number. But '0' outside any other context is a plain int in
C++, which is where the ambiguity comes in. With this second integer
overload, we essentially have duplicate code, and all the problems that
come with it.

I'd be less against simply changing SizeType to be a plain int and
letting that change ripple through the hierarchy (don't forget Fields
and FieldNames!) but that would break the ABI.

--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.