Commit c1826085 authored by Murray Cumming's avatar Murray Cumming

Replace all operator bool() with operator void*().

* gtk/gtkmm/stockid.[h|cc]:
* gtk/src/iconinfo.[hg|ccg]:
* gtk/src/papersize.[hg|ccg]:
* gtk/src/recentinfo.[hg|ccg]:
* gtk/src/textiter.[hg|ccg]:
* gtk/src/treeiter.hg:
* gtk/src/treepath.[hg|ccg]:
* gtk/src/treerowreference.[hg|ccg]: Use operator void*() instead of
operator bool() because this avoids an implicit conversion to int instead of
bool. This is apparently generally considered a good thing.
parent 45b41f10
2011-04-01 Murray Cumming <murrayc@murrayc.com>
Replace all operator bool() with operator void*().
* gtk/gtkmm/stockid.[h|cc]:
* gtk/src/iconinfo.[hg|ccg]:
* gtk/src/papersize.[hg|ccg]:
* gtk/src/recentinfo.[hg|ccg]:
* gtk/src/textiter.[hg|ccg]:
* gtk/src/treeiter.hg:
* gtk/src/treepath.[hg|ccg]:
* gtk/src/treerowreference.[hg|ccg]: Use operator void*() instead of
operator bool() because this avoids an implicit conversion to int instead of
bool. This is apparently generally considered a good thing. Daniel Elstner
mentioned this at some point in the last year or so too.
2011-03-26 Kalev Lember <kalev@smartlink.ee>
Wrap a missing flag in GtkStateFlags
......
......@@ -59,9 +59,9 @@ StockID& StockID::operator=(const StockID& other)
return *this;
}
StockID::operator bool() const
StockID::operator void*() const
{
return !(id_.empty());
return (void*)!(id_.empty());
}
bool StockID::equal(const StockID& rhs) const
......
......@@ -70,7 +70,7 @@ public:
/** Tests whether the StockID is not empty.
*/
operator bool() const;
operator void*() const;
/** Check if two StockIDs are equal.
* @param rhs Another StockID.
......
......@@ -41,9 +41,9 @@ std::vector<Gdk::Point> IconInfo::get_attach_points() const
return std::vector<Gdk::Point> ();
}
IconInfo::operator bool() const
IconInfo::operator void*() const
{
return gobj() != 0;
return (void*)(gobj() != 0);
}
......
......@@ -42,7 +42,7 @@ public:
_IGNORE(gtk_icon_info_new_for_pixbuf)
///Tests whether the IconInfo is valid.
operator bool() const;
operator void*() const;
_WRAP_METHOD(int get_base_size() const, gtk_icon_info_get_base_size)
_WRAP_METHOD(Glib::ustring get_filename() const, gtk_icon_info_get_filename)
......
......@@ -49,7 +49,7 @@ PaperSize::PaperSize(const Glib::ustring& name, const Glib::ustring& display_nam
GtkUnit(unit)))
{}
//TODO: Add an operator bool() so we can detect if this succeeded:
//TODO: Add an operator void*() so we can detect if this succeeded:
//TODO: No, throw the error/exception instead.
PaperSize::PaperSize(const Glib::KeyFile& key_file, const Glib::ustring& group_name)
:
......@@ -62,9 +62,9 @@ bool PaperSize::equal(const PaperSize& other) const
const_cast<GtkPaperSize*>(other.gobj()))));
}
PaperSize::operator bool() const
PaperSize::operator void*() const
{
return (gobj() != NULL);
return (void*)(gobj() != 0);
}
void PaperSize::save_to_key_file(Glib::KeyFile& key_file)
......
......@@ -71,7 +71,7 @@ public:
/** Returns true if the PaperSize is a valid object.
* @newin{2,12}
*/
operator bool() const;
operator void*() const;
#m4 _CONVERSION(`GList*', `std::vector<PaperSize>',`Glib::ListHandler<PaperSize, PaperSizeTraits>::list_to_vector($3, Glib::OWNERSHIP_DEEP)')
_WRAP_METHOD(static std::vector<PaperSize> get_paper_sizes(bool include_custom = true), gtk_paper_size_get_paper_sizes)
......
......@@ -22,9 +22,9 @@
namespace Gtk
{
RecentInfo::operator bool() const
RecentInfo::operator void*() const
{
return gobj() != 0;
return (void*)(gobj() != 0);
}
std::vector<Glib::ustring> RecentInfo::get_applications() const
......
......@@ -53,7 +53,7 @@ public:
//#ifndef DOXYGEN_SHOULD_SKIP_THIS
//# if (!defined(GTKMM_DISABLE_DEPRECATED) || defined(GTKMM_COMPILATION))
/// Tests whether the RecentInfo is valid.
operator bool() const;
operator void*() const;
//# endif
//#endif
......
......@@ -76,7 +76,7 @@ public:
inline value_type operator*() const;
/** Alias for !is_end(). */
inline operator bool() const;
inline operator void*() const;
#ifndef DOXYGEN_SHOULD_SKIP_THIS
......@@ -325,9 +325,9 @@ TextIter::value_type TextIter::operator*() const
}
inline
TextIter::operator bool() const
TextIter::operator void*() const
{
return !is_end();
return (void*)!is_end();
}
template <class Predicate>
......
......@@ -137,12 +137,12 @@ bool TreeIter::equal(const TreeIter& other) const
(gobject_.user_data3 == other.gobject_.user_data3);
}
TreeIter::operator bool() const
TreeIter::operator void*() const
{
// Test whether the GtkTreeIter is valid and not an end iterator. This check
// is almost the same as the private VALID_ITER() macro in gtkliststore.c and
// gtktreestore.c.
return (!is_end_ && gobject_.stamp != 0);
return (void*)(!is_end_ && gobject_.stamp != 0);
}
void TreeIter::setup_end_iterator(const TreeIter& last_valid)
......@@ -215,9 +215,9 @@ void TreeRow::get_value_impl(int column, Glib::ValueBase& value) const
model_->get_value_impl(*this, column, value);
}
TreeRow::operator bool() const
TreeRow::operator void*() const
{
return TreeIter::operator bool();
return (void*)TreeIter::operator void*();
}
......
......@@ -120,7 +120,7 @@ public:
/** Discover whether the iterator is valid, and not equal to end().
*/
operator bool() const;
operator void*() const;
/** This is only useful when implementing a custom Gtk::TreeModel class.
* Compare the iterator's stamp with your model's stamp to discover whether it is valid.
......@@ -288,7 +288,7 @@ public:
/** Discover whether this is a valid row.
*/
operator bool() const;
operator void*() const;
/// Provides access to the underlying C GObject.
GtkTreeIter* gobj() { return TreeIter::gobj(); }
......@@ -349,7 +349,7 @@ public:
size_type size() const;
bool empty() const;
operator bool() const { return !empty(); }
operator void*() const { return (void*)!empty(); }
#ifndef DOXYGEN_SHOULD_SKIP_THIS
......
......@@ -63,9 +63,9 @@ TreePath::size_type TreePath::size() const
return gtk_tree_path_get_depth(gobject_);
}
TreePath::operator bool() const
TreePath::operator void*() const
{
return !empty();
return (void*)!empty();
}
bool TreePath::empty() const
......
......@@ -86,7 +86,7 @@ public:
/** Checks that the path is not empty, by calling empty().
* @newin{2,16}
*/
operator bool() const;
operator void*() const;
template <class In> inline void assign(In pbegin, In pend);
template <class In> void append(In pbegin, In pend);
......
......@@ -29,9 +29,9 @@ TreeRowReference::TreeRowReference(const Glib::RefPtr<TreeModel>& model, const T
gobject_ ( gtk_tree_row_reference_new(model->gobj(), const_cast<GtkTreePath*>(path.gobj())) )
{}
TreeRowReference::operator bool() const
TreeRowReference::operator void*() const
{
return is_valid();
return (void*)is_valid();
}
} // namespace Gtk
......
......@@ -40,7 +40,7 @@ public:
TreeRowReference(const Glib::RefPtr<TreeModel>& model, const TreeModel::Path& path);
///The same as is_valid().
operator bool() const;
operator void*() const;
_WRAP_METHOD(TreeModel::Path get_path() const, gtk_tree_row_reference_get_path)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment