mirror of https://github.com/CGAL/cgal
Merge pull request #7229 from GilesBathgate/General-safe_bool_idiom-GilesBathgate
Remove use of the safe-bool idiom, replace with explicit operator bool
This commit is contained in:
commit
1b84329710
|
|
@ -213,16 +213,10 @@ public:
|
||||||
{}
|
{}
|
||||||
|
|
||||||
#ifndef DOXYGEN_RUNNING
|
#ifndef DOXYGEN_RUNNING
|
||||||
// design pattern: "safe bool"
|
|
||||||
// will be replaced by explicit operator bool with C++11
|
|
||||||
typedef void (Halfedge_around_source_iterator::*bool_type)() const;
|
|
||||||
|
|
||||||
void this_type_does_not_support_comparisons() const {}
|
explicit operator bool() const
|
||||||
|
|
||||||
operator bool_type() const
|
|
||||||
{
|
{
|
||||||
return (! (this->base() == nullptr)) ?
|
return (! (this->base() == nullptr));
|
||||||
&Halfedge_around_source_iterator::this_type_does_not_support_comparisons : 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator==( const Self& i) const {
|
bool operator==( const Self& i) const {
|
||||||
|
|
@ -313,16 +307,10 @@ public:
|
||||||
{}
|
{}
|
||||||
|
|
||||||
#ifndef DOXYGEN_RUNNING
|
#ifndef DOXYGEN_RUNNING
|
||||||
// design pattern: "safe bool"
|
|
||||||
// will be replaced by explicit operator bool with C++11
|
|
||||||
typedef void (Halfedge_around_target_iterator::*bool_type)() const;
|
|
||||||
|
|
||||||
void this_type_does_not_support_comparisons() const {}
|
explicit operator bool() const
|
||||||
|
|
||||||
operator bool_type() const
|
|
||||||
{
|
{
|
||||||
return (! (this->base() == nullptr)) ?
|
return (! (this->base() == nullptr));
|
||||||
&Halfedge_around_target_iterator::this_type_does_not_support_comparisons : 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator==( const Self& i) const {
|
bool operator==( const Self& i) const {
|
||||||
|
|
@ -412,16 +400,9 @@ public:
|
||||||
pointer operator -> ( ) { return &pos; }
|
pointer operator -> ( ) { return &pos; }
|
||||||
const value_type* operator -> ( ) const { return &pos; }
|
const value_type* operator -> ( ) const { return &pos; }
|
||||||
|
|
||||||
// design pattern: "safe bool"
|
explicit operator bool() const
|
||||||
// will be replaced by explicit operator bool with C++11
|
|
||||||
typedef void (Halfedge_around_face_iterator::*bool_type)() const;
|
|
||||||
|
|
||||||
void this_type_does_not_support_comparisons() const {}
|
|
||||||
|
|
||||||
operator bool_type() const
|
|
||||||
{
|
{
|
||||||
return (! (this->base() == nullptr)) ?
|
return (! (this->base() == nullptr));
|
||||||
&Halfedge_around_face_iterator::this_type_does_not_support_comparisons : 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator==( const Self& i) const {
|
bool operator==( const Self& i) const {
|
||||||
|
|
@ -522,16 +503,10 @@ public:
|
||||||
Halfedge_around_source_circulator(vertex_descriptor vd, const Graph& g)
|
Halfedge_around_source_circulator(vertex_descriptor vd, const Graph& g)
|
||||||
: Halfedge_around_source_circulator::iterator_adaptor_(Halfedge_around_target_circulator<Graph>(halfedge(vd,g),g)), opp(g)
|
: Halfedge_around_source_circulator::iterator_adaptor_(Halfedge_around_target_circulator<Graph>(halfedge(vd,g),g)), opp(g)
|
||||||
{}
|
{}
|
||||||
// design pattern: "safe bool"
|
|
||||||
// will be replaced by explicit operator bool with C++11
|
|
||||||
typedef void (Halfedge_around_source_circulator::*bool_type)() const;
|
|
||||||
|
|
||||||
void this_type_does_not_support_comparisons() const {}
|
explicit operator bool() const
|
||||||
|
|
||||||
operator bool_type() const
|
|
||||||
{
|
{
|
||||||
return (! (this->base_reference() == nullptr)) ?
|
return (! (this->base_reference() == nullptr));
|
||||||
&Halfedge_around_source_circulator::this_type_does_not_support_comparisons : 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator== (void*) const
|
bool operator== (void*) const
|
||||||
|
|
@ -539,6 +514,11 @@ public:
|
||||||
return this->base_reference() == nullptr;
|
return this->base_reference() == nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool operator!= (void*) const
|
||||||
|
{
|
||||||
|
return this->base_reference() != nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class boost::iterator_core_access;
|
friend class boost::iterator_core_access;
|
||||||
typename boost::graph_traits<Graph>::halfedge_descriptor dereference() const { return opp(*this->base_reference()); }
|
typename boost::graph_traits<Graph>::halfedge_descriptor dereference() const { return opp(*this->base_reference()); }
|
||||||
|
|
@ -580,16 +560,9 @@ public:
|
||||||
#ifndef DOXYGEN_RUNNING
|
#ifndef DOXYGEN_RUNNING
|
||||||
typedef std::size_t size_type;
|
typedef std::size_t size_type;
|
||||||
|
|
||||||
// design pattern: "safe bool"
|
explicit operator bool() const
|
||||||
// will be replaced by explicit operator bool with C++11
|
|
||||||
typedef void (Face_around_target_circulator::*bool_type)() const;
|
|
||||||
|
|
||||||
void this_type_does_not_support_comparisons() const {}
|
|
||||||
|
|
||||||
operator bool_type() const
|
|
||||||
{
|
{
|
||||||
return (! (this->base_reference() == nullptr)) ?
|
return (! (this->base_reference() == nullptr));
|
||||||
&Face_around_target_circulator::this_type_does_not_support_comparisons : 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator== (void*) const
|
bool operator== (void*) const
|
||||||
|
|
@ -597,6 +570,11 @@ public:
|
||||||
return this->base_reference() == nullptr;
|
return this->base_reference() == nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool operator!= (void*) const
|
||||||
|
{
|
||||||
|
return this->base_reference() != nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class boost::iterator_core_access;
|
friend class boost::iterator_core_access;
|
||||||
|
|
@ -654,17 +632,9 @@ public:
|
||||||
bool operator == ( const Self& other) const { return g == other.g && pos == other.pos; }
|
bool operator == ( const Self& other) const { return g == other.g && pos == other.pos; }
|
||||||
bool operator != ( const Self& other) const { return g != other.g || pos != other.pos; }
|
bool operator != ( const Self& other) const { return g != other.g || pos != other.pos; }
|
||||||
|
|
||||||
|
explicit operator bool() const
|
||||||
// design pattern: "safe bool"
|
|
||||||
// will be replaced by explicit operator bool with C++11
|
|
||||||
typedef void (Halfedge_around_target_circulator::*bool_type)() const;
|
|
||||||
|
|
||||||
void this_type_does_not_support_comparisons() const {}
|
|
||||||
|
|
||||||
operator bool_type() const
|
|
||||||
{
|
{
|
||||||
return (! (g == nullptr)) ?
|
return (! (g == nullptr));
|
||||||
&Halfedge_around_target_circulator::this_type_does_not_support_comparisons : 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -673,6 +643,11 @@ public:
|
||||||
return g == nullptr;
|
return g == nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool operator!= (void* ) const
|
||||||
|
{
|
||||||
|
return g != nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Self& operator++()
|
Self& operator++()
|
||||||
{
|
{
|
||||||
|
|
@ -751,17 +726,9 @@ public:
|
||||||
bool operator == ( const Self& other) const { return g == other.g && pos == other.pos; }
|
bool operator == ( const Self& other) const { return g == other.g && pos == other.pos; }
|
||||||
bool operator != ( const Self& other) const { return g != other.g || pos != other.pos; }
|
bool operator != ( const Self& other) const { return g != other.g || pos != other.pos; }
|
||||||
|
|
||||||
|
explicit operator bool() const
|
||||||
// design pattern: "safe bool"
|
|
||||||
// will be replaced by explicit operator bool with C++11
|
|
||||||
typedef void (Halfedge_around_face_circulator::*bool_type)() const;
|
|
||||||
|
|
||||||
void this_type_does_not_support_comparisons() const {}
|
|
||||||
|
|
||||||
operator bool_type() const
|
|
||||||
{
|
{
|
||||||
return (! (g == nullptr)) ?
|
return (! (g == nullptr));
|
||||||
&Halfedge_around_face_circulator::this_type_does_not_support_comparisons : 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator== (void* ) const
|
bool operator== (void* ) const
|
||||||
|
|
@ -769,6 +736,11 @@ public:
|
||||||
return g == nullptr;
|
return g == nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool operator!= (void* ) const
|
||||||
|
{
|
||||||
|
return g != nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
Self& operator++()
|
Self& operator++()
|
||||||
{
|
{
|
||||||
CGAL_assertion(g != nullptr);
|
CGAL_assertion(g != nullptr);
|
||||||
|
|
@ -1014,22 +986,22 @@ public:
|
||||||
{}
|
{}
|
||||||
|
|
||||||
#ifndef DOXYGEN_RUNNING
|
#ifndef DOXYGEN_RUNNING
|
||||||
// design pattern: "safe bool"
|
|
||||||
// will be replaced by explicit operator bool with C++11
|
|
||||||
typedef void (Vertex_around_face_circulator::*bool_type)() const;
|
|
||||||
|
|
||||||
void this_type_does_not_support_comparisons() const {}
|
explicit operator bool() const
|
||||||
|
|
||||||
operator bool_type() const
|
|
||||||
{
|
{
|
||||||
return (! (this->base_reference() == nullptr)) ?
|
return (! (this->base_reference() == nullptr));
|
||||||
&Vertex_around_face_circulator::this_type_does_not_support_comparisons : 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator== (void*) const
|
bool operator== (void*) const
|
||||||
{
|
{
|
||||||
return this->base_reference()== nullptr;
|
return this->base_reference()== nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool operator!= (void*) const
|
||||||
|
{
|
||||||
|
return this->base_reference()!= nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class boost::iterator_core_access;
|
friend class boost::iterator_core_access;
|
||||||
typename boost::graph_traits<Graph>::vertex_descriptor dereference() const { return fct(*this->base_reference()); }
|
typename boost::graph_traits<Graph>::vertex_descriptor dereference() const { return fct(*this->base_reference()); }
|
||||||
|
|
@ -1068,16 +1040,10 @@ public:
|
||||||
{}
|
{}
|
||||||
|
|
||||||
#ifndef DOXYGEN_RUNNING
|
#ifndef DOXYGEN_RUNNING
|
||||||
// design pattern: "safe bool"
|
|
||||||
// will be replaced by explicit operator bool with C++11
|
|
||||||
typedef void (Vertex_around_face_iterator::*bool_type)() const;
|
|
||||||
|
|
||||||
void this_type_does_not_support_comparisons() const {}
|
explicit operator bool() const
|
||||||
|
|
||||||
operator bool_type() const
|
|
||||||
{
|
{
|
||||||
return (! (this->base_reference() == nullptr)) ?
|
return (! (this->base_reference() == nullptr));
|
||||||
&Vertex_around_face_iterator::this_type_does_not_support_comparisons : 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator== (void*) const
|
bool operator== (void*) const
|
||||||
|
|
@ -1198,16 +1164,10 @@ public:
|
||||||
{}
|
{}
|
||||||
|
|
||||||
#ifndef DOXYGEN_RUNNING
|
#ifndef DOXYGEN_RUNNING
|
||||||
// design pattern: "safe bool"
|
|
||||||
// will be replaced by explicit operator bool with C++11
|
|
||||||
typedef void (Vertex_around_target_circulator::*bool_type)() const;
|
|
||||||
|
|
||||||
void this_type_does_not_support_comparisons() const {}
|
explicit operator bool() const
|
||||||
|
|
||||||
operator bool_type() const
|
|
||||||
{
|
{
|
||||||
return (! (this->base_reference() == nullptr)) ?
|
return (! (this->base_reference() == nullptr));
|
||||||
&Vertex_around_target_circulator::this_type_does_not_support_comparisons : 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator== (void*) const
|
bool operator== (void*) const
|
||||||
|
|
@ -1215,6 +1175,11 @@ public:
|
||||||
return this->base_reference()== nullptr;
|
return this->base_reference()== nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool operator!= (void*) const
|
||||||
|
{
|
||||||
|
return this->base_reference()!= nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class boost::iterator_core_access;
|
friend class boost::iterator_core_access;
|
||||||
typename boost::graph_traits<Graph>::vertex_descriptor dereference() const { return fct(*this->base_reference()); }
|
typename boost::graph_traits<Graph>::vertex_descriptor dereference() const { return fct(*this->base_reference()); }
|
||||||
|
|
@ -1256,16 +1221,10 @@ public:
|
||||||
{}
|
{}
|
||||||
|
|
||||||
#ifndef DOXYGEN_RUNNING
|
#ifndef DOXYGEN_RUNNING
|
||||||
// design pattern: "safe bool"
|
|
||||||
// will be replaced by explicit operator bool with C++11
|
|
||||||
typedef void (Vertex_around_target_iterator::*bool_type)() const;
|
|
||||||
|
|
||||||
void this_type_does_not_support_comparisons() const {}
|
explicit operator bool() const
|
||||||
|
|
||||||
operator bool_type() const
|
|
||||||
{
|
{
|
||||||
return (! (this->base_reference() == nullptr)) ?
|
return (! (this->base_reference() == nullptr));
|
||||||
&Vertex_around_target_iterator::this_type_does_not_support_comparisons : 0;
|
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
friend class boost::iterator_core_access;
|
friend class boost::iterator_core_access;
|
||||||
|
|
@ -1343,16 +1302,9 @@ public:
|
||||||
Out_edge_iterator(halfedge_descriptor h, const Graph& g, int n = 0)
|
Out_edge_iterator(halfedge_descriptor h, const Graph& g, int n = 0)
|
||||||
: Out_edge_iterator::iterator_adaptor_(Halfedge_around_target_iterator<Graph>(h,g,(h==halfedge_descriptor())?1:n)), opp(g) {}
|
: Out_edge_iterator::iterator_adaptor_(Halfedge_around_target_iterator<Graph>(h,g,(h==halfedge_descriptor())?1:n)), opp(g) {}
|
||||||
|
|
||||||
// design pattern: "safe bool"
|
explicit operator bool() const
|
||||||
// will be replaced by explicit operator bool with C++11
|
|
||||||
typedef void (Out_edge_iterator::*bool_type)() const;
|
|
||||||
|
|
||||||
void this_type_does_not_support_comparisons() const {}
|
|
||||||
|
|
||||||
operator bool_type() const
|
|
||||||
{
|
{
|
||||||
return (! (this->base_reference() == nullptr)) ?
|
return (! (this->base_reference() == nullptr));
|
||||||
&Out_edge_iterator::this_type_does_not_support_comparisons : 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1385,16 +1337,9 @@ public:
|
||||||
: In_edge_iterator::iterator_adaptor_(Halfedge_around_target_iterator<Graph>(h,g,(h==halfedge_descriptor())?1:n)), fct(g)
|
: In_edge_iterator::iterator_adaptor_(Halfedge_around_target_iterator<Graph>(h,g,(h==halfedge_descriptor())?1:n)), fct(g)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
// design pattern: "safe bool"
|
explicit operator bool() const
|
||||||
// will be replaced by explicit operator bool with C++11
|
|
||||||
typedef void (In_edge_iterator::*bool_type)() const;
|
|
||||||
|
|
||||||
void this_type_does_not_support_comparisons() const {}
|
|
||||||
|
|
||||||
operator bool_type() const
|
|
||||||
{
|
{
|
||||||
return (! (this->base_reference() == nullptr)) ?
|
return (! (this->base_reference() == nullptr));
|
||||||
&In_edge_iterator::this_type_does_not_support_comparisons : 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
||||||
|
|
@ -52,8 +52,6 @@ class Object
|
||||||
template<class T>
|
template<class T>
|
||||||
friend T object_cast(const Object & o);
|
friend T object_cast(const Object & o);
|
||||||
|
|
||||||
typedef void (Object::*bool_type)() const;
|
|
||||||
void this_type_does_not_support_comparisons() const {}
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
struct private_tag{};
|
struct private_tag{};
|
||||||
|
|
@ -97,8 +95,8 @@ class Object
|
||||||
}
|
}
|
||||||
|
|
||||||
// safe-bool conversion
|
// safe-bool conversion
|
||||||
operator bool_type() const {
|
explicit operator bool() const {
|
||||||
return empty() == false ? &Object::this_type_does_not_support_comparisons : 0;
|
return !empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -538,8 +538,6 @@ class Property_map_base
|
||||||
CRTP_derived_class>
|
CRTP_derived_class>
|
||||||
/// @endcond
|
/// @endcond
|
||||||
{
|
{
|
||||||
typedef void (Property_map_base::*bool_type)() const;
|
|
||||||
void this_type_does_not_support_comparisons() const {}
|
|
||||||
public:
|
public:
|
||||||
typedef I key_type;
|
typedef I key_type;
|
||||||
typedef T value_type;
|
typedef T value_type;
|
||||||
|
|
@ -596,11 +594,19 @@ public:
|
||||||
/// can be used, and \c false otherwise.
|
/// can be used, and \c false otherwise.
|
||||||
operator bool () const;
|
operator bool () const;
|
||||||
#else
|
#else
|
||||||
operator bool_type() const {
|
explicit operator bool() const {
|
||||||
return parray_ != nullptr ?
|
return parray_ != nullptr;
|
||||||
&Property_map_base::this_type_does_not_support_comparisons : 0;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
bool operator==(const Property_map_base& pm) const {
|
||||||
|
return parray_ == pm.parray_;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator!=(const Property_map_base& pm) const {
|
||||||
|
return parray_ != pm.parray_;
|
||||||
|
}
|
||||||
|
|
||||||
/// Access the property associated with the key \c i.
|
/// Access the property associated with the key \c i.
|
||||||
reference operator[](const I& i)
|
reference operator[](const I& i)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue