[EMAIL PROTECTED] (Lars Gullik Bjønnes) writes:

| I know that I am the one who began introducing pimpls to lyx. After
| that I have become quite wary of them... and feel more and more that
| you should have a good reason to use them. 
>
| This boils down to: (right now) What is the use of the pimpl in
| ParIterator?
>
| I have a patch where I remove it, get rid of asPosIterator, etc.
| I think it is nice and it makes the code size smaller (should be
| faster as well.)
| This is with gcc 3.4 prerelease and cvs boost.

I couldn't help myself, and used boost::bind to get rid of
lyxfunctional.h and several other functors.

I like the result, how about you?

Index: BranchList.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BranchList.C,v
retrieving revision 1.10
diff -u -p -b -r1.10 BranchList.C
--- BranchList.C	14 Dec 2003 16:33:51 -0000	1.10
+++ BranchList.C	4 Jan 2004 15:07:25 -0000
@@ -13,13 +13,15 @@
 #include "BranchList.h"
 
 #include <boost/assert.hpp>
+#include <boost/bind.hpp>
 
 #include <functional>
 
 
+using boost::bind;
+
 using std::string;
-using std::bind2nd;
-using std::binary_function;
+using std::equal_to;
 
 
 string const & Branch::getBranch() const
@@ -127,20 +129,11 @@ bool BranchList::add(string const & s)
 }
 
 
-namespace {
-
-struct match : public binary_function<Branch, string, bool> {
-	bool operator()(Branch const & br, string const & s) const {
-	return (br.getBranch() == s);
-	}
-};
-
-} // namespace anon.
-
-
 bool BranchList::remove(string const & s)
 {
 	List::size_type const size = list.size();
-	list.remove_if(bind2nd(match(), s));
+	list.remove_if(bind(equal_to<string>(),
+			    bind(&Branch::getBranch, _1),
+			    s));
 	return size != list.size();
 }
Index: BufferView_pimpl.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.C,v
retrieving revision 1.480
diff -u -p -b -r1.480 BufferView_pimpl.C
--- BufferView_pimpl.C	18 Dec 2003 04:43:05 -0000	1.480
+++ BufferView_pimpl.C	4 Jan 2004 15:07:25 -0000
@@ -741,7 +741,9 @@ InsetOld * BufferView::Pimpl::getInsetBy
 		find_if(Buffer::inset_iterator(
 			cursorPar(), cursor.pos()),
 			buffer_->inset_iterator_end(),
-			lyx::compare_memfun(&Inset::lyxCode, code));
+			bind(equal_to<InsetOld::Code>(),
+			     bind(Inset::lyxCode, _1),
+			     code));
 	return it != buffer_->inset_iterator_end() ? (*it) : 0;
 #else
 	// Ok, this is a little bit too brute force but it
Index: MenuBackend.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/MenuBackend.C,v
retrieving revision 1.94
diff -u -p -b -r1.94 MenuBackend.C
--- MenuBackend.C	12 Nov 2003 14:38:24 -0000	1.94
+++ MenuBackend.C	4 Jan 2004 15:07:25 -0000
@@ -40,10 +40,11 @@
 #include "frontends/LyXView.h"
 
 #include "support/filetools.h"
-#include "support/lyxfunctional.h"
 #include "support/lstrings.h"
 #include "support/tostr.h"
 
+#include <boost/bind.hpp>
+
 #include <algorithm>
 
 using lyx::support::compare_ascii_no_case;
@@ -51,8 +52,11 @@ using lyx::support::contains;
 using lyx::support::MakeDisplayPath;
 using lyx::support::token;
 
+using boost::bind;
+
 using std::auto_ptr;
 using std::endl;
+using std::equal_to;
 using std::find_if;
 using std::max;
 using std::sort;
@@ -770,7 +774,8 @@ void MenuBackend::expand(Menu const & fr
 bool Menu::hasSubmenu(string const & name) const
 {
 	return find_if(begin(), end(),
-		       lyx::compare_memfun(&MenuItem::submenuname,
+		       bind(equal_to<string>(),
+			    bind(&MenuItem::submenuname, _1),
 					   name)) != end();
 }
 
@@ -841,14 +846,18 @@ void MenuBackend::add(Menu const & menu)
 bool MenuBackend::hasMenu(string const & name) const
 {
 	return find_if(begin(), end(),
-		       lyx::compare_memfun(&Menu::name, name)) != end();
+		       bind(equal_to<string>(),
+			    bind(&Menu::name, _1),
+			    name)) != end();
 }
 
 
 Menu const & MenuBackend::getMenu(string const & name) const
 {
 	const_iterator cit = find_if(begin(), end(),
-				     lyx::compare_memfun(&Menu::name, name));
+				     bind(equal_to<string>(),
+					  bind(&Menu::name, _1),
+					  name));
 	if (cit == end())
 		lyxerr << "No submenu named " << name << endl;
 	BOOST_ASSERT(cit != end());
@@ -860,7 +869,9 @@ Menu & MenuBackend::getMenu(string const
 {
 	MenuList::iterator it =
 		find_if(menulist_.begin(), menulist_.end(),
-			lyx::compare_memfun(&Menu::name, name));
+			bind(equal_to<string>(),
+			     bind(&Menu::name, _1),
+			     name));
 	BOOST_ASSERT(it != menulist_.end());
 	return (*it);
 }
Index: PosIterator.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/PosIterator.C,v
retrieving revision 1.5
diff -u -p -b -r1.5 PosIterator.C
--- PosIterator.C	3 Dec 2003 18:17:15 -0000	1.5
+++ PosIterator.C	4 Jan 2004 15:07:25 -0000
@@ -26,6 +26,58 @@
 
 using boost::prior;
 
+
+PosIterator::PosIterator(ParagraphList * pl,
+			 ParagraphList::iterator pit,
+			 lyx::pos_type pos)
+{
+	stack_.push_back(PosIteratorItem(pl, pit, pos));
+}
+
+
+PosIterator::PosIterator(BufferView & bv)
+{
+	LyXText * text = bv.getLyXText();
+	lyx::pos_type pos = text->cursor.pos();
+	ParagraphList::iterator pit = text->cursorPar();
+
+	ParIterator par = bv.buffer()->par_iterator_begin();
+	ParIterator end = bv.buffer()->par_iterator_end();
+	for ( ; par != end; ++par) {
+		if (par.pit() == pit)
+			break;
+	}
+
+	setFrom(par, pos);
+}
+
+
+PosIterator::PosIterator(ParIterator const & par, lyx::pos_type pos)
+{
+	setFrom(par, pos);
+}
+
+
+void PosIterator::setFrom(ParIterator const & par, lyx::pos_type pos)
+{
+	BOOST_ASSERT(par.size() > 0);
+
+	ParIterator::PosHolder const & ph = par.positions();
+
+	int const last = par.size() - 1;
+	for (int i = 0; i < last; ++i) {
+		ParPosition const & pp = ph[i];
+		stack_.push_back(
+			PosIteratorItem(const_cast<ParagraphList *>(pp.plist),
+					pp.pit, (*pp.it)->pos, *pp.index + 1));
+	}
+	ParPosition const & pp = ph[last];
+	stack_.push_back(
+		PosIteratorItem(const_cast<ParagraphList *>(pp.plist), pp.pit, pos, 0));
+}
+
+
+
 PosIterator & PosIterator::operator++()
 {
 	BOOST_ASSERT(!stack_.empty());
@@ -95,15 +147,8 @@ PosIterator & PosIterator::operator--()
 }
 
 
-bool operator!=(PosIterator const & lhs, PosIterator const & rhs)
-{
-	return !(lhs == rhs);
-}
-
-
 bool operator==(PosIterator const & lhs, PosIterator const & rhs)
 {
-	
 	PosIteratorItem const & li = lhs.stack_.back();
 	PosIteratorItem const & ri = rhs.stack_.back();
 	
@@ -118,53 +163,10 @@ bool PosIterator::at_end() const
 }
 
 
-PosIterator::PosIterator(ParagraphList * pl, ParagraphList::iterator pit,
-			 lyx::pos_type pos)
-{
-	stack_.push_back(PosIteratorItem(pl, pit, pos));
-}
-
-
-PosIterator::PosIterator(BufferView & bv)
-{
-	LyXText * text = bv.getLyXText();
-	lyx::pos_type pos = text->cursor.pos();
-	ParagraphList::iterator pit = text->cursorPar();
-	
-	ParIterator par = bv.buffer()->par_iterator_begin();
-	ParIterator end = bv.buffer()->par_iterator_end();
-	for ( ; par != end; ++par) {
-		if (par.pit() == pit)
-			break;
-	}
-
-	operator=(par.asPosIterator(pos));
-}
-
-
 InsetOld * PosIterator::inset() const
 {
 	if (stack_.size() == 1)
 		return 0;
 	PosIteratorItem const & pi = stack_[stack_.size() - 2];
 	return pi.pit->getInset(pi.pos);
-}
-
-
-int distance(PosIterator const & cur, PosIterator const & end)
-{
-	PosIterator p = cur;
-	int count = 0;
-	for (; p != end; ++p, ++count)
-		;
-	return count;
-}
-
-
-void advance(PosIterator & cur, int howmuch)
-{
-	for (int i = 0; i < howmuch; ++i)
-		++cur;
-	for (int i = 0; i > howmuch; --i)
-		--cur;
 }
Index: PosIterator.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/PosIterator.h,v
retrieving revision 1.5
diff -u -p -b -r1.5 PosIterator.h
--- PosIterator.h	7 Nov 2003 09:40:48 -0000	1.5
+++ PosIterator.h	4 Jan 2004 15:07:25 -0000
@@ -36,14 +36,18 @@ struct PosIteratorItem 
 };
 
 
-class PosIterator
+class PosIterator : public std::iterator<
+	std::bidirectional_iterator_tag,
+	ParagraphList::value_type>
 {
 public:
+	// Creates a singular.
+	PosIterator() {};
+
 	PosIterator(BufferView & bv);
-	PosIterator(ParIterator & par, lyx::pos_type pos);
 	PosIterator(ParagraphList * pl, ParagraphList::iterator pit,
 		    lyx::pos_type pos);
-	PosIterator(ParIterator const & parit, lyx::pos_type p);
+	PosIterator(ParIterator const & par, lyx::pos_type pos);
 	PosIterator & operator++();
 	PosIterator & operator--();
 	friend bool operator==(PosIterator const &, PosIterator const &);
@@ -52,20 +56,24 @@ public:
 	lyx::pos_type pos() const { return stack_.back().pos; }
 	bool at_end() const;
 	InsetOld * inset() const;
-	friend PosIterator ParIterator::asPosIterator(lyx::pos_type) const;
+//	friend PosIterator ParIterator::asPosIterator(lyx::pos_type) const;
 	friend ParIterator::ParIterator(PosIterator const &);
 	
 private:
-	PosIterator() {};
-	//this is conceptually a stack, but we need random access sometimes
+	void setFrom(ParIterator const & par, lyx::pos_type pos);
+	// This is conceptually a stack,
+	// but we need random access sometimes.
 	std::vector<PosIteratorItem> stack_;
 };
 
-bool operator!=(PosIterator const &, PosIterator const &);
+
 bool operator==(PosIterator const &, PosIterator const &);
 
-int distance(PosIterator const &, PosIterator const &);
-void advance(PosIterator &, int);
 
-#endif
+inline
+bool operator!=(PosIterator const & lhs, PosIterator const & rhs)
+{
+	return !(lhs == rhs);
+}
 
+#endif
Index: ShareContainer.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ShareContainer.h,v
retrieving revision 1.14
diff -u -p -b -r1.14 ShareContainer.h
--- ShareContainer.h	23 Aug 2003 00:16:06 -0000	1.14
+++ ShareContainer.h	4 Jan 2004 15:07:25 -0000
@@ -62,7 +62,7 @@ public:
 	}
 private:
 	/// A functor returning true if the elements are equal.
-	struct isEqual {
+	struct isEqual : public std::unary_function<value_type, bool> {
 		isEqual(Share const & s) : p_(s) {}
 		bool operator()(value_type const & p1) const {
 			return *p1.get() == p_;
@@ -71,7 +71,7 @@ private:
 		Share const & p_;
 	};
 	/// A functor returning true if the element is unique.
-	struct isUnique {
+	struct isUnique : public std::unary_function<value_type, bool> {
 		bool operator()(value_type const & p) const {
 			return p.unique();
 		}
Index: bufferlist.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/bufferlist.C,v
retrieving revision 1.139
diff -u -p -b -r1.139 bufferlist.C
--- bufferlist.C	5 Nov 2003 12:06:02 -0000	1.139
+++ bufferlist.C	4 Jan 2004 15:07:25 -0000
@@ -26,9 +26,11 @@
 #include "frontends/Alert.h"
 
 #include "support/filetools.h"
-#include "support/lyxfunctional.h"
 
 #include <boost/bind.hpp>
+#include <boost/function_output_iterator.hpp>
+
+#include <iterator>
 
 using lyx::support::AddName;
 using lyx::support::bformat;
@@ -39,8 +41,11 @@ using lyx::support::OnlyFilename;
 using lyx::support::removeAutosaveFile;
 using lyx::support::prefixIs;
 
+using boost::bind;
+
 using std::auto_ptr;
 using std::endl;
+using std::equal_to;
 using std::find;
 using std::find_if;
 using std::for_each;
@@ -193,7 +198,12 @@ vector<string> const BufferList::getFile
 {
 	vector<string> nvec;
 	std::copy(bstore.begin(), bstore.end(),
-		  lyx::back_inserter_fun(nvec, &Buffer::fileName));
+		  boost::make_function_output_iterator(
+			  bind(&vector<string>::push_back,
+			       boost::ref(nvec),
+			       bind(&Buffer::fileName, _1))
+			  )
+		);
 	return nvec;
 }
 
@@ -235,7 +245,7 @@ void BufferList::updateIncludedTeXfiles(
 void BufferList::emergencyWriteAll()
 {
 	for_each(bstore.begin(), bstore.end(),
-		 boost::bind(&BufferList::emergencyWrite, this, _1));
+		 bind(&BufferList::emergencyWrite, this, _1));
 }
 
 
@@ -300,8 +310,9 @@ void BufferList::emergencyWrite(Buffer *
 bool BufferList::exists(string const & s) const
 {
 	return find_if(bstore.begin(), bstore.end(),
-		       lyx::compare_memfun(&Buffer::fileName, s))
-		!= bstore.end();
+		       bind(equal_to<string>(),
+			    bind(&Buffer::fileName, _1),
+			    s)) != bstore.end();
 }
 
 
@@ -318,7 +329,9 @@ Buffer * BufferList::getBuffer(string co
 {
 	BufferStorage::iterator it =
 		find_if(bstore.begin(), bstore.end(),
-			lyx::compare_memfun(&Buffer::fileName, s));
+			bind(equal_to<string>(),
+			     bind(&Buffer::fileName, _1),
+			     s));
 	return it != bstore.end() ? (*it) : 0;
 }
 
Index: format.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/format.C,v
retrieving revision 1.20
diff -u -p -b -r1.20 format.C
--- format.C	14 Oct 2003 11:35:50 -0000	1.20
+++ format.C	4 Jan 2004 15:07:26 -0000
@@ -23,7 +23,8 @@
 #include "support/filetools.h"
 #include "support/path.h"
 #include "support/systemcall.h"
-#include "support/lyxfunctional.h"
+
+#include <boost/bind.hpp>
 
 using lyx::support::bformat;
 using lyx::support::compare_ascii_no_case;
@@ -35,6 +36,9 @@ using lyx::support::QuoteName;
 using lyx::support::subst;
 using lyx::support::Systemcall;
 
+using boost::bind;
+
+using std::equal_to;
 using std::string;
 
 extern LyXServerSocket * lyxsocket;
@@ -91,7 +95,9 @@ Format const * Formats::getFormat(string
 {
 	FormatList::const_iterator cit =
 		find_if(formatlist.begin(), formatlist.end(),
-			lyx::compare_memfun(&Format::name, name));
+			bind(equal_to<string>(),
+			     bind(&Format::name, _1),
+			     name));
 	if (cit != formatlist.end())
 		return &(*cit);
 	else
@@ -103,7 +109,9 @@ int Formats::getNumber(string const & na
 {
 	FormatList::const_iterator cit =
 		find_if(formatlist.begin(), formatlist.end(),
-			lyx::compare_memfun(&Format::name, name));
+			bind(equal_to<string>(),
+			     bind(&Format::name, _1),
+			     name));
 	if (cit != formatlist.end())
 		return cit - formatlist.begin();
 	else
@@ -123,7 +131,9 @@ void Formats::add(string const & name, s
 {
 	FormatList::iterator it =
 		find_if(formatlist.begin(), formatlist.end(),
-			lyx::compare_memfun(&Format::name, name));
+			bind(equal_to<string>(),
+			     bind(&Format::name, _1),
+			     name));
 	if (it == formatlist.end())
 		formatlist.push_back(Format(name, extension, prettyname,
 					    shortcut, ""));
@@ -138,7 +148,9 @@ void Formats::erase(string const & name)
 {
 	FormatList::iterator it =
 		find_if(formatlist.begin(), formatlist.end(),
-			lyx::compare_memfun(&Format::name, name));
+			bind(equal_to<string>(),
+			     bind(&Format::name, _1),
+			     name));
 	if (it != formatlist.end())
 		formatlist.erase(it);
 }
@@ -155,7 +167,9 @@ void Formats::setViewer(string const & n
 	add(name);
 	FormatList::iterator it =
 		find_if(formatlist.begin(), formatlist.end(),
-			lyx::compare_memfun(&Format::name, name));
+			bind(equal_to<string>(),
+			     bind(&Format::name, _1),
+			     name));
 	if (it != formatlist.end())
 		it->setViewer(command);
 }
Index: iterators.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/iterators.C,v
retrieving revision 1.36
diff -u -p -b -r1.36 iterators.C
--- iterators.C	5 Dec 2003 08:33:38 -0000	1.36
+++ iterators.C	4 Jan 2004 15:07:26 -0000
@@ -24,30 +24,13 @@
 #include "insets/insettext.h"
 
 #include <boost/next_prior.hpp>
-#include <boost/optional.hpp>
 
 using boost::next;
-using boost::optional;
-using std::vector;
 
 ///
 /// ParPosition
 ///
 
-class ParPosition {
-public:
-	///
-	ParPosition(ParagraphList::iterator p, ParagraphList const & pl);
-	///
-	ParagraphList::iterator pit;
-	///
-	ParagraphList const * plist;
-	///
-	optional<InsetList::iterator> it;
-	///
-	optional<int> index;
-};
-
 
 ParPosition::ParPosition(ParagraphList::iterator p, ParagraphList const & pl)
 	: pit(p), plist(&pl)
@@ -74,15 +57,9 @@ bool operator!=(ParPosition const & pos1
 /// ParIterator
 ///
 
-struct ParIterator::Pimpl {
-	typedef vector<ParPosition> PosHolder;
-	PosHolder positions;
-};
-
 ParIterator::ParIterator(ParagraphList::iterator pit, ParagraphList const & pl)
-	: pimpl_(new Pimpl)
 {
-	pimpl_->positions.push_back(ParPosition(pit, pl));
+	positions_.push_back(ParPosition(pit, pl));
 }
 
 
@@ -91,21 +68,21 @@ ParIterator::~ParIterator()
 
 
 ParIterator::ParIterator(ParIterator const & pi)
-	: pimpl_(new Pimpl(*pi.pimpl_))
+	: positions_(pi.positions_)
 {}
 
 
 void ParIterator::operator=(ParIterator const & pi)
 {
 	ParIterator tmp(pi);
-	pimpl_.swap(tmp.pimpl_);
+	swap(positions_ , tmp.positions_);
 }
 
 
 ParIterator & ParIterator::operator++()
 {
-	while (!pimpl_->positions.empty()) {
-		ParPosition & p = pimpl_->positions.back();
+	while (!positions_.empty()) {
+		ParPosition & p = positions_.back();
 
 		// Does the current inset contain more "cells" ?
 		if (p.index) {
@@ -113,7 +90,7 @@ ParIterator & ParIterator::operator++()
 			if (LyXText * text = (*p.it)->inset->getText(*p.index)) {
 				ParagraphList & plist = text->paragraphs();
 				if (!plist.empty()) {
-					pimpl_->positions.push_back(ParPosition(plist.begin(), plist));
+					positions_.push_back(ParPosition(plist.begin(), plist));
 					return *this;
 				}
 			}
@@ -132,7 +109,7 @@ ParIterator & ParIterator::operator++()
 				ParagraphList & plist = text->paragraphs();
 				if (!plist.empty()) {
 					p.index.reset(0);
-					pimpl_->positions.push_back(ParPosition(plist.begin(), plist));
+					positions_.push_back(ParPosition(plist.begin(), plist));
 					return *this;
 				}
 			}
@@ -140,7 +117,7 @@ ParIterator & ParIterator::operator++()
 
 		// Try to go to the next paragarph
 		if (next(p.pit) != const_cast<ParagraphList*>(p.plist)->end()
-		    || pimpl_->positions.size() == 1) {
+		    || positions_.size() == 1) {
 			++p.pit;
 			p.index.reset();
 			p.it.reset();
@@ -149,7 +126,7 @@ ParIterator & ParIterator::operator++()
 		}
 
 		// Drop end and move up in the stack.
-		pimpl_->positions.pop_back();
+		positions_.pop_back();
 	}
 	return *this;
 }
@@ -158,10 +135,10 @@ ParIterator & ParIterator::operator++()
 LyXText * ParIterator::text(Buffer & buf) const
 {
 	//lyxerr << "positions.size: " << pimpl_->positions.size() << std::endl;
-	if (pimpl_->positions.size() <= 1)
+	if (positions_.size() <= 1)
 		return &buf.text();
 
-	ParPosition const & pos = pimpl_->positions[pimpl_->positions.size() - 2];
+	ParPosition const & pos = positions_[positions_.size() - 2];
 	return (*pos.it)->inset->getText(*pos.index);
 }
 
@@ -169,62 +146,94 @@ LyXText * ParIterator::text(Buffer & buf
 InsetOld * ParIterator::inset() const
 {
 	//lyxerr << "positions.size: " << pimpl_->positions.size() << std::endl;
-	if (pimpl_->positions.size() <= 1)
+	if (positions_.size() <= 1)
 		return 0;
 
-	ParPosition const & pos = pimpl_->positions[pimpl_->positions.size() - 2];
+	ParPosition const & pos = positions_[positions_.size() - 2];
 	return (*pos.it)->inset;
 }
 
 
 int ParIterator::index() const
 {
-	if (pimpl_->positions.size() <= 1)
+	if (positions_.size() <= 1)
 		return 0;
 
-	return *(pimpl_->positions[pimpl_->positions.size() - 2].index);
+	return *(positions_[positions_.size() - 2].index);
 }
 
 
 Paragraph & ParIterator::operator*() const
 {
-	return *pimpl_->positions.back().pit;
+	return *positions_.back().pit;
 }
 
 
 ParagraphList::iterator ParIterator::pit() const
 {
-	return pimpl_->positions.back().pit;
+	return positions_.back().pit;
 }
 
 
 ParagraphList::iterator ParIterator::operator->() const
 {
-	return pimpl_->positions.back().pit;
+	return positions_.back().pit;
 }
 
 
 ParagraphList::iterator ParIterator::outerPar() const
 {
-	return pimpl_->positions[0].pit;
+	return positions_[0].pit;
 }
 
 
 size_t ParIterator::size() const
 {
-	return pimpl_->positions.size();
+	return positions_.size();
 }
 
 
 ParagraphList & ParIterator::plist() const
 {
-	return *const_cast<ParagraphList*>(pimpl_->positions.back().plist);
+	return *const_cast<ParagraphList*>(positions_.back().plist);
+}
+
+
+ParIterator::ParIterator(PosIterator const & pos)
+{
+	int const size = pos.stack_.size();
+
+	for (int i = 0; i < size; ++i) {
+		PosIteratorItem const & it = pos.stack_[i];
+		ParPosition pp(it.pit, *it.pl);
+		if (i < size - 1) {
+			InsetOld * inset = it.pit->getInset(it.pos);
+			BOOST_ASSERT(inset);
+			InsetList::iterator beg = it.pit->insetlist.begin();
+			InsetList::iterator end = it.pit->insetlist.end();
+			for ( ; beg != end && beg->inset != inset; ++beg)
+				;
+			pp.it.reset(beg);
+			pp.index.reset(it.index - 1);
+		}
+		positions_.push_back(pp);
+	}
+}
+
+
+void ParIterator::lockPath(BufferView * bv) const
+{
+	bv->cursor() = LCursor(bv);
+	int last = size() - 1;
+#warning this seems to create just one entry for InsetTabulars
+	for (int i = 0; i < last; ++i)
+		(*positions_[i].it)->inset->edit(bv, true);
 }
 
 
 bool operator==(ParIterator const & iter1, ParIterator const & iter2)
 {
-	return iter1.pimpl_->positions == iter2.pimpl_->positions;
+	return iter1.positions() == iter2.positions();
 }
 
 
@@ -239,17 +248,10 @@ bool operator!=(ParIterator const & iter
 ///
 
 
-struct ParConstIterator::Pimpl {
-	typedef vector<ParPosition> PosHolder;
-	PosHolder positions;
-};
-
-
 ParConstIterator::ParConstIterator(ParagraphList::iterator pit,
 				   ParagraphList const & pl)
-	: pimpl_(new Pimpl)
 {
-	pimpl_->positions.push_back(ParPosition(pit, pl));
+	positions_.push_back(ParPosition(pit, pl));
 }
 
 
@@ -258,14 +260,14 @@ ParConstIterator::~ParConstIterator()
 
 
 ParConstIterator::ParConstIterator(ParConstIterator const & pi)
-	: pimpl_(new Pimpl(*pi.pimpl_))
+	: positions_(pi.positions_)
 {}
 
 
 ParConstIterator & ParConstIterator::operator++()
 {
-	while (!pimpl_->positions.empty()) {
-		ParPosition & p = pimpl_->positions.back();
+	while (!positions_.empty()) {
+		ParPosition & p = positions_.back();
 
 		// Does the current inset contain more "cells" ?
 		if (p.index) {
@@ -273,7 +275,7 @@ ParConstIterator & ParConstIterator::ope
 			if (LyXText * text = (*p.it)->inset->getText(*p.index)) {
 				ParagraphList & plist = text->paragraphs();
 				if (!plist.empty()) {
-					pimpl_->positions.push_back(ParPosition(plist.begin(), plist));
+					positions_.push_back(ParPosition(plist.begin(), plist));
 					return *this;
 				}
 			}
@@ -292,7 +294,7 @@ ParConstIterator & ParConstIterator::ope
 				ParagraphList & plist = text->paragraphs();
 				if (!plist.empty()) {
 					p.index.reset(0);
-					pimpl_->positions.push_back(ParPosition(plist.begin(), plist));
+					positions_.push_back(ParPosition(plist.begin(), plist));
 					return *this;
 				}
 			}
@@ -300,7 +302,7 @@ ParConstIterator & ParConstIterator::ope
 
 		// Try to go to the next paragarph
 		if (next(p.pit) != const_cast<ParagraphList*>(p.plist)->end()
-		    || pimpl_->positions.size() == 1) {
+		    || positions_.size() == 1) {
 			++p.pit;
 			p.index.reset();
 			p.it.reset();
@@ -309,7 +311,7 @@ ParConstIterator & ParConstIterator::ope
 		}
 
 		// Drop end and move up in the stack.
-		pimpl_->positions.pop_back();
+		positions_.pop_back();
 	}
 
 	return *this;
@@ -318,92 +320,41 @@ ParConstIterator & ParConstIterator::ope
 
 Paragraph const & ParConstIterator::operator*() const
 {
-	return *pimpl_->positions.back().pit;
+	return *positions_.back().pit;
 }
 
 
 ParagraphList::const_iterator ParConstIterator::pit() const
 {
-	return pimpl_->positions.back().pit;
+	return positions_.back().pit;
 }
 
 
 ParagraphList::const_iterator ParConstIterator::operator->() const
 {
-	return pimpl_->positions.back().pit;
+	return positions_.back().pit;
 }
 
 
 ParagraphList const & ParConstIterator::plist() const
 {
-	return *pimpl_->positions.back().plist;
+	return *positions_.back().plist;
 }
 
 
 size_t ParConstIterator::size() const
 {
-	return pimpl_->positions.size();
+	return positions_.size();
 }
 
 
 bool operator==(ParConstIterator const & iter1, ParConstIterator const & iter2)
 {
-	return iter1.pimpl_->positions == iter2.pimpl_->positions;
+	return iter1.positions() == iter2.positions();
 }
 
 
 bool operator!=(ParConstIterator const & iter1, ParConstIterator const & iter2)
 {
 	return !(iter1 == iter2);
-}
-
-
-PosIterator ParIterator::asPosIterator(lyx::pos_type pos) const
-{
-	PosIterator p;
-
-	int const last = size() - 1;
-	for (int i = 0; i < last; ++i) {
-		ParPosition & pp = pimpl_->positions[i];
-		p.stack_.push_back(
-			PosIteratorItem(const_cast<ParagraphList *>(pp.plist),
-				pp.pit, (*pp.it)->pos, *pp.index + 1));
-	}
-	ParPosition const & pp = pimpl_->positions[last];
-	p.stack_.push_back(
-		PosIteratorItem(const_cast<ParagraphList *>(pp.plist), pp.pit, pos, 0));
-	return p;
-}
-
-
-ParIterator::ParIterator(PosIterator const & pos)
-	: pimpl_(new Pimpl)
-{
-	int const size = pos.stack_.size();
-
-	for (int i = 0; i < size; ++i) {
-		PosIteratorItem const & it = pos.stack_[i];
-		ParPosition pp(it.pit, *it.pl);
-		if (i < size - 1) {
-			InsetOld * inset = it.pit->getInset(it.pos);
-			BOOST_ASSERT(inset);
-			InsetList::iterator beg = it.pit->insetlist.begin();
-			InsetList::iterator end = it.pit->insetlist.end();
-			for ( ; beg != end && beg->inset != inset; ++beg)
-				;
-			pp.it.reset(beg);
-			pp.index.reset(it.index - 1);
-		}
-		pimpl_->positions.push_back(pp);
-	}
-}
-
-
-void ParIterator::lockPath(BufferView * bv) const
-{
-	bv->cursor() = LCursor(bv);
-	int last = size() - 1;
-#warning this seems to create just one entry for InsetTabulars
-	for (int i = 0; i < last; ++i)
-		(*pimpl_->positions[i].it)->inset->edit(bv, true);
 }
Index: iterators.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/iterators.h,v
retrieving revision 1.25
diff -u -p -b -r1.25 iterators.h
--- iterators.h	1 Dec 2003 13:35:38 -0000	1.25
+++ iterators.h	4 Jan 2004 15:07:26 -0000
@@ -13,9 +13,13 @@
 #define ITERATORS_H
 
 #include "ParagraphList_fwd.h"
+#include "InsetList.h"
+
 #include "support/types.h"
 
-#include <boost/scoped_ptr.hpp>
+#include <boost/optional.hpp>
+
+#include <vector>
 
 class LyXText;
 class InsetOld;
@@ -25,7 +29,25 @@ class BufferView;
 class PosIterator;
 
 
-class ParIterator {
+class ParPosition {
+public:
+	///
+	ParPosition(ParagraphList::iterator p, ParagraphList const & pl);
+	///
+	ParagraphList::iterator pit;
+	///
+	ParagraphList const * plist;
+	///
+	boost::optional<InsetList::iterator> it;
+	///
+	boost::optional<int> index;
+};
+
+
+class ParIterator : public std::iterator<
+	std::forward_iterator_tag,
+	ParagraphList::value_type>
+{
 public:
 	///
 	ParIterator(ParagraphList::iterator pit, ParagraphList const & pl);
@@ -58,16 +80,15 @@ public:
 	///
 	size_t size() const;
 	///
-	friend
-	bool operator==(ParIterator const & iter1, ParIterator const & iter2);
-	///
 	void lockPath(BufferView *) const;
 
-	///
-	PosIterator asPosIterator(lyx::pos_type) const;
+	typedef std::vector<ParPosition> PosHolder;
+	PosHolder const & positions() const
+	{
+		return positions_;
+	}
 private:
-	struct Pimpl;
-	boost::scoped_ptr<Pimpl> pimpl_;
+	PosHolder positions_;
 };
 
 ///
@@ -77,7 +98,10 @@ bool operator==(ParIterator const & iter
 bool operator!=(ParIterator const & iter1, ParIterator const & iter2);
 
 
-class ParConstIterator {
+class ParConstIterator : public std::iterator<
+	std::forward_iterator_tag,
+	ParagraphList::value_type>
+{
 public:
 	///
 	ParConstIterator(ParagraphList::iterator pit, ParagraphList const & pl);
@@ -98,14 +122,13 @@ public:
 
 	/// depth of nesting
 	size_t size() const;
-	///
-	friend
-	bool operator==(ParConstIterator const & iter1,
-			ParConstIterator const & iter2);
-
+	typedef std::vector<ParPosition> PosHolder;
+	PosHolder const & positions() const
+	{
+		return positions_;
+	}
 private:
-	struct Pimpl;
-	boost::scoped_ptr<Pimpl> pimpl_;
+	PosHolder positions_;
 };
 
 bool operator==(ParConstIterator const & iter1,
Index: lyxfind.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxfind.C,v
retrieving revision 1.61
diff -u -p -b -r1.61 lyxfind.C
--- lyxfind.C	12 Dec 2003 15:19:32 -0000	1.61
+++ lyxfind.C	4 Jan 2004 15:07:26 -0000
@@ -106,7 +106,7 @@ bool findBackwards(PosIterator & cur, Po
 bool findChange(PosIterator & cur, PosIterator const & end)
 {
 	for (; cur != end; ++cur) {
-		if ((!cur.pit()->size() || !cur.at_end())
+		if ((cur.pit()->empty() || !cur.at_end())
 		    && cur.pit()->lookupChange(cur.pos()) != Change::UNCHANGED)
 			return true;
 	}
@@ -175,7 +175,7 @@ int replaceAll(BufferView * bv,
 			= cur.pit()->getFontSettings(buf.params(), pos);
 		int striked = ssize - cur.pit()->erase(pos, pos + ssize);
 		cur.pit()->insert(pos, replacestr, font);
-		advance(cur, rsize + striked);
+		std::advance(cur, rsize + striked);
 		++num;
 	}
 
Index: lyxtextclass.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxtextclass.C,v
retrieving revision 1.45
diff -u -p -b -r1.45 lyxtextclass.C
--- lyxtextclass.C	1 Dec 2003 16:01:49 -0000	1.45
+++ lyxtextclass.C	4 Jan 2004 15:07:26 -0000
@@ -24,38 +24,23 @@
 #include "support/lstrings.h"
 #include "support/filetools.h"
 
+#include <boost/bind.hpp>
+
+using boost::bind;
+
 using lyx::support::LibFileSearch;
 using lyx::support::MakeDisplayPath;
 using lyx::support::rtrim;
 using lyx::support::subst;
 
 using std::endl;
+using std::equal_to;
 using std::find_if;
 using std::remove_if;
 using std::string;
 using std::ostream;
 
 
-namespace { // anon
-
-struct compare_name {
-
-	compare_name(string const & name)
-		: name_(name)
-	{}
-
-	bool operator()(boost::shared_ptr<LyXLayout> const & c)
-	{
-		return c->name() == name_;
-	}
-
-	string name_;
-
-};
-
-} // anon
-
-
 LyXTextClass::LyXTextClass(string const & fn, string const & cln,
 			   string const & desc, bool texClassAvail )
 	: name_(fn), latexname_(cln), description_(desc),
@@ -790,7 +775,9 @@ bool LyXTextClass::hasLayout(string cons
 	string const name = (n.empty() ? defaultLayoutName() : n);
 
 	return find_if(layoutlist_.begin(), layoutlist_.end(),
-		       compare_name(name))
+		       bind(equal_to<string>(),
+			    bind(&LyXLayout::name, bind(&LyXLayout_ptr::operator->, _1)),
+			    name))
 		!= layoutlist_.end();
 }
 
@@ -803,7 +790,9 @@ LyXLayout_ptr const & LyXTextClass::oper
 	LayoutList::const_iterator cit =
 		find_if(layoutlist_.begin(),
 			layoutlist_.end(),
-			compare_name(name));
+			bind(equal_to<string>(),
+			     bind(&LyXLayout::name, bind(&LyXLayout_ptr::operator->, _1)),
+			     name));
 
 	if (cit == layoutlist_.end()) {
 		lyxerr << "We failed to find the layout '" << name
@@ -827,14 +816,14 @@ bool LyXTextClass::delete_layout(string 
 	if (name == defaultLayoutName())
 		return false;
 
-	LayoutList::iterator it =
-		remove_if(layoutlist_.begin(), layoutlist_.end(),
-			  compare_name(name));
-
 	LayoutList::iterator end = layoutlist_.end();
-	bool const ret = (it != end);
-	layoutlist_.erase(it, end);
-	return ret;
+	LayoutList::iterator it = layoutlist_.erase(
+		remove_if(layoutlist_.begin(), end,
+			  bind(equal_to<string>(),
+			       bind(&LyXLayout::name, bind(&LyXLayout_ptr::operator->, _1)),
+			       name)), end);
+
+	return it != end;
 }
 
 
Index: lyxtextclasslist.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxtextclasslist.C,v
retrieving revision 1.19
diff -u -p -b -r1.19 lyxtextclasslist.C
--- lyxtextclasslist.C	6 Oct 2003 15:42:29 -0000	1.19
+++ lyxtextclasslist.C	4 Jan 2004 15:07:26 -0000
@@ -16,18 +16,22 @@
 #include "debug.h"
 #include "lyxlex.h"
 
-#include "support/lyxfunctional.h"
 #include "support/filetools.h"
 
+#include <boost/bind.hpp>
+
 using lyx::textclass_type;
 
 using lyx::support::LibFileSearch;
 using lyx::support::MakeDisplayPath;
 
+using boost::bind;
+
 #ifndef CXX_GLOBAL_CSTD
 using std::exit;
 #endif
 
+using std::equal_to;
 using std::endl;
 using std::find_if;
 using std::make_pair;
@@ -42,7 +46,9 @@ LyXTextClassList::NumberOfClass(string c
 {
 	ClassList::const_iterator cit =
 		find_if(classlist_.begin(), classlist_.end(),
-			lyx::compare_memfun(&LyXTextClass::name, textclass));
+			bind(equal_to<string>(),
+			     bind(&LyXTextClass::name, _1),
+			     textclass));
 	return cit != classlist_.end() ?
 		make_pair(true, textclass_type(cit - classlist_.begin())) :
 		make_pair(false, textclass_type(0));
Index: paragraph_pimpl.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/paragraph_pimpl.h,v
retrieving revision 1.41
diff -u -p -b -r1.41 paragraph_pimpl.h
--- paragraph_pimpl.h	5 Nov 2003 12:06:05 -0000	1.41
+++ paragraph_pimpl.h	4 Jan 2004 15:07:26 -0000
@@ -126,10 +126,10 @@ struct Paragraph::Pimpl {
 	///
 	friend struct matchFT;
 	///
-	struct matchFT {
+	struct matchFT : public std::binary_function<FontTable, FontTable, int> {
 		/// used by lower_bound and upper_bound
-		inline
-		int operator()(FontTable const & a, FontTable const & b) const {
+		int operator()(FontTable const & a, FontTable const & b) const
+		{
 			return a.pos() < b.pos();
 		}
 	};
Index: text.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text.C,v
retrieving revision 1.512
diff -u -p -b -r1.512 text.C
--- text.C	18 Dec 2003 04:43:06 -0000	1.512
+++ text.C	4 Jan 2004 15:07:27 -0000
@@ -1400,8 +1400,7 @@ ParagraphList::iterator LyXText::getPar(
 	BOOST_ASSERT(par >= 0);
 	BOOST_ASSERT(par < int(paragraphs().size()));
 	ParagraphList::iterator pit = paragraphs().begin();
-	std::advance(pit, par);
-	return pit;
+	return boost::next(pit, par);
 }
 
 
@@ -1932,4 +1931,3 @@ int LyXText::cursorY(LyXCursor const & c
 	Row & row = *par.getRow(cur.pos());
 	return par.y + row.y_offset() + row.baseline();
 }
-
Index: undo.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/undo.C,v
retrieving revision 1.31
diff -u -p -b -r1.31 undo.C
Index: vspace.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/vspace.C,v
retrieving revision 1.80
diff -u -p -b -r1.80 vspace.C
Index: frontends/controllers/ControlCommandBuffer.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlCommandBuffer.C,v
retrieving revision 1.19
diff -u -p -b -r1.19 ControlCommandBuffer.C
--- frontends/controllers/ControlCommandBuffer.C	17 Oct 2003 18:01:12 -0000	1.19
+++ frontends/controllers/ControlCommandBuffer.C	4 Jan 2004 15:07:27 -0000
@@ -50,7 +50,7 @@ ControlCommandBuffer::ControlCommandBuff
 	: lv_(lv), history_pos_(history_.end())
 {
 	transform(lyxaction.func_begin(), lyxaction.func_end(),
-		back_inserter(commands_), lyx::firster());
+		back_inserter(commands_), lyx::firster<LyXAction::func_map::value_type>());
 }
 
 
Index: frontends/controllers/ControlErrorList.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlErrorList.C,v
retrieving revision 1.16
diff -u -p -b -r1.16 ControlErrorList.C
--- frontends/controllers/ControlErrorList.C	6 Nov 2003 10:52:15 -0000	1.16
+++ frontends/controllers/ControlErrorList.C	4 Jan 2004 15:07:27 -0000
@@ -74,6 +74,6 @@ void ControlErrorList::goTo(int item)
 	int const range = end - start;
 
 	// Now make the selection.
-	PosIterator const pos = pit.asPosIterator(start);
+	PosIterator const pos(pit, start);
 	bv_funcs::put_selection_at(kernel().bufferview(), pos, range, false);
 }
Index: frontends/controllers/ControlExternal.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlExternal.C,v
retrieving revision 1.53
diff -u -p -b -r1.53 ControlExternal.C
--- frontends/controllers/ControlExternal.C	4 Dec 2003 18:51:55 -0000	1.53
+++ frontends/controllers/ControlExternal.C	4 Jan 2004 15:07:27 -0000
@@ -127,9 +127,7 @@ int ControlExternal::getTemplateNumber(s
 external::Template ControlExternal::getTemplate(int i) const
 {
 	external::TemplateManager::Templates::const_iterator i1
-		= external::TemplateManager::get().getTemplates().begin();
-
-	std::advance(i1, i);
+		= boost::next(external::TemplateManager::get().getTemplates().begin(), i);
 
 	return i1->second;
 }
Index: frontends/controllers/ControlSendto.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlSendto.C,v
retrieving revision 1.22
diff -u -p -b -r1.22 ControlSendto.C
--- frontends/controllers/ControlSendto.C	6 Oct 2003 15:42:46 -0000	1.22
+++ frontends/controllers/ControlSendto.C	4 Jan 2004 15:07:27 -0000
@@ -85,13 +85,7 @@ vector<Format const *> const ControlSend
 
 	// Remove repeated formats.
 	std::sort(to.begin(), to.end());
-
-	vector<Format const *>::iterator to_begin = to.begin();
-	vector<Format const *>::iterator to_end   = to.end();
-	vector<Format const *>::iterator to_it =
-		std::unique(to_begin, to_end);
-	if (to_it != to_end)
-		to.erase(to_it, to_end);
+	to.erase(std::unique(to.begin(), to.end()), to.end());
 
 	return to;
 }
Index: frontends/controllers/ControlSpellchecker.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlSpellchecker.C,v
retrieving revision 1.59
diff -u -p -b -r1.59 ControlSpellchecker.C
--- frontends/controllers/ControlSpellchecker.C	7 Nov 2003 09:40:48 -0000	1.59
+++ frontends/controllers/ControlSpellchecker.C	4 Jan 2004 15:07:27 -0000
@@ -195,8 +195,9 @@ void ControlSpellchecker::check()
 	PosIterator const beg = buffer()->pos_iterator_begin();
 	PosIterator const end = buffer()->pos_iterator_end();
 
-	int start = distance(beg, cur);
-	int const total = start + distance(cur, end);
+	PosIterator::difference_type start = std::distance(beg, cur);
+	PosIterator::difference_type const total =
+		start + std::distance(cur, end);
 
 	if (cur != buffer()->pos_iterator_begin())
 		for (; cur != end && isLetter(cur); ++cur, ++start);
@@ -235,9 +236,9 @@ void ControlSpellchecker::check()
 
 	if (!word_.word().empty()) {
 		int const size = word_.word().size();
-		advance(cur, -size);
+		std::advance(cur, -size);
 		bv_funcs::put_selection_at(bufferview(), cur, size, false);
-		advance(cur, size);
+		std::advance(cur, size);
 	} else {
 		showSummary();
 		endSession();
Index: frontends/controllers/biblio.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/biblio.C,v
retrieving revision 1.59
diff -u -p -b -r1.59 biblio.C
--- frontends/controllers/biblio.C	6 Oct 2003 15:42:47 -0000	1.59
+++ frontends/controllers/biblio.C	4 Jan 2004 15:07:27 -0000
@@ -157,9 +157,10 @@ string const getYear(InfoMap const & map
 namespace {
 
 // A functor for use with std::sort, leading to case insensitive sorting
-struct compareNoCase: public std::binary_function<string, string, bool>
+struct compareNoCase : public std::binary_function<string, string, bool>
 {
-	bool operator()(string const & s1, string const & s2) const {
+	bool operator()(string const & s1, string const & s2) const
+	{
 		return compare_ascii_no_case(s1, s2) < 0;
 	}
 };
@@ -272,7 +273,7 @@ string const escape_special_chars(string
 
 // A functor for use with std::find_if, used to ascertain whether a
 // data entry matches the required regex_
-struct RegexMatch
+struct RegexMatch : public std::unary_function<string const &, bool>
 {
 	// re and icase are used to construct an instance of boost::RegEx.
 	// if icase is true, then matching is insensitive to case
Index: frontends/controllers/helper_funcs.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/helper_funcs.h,v
retrieving revision 1.22
diff -u -p -b -r1.22 helper_funcs.h
--- frontends/controllers/helper_funcs.h	6 Oct 2003 15:42:47 -0000	1.22
+++ frontends/controllers/helper_funcs.h	4 Jan 2004 15:07:27 -0000
@@ -12,6 +12,8 @@
 #ifndef HELPERFUNCS_H
 #define HELPERFUNCS_H
 
+#include "support/lyxalgo.h"
+
 #include <utility>
 #include <vector>
 #include <string>
@@ -70,26 +72,6 @@ browseDir(std::string const & pathname,
 std::vector<std::string> const getLatexUnits();
 
 
-/** Functions to extract vectors of the first and second elems from a
-    vector<pair<A,B> >
-*/
-
-namespace detail {
-
-template<class Pair>
-struct firster {
-	typedef typename Pair::first_type first_type;
-	first_type const & operator()(Pair const & p) { return p.first; }
-};
-
-template<class Pair>
-struct seconder {
-	typedef typename Pair::second_type second_type;
-	second_type const & operator()(Pair const & p) { return p.second; }
-};
-
-} // namespace detail
-
 ///
 template<class Pair>
 std::vector<typename Pair::first_type> const
@@ -97,10 +79,11 @@ getFirst(std::vector<Pair> const & pr)
 {
 	std::vector<typename Pair::first_type> tmp(pr.size());
 	std::transform(pr.begin(), pr.end(), tmp.begin(),
-		       detail::firster<Pair>());
+		       lyx::firster<Pair>());
 	return tmp;
 }
 
+
 ///
 template<class Pair>
 std::vector<typename Pair::second_type> const
@@ -108,7 +91,7 @@ getSecond(std::vector<Pair> const & pr)
 {
 	std::vector<typename Pair::second_type> tmp(pr.size());
 	std::transform(pr.begin(), pr.end(), tmp.begin(),
-		       detail::seconder<Pair>());
+		       lyx::seconder<Pair>());
 	return tmp;
 }
 
Index: frontends/qt2/QLImage.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QLImage.C,v
retrieving revision 1.29
diff -u -p -b -r1.29 QLImage.C
--- frontends/qt2/QLImage.C	20 Nov 2003 01:22:51 -0000	1.29
+++ frontends/qt2/QLImage.C	4 Jan 2004 15:07:27 -0000
@@ -16,17 +16,20 @@
 #include "graphics/GraphicsParams.h"
 #include "format.h"
 #include "support/lstrings.h"       // lowercase
-#include "support/lyxfunctional.h"  // compare_memfun
 #include "qt_helpers.h"
 
 #include <qimage.h>
 #include <qpainter.h>
 
+#include <boost/bind.hpp>
 #include <boost/tuple/tuple.hpp>
 
 using lyx::support::lowercase;
 
+using boost::bind;
+
 using std::endl;
+using std::equal_to;
 using std::find_if;
 using std::string;
 
@@ -72,7 +75,10 @@ Image::FormatList QLImage::loadableForma
 			ext = "jpg";
 
 		Formats::const_iterator fit =
-			find_if(begin, end, lyx::compare_memfun(&Format::extension, ext));
+			find_if(begin, end,
+				bind(equal_to<string>(),
+				     bind(&Format::extension, _1),
+				     ext));
 		if (fit != end)
 			fmts.push_back(fit->name());
 	}
Index: frontends/xforms/FormDocument.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/FormDocument.C,v
retrieving revision 1.164
diff -u -p -b -r1.164 FormDocument.C
Index: frontends/xforms/RadioButtonGroup.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/RadioButtonGroup.C,v
retrieving revision 1.29
diff -u -p -b -r1.29 RadioButtonGroup.C
--- frontends/xforms/RadioButtonGroup.C	15 Sep 2003 10:53:02 -0000	1.29
+++ frontends/xforms/RadioButtonGroup.C	4 Jan 2004 15:07:28 -0000
@@ -17,13 +17,15 @@
 
 #include "debug.h"
 
-#include "support/lyxfunctional.h"
-
 #include "lyx_forms.h"
 
 #include <boost/assert.hpp>
+#include <boost/bind.hpp>
+
+using boost::bind;
 
 using std::endl;
+using std::equal_to;
 
 
 void RadioButtonGroup::init(FL_OBJECT * ob, size_type value)
@@ -41,8 +43,9 @@ void RadioButtonGroup::set(size_type val
 {
 	ButtonValueMap::const_iterator it =
 		find_if(map.begin(), map.end(),
-			lyx::equal_2nd_in_pair<ButtonValuePair>(value));
-
+			bind(equal_to<size_type>(),
+			     bind(&ButtonValueMap::value_type::second, _1),
+			     value));
 	if (it != map.end()) {
 		fl_set_button(it->first, 1);
 	} else {
Index: frontends/xforms/xformsImage.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/xformsImage.C,v
retrieving revision 1.35
diff -u -p -b -r1.35 xformsImage.C
--- frontends/xforms/xformsImage.C	6 Oct 2003 15:42:58 -0000	1.35
+++ frontends/xforms/xformsImage.C	4 Jan 2004 15:07:28 -0000
@@ -20,7 +20,6 @@
 #include "graphics/GraphicsParams.h"
 
 #include "support/lstrings.h"
-#include "support/lyxfunctional.h"  // compare_memfun
 #include "support/lyxlib.h"
 
 #include "lyx_forms.h"
@@ -33,6 +32,7 @@
 # endif
 #endif
 
+#include <boost/bind.hpp>
 #include <boost/tuple/tuple.hpp>
 
 
@@ -40,6 +40,9 @@ using lyx::support::float_equal;
 using lyx::support::prefixIs;
 using lyx::support::rtrim;
 
+using boost::bind;
+
+using std::equal_to;
 using std::find_if;
 using std::string;
 
@@ -103,7 +106,9 @@ Image::FormatList xformsImage::loadableF
 
 		Formats::const_iterator it =
 			find_if(begin, end,
-				lyx::compare_memfun(&Format::extension, ext));
+				bind(equal_to<string>(),
+				     bind(&Format::extension, _1),
+				     ext));
 		if (it != end)
 			fmts.push_back(it->name());
 	}
Index: graphics/GraphicsTypes.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/graphics/GraphicsTypes.C,v
retrieving revision 1.12
diff -u -p -b -r1.12 GraphicsTypes.C
--- graphics/GraphicsTypes.C	13 Oct 2003 21:50:32 -0000	1.12
+++ graphics/GraphicsTypes.C	4 Jan 2004 15:07:28 -0000
@@ -12,6 +12,8 @@
 
 #include "graphics/GraphicsTypes.h"
 
+#include <string>
+
 using std::string;
 
 
Index: insets/Makefile.am
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/Makefile.am,v
retrieving revision 1.75
diff -u -p -b -r1.75 Makefile.am
--- insets/Makefile.am	14 Dec 2003 13:47:40 -0000	1.75
+++ insets/Makefile.am	4 Jan 2004 15:07:28 -0000
@@ -117,4 +117,4 @@ libinsets_la_SOURCES = \
 #	insetsection.h \
 #	insetsection.C \
 #	insettheorem.C \
-#	insettheorem.h \
+#	insettheorem.h
Index: support/BoostFormat.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/BoostFormat.h,v
retrieving revision 1.5
diff -u -p -b -r1.5 BoostFormat.h
--- support/BoostFormat.h	23 Aug 2003 00:16:56 -0000	1.5
+++ support/BoostFormat.h	4 Jan 2004 15:07:28 -0000
@@ -39,11 +39,11 @@ str<char, std::char_traits<char> >(boost
 namespace detail
 {
 
-extern template
-bool parse_printf_directive<char, std::char_traits<char> >
-(std::string const &, std::string::size_type*,
- format_item<char, std::char_traits<char> >*,
- std::ios &, unsigned char);
+// extern template
+// bool parse_printf_directive<char, std::char_traits<char> >
+// (std::string const &, std::string::size_type*,
+//  format_item<char, std::char_traits<char> >*,
+//  std::ios &, unsigned char);
 
 extern template
 void distribute<char, std::char_traits<char>, std::string const &>
Index: support/Makefile.am
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/Makefile.am,v
retrieving revision 1.71
diff -u -p -b -r1.71 Makefile.am
--- support/Makefile.am	13 Oct 2003 12:25:11 -0000	1.71
+++ support/Makefile.am	4 Jan 2004 15:07:28 -0000
@@ -44,7 +44,6 @@ libsupport_la_SOURCES = \
 	lstrings.C \
 	lstrings.h \
 	lyxalgo.h \
-	lyxfunctional.h \
 	lyxlib.h \
 	lyxmanip.h \
 	lyxtime.C \
Index: support/boost-inst.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/boost-inst.C,v
retrieving revision 1.6
diff -u -p -b -r1.6 boost-inst.C
--- support/boost-inst.C	8 Sep 2003 00:33:40 -0000	1.6
+++ support/boost-inst.C	4 Jan 2004 15:07:28 -0000
@@ -34,11 +34,11 @@ str<char, std::char_traits<char> >(boost
 namespace detail
 {
 
-template
-bool parse_printf_directive<char, std::char_traits<char> >
-(std::string const &, std::string::size_type*,
- format_item<char, std::char_traits<char> >*,
- std::ios &, unsigned char);
+// template
+// bool parse_printf_directive<char, std::char_traits<char> >
+// (std::string const &, std::string::size_type*,
+//  format_item<char, std::char_traits<char> >*,
+//  std::ios &, unsigned char);
 
 template
 void distribute<char, std::char_traits<char>, std::string const &>
Index: support/forkedcontr.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/forkedcontr.C,v
retrieving revision 1.16
diff -u -p -b -r1.16 forkedcontr.C
--- support/forkedcontr.C	3 Nov 2003 17:47:28 -0000	1.16
+++ support/forkedcontr.C	4 Jan 2004 15:07:29 -0000
@@ -16,7 +16,6 @@
 
 #include "forkedcontr.h"
 #include "forkedcall.h"
-#include "lyxfunctional.h"
 #include "debug.h"
 
 #include "frontends/Timeout.h"
@@ -29,7 +28,10 @@
 #include <sys/wait.h>
 
 
+using boost::bind;
+
 using std::endl;
+using std::equal_to;
 using std::find_if;
 using std::string;
 using std::vector;
@@ -55,7 +57,7 @@ ForkedcallsController::ForkedcallsContro
 	timeout_ = new Timeout(100, Timeout::ONETIME);
 
 	timeout_->timeout
-		.connect(boost::bind(&ForkedcallsController::timer, this));
+		.connect(bind(&ForkedcallsController::timer, this));
 }
 
 
@@ -185,7 +187,9 @@ string const ForkedcallsController::getC
 {
 	ListType::const_iterator it =
 		find_if(forkedCalls.begin(), forkedCalls.end(),
-			lyx::compare_memfun(&Forkedcall::pid, pid));
+			bind(equal_to<pid_t>(),
+			     bind(&Forkedcall::pid, _1),
+			     pid));
 
 	if (it == forkedCalls.end())
 		return string();
@@ -200,7 +204,9 @@ void ForkedcallsController::kill(pid_t p
 {
 	ListType::iterator it =
 		find_if(forkedCalls.begin(), forkedCalls.end(),
-			lyx::compare_memfun(&Forkedcall::pid, pid));
+			bind(equal_to<pid_t>(),
+			     bind(&Forkedcall::pid, _1),
+			     pid));
 
 	if (it == forkedCalls.end())
 		return;
Index: support/lstrings.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/lstrings.h,v
retrieving revision 1.54
diff -u -p -b -r1.54 lstrings.h
--- support/lstrings.h	6 Oct 2003 15:43:18 -0000	1.54
+++ support/lstrings.h	4 Jan 2004 15:07:29 -0000
@@ -103,13 +103,10 @@ bool contains(std::string const & a, std
 bool contains(std::string const & a, char b);
 
 /// This should probably we rewritten to be more general.
-class contains_functor {
+class contains_functor : public std::binary_function<std::string, std::string, bool> {
 public:
-	typedef std::string first_argument_type;
-	typedef std::string second_argument_type;
-	typedef bool result_type;
-
-	bool operator()(std::string const & haystack, std::string const & needle) const {
+	bool operator()(std::string const & haystack, std::string const & needle) const
+	{
 		return contains(haystack, needle);
 	}
 };
Index: support/lyxalgo.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/lyxalgo.h,v
retrieving revision 1.14
diff -u -p -b -r1.14 lyxalgo.h
--- support/lyxalgo.h	23 Aug 2003 00:16:57 -0000	1.14
+++ support/lyxalgo.h	4 Jan 2004 15:07:29 -0000
@@ -18,6 +18,7 @@
 #include <iterator>
 #include <algorithm>
 #include <set>
+#include <functional>
 
 
 namespace lyx {
@@ -49,10 +50,22 @@ bool sorted(For first, For last, Cmp cmp
 }
 
 
-struct firster {
-	template <class P1, class P2>
-	P1 operator()(std::pair<P1, P2> const & p) {
+template<class Pair>
+struct firster : public std::unary_function<Pair, typename Pair::first_type> {
+	typedef typename Pair::first_type first_type;
+	first_type const & operator()(Pair const & p) const
+	{
 		return p.first;
+	}
+};
+
+
+template<class Pair>
+struct seconder : public std::unary_function<Pair, typename Pair::second_type> {
+	typedef typename Pair::second_type second_type;
+	second_type const & operator()(Pair const & p) const
+	{
+		return p.second;
 	}
 };
 
Index: support/lyxfunctional.h
===================================================================
RCS file: support/lyxfunctional.h
diff -N support/lyxfunctional.h
--- support/lyxfunctional.h	23 Aug 2003 00:16:57 -0000	1.17
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,215 +0,0 @@
-// -*- C++ -*-
-/**
- * \file lyxfunctional.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Lars Gullik Bjønnes
- *
- * Full author contact details are available in file CREDITS.
- *
- * \brief Convenient function objects for use with LyX
- *
- * This is currently a small collection of small function objects for use
- * together with std::algorithms.
- */
-
-
-#ifndef LYX_FUNCTIONAL_H
-#define LYX_FUNCTIONAL_H
-
-#include <iterator>
-
-namespace lyx {
-
-template <class Cont, class Type, class MemRet>
-class back_insert_fun_iterator {
-protected:
-	Cont * container;
-	MemRet(Type::*pmf)();
-public:
-	typedef Cont container_type;
-	typedef std::output_iterator_tag iterator_category;
-	typedef void value_type;
-	typedef void difference_type;
-	typedef void pointer;
-	typedef void reference;
-
-	back_insert_fun_iterator(Cont & x, MemRet(Type::*p)())
-		: container(&x), pmf(p) {}
-
-	back_insert_fun_iterator &
-	operator=(Type * val) {
-		container->push_back((val->*pmf)());
-		return *this;
-	}
-
-	back_insert_fun_iterator &
-	operator=(Type & val) {
-		container->push_back((val.*pmf)());
-		return *this;
-	}
-
-	back_insert_fun_iterator & operator*() {
-		return *this;
-	}
-	back_insert_fun_iterator & operator++() { // prefix ++
-		return *this;
-	}
-	back_insert_fun_iterator & operator++(int) { // postfix ++
-		return *this;
-	}
-};
-
-
-template <class Cont, class Type, class MemRet>
-class const_back_insert_fun_iterator {
-protected:
-	Cont * container;
-	MemRet(Type::*pmf)() const;
-public:
-	typedef Cont container_type;
-	typedef std::output_iterator_tag iterator_category;
-	typedef void value_type;
-	typedef void difference_type;
-	typedef void pointer;
-	typedef void reference;
-
-	const_back_insert_fun_iterator(Cont & x, MemRet(Type::*p)() const)
-		: container(&x), pmf(p) {}
-
-	~const_back_insert_fun_iterator() {}
-
-	const_back_insert_fun_iterator &
-	operator=(Type const * val) {
-		container->push_back((val->*pmf)());
-		return *this;
-	}
-
-	const_back_insert_fun_iterator &
-	operator=(Type const & val) {
-		container->push_back((val.*pmf)());
-		return *this;
-	}
-
-	const_back_insert_fun_iterator & operator*() {
-		return *this;
-	}
-	const_back_insert_fun_iterator & operator++() { // prefix ++
-		return *this;
-	}
-	const_back_insert_fun_iterator & operator++(int) { // postfix ++
-		return *this;
-	}
-};
-
-
-template <class Cont, class Type, class MemRet>
-back_insert_fun_iterator<Cont, Type, MemRet>
-back_inserter_fun(Cont & cont, MemRet(Type::*p)())
-{
-	return back_insert_fun_iterator<Cont, Type, MemRet>(cont, p);
-}
-
-
-template <class Cont, class Type, class MemRet>
-const_back_insert_fun_iterator<Cont, Type, MemRet>
-back_inserter_fun(Cont & cont, MemRet(Type::*p)() const)
-{
-	return const_back_insert_fun_iterator<Cont, Type, MemRet>(cont, p);
-}
-
-
-template <class R, class C, class A>
-class compare_memfun_t {
-public:
-	compare_memfun_t(R(C::*p)(), A const & a)
-		: pmf(p), arg(a) {}
-	bool operator()(C * c) {
-		return (c->*pmf)() == arg;
-	}
-	bool operator()(C & c) {
-		return (c.*pmf)() == arg;
-	}
-private:
-	R(C::*pmf)();
-	A const & arg;
-};
-
-
-template <class R, class C, class A>
-class const_compare_memfun_t {
-public:
-	const_compare_memfun_t(R(C::*p)() const, A const & a)
-		: pmf(p), arg(a) {}
-	bool operator()(C const * c) {
-		return (c->*pmf)() == arg;
-	}
-	bool operator()(C const & c) {
-		return (c.*pmf)() == arg;
-	}
-private:
-	R(C::*pmf)() const;
-	A const & arg;
-};
-
-
-template <class R, class C, class A>
-compare_memfun_t<R, C, A>
-compare_memfun(R(C::*p)(), A const & a)
-{
-	return compare_memfun_t<R, C, A>(p, a);
-}
-
-
-template <class R, class C, class A>
-const_compare_memfun_t<R, C, A>
-compare_memfun(R(C::*p)() const, A const & a)
-{
-	return const_compare_memfun_t<R, C, A>(p, a);
-}
-
-
-// Functors used in the template.
-
-///
-template<typename T>
-class equal_1st_in_pair {
-public:
-	///
-	typedef typename T::first_type first_type;
-	///
-	typedef T pair_type;
-	///
-	equal_1st_in_pair(first_type const & value) : value_(value) {}
-	///
-	bool operator() (pair_type const & p) const {
-		return p.first == value_;
-	}
-private:
-	///
-	first_type const & value_;
-};
-
-
-///
-template<typename T>
-class equal_2nd_in_pair {
-public:
-	///
-	typedef typename T::second_type second_type;
-	///
-	typedef T pair_type;
-	///
-	equal_2nd_in_pair(second_type const & value) : value_(value) {}
-	///
-	bool operator() (pair_type const & p) const {
-		return p.second == value_;
-	}
-private:
-	///
-	second_type const & value_;
-};
-
-}  // end of namespace lyx
-#endif
Index: support/translator.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/translator.h,v
retrieving revision 1.20
diff -u -p -b -r1.20 translator.h
--- support/translator.h	25 Sep 2003 10:49:13 -0000	1.20
+++ support/translator.h	4 Jan 2004 15:07:29 -0000
@@ -14,12 +14,13 @@
 
 #include <boost/assert.hpp>
 
+#include <boost/bind.hpp>
+
 #include <vector>
 #include <utility>
 #include <algorithm>
 #include <functional>
 
-#include "support/lyxfunctional.h"
 /**
  * This class template is used to translate between two elements, specifically
  * it was worked out to translate between an enum and strings when reading
@@ -62,7 +63,9 @@ public:
 		// For explanation see the next find() function.
 		typename Map::const_iterator it =
 			std::find_if(map.begin(), map.end(),
-				     lyx::equal_1st_in_pair<MapPair>(first)
+				     boost::bind(std::equal_to<T1>(),
+						 boost::bind(&MapPair::first, _1),
+						 first)
 				);
 
 		if (it != map.end()) {
@@ -89,7 +92,9 @@ public:
 		// equal_to(select2nd(pair) , second)
 		typename Map::const_iterator it =
 			std::find_if(map.begin(), map.end(),
-				     lyx::equal_2nd_in_pair<MapPair>(second)
+				     boost::bind(std::equal_to<T2>(),
+						 boost::bind(&MapPair::second, _1),
+						 second)
 				);
 
 		if (it != map.end())
-- 
        Lgb

Reply via email to