mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-06 09:37:31 +00:00
Fix compilation with boost 1.60
Newer boost versions use complicated type traits for boost::next and boost::prior, which do not work with the RandomAccessList iterators. The long term solution is to use std::next and std::prev, for now supply simple replacements for compilers that do not support C++11 yet. This is was cherry picked fromb5963300
and7e72c1d0d3
.
This commit is contained in:
parent
28f9d61dc3
commit
ef81af7037
@ -29,7 +29,6 @@ bcp --boost=$1 \
|
||||
boost/function.hpp \
|
||||
boost/functional.hpp \
|
||||
boost/lexical_cast.hpp \
|
||||
boost/next_prior.hpp \
|
||||
boost/noncopyable.hpp \
|
||||
boost/regex.hpp \
|
||||
boost/scoped_array.hpp \
|
||||
|
@ -19,11 +19,10 @@
|
||||
|
||||
#include "insets/InsetText.h"
|
||||
|
||||
#include "support/lassert.h"
|
||||
#include "support/lassert.h"
|
||||
#include "support/lyxalgo.h"
|
||||
#include "support/qstring_helpers.h"
|
||||
|
||||
#include <boost/next_prior.hpp>
|
||||
|
||||
using namespace std;
|
||||
using namespace lyx::support;
|
||||
|
||||
@ -420,8 +419,8 @@ static void getParagraphList(DocRange const & range,
|
||||
pit_type startpit = range.from.pit();
|
||||
pit_type endpit = range.to.pit();
|
||||
ParagraphList const & ps_ = range.text()->paragraphs();
|
||||
ParagraphList tmp_pars(boost::next(ps_.begin(), startpit),
|
||||
boost::next(ps_.begin(), endpit + 1));
|
||||
ParagraphList tmp_pars(lyx::next(ps_.begin(), startpit),
|
||||
lyx::next(ps_.begin(), endpit + 1));
|
||||
|
||||
// Remove the end of the last paragraph; afterwards, remove the
|
||||
// beginning of the first paragraph. Keep this order - there may only
|
||||
|
@ -132,7 +132,7 @@ bool bruteFind(Cursor & cursor,
|
||||
// Get an iterator after the last paragraph in the cache
|
||||
DocIterator et(inset);
|
||||
et.push_back(CursorSlice(inset));
|
||||
et.pit() = boost::prior(cache.end())->first;
|
||||
et.pit() = lyx::prev(cache.end(), 1)->first;
|
||||
if (et.pit() >= et.lastpit())
|
||||
et = doc_iterator_end(inset);
|
||||
else
|
||||
|
@ -60,13 +60,13 @@
|
||||
#include "support/lassert.h"
|
||||
#include "support/limited_stack.h"
|
||||
#include "support/lstrings.h"
|
||||
#include "support/lyxalgo.h"
|
||||
|
||||
#include "frontends/alert.h"
|
||||
#include "frontends/Clipboard.h"
|
||||
#include "frontends/Selection.h"
|
||||
|
||||
#include <boost/tuple/tuple.hpp>
|
||||
#include <boost/next_prior.hpp>
|
||||
|
||||
#include <string>
|
||||
|
||||
@ -383,7 +383,7 @@ pasteSelectionHelper(DocIterator const & cur, ParagraphList const & parlist,
|
||||
|
||||
// Paste it!
|
||||
if (empty) {
|
||||
pars.insert(boost::next(pars.begin(), pit),
|
||||
pars.insert(lyx::next(pars.begin(), pit),
|
||||
insertion.begin(),
|
||||
insertion.end());
|
||||
|
||||
@ -391,7 +391,7 @@ pasteSelectionHelper(DocIterator const & cur, ParagraphList const & parlist,
|
||||
mergeParagraph(buffer.params(), pars,
|
||||
pit + insertion.size() - 1);
|
||||
} else {
|
||||
pars.insert(boost::next(pars.begin(), pit + 1),
|
||||
pars.insert(lyx::next(pars.begin(), pit + 1),
|
||||
insertion.begin(),
|
||||
insertion.end());
|
||||
|
||||
@ -592,8 +592,8 @@ void copySelectionHelper(Buffer const & buf, Text const & text,
|
||||
LASSERT(startpit != endpit || start <= end, return);
|
||||
|
||||
// Clone the paragraphs within the selection.
|
||||
ParagraphList copy_pars(boost::next(pars.begin(), startpit),
|
||||
boost::next(pars.begin(), endpit + 1));
|
||||
ParagraphList copy_pars(lyx::next(pars.begin(), startpit),
|
||||
lyx::next(pars.begin(), endpit + 1));
|
||||
|
||||
// Remove the end of the last paragraph; afterwards, remove the
|
||||
// beginning of the first paragraph. Keep this order - there may only
|
||||
|
@ -20,9 +20,7 @@
|
||||
|
||||
#include "FontList.h"
|
||||
|
||||
#include <boost/next_prior.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include "support/lyxalgo.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@ -71,7 +69,7 @@ void FontList::erase(pos_type pos)
|
||||
iterator beg = list_.begin();
|
||||
if (it != list_.end() && it->pos() == pos
|
||||
&& (pos == 0
|
||||
|| (it != list_.begin() && boost::prior(it)->pos() == pos - 1))) {
|
||||
|| (it != list_.begin() && lyx::prev(it, 1)->pos() == pos - 1))) {
|
||||
|
||||
// If it is a multi-character font
|
||||
// entry, we just make it smaller
|
||||
|
13
src/Text.cpp
13
src/Text.cpp
@ -66,10 +66,9 @@
|
||||
#include "support/gettext.h"
|
||||
#include "support/lassert.h"
|
||||
#include "support/lstrings.h"
|
||||
#include "support/lyxalgo.h"
|
||||
#include "support/textutils.h"
|
||||
|
||||
#include <boost/next_prior.hpp>
|
||||
|
||||
#include <limits>
|
||||
#include <sstream>
|
||||
|
||||
@ -137,7 +136,7 @@ void breakParagraphConservative(BufferParams const & bparams,
|
||||
ParagraphList & pars, pit_type par_offset, pos_type pos)
|
||||
{
|
||||
// create a new paragraph
|
||||
Paragraph & tmp = *pars.insert(boost::next(pars.begin(), par_offset + 1),
|
||||
Paragraph & tmp = *pars.insert(lyx::next(pars.begin(), par_offset + 1),
|
||||
Paragraph());
|
||||
Paragraph & par = pars[par_offset];
|
||||
|
||||
@ -193,7 +192,7 @@ void mergeParagraph(BufferParams const & bparams,
|
||||
// move the change of the end-of-paragraph character
|
||||
par.setChange(par.size(), change);
|
||||
|
||||
pars.erase(boost::next(pars.begin(), par_offset + 1));
|
||||
pars.erase(lyx::next(pars.begin(), par_offset + 1));
|
||||
}
|
||||
|
||||
|
||||
@ -639,7 +638,7 @@ static void breakParagraph(Text & text, pit_type par_offset, pos_type pos,
|
||||
ParagraphList & pars = text.paragraphs();
|
||||
// create a new paragraph, and insert into the list
|
||||
ParagraphList::iterator tmp =
|
||||
pars.insert(boost::next(pars.begin(), par_offset + 1),
|
||||
pars.insert(lyx::next(pars.begin(), par_offset + 1),
|
||||
Paragraph());
|
||||
|
||||
Paragraph & par = pars[par_offset];
|
||||
@ -1603,14 +1602,14 @@ bool Text::backspacePos0(Cursor & cur)
|
||||
if (cur.lastpos() == 0
|
||||
|| (cur.lastpos() == 1 && par.isSeparator(0))) {
|
||||
cur.recordUndo(ATOMIC_UNDO, prevcur.pit(), cur.pit());
|
||||
plist.erase(boost::next(plist.begin(), cur.pit()));
|
||||
plist.erase(lyx::next(plist.begin(), cur.pit()));
|
||||
needsUpdate = true;
|
||||
}
|
||||
// is previous par empty?
|
||||
else if (prevcur.lastpos() == 0
|
||||
|| (prevcur.lastpos() == 1 && prevpar.isSeparator(0))) {
|
||||
cur.recordUndo(ATOMIC_UNDO, prevcur.pit(), cur.pit());
|
||||
plist.erase(boost::next(plist.begin(), prevcur.pit()));
|
||||
plist.erase(lyx::next(plist.begin(), prevcur.pit()));
|
||||
needsUpdate = true;
|
||||
}
|
||||
// Pasting is not allowed, if the paragraphs have different
|
||||
|
@ -50,10 +50,9 @@
|
||||
#include "support/lassert.h"
|
||||
#include "support/debug.h"
|
||||
#include "support/gettext.h"
|
||||
#include "support/lyxalgo.h"
|
||||
#include "support/textutils.h"
|
||||
|
||||
#include <boost/next_prior.hpp>
|
||||
|
||||
#include <sstream>
|
||||
|
||||
using namespace std;
|
||||
@ -396,7 +395,7 @@ bool Text::cursorTop(Cursor & cur)
|
||||
bool Text::cursorBottom(Cursor & cur)
|
||||
{
|
||||
LBUFERR(this == cur.text());
|
||||
return setCursor(cur, cur.lastpit(), boost::prior(paragraphs().end())->size());
|
||||
return setCursor(cur, cur.lastpit(), lyx::prev(paragraphs().end(), 1)->size());
|
||||
}
|
||||
|
||||
|
||||
@ -895,7 +894,7 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
|
||||
min(old.pit() + 1, old.lastpit()));
|
||||
ParagraphList & plist = old.text()->paragraphs();
|
||||
bool const soa = oldpar.params().startOfAppendix();
|
||||
plist.erase(boost::next(plist.begin(), old.pit()));
|
||||
plist.erase(lyx::next(plist.begin(), old.pit()));
|
||||
// do not lose start of appendix marker (bug 4212)
|
||||
if (soa && old.pit() < pit_type(plist.size()))
|
||||
plist[old.pit()].params().startOfAppendix(true);
|
||||
@ -959,7 +958,7 @@ void Text::deleteEmptyParagraphMechanism(pit_type first, pit_type last, bool tra
|
||||
continue;
|
||||
|
||||
if (par.empty() || (par.size() == 1 && par.isLineSeparator(0))) {
|
||||
pars_.erase(boost::next(pars_.begin(), pit));
|
||||
pars_.erase(lyx::next(pars_.begin(), pit));
|
||||
--pit;
|
||||
--last;
|
||||
continue;
|
||||
|
@ -71,6 +71,7 @@
|
||||
#include "support/gettext.h"
|
||||
#include "support/lassert.h"
|
||||
#include "support/lstrings.h"
|
||||
#include "support/lyxalgo.h"
|
||||
#include "support/lyxtime.h"
|
||||
#include "support/os.h"
|
||||
#include "support/regex.h"
|
||||
@ -78,8 +79,6 @@
|
||||
#include "mathed/InsetMathHull.h"
|
||||
#include "mathed/MathMacroTemplate.h"
|
||||
|
||||
#include <boost/next_prior.hpp>
|
||||
|
||||
#include <clocale>
|
||||
#include <sstream>
|
||||
|
||||
@ -340,7 +339,7 @@ static void outline(OutlineOp mode, Cursor & cur)
|
||||
ParagraphList & pars = buf.text().paragraphs();
|
||||
ParagraphList::iterator const bgn = pars.begin();
|
||||
// The first paragraph of the area to be copied:
|
||||
ParagraphList::iterator start = boost::next(bgn, pit);
|
||||
ParagraphList::iterator start = lyx::next(bgn, pit);
|
||||
// The final paragraph of area to be copied:
|
||||
ParagraphList::iterator finish = start;
|
||||
ParagraphList::iterator const end = pars.end();
|
||||
@ -393,7 +392,7 @@ static void outline(OutlineOp mode, Cursor & cur)
|
||||
// Nothing to move.
|
||||
return;
|
||||
// Go one down from *this* header:
|
||||
ParagraphList::iterator dest = boost::next(finish, 1);
|
||||
ParagraphList::iterator dest = lyx::next(finish, 1);
|
||||
// Go further down to find header to insert in front of:
|
||||
for (; dest != end; ++dest) {
|
||||
toclevel = buf.text().getTocLevel(distance(bgn, dest));
|
||||
@ -781,7 +780,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
||||
ParagraphList & pars = buf.text().paragraphs();
|
||||
ParagraphList::iterator bgn = pars.begin();
|
||||
// The first paragraph of the area to be selected:
|
||||
ParagraphList::iterator start = boost::next(bgn, pit);
|
||||
ParagraphList::iterator start = lyx::next(bgn, pit);
|
||||
// The final paragraph of area to be selected:
|
||||
ParagraphList::iterator finish = start;
|
||||
ParagraphList::iterator end = pars.end();
|
||||
|
@ -51,7 +51,6 @@
|
||||
#include "support/lstrings.h"
|
||||
|
||||
#include "support/regex.h"
|
||||
#include <boost/next_prior.hpp>
|
||||
|
||||
using namespace std;
|
||||
using namespace lyx::support;
|
||||
|
@ -38,7 +38,7 @@
|
||||
|
||||
#include "support/gettext.h"
|
||||
#include "support/lassert.h"
|
||||
#include <boost/next_prior.hpp>
|
||||
#include "support/lyxalgo.h"
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
@ -892,7 +892,7 @@ MathData::size_type MathData::x2pos(BufferView const * bv, int targetx, int glue
|
||||
* See bug 1918 for details.
|
||||
**/
|
||||
if (it != begin() && currx >= targetx
|
||||
&& ((*boost::prior(it))->asNestInset()
|
||||
&& ((*lyx::prev(it, 1))->asNestInset()
|
||||
|| abs(lastx - targetx) < abs(currx - targetx))) {
|
||||
--it;
|
||||
}
|
||||
|
@ -30,8 +30,7 @@
|
||||
#include "support/lassert.h"
|
||||
#include "support/debug.h"
|
||||
#include "support/lstrings.h"
|
||||
|
||||
#include <boost/next_prior.hpp>
|
||||
#include "support/lyxalgo.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace lyx::support;
|
||||
@ -329,8 +328,8 @@ void docbookParagraphs(Text const & text,
|
||||
|
||||
// if only part of the paragraphs will be outputed
|
||||
if (runparams.par_begin != runparams.par_end) {
|
||||
par = boost::next(paragraphs.begin(), runparams.par_begin);
|
||||
pend = boost::next(paragraphs.begin(), runparams.par_end);
|
||||
par = lyx::next(paragraphs.begin(), runparams.par_begin);
|
||||
pend = lyx::next(paragraphs.begin(), runparams.par_end);
|
||||
// runparams will be passed to nested paragraphs, so
|
||||
// we have to reset the range parameters.
|
||||
const_cast<OutputParams&>(runparams).par_begin = 0;
|
||||
|
@ -33,12 +33,11 @@
|
||||
#include "support/convert.h"
|
||||
#include "support/debug.h"
|
||||
#include "support/lstrings.h"
|
||||
#include "support/lyxalgo.h"
|
||||
#include "support/textutils.h"
|
||||
|
||||
#include <QThreadStorage>
|
||||
|
||||
#include <algorithm>
|
||||
#include <boost/next_prior.hpp>
|
||||
#include <list>
|
||||
|
||||
using namespace std;
|
||||
@ -116,7 +115,7 @@ static TeXEnvironmentData prepareEnvironment(Buffer const & buf,
|
||||
|
||||
ParagraphList const & paragraphs = text.paragraphs();
|
||||
ParagraphList::const_iterator const priorpit =
|
||||
pit == paragraphs.begin() ? pit : boost::prior(pit);
|
||||
pit == paragraphs.begin() ? pit : lyx::prev(pit, 1);
|
||||
|
||||
OutputState * state = getOutputState();
|
||||
bool const use_prev_env_language = state->prev_env_language_ != 0
|
||||
@ -474,9 +473,9 @@ void latexArgInsets(ParagraphList const & pars, ParagraphList::const_iterator pi
|
||||
// get the first paragraph in sequence with this layout and depth
|
||||
pit_type offset = 0;
|
||||
while (true) {
|
||||
if (boost::prior(pit, offset) == pars.begin())
|
||||
if (lyx::prev(pit, offset) == pars.begin())
|
||||
break;
|
||||
ParagraphList::const_iterator priorpit = boost::prior(pit, offset + 1);
|
||||
ParagraphList::const_iterator priorpit = lyx::prev(pit, offset + 1);
|
||||
if (priorpit->layout() == current_layout
|
||||
&& priorpit->params().depth() == current_depth)
|
||||
++offset;
|
||||
@ -484,7 +483,7 @@ void latexArgInsets(ParagraphList const & pars, ParagraphList::const_iterator pi
|
||||
break;
|
||||
}
|
||||
|
||||
ParagraphList::const_iterator spit = boost::prior(pit, offset);
|
||||
ParagraphList::const_iterator spit = lyx::prev(pit, offset);
|
||||
|
||||
for (; spit != pars.end(); ++spit) {
|
||||
if (spit->layout() != current_layout || spit->params().depth() < current_depth)
|
||||
|
@ -83,6 +83,32 @@ void eliminate_duplicates(C & c)
|
||||
c.erase(std::unique(c.begin(), c.end()), c.end());
|
||||
}
|
||||
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
using std::next;
|
||||
#else
|
||||
/// Replacement of std::next for older compilers
|
||||
template <typename It, typename Diff>
|
||||
inline It next(It i, Diff n = 1)
|
||||
{
|
||||
std::advance(i, n);
|
||||
return i;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
using std::prev;
|
||||
#else
|
||||
/// Replacement of std::prev for older compilers
|
||||
template <typename It, typename Diff>
|
||||
inline It prev(It i, Diff n = 1)
|
||||
{
|
||||
std::advance(i, -n);
|
||||
return i;
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace lyx
|
||||
|
||||
#endif // LYX_ALGO_H
|
||||
|
Loading…
Reference in New Issue
Block a user