"Fossies" - the Fresh Open Source Software Archive

Member "gama-2.05/lib/matvec/unsigned.h" (10 May 2019, 1507 Bytes) of package /linux/privat/gama-2.05.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "unsigned.h" see the Fossies "Dox" file reference documentation.

    1 /* GNU Gama -- adjustment of geodetic networks
    2    Copyright (C) 2014, 2018  Ales Cepek <cepek@gnu.org>
    3 
    4    This file is part of the GNU Gama C++ library.
    5 
    6    This library is free software; you can redistribute it and/or modify
    7    it under the terms of the GNU General Public License as published by
    8    the Free Software Foundation; either version 3, or (at your option)
    9    any later version.
   10 
   11    This program is distributed in the hope that it will be useful,
   12    but WITHOUT ANY WARRANTY; without even the implied warranty of
   13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   14    GNU General Public License for more details.
   15 
   16    You should have received a copy of the GNU General Public License
   17    along with GNU Gama.  If not, see <http://www.gnu.org/licenses/>.
   18 */
   19 
   20 /** \file unsigned.h
   21  * \brief Helper functions replacing tests like "k < 0" where k may be
   22  * unsigned and the condition is always true aand produces compiler warnings
   23  * (similarly "k >= 0")
   24  *
   25  * \author Ales Cepek
   26  */
   27 
   28 #ifndef GNU_gama_matvec_unsigned_h_UNSIGNED_h
   29 #define GNU_gama_matvec_unsigned_h_UNSIGNED_h
   30 
   31 template<typename T> inline bool isNegative(T i) { return i < 0; }
   32 
   33 template<> inline bool isNegative<unsigned short>(unsigned short) { return false; }
   34 template<> inline bool isNegative<unsigned int  >(unsigned int  ) { return false; }
   35 template<> inline bool isNegative<unsigned long >(unsigned long ) { return false; }
   36 
   37 template <typename T> inline bool isNonNegative(T i) { return !isNegative(i); }
   38 
   39 #endif