Alfredo Braunstein <[EMAIL PROTECTED]> writes:

| Lgb wrote:
>
>> I have never liked OUT arguements... and when I see code like:
>> 
>>   ParagraphList::iterator beg, end;
>>   getSelectionSpan(cur, *this, beg, end);
>> 
>> I get a chilly feeling (in the shoulder region).
>
| [...]
>
>> (also why coudn't cur and text be const refs in this funtion?)
|  
| Both valid criticisms IMO. 

Patch would look like this:

Index: src/text2.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text2.C,v
retrieving revision 1.550
diff -u -p -b -r1.550 text2.C
--- src/text2.C 20 Feb 2004 17:19:51 -0000      1.550
+++ src/text2.C 22 Feb 2004 15:41:26 -0000
@@ -67,7 +67,9 @@ using lyx::pos_type;
 using lyx::support::bformat;
 
 using std::endl;
+using std::make_pair;
 using std::ostringstream;
+using std::pair;
 using std::string;
 
 
@@ -308,10 +310,11 @@ void LyXText::setLayout(LCursor & cur, s
 namespace {
 
 
-void getSelectionSpan(LCursor & cur, LyXText & text,
-       ParagraphList::iterator & beg,
-       ParagraphList::iterator & end)
+pair<ParagraphList::iterator, ParagraphList::iterator>
+getSelectionSpan(LCursor const & cur, LyXText const & text)
 {
+       ParagraphList::iterator beg, end;
+
        if (!cur.selection()) {
                beg = text.getPar(cur.par());
                end = boost::next(beg);
@@ -319,6 +322,8 @@ void getSelectionSpan(LCursor & cur, LyX
                beg = text.getPar(cur.selBegin());
                end = boost::next(text.getPar(cur.selEnd()));
        }
+
+       return make_pair(beg, end);
 }
 
 
@@ -337,14 +342,15 @@ bool changeDepthAllowed(bv_funcs::DEPTH_
 }
 
 
-}
+} // namespace anon
 
 
 bool LyXText::changeDepthAllowed(LCursor & cur, bv_funcs::DEPTH_CHANGE type)
 {
        BOOST_ASSERT(this == cur.text());
        ParagraphList::iterator beg, end; 
-       getSelectionSpan(cur, *this, beg, end);
+       boost::tie(beg, end) = getSelectionSpan(cur, *this);
+
        int max_depth = 0;
        if (beg != paragraphs().begin())
                max_depth = boost::prior(beg)->getMaxDepthAfter();
@@ -362,7 +368,7 @@ void LyXText::changeDepth(LCursor & cur,
 {
        BOOST_ASSERT(this == cur.text());
        ParagraphList::iterator beg, end;
-       getSelectionSpan(cur, *this, beg, end);
+       boost::tie(beg, end) = getSelectionSpan(cur, *this);
        recordUndoSelection(cur);
 
        int max_depth = 0;



FYI: tuples will be in TC1

-- 
        Lgb

Reply via email to