alpar@7: /* -*- C++ -*-
alpar@7:  *
alpar@7:  * This file is a part of LEMON, a generic C++ optimization library
alpar@7:  *
alpar@39:  * Copyright (C) 2003-2008
alpar@7:  * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
alpar@7:  * (Egervary Research Group on Combinatorial Optimization, EGRES).
alpar@7:  *
alpar@7:  * Permission to use, modify and distribute this software is granted
alpar@7:  * provided that this copyright notice appears in all copies. For
alpar@7:  * precise terms see the accompanying LICENSE file.
alpar@7:  *
alpar@7:  * This software is provided "AS IS" with no warranty of any kind,
alpar@7:  * express or implied, and with no claim as to its suitability for any
alpar@7:  * purpose.
alpar@7:  *
alpar@7:  */
alpar@7: 
alpar@7: #ifndef LEMON_BITS_INVALID_H
alpar@7: #define LEMON_BITS_INVALID_H
alpar@7: 
alpar@7: ///\file
alpar@7: ///\brief Definition of INVALID.
alpar@7: 
alpar@7: namespace lemon {
alpar@7: 
kpeter@13:   /// \brief Dummy type to make it easier to create invalid iterators.
alpar@7:   ///
kpeter@49:   /// Dummy type to make it easier to create invalid iterators.
alpar@7:   /// See \ref INVALID for the usage.
alpar@7:   struct Invalid {
alpar@7:   public:
alpar@7:     bool operator==(Invalid) { return true;  }
alpar@7:     bool operator!=(Invalid) { return false; }
alpar@7:     bool operator< (Invalid) { return false; }
alpar@7:   };
alpar@7:   
kpeter@13:   /// \brief Invalid iterators.
kpeter@13:   ///
alpar@7:   /// \ref Invalid is a global type that converts to each iterator
alpar@7:   /// in such a way that the value of the target iterator will be invalid.
alpar@7: 
alpar@7:   //Some people didn't like this:
alpar@7:   //const Invalid &INVALID = *(Invalid *)0;
alpar@7: 
alpar@7: #ifdef LEMON_ONLY_TEMPLATES
alpar@7:   const Invalid INVALID = Invalid();
alpar@7: #else
alpar@7:   extern const Invalid INVALID;
alpar@7: #endif
alpar@7: 
alpar@7: } //namespace lemon
alpar@7: 
alpar@7: #endif
alpar@7: