Visual Studio 2010 C4717 C ++ compiler warning in one part of the code, but not in the other

These six methods (indeed three, those that actually throw a warning, are non-constant versions) call C4717 (functions recursive in all ways), but the method following them is not (just like I can tell ... ) What am I missing that causes a warning for them, but not another?

Warning methods:

template<class T>
const QuadTreeNode<T>* QuadTree<T>::GetRoot() const {
    return _root;
}


template<class T>
QuadTreeNode<T>* QuadTree<T>::GetRoot() {
    return static_cast<const QuadTree<T> >(*this).GetRoot();
}

template<class T>
const int QuadTree<T>::GetNumLevels() const {
    return _levels;
}

template<class T>
int QuadTree<T>::GetNumLevels() {
    return static_cast<const QuadTree<T> >(*this).GetNumLevels();
}

template<class T>
const bool QuadTree<T>::IsEmpty() const {
    return _root == NULL;
}


template<class T>
bool QuadTree<T>::IsEmpty() {
    return static_cast<const QuadTree<T> >(*this).IsEmpty();
}

No warning method:

template<class T>
const Rectangle QuadTreeNode<T>::GetNodeDimensions() const {
    return _node_bounds;
}

template<class T>
Rectangle QuadTreeNode<T>::GetNodeDimensions() {
    return static_cast<const QuadTreeNode<T> >(*this).GetNodeDimensions();
}
+3
source share
1 answer

ildjarn, . , , ( ).

class A
{
public:
    bool IsEmpty()
    {
        return static_cast<const A>(*this).IsEmpty();
    }

    bool IsEmpty() const
    {
        return true;
    }
};

int main()
{
    A whatever;
    whatever.IsEmpty();

    return 0;
}
+1

All Articles