1 /*************************************************************************** 2 * foxxll/common/types.hpp 3 * 4 * Part of FOXXLL. See http://foxxll.org 5 * 6 * Copyright (C) 2007 Roman Dementiev <dementiev@ira.uka.de> 7 * Copyright (C) 2010 Andreas Beckmann <beckmann@cs.uni-frankfurt.de> 8 * 9 * Distributed under the Boost Software License, Version 1.0. 10 * (See accompanying file LICENSE_1_0.txt or copy at 11 * http://www.boost.org/LICENSE_1_0.txt) 12 **************************************************************************/ 13 14 #ifndef FOXXLL_COMMON_TYPES_HEADER 15 #define FOXXLL_COMMON_TYPES_HEADER 16 17 #include <cstddef> 18 #include <cstdint> 19 #include <type_traits> 20 21 #include <foxxll/config.hpp> 22 23 namespace foxxll { 24 25 static_assert(sizeof(size_t) == 8, "FOXXLL supports only 64-bit builds"); 26 27 using external_size_type = uint64_t; // may require external memory 28 using external_diff_type = int64_t; // may require external memory 29 30 //! Return the given value casted to the corresponding unsigned type 31 template <typename Integral> as_unsigned(Integral value)32typename std::make_unsigned<Integral>::type as_unsigned(Integral value) 33 { 34 return static_cast<typename std::make_unsigned<Integral>::type>(value); 35 } 36 37 //! Return the given value casted to the corresponding signed type 38 template <typename Integral> as_signed(Integral value)39typename std::make_signed<Integral>::type as_signed(Integral value) 40 { 41 return static_cast<typename std::make_signed<Integral>::type>(value); 42 } 43 44 } // namespace foxxll 45 46 #endif // !FOXXLL_COMMON_TYPES_HEADER 47 48 /**************************************************************************/ 49