mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 05:16:21 +00:00
Fix compilation with boost 1.58
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 commit is contained in:
parent
ef456e9607
commit
b596330093
@ -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 \
|
||||
|
@ -20,10 +20,9 @@
|
||||
#include "insets/InsetText.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;
|
||||
|
||||
@ -423,8 +422,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(next(ps_.begin(), startpit),
|
||||
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() = prev(cache.end(), 1)->first;
|
||||
if (et.pit() >= et.lastpit())
|
||||
et = doc_iterator_end(inset);
|
||||
else
|
||||
|
@ -60,6 +60,7 @@
|
||||
#include "support/lassert.h"
|
||||
#include "support/limited_stack.h"
|
||||
#include "support/lstrings.h"
|
||||
#include "support/lyxalgo.h"
|
||||
#include "support/TempFile.h"
|
||||
|
||||
#include "frontends/alert.h"
|
||||
@ -67,7 +68,6 @@
|
||||
#include "frontends/Selection.h"
|
||||
|
||||
#include <boost/tuple/tuple.hpp>
|
||||
#include <boost/next_prior.hpp>
|
||||
|
||||
#include <string>
|
||||
|
||||
@ -387,7 +387,7 @@ pasteSelectionHelper(DocIterator const & cur, ParagraphList const & parlist,
|
||||
|
||||
// Paste it!
|
||||
if (empty) {
|
||||
pars.insert(boost::next(pars.begin(), pit),
|
||||
pars.insert(next(pars.begin(), pit),
|
||||
insertion.begin(),
|
||||
insertion.end());
|
||||
|
||||
@ -395,7 +395,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(next(pars.begin(), pit + 1),
|
||||
insertion.begin(),
|
||||
insertion.end());
|
||||
|
||||
@ -599,8 +599,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(next(pars.begin(), startpit),
|
||||
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;
|
||||
|
||||
@ -72,7 +70,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() && prev(it, 1)->pos() == pos - 1))) {
|
||||
|
||||
// If it is a multi-character font
|
||||
// entry, we just make it smaller
|
||||
|
@ -24,12 +24,10 @@
|
||||
|
||||
#include "support/debug.h"
|
||||
#include "support/lassert.h"
|
||||
#include "support/lyxalgo.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <ostream>
|
||||
|
||||
#include <boost/next_prior.hpp>
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace lyx {
|
||||
@ -417,7 +415,7 @@ void Row::shortenIfNeeded(pos_type const keep, int const w)
|
||||
end_ = cit->endpos;
|
||||
dim_.wid = left_margin + cit->dim.wid;
|
||||
// If there are other elements, they should be removed.
|
||||
elements_.erase(boost::next(cit), end);
|
||||
elements_.erase(next(cit, 1), end);
|
||||
}
|
||||
}
|
||||
|
||||
|
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(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));
|
||||
}
|
||||
|
||||
|
||||
@ -663,7 +662,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(next(pars.begin(), par_offset + 1),
|
||||
Paragraph());
|
||||
|
||||
Paragraph & par = pars[par_offset];
|
||||
@ -1641,14 +1640,14 @@ bool Text::backspacePos0(Cursor & cur)
|
||||
if (cur.lastpos() == 0
|
||||
|| (cur.lastpos() == 1 && par.isSeparator(0))) {
|
||||
cur.recordUndo(prevcur.pit());
|
||||
plist.erase(boost::next(plist.begin(), cur.pit()));
|
||||
plist.erase(next(plist.begin(), cur.pit()));
|
||||
needsUpdate = true;
|
||||
}
|
||||
// is previous par empty?
|
||||
else if (prevcur.lastpos() == 0
|
||||
|| (prevcur.lastpos() == 1 && prevpar.isSeparator(0))) {
|
||||
cur.recordUndo(prevcur.pit());
|
||||
plist.erase(boost::next(plist.begin(), prevcur.pit()));
|
||||
plist.erase(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;
|
||||
@ -395,7 +394,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(), prev(paragraphs().end(), 1)->size());
|
||||
}
|
||||
|
||||
|
||||
@ -905,7 +904,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(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);
|
||||
@ -969,7 +968,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(next(pars_.begin(), pit));
|
||||
--pit;
|
||||
--last;
|
||||
continue;
|
||||
|
@ -72,6 +72,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"
|
||||
@ -79,8 +80,6 @@
|
||||
#include "mathed/InsetMathHull.h"
|
||||
#include "mathed/MathMacroTemplate.h"
|
||||
|
||||
#include <boost/next_prior.hpp>
|
||||
|
||||
#include <clocale>
|
||||
#include <sstream>
|
||||
|
||||
@ -370,7 +369,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 = next(bgn, pit);
|
||||
// The final paragraph of area to be copied:
|
||||
ParagraphList::iterator finish = start;
|
||||
ParagraphList::iterator const end = pars.end();
|
||||
@ -421,7 +420,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 = 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));
|
||||
@ -799,7 +798,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 = 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>
|
||||
|
||||
@ -901,7 +901,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()
|
||||
&& ((*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 = next(paragraphs.begin(), runparams.par_begin);
|
||||
pend = 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;
|
||||
@ -130,7 +129,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 : prev(pit, 1);
|
||||
|
||||
OutputState * state = getOutputState();
|
||||
bool const use_prev_env_language = state->prev_env_language_ != 0
|
||||
@ -470,9 +469,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 (prev(pit, offset) == pars.begin())
|
||||
break;
|
||||
ParagraphList::const_iterator priorpit = boost::prior(pit, offset + 1);
|
||||
ParagraphList::const_iterator priorpit = prev(pit, offset + 1);
|
||||
if (priorpit->layout() == current_layout
|
||||
&& priorpit->params().depth() == current_depth)
|
||||
++offset;
|
||||
@ -480,7 +479,7 @@ void latexArgInsets(ParagraphList const & pars, ParagraphList::const_iterator pi
|
||||
break;
|
||||
}
|
||||
|
||||
ParagraphList::const_iterator spit = boost::prior(pit, offset);
|
||||
ParagraphList::const_iterator spit = 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