[gnote] Do not use BOOST_FOREACH if C++11 is supported
- From: Aurimas Černius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote] Do not use BOOST_FOREACH if C++11 is supported
- Date: Fri, 2 Aug 2013 22:02:27 +0000 (UTC)
commit 58ed98233581a16048fa75ba7c8a41ac6941a7f4
Author: Aurimas Černius <aurisc4 gmail com>
Date: Sat Aug 3 01:00:52 2013 +0300
Do not use BOOST_FOREACH if C++11 is supported
configure.ac | 2 +-
src/base/macros.hpp | 3 +++
src/notebooks/notebook.cpp | 5 ++---
src/recentchanges.cpp | 11 ++++-------
4 files changed, 10 insertions(+), 11 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index a5b1614..140c866 100644
--- a/configure.ac
+++ b/configure.ac
@@ -89,7 +89,6 @@ PKG_CHECK_MODULES(LIBSECRET, [libsecret-1 >= $LIBSECRET_VERSION])
BOOST_REQUIRE([$BOOST_VERSION])
BOOST_BIND
-BOOST_FOREACH
BOOST_FORMAT
BOOST_TEST([s])
AC_CHECK_HEADER(tr1/memory,,[
@@ -102,6 +101,7 @@ if test $HAVE_CXX11 == 1; then
else
cxx11_support="no";
BOOST_CONVERSION
+ BOOST_FOREACH
fi
diff --git a/src/base/macros.hpp b/src/base/macros.hpp
index 0220587..caca1d4 100644
--- a/src/base/macros.hpp
+++ b/src/base/macros.hpp
@@ -30,6 +30,7 @@
#define __BASE_MACROS_
#if __cplusplus < 201103L
+ #include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
#else
#include <string>
@@ -46,9 +47,11 @@
#if __cplusplus < 201103L
#define final
#define override
+ #define FOREACH(var, container) BOOST_FOREACH(var, container)
#define TO_STRING(x) boost::lexical_cast<std::string>(x)
#define STRING_TO_INT(x) boost::lexical_cast<int>(x)
#else
+ #define FOREACH(var, container) for(var : container)
#define TO_STRING(x) std::to_string(x)
#define STRING_TO_INT(x) std::stoi(x)
#endif
diff --git a/src/notebooks/notebook.cpp b/src/notebooks/notebook.cpp
index 0ed79a4..993ed42 100644
--- a/src/notebooks/notebook.cpp
+++ b/src/notebooks/notebook.cpp
@@ -20,7 +20,6 @@
-#include <boost/foreach.hpp>
#include <boost/format.hpp>
#include <glibmm/i18n.h>
@@ -116,7 +115,7 @@ namespace notebooks {
}
std::list<Note*> notes;
template_tag->get_notes(notes);
- BOOST_FOREACH(Note *n, notes) {
+ FOREACH(Note *n, notes) {
if(n->contains_tag(notebook_tag)) {
note = n->shared_from_this();
break;
@@ -348,7 +347,7 @@ namespace notebooks {
// ignore template notes
Tag::Ptr template_tag =
ITagManager::obj().get_or_create_system_tag(ITagManager::TEMPLATE_NOTE_SYSTEM_TAG);
- BOOST_FOREACH(Note::Ptr note, m_notes) {
+ FOREACH(const Note::Ptr & note, m_notes) {
if(!note->contains_tag(template_tag)) {
return false;
}
diff --git a/src/recentchanges.cpp b/src/recentchanges.cpp
index 24a3223..f751807 100644
--- a/src/recentchanges.cpp
+++ b/src/recentchanges.cpp
@@ -24,7 +24,6 @@
#endif
#include <boost/bind.hpp>
-#include <boost/foreach.hpp>
#include <glibmm/i18n.h>
#include <gtkmm/alignment.h>
#include <gtkmm/image.h>
@@ -536,8 +535,8 @@ namespace gnote {
bool NoteRecentChanges::contains(EmbeddableWidget & widget)
{
- BOOST_FOREACH(EmbeddableWidget *wgt, m_embedded_widgets) {
- if(wgt == &widget) {
+ FOREACH(EmbeddableWidget *wgt, m_embedded_widgets) {
+ if(dynamic_cast<EmbeddableWidget*>(wgt) == &widget) {
return true;
}
}
@@ -547,10 +546,8 @@ namespace gnote {
bool NoteRecentChanges::is_foreground(EmbeddableWidget & widget)
{
- std::vector<Gtk::Widget*> current = m_embed_box.get_children();
- for(std::vector<Gtk::Widget*>::iterator iter = current.begin();
- iter != current.end(); ++iter) {
- if(dynamic_cast<EmbeddableWidget*>(*iter) == &widget) {
+ FOREACH(Gtk::Widget *wgt, m_embed_box.get_children()) {
+ if(dynamic_cast<EmbeddableWidget*>(wgt) == &widget) {
return true;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]