From 61b2bd5e7fd9399128342d9048aa814ae5f086fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20K=C3=BCmmel?= Date: Thu, 22 Apr 2010 11:16:58 +0000 Subject: [PATCH] Using "using namespace std" with msvc10 makes also std::tr1::bind visible and generates conflicts with boost::bind. Solution: don't use boost::bind for msvc10 (could also be extended to several GCC versions) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34257 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/Buffer.cpp | 4 ++-- src/BufferList.cpp | 6 ++--- src/Cursor.cpp | 4 ++-- src/LayoutFile.cpp | 4 ++-- src/LyX.cpp | 4 ++-- src/ParagraphMetrics.cpp | 2 +- src/Server.cpp | 4 ++-- src/ServerSocket.cpp | 6 ++--- src/frontends/qt4/GuiApplication.cpp | 2 +- src/frontends/qt4/GuiView.cpp | 4 ++-- src/frontends/qt4/GuiWorkArea.cpp | 4 ++-- src/frontends/qt4/Toolbars.cpp | 2 +- src/graphics/GraphicsCacheItem.cpp | 6 ++--- src/graphics/GraphicsConverter.cpp | 4 ++-- src/graphics/GraphicsLoader.cpp | 6 ++--- src/graphics/PreviewImage.cpp | 4 ++-- src/graphics/PreviewLoader.cpp | 4 ++-- src/insets/InsetBox.cpp | 21 +++++++++++------ src/insets/InsetExternal.cpp | 4 ++-- src/insets/InsetInclude.cpp | 6 ++--- src/insets/InsetText.cpp | 4 +--- src/insets/RenderGraphic.cpp | 6 ++--- src/insets/RenderPreview.cpp | 4 ++-- src/mathed/InsetMathGrid.cpp | 1 + src/support/FileMonitor.cpp | 4 ++-- src/support/ForkedCalls.cpp | 8 +++---- src/support/bind.h | 34 ++++++++++++++++++++++++++++ src/support/docstream.h | 5 ++++ 28 files changed, 106 insertions(+), 61 deletions(-) create mode 100644 src/support/bind.h diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 53f331a920..b91322ad94 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -102,7 +102,7 @@ #include "support/textutils.h" #include "support/types.h" -#include +#include "support/bind.h" #include #include @@ -1656,7 +1656,7 @@ void Buffer::validate(LaTeXFeatures & features) const updateMacros(); for_each(paragraphs().begin(), paragraphs().end(), - boost::bind(&Paragraph::validate, _1, boost::ref(features))); + bind(&Paragraph::validate, _1, boost::ref(features))); if (lyxerr.debugging(Debug::LATEX)) { features.showStruct(); diff --git a/src/BufferList.cpp b/src/BufferList.cpp index 6935324f3c..b68dea9a3a 100644 --- a/src/BufferList.cpp +++ b/src/BufferList.cpp @@ -32,12 +32,12 @@ #include "support/Package.h" #include "support/lassert.h" -#include +#include "support/bind.h" #include #include -using boost::bind; + using namespace std; using namespace lyx::support; @@ -142,7 +142,7 @@ FileNameList const & BufferList::fileNames() const nvec.clear(); transform(bstore.begin(), bstore.end(), back_inserter(nvec), - boost::bind(&Buffer::fileName, _1)); + bind(&Buffer::fileName, _1)); return nvec; } diff --git a/src/Cursor.cpp b/src/Cursor.cpp index 75f7a2df99..faa612727e 100644 --- a/src/Cursor.cpp +++ b/src/Cursor.cpp @@ -49,7 +49,7 @@ #include "mathed/MathData.h" #include "mathed/MathMacro.h" -#include +#include "support/bind.h" #include #include @@ -1281,7 +1281,7 @@ void Cursor::plainInsert(MathAtom const & t) void Cursor::insert(docstring const & str) { for_each(str.begin(), str.end(), - boost::bind(static_cast + bind(static_cast (&Cursor::insert), this, _1)); } diff --git a/src/LayoutFile.cpp b/src/LayoutFile.cpp index 6471f726ae..8891969faa 100644 --- a/src/LayoutFile.cpp +++ b/src/LayoutFile.cpp @@ -27,7 +27,7 @@ #include "support/lassert.h" #include "support/lstrings.h" -#include +#include "support/bind.h" #include #include @@ -37,7 +37,7 @@ using namespace lyx::support; namespace lyx { -using boost::bind; + using boost::regex; using boost::smatch; diff --git a/src/LyX.cpp b/src/LyX.cpp index 99ec2e46a3..49ee0b081b 100644 --- a/src/LyX.cpp +++ b/src/LyX.cpp @@ -62,7 +62,7 @@ #include "support/Path.h" #include "support/Systemcall.h" -#include +#include "support/bind.h" #include #include @@ -484,7 +484,7 @@ bool LyX::loadFiles() ErrorList const & el = buf->errorList("Parse"); if (!el.empty()) for_each(el.begin(), el.end(), - boost::bind(&LyX::printError, this, _1)); + bind(&LyX::printError, this, _1)); } else { pimpl_->buffer_list_.release(buf); diff --git a/src/ParagraphMetrics.cpp b/src/ParagraphMetrics.cpp index d0822312fb..1ed12b079a 100644 --- a/src/ParagraphMetrics.cpp +++ b/src/ParagraphMetrics.cpp @@ -47,7 +47,7 @@ #include "support/lstrings.h" #include "support/textutils.h" -#include +#include "support/bind.h" #include #include diff --git a/src/Server.cpp b/src/Server.cpp index 9b9f6e0a75..6a6ed2f837 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -55,7 +55,7 @@ #include "support/lstrings.h" #include "support/os.h" -#include +#include "support/bind.h" #ifdef _WIN32 #include @@ -840,7 +840,7 @@ int LyXComm::startPipe(string const & file, bool write) if (!write) { theApp()->registerSocketCallback(fd, - boost::bind(&LyXComm::read_ready, this)); + bind(&LyXComm::read_ready, this)); } return fd; diff --git a/src/ServerSocket.cpp b/src/ServerSocket.cpp index e36b071e34..12386af838 100644 --- a/src/ServerSocket.cpp +++ b/src/ServerSocket.cpp @@ -28,7 +28,7 @@ #include "support/FileName.h" #include "support/socktools.h" -#include +#include "support/bind.h" #include #include @@ -64,7 +64,7 @@ ServerSocket::ServerSocket(FileName const & addr) theApp()->registerSocketCallback( fd_, - boost::bind(&ServerSocket::serverCallback, this) + bind(&ServerSocket::serverCallback, this) ); LYXERR(Debug::LYXSERVER, "lyx: New server socket " @@ -115,7 +115,7 @@ void ServerSocket::serverCallback() shared_ptr(new LyXDataSocket(client_fd)); theApp()->registerSocketCallback( client_fd, - boost::bind(&ServerSocket::dataCallback, + bind(&ServerSocket::dataCallback, this, client_fd) ); } diff --git a/src/frontends/qt4/GuiApplication.cpp b/src/frontends/qt4/GuiApplication.cpp index bfad7152c7..98e9cae8ac 100644 --- a/src/frontends/qt4/GuiApplication.cpp +++ b/src/frontends/qt4/GuiApplication.cpp @@ -124,7 +124,7 @@ #include #endif // Q_WS_WIN -#include +#include "support/bind.h" #include #include diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index 3f9d8b7f32..e3aa1ecab9 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -118,7 +118,7 @@ #include #endif -#include +#include "support/bind.h" #include @@ -393,7 +393,7 @@ GuiView::GuiView(int id) // Start autosave timer if (lyxrc.autosave) { - d.autosave_timeout_.timeout.connect(boost::bind(&GuiView::autoSave, this)); + d.autosave_timeout_.timeout.connect(bind(&GuiView::autoSave, this)); d.autosave_timeout_.setTimeout(lyxrc.autosave * 1000); d.autosave_timeout_.start(); } diff --git a/src/frontends/qt4/GuiWorkArea.cpp b/src/frontends/qt4/GuiWorkArea.cpp index f71fd12de0..8a9346b6a8 100644 --- a/src/frontends/qt4/GuiWorkArea.cpp +++ b/src/frontends/qt4/GuiWorkArea.cpp @@ -68,7 +68,7 @@ #include #include -#include +#include "support/bind.h" #include @@ -296,7 +296,7 @@ void GuiWorkArea::init() viewport()->setCursor(Qt::IBeamCursor); synthetic_mouse_event_.timeout.timeout.connect( - boost::bind(&GuiWorkArea::generateSyntheticMouseEvent, + bind(&GuiWorkArea::generateSyntheticMouseEvent, this)); // Initialize the vertical Scroll Bar diff --git a/src/frontends/qt4/Toolbars.cpp b/src/frontends/qt4/Toolbars.cpp index 63e46b9c3e..b03b110d13 100644 --- a/src/frontends/qt4/Toolbars.cpp +++ b/src/frontends/qt4/Toolbars.cpp @@ -23,7 +23,7 @@ #include "support/gettext.h" #include "support/lstrings.h" -#include +#include "support/bind.h" #include diff --git a/src/graphics/GraphicsCacheItem.cpp b/src/graphics/GraphicsCacheItem.cpp index afe83b3bcc..e2df63d4bc 100644 --- a/src/graphics/GraphicsCacheItem.cpp +++ b/src/graphics/GraphicsCacheItem.cpp @@ -26,7 +26,7 @@ #include "support/filetools.h" #include "support/FileMonitor.h" -#include +#include "support/bind.h" using namespace std; using namespace lyx::support; @@ -208,7 +208,7 @@ CacheItem::Impl::Impl(FileName const & file) remove_loaded_file_(false), status_(WaitingToLoad) { - monitor_.connect(boost::bind(&Impl::startLoading, this)); + monitor_.connect(bind(&Impl::startLoading, this)); } @@ -428,7 +428,7 @@ void CacheItem::Impl::convertToDisplayFormat() // the graphics converter so that we can load the modified file // on completion of the conversion process. converter_.reset(new Converter(filename, to_file_base.absFileName(), from, to_)); - converter_->connect(boost::bind(&Impl::imageConverted, this, _1)); + converter_->connect(bind(&Impl::imageConverted, this, _1)); converter_->startConversion(); } diff --git a/src/graphics/GraphicsConverter.cpp b/src/graphics/GraphicsConverter.cpp index 82e7edf37f..97c4f68e25 100644 --- a/src/graphics/GraphicsConverter.cpp +++ b/src/graphics/GraphicsConverter.cpp @@ -24,7 +24,7 @@ #include "support/lstrings.h" #include "support/os.h" -#include +#include "support/bind.h" #include #include @@ -178,7 +178,7 @@ void Converter::Impl::startConversion() ForkedCall::SignalTypePtr ptr = ForkedCallQueue::add(script_command_); - ptr->connect(boost::bind(&Impl::converted, this, _1, _2)); + ptr->connect(bind(&Impl::converted, this, _1, _2)); } diff --git a/src/graphics/GraphicsLoader.cpp b/src/graphics/GraphicsLoader.cpp index ac5d614c6e..559c3a7af9 100644 --- a/src/graphics/GraphicsLoader.cpp +++ b/src/graphics/GraphicsLoader.cpp @@ -20,7 +20,7 @@ #include "support/debug.h" #include "support/Timeout.h" -#include +#include "support/bind.h" #include #include @@ -107,7 +107,7 @@ void LoaderQueue::loadNext() LoaderQueue::LoaderQueue() : timer(s_millisecs_, Timeout::ONETIME), running_(false) { - timer.timeout.connect(boost::bind(&LoaderQueue::loadNext, this)); + timer.timeout.connect(bind(&LoaderQueue::loadNext, this)); } @@ -388,7 +388,7 @@ void Loader::Impl::resetFile(FileName const & file) if (continue_monitoring && !cached_item_->monitoring()) cached_item_->startMonitoring(); - sc_ = cached_item_->connect(boost::bind(&Impl::statusChanged, this)); + sc_ = cached_item_->connect(bind(&Impl::statusChanged, this)); } diff --git a/src/graphics/PreviewImage.cpp b/src/graphics/PreviewImage.cpp index 306c2bfb12..d84e425c1f 100644 --- a/src/graphics/PreviewImage.cpp +++ b/src/graphics/PreviewImage.cpp @@ -17,7 +17,7 @@ #include "support/FileName.h" -#include +#include "support/bind.h" using namespace std; using namespace lyx::support; @@ -97,7 +97,7 @@ PreviewImage::Impl::Impl(PreviewImage & p, PreviewLoader & l, : parent_(p), ploader_(l), iloader_(bf), snippet_(s), ascent_frac_(af) { - iloader_.connect(boost::bind(&Impl::statusChanged, this)); + iloader_.connect(bind(&Impl::statusChanged, this)); } diff --git a/src/graphics/PreviewLoader.cpp b/src/graphics/PreviewLoader.cpp index 2b7b3e8c66..bca80c2816 100644 --- a/src/graphics/PreviewLoader.cpp +++ b/src/graphics/PreviewLoader.cpp @@ -37,7 +37,7 @@ #include "support/ForkedCalls.h" #include "support/lstrings.h" -#include +#include "support/bind.h" #include #include @@ -46,7 +46,7 @@ using namespace std; using namespace lyx::support; -using boost::bind; + namespace { diff --git a/src/insets/InsetBox.cpp b/src/insets/InsetBox.cpp index 2681bcd173..66313f368d 100644 --- a/src/insets/InsetBox.cpp +++ b/src/insets/InsetBox.cpp @@ -9,9 +9,11 @@ * * Full author contact details are available in file CREDITS. */ - +#if 1 #include + + #include "InsetBox.h" #include "Buffer.h" @@ -37,6 +39,7 @@ #include + using namespace std; using namespace lyx::support; @@ -272,6 +275,7 @@ int InsetBox::latex(odocstream & os, OutputParams const & runparams) const if (stdwidth) os << "\\noindent"; + switch (btype) { case Frameless: break; @@ -286,14 +290,14 @@ int InsetBox::latex(odocstream & os, OutputParams const & runparams) const // Special widths, see usrguide §3.5 // FIXME UNICODE if (params_.special != "none") { - os << "[" << params_.width.value() + os << "["/* << params_.width.value()*/ << (double) 1 << '\\' << from_utf8(params_.special) << ']'; - } else + } /*else os << '[' << from_ascii(width_string) << ']'; if (params_.hor_pos != 'c') - os << "[" << params_.hor_pos << "]"; + os << "[" << params_.hor_pos << "]";*/ } os << "{"; @@ -314,7 +318,7 @@ int InsetBox::latex(odocstream & os, OutputParams const & runparams) const os << "\\doublebox{"; break; } - + #if 0 if (params_.inner_box) { if (params_.use_parbox) os << "\\parbox"; @@ -392,9 +396,11 @@ int InsetBox::latex(odocstream & os, OutputParams const & runparams) const i += 2; return i; +#endif + return 1; } - +#else int InsetBox::plaintext(odocstream & os, OutputParams const & runparams) const { BoxType const btype = boxtranslator().find(params_.type); @@ -610,5 +616,6 @@ void InsetBoxParams::read(Lexer & lex) lex >> "height_special" >> height_special; } - +#endif } // namespace lyx + diff --git a/src/insets/InsetExternal.cpp b/src/insets/InsetExternal.cpp index 3ab50c2b63..7225da7472 100644 --- a/src/insets/InsetExternal.cpp +++ b/src/insets/InsetExternal.cpp @@ -45,7 +45,7 @@ #include "support/lyxlib.h" #include "support/Translator.h" -#include +#include "support/bind.h" #include @@ -571,7 +571,7 @@ void InsetExternal::setParams(InsetExternalParams const & p) RenderMonitoredPreview * preview_ptr = renderer_->asMonitoredPreview(); renderer_.reset(new RenderMonitoredPreview(this)); preview_ptr = renderer_->asMonitoredPreview(); - preview_ptr->fileChanged(boost::bind(&InsetExternal::fileChanged, this)); + preview_ptr->fileChanged(bind(&InsetExternal::fileChanged, this)); if (preview_ptr->monitoring()) preview_ptr->stopMonitoring(); add_preview_and_start_loading(*preview_ptr, *this, buffer()); diff --git a/src/insets/InsetInclude.cpp b/src/insets/InsetInclude.cpp index ab916e6832..e23903005a 100644 --- a/src/insets/InsetInclude.cpp +++ b/src/insets/InsetInclude.cpp @@ -57,7 +57,7 @@ #include "support/lstrings.h" // contains #include "support/lyxalgo.h" -#include +#include "support/bind.h" using namespace std; using namespace lyx::support; @@ -164,7 +164,7 @@ InsetInclude::InsetInclude(Buffer * buf, InsetCommandParams const & p) preview_(new RenderMonitoredPreview(this)), failedtoload_(false), set_label_(false), label_(0), child_buffer_(0) { - preview_->fileChanged(boost::bind(&InsetInclude::fileChanged, this)); + preview_->fileChanged(bind(&InsetInclude::fileChanged, this)); if (isListings(params())) { InsetListingsParams listing_params(to_utf8(p["lstparams"])); @@ -178,7 +178,7 @@ InsetInclude::InsetInclude(InsetInclude const & other) preview_(new RenderMonitoredPreview(this)), failedtoload_(false), set_label_(false), label_(0), child_buffer_(0) { - preview_->fileChanged(boost::bind(&InsetInclude::fileChanged, this)); + preview_->fileChanged(bind(&InsetInclude::fileChanged, this)); if (other.label_) label_ = new InsetLabel(*other.label_); diff --git a/src/insets/InsetText.cpp b/src/insets/InsetText.cpp index 5a1d839e8e..f427118e75 100644 --- a/src/insets/InsetText.cpp +++ b/src/insets/InsetText.cpp @@ -58,14 +58,12 @@ #include "support/gettext.h" #include "support/lstrings.h" -#include +#include "support/bind.h" #include "support/lassert.h" using namespace std; using namespace lyx::support; -using boost::bind; -using boost::ref; namespace lyx { diff --git a/src/insets/RenderGraphic.cpp b/src/insets/RenderGraphic.cpp index fba651ccdc..a9342cce87 100644 --- a/src/insets/RenderGraphic.cpp +++ b/src/insets/RenderGraphic.cpp @@ -27,7 +27,7 @@ #include "support/filetools.h" #include "support/gettext.h" -#include +#include "support/bind.h" using namespace std; @@ -36,14 +36,14 @@ namespace lyx { RenderGraphic::RenderGraphic(Inset const * inset) { - loader_.connect(boost::bind(&Inset::updateFrontend, inset)); + loader_.connect(bind(&Inset::updateFrontend, inset)); } RenderGraphic::RenderGraphic(RenderGraphic const & other, Inset const * inset) : RenderBase(other), loader_(other.loader_), params_(other.params_) { - loader_.connect(boost::bind(&Inset::updateFrontend, inset)); + loader_.connect(bind(&Inset::updateFrontend, inset)); } diff --git a/src/insets/RenderPreview.cpp b/src/insets/RenderPreview.cpp index c9086d5282..ee2bbce4d1 100644 --- a/src/insets/RenderPreview.cpp +++ b/src/insets/RenderPreview.cpp @@ -31,7 +31,7 @@ #include "support/lassert.h" #include "support/lstrings.h" -#include +#include "support/bind.h" using namespace std; using namespace lyx::support; @@ -216,7 +216,7 @@ void RenderPreview::addPreview(docstring const & latex_snippet, // is ready for loading. if (!ploader_connection_.connected()) { ploader_connection_ = ploader.connect( - boost::bind(&RenderPreview::imageReady, this, _1)); + bind(&RenderPreview::imageReady, this, _1)); } ploader.add(snippet_); diff --git a/src/mathed/InsetMathGrid.cpp b/src/mathed/InsetMathGrid.cpp index 19c9d8c54b..900d37abc5 100644 --- a/src/mathed/InsetMathGrid.cpp +++ b/src/mathed/InsetMathGrid.cpp @@ -42,6 +42,7 @@ using namespace std; using namespace lyx::support; + namespace lyx { static docstring verboseHLine(int n) diff --git a/src/support/FileMonitor.cpp b/src/support/FileMonitor.cpp index 7a625d2f6c..9f959d5a3a 100644 --- a/src/support/FileMonitor.cpp +++ b/src/support/FileMonitor.cpp @@ -15,7 +15,7 @@ #include "support/FileName.h" #include "support/Timeout.h" -#include +#include "support/bind.h" #include using namespace std; @@ -145,7 +145,7 @@ FileMonitor::Impl::Impl(FileName const & file_with_path, int interval) timestamp_(0), checksum_(0) { - timer_.timeout.connect(boost::bind(&Impl::monitorFile, this)); + timer_.timeout.connect(bind(&Impl::monitorFile, this)); } diff --git a/src/support/ForkedCalls.cpp b/src/support/ForkedCalls.cpp index e5e2aa8c2b..e59c008557 100644 --- a/src/support/ForkedCalls.cpp +++ b/src/support/ForkedCalls.cpp @@ -21,7 +21,7 @@ #include "support/os.h" #include "support/Timeout.h" -#include +#include "support/bind.h" #include #include @@ -46,7 +46,7 @@ using namespace std; -using boost::bind; + namespace lyx { namespace support { @@ -84,7 +84,7 @@ private: Murder(int secs, pid_t pid) : timeout_(1000*secs, Timeout::ONETIME), pid_(pid) { - timeout_.timeout.connect(boost::bind(&Murder::kill, this)); + timeout_.timeout.connect(bind(&Murder::kill, this)); timeout_.start(); } @@ -442,7 +442,7 @@ void callNext() Process pro = callQueue_.front(); callQueue_.pop(); // Bind our chain caller - pro.second->connect(boost::bind(&ForkedCallQueue::callback, _1, _2)); + pro.second->connect(bind(&ForkedCallQueue::callback, _1, _2)); ForkedCall call; //If we fail to fork the process, then emit the signal //to tell the outside world that it failed. diff --git a/src/support/bind.h b/src/support/bind.h new file mode 100644 index 0000000000..2c636dce6d --- /dev/null +++ b/src/support/bind.h @@ -0,0 +1,34 @@ +// -*- C++ -*- +/** + * \file bind.h + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author Peter Kümmel + * + * Full author contact details are available in file CREDITS. + */ + +#ifndef LYX_BIND_H +#define LYX_BIND_H + +#if defined(_MSC_VER) && (_MSC_VER >= 1600) + +#include +using std::tr1::bind; +using std::tr1::placeholders::_1; +using std::tr1::placeholders::_2; +using std::tr1::ref; + +#else + +#include "support/bind.h" +using boost::bind; +using boost::_1; +using boost::_2; +using boost::ref; + +#endif + + +#endif diff --git a/src/support/docstream.h b/src/support/docstream.h index 056205df19..8a60e55509 100644 --- a/src/support/docstream.h +++ b/src/support/docstream.h @@ -54,6 +54,7 @@ public: /// File stream for writing files in 8bit encoding \p encoding with automatic /// conversion from UCS4. + class ofdocstream : public std::basic_ofstream { typedef std::basic_ofstream base; public: @@ -66,6 +67,10 @@ public: void reset(std::string const & encoding); }; + +extern template class std::numpunct; +extern template class std::basic_ofstream; + /// UCS4 input stringstream typedef std::basic_istringstream idocstringstream;