1 /****************************************************************/ 2 /* Parallel Combinatorial BLAS Library (for Graph Computations) */ 3 /* version 1.6 -------------------------------------------------*/ 4 /* date: 6/15/2017 ---------------------------------------------*/ 5 /* authors: Ariful Azad, Aydin Buluc --------------------------*/ 6 /****************************************************************/ 7 /* 8 Copyright (c) 2010-2017, The Regents of the University of California 9 10 Permission is hereby granted, free of charge, to any person obtaining a copy 11 of this software and associated documentation files (the "Software"), to deal 12 in the Software without restriction, including without limitation the rights 13 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 copies of the Software, and to permit persons to whom the Software is 15 furnished to do so, subject to the following conditions: 16 17 The above copyright notice and this permission notice shall be included in 18 all copies or substantial portions of the Software. 19 20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 THE SOFTWARE. 27 */ 28 29 30 #ifndef _PROMOTE_H_ 31 #define _PROMOTE_H_ 32 33 #include "myenableif.h" 34 35 namespace combblas { 36 37 template <class T1, class T2, class Enable = void> 38 struct promote_trait { }; 39 40 // typename disable_if< is_boolean<NT>::value, NT >::type won't work, 41 // because then it will send Enable=NT which is different from the default template parameter 42 template <class NT> struct promote_trait< NT , bool, typename combblas::disable_if< combblas::is_boolean<NT>::value >::type > 43 { 44 typedef NT T_promote; 45 }; 46 template <class NT> struct promote_trait< bool , NT, typename combblas::disable_if< combblas::is_boolean<NT>::value >::type > 47 { 48 typedef NT T_promote; 49 }; 50 51 #define DECLARE_PROMOTE(A,B,C) \ 52 template <> struct promote_trait<A,B> \ 53 { \ 54 typedef C T_promote; \ 55 }; 56 DECLARE_PROMOTE(int64_t, bool, int64_t); 57 DECLARE_PROMOTE(int64_t, int, int64_t); 58 DECLARE_PROMOTE(bool, int64_t, int64_t); 59 DECLARE_PROMOTE(int, int64_t, int64_t); 60 DECLARE_PROMOTE(int64_t, int64_t, int64_t); 61 DECLARE_PROMOTE(int, bool,int); 62 DECLARE_PROMOTE(short, bool,short); 63 DECLARE_PROMOTE(unsigned, bool, unsigned); 64 DECLARE_PROMOTE(float, bool, float); 65 DECLARE_PROMOTE(double, bool, double); 66 DECLARE_PROMOTE(unsigned long long, bool, unsigned long long); 67 DECLARE_PROMOTE(bool, int, int); 68 DECLARE_PROMOTE(bool, short, short); 69 DECLARE_PROMOTE(bool, unsigned, unsigned); 70 DECLARE_PROMOTE(bool, float, float); 71 DECLARE_PROMOTE(bool, double, double); 72 DECLARE_PROMOTE(bool, unsigned long long, unsigned long long); 73 DECLARE_PROMOTE(bool, bool, bool); 74 DECLARE_PROMOTE(float, int, float); 75 DECLARE_PROMOTE(double, int, double); 76 DECLARE_PROMOTE(int, float, float); 77 DECLARE_PROMOTE(int, double, double); 78 DECLARE_PROMOTE(double, int64_t, double); 79 DECLARE_PROMOTE(int64_t, double, double); 80 DECLARE_PROMOTE(double, uint64_t, double); 81 DECLARE_PROMOTE(uint64_t, double, double); 82 DECLARE_PROMOTE(float, float, float); 83 DECLARE_PROMOTE(double, double, double); 84 DECLARE_PROMOTE(int, int, int); 85 DECLARE_PROMOTE(unsigned, unsigned, unsigned); 86 DECLARE_PROMOTE(unsigned long long, unsigned long long, unsigned long long); 87 88 } 89 90 #endif 91