~zorba-coders/zorba/bug-857263-build-doc

« back to all changes in this revision

Viewing changes to src/util/stl_util.h

  • Committer: Tarmac
  • Author(s): Rodolfo Ochoa, Paul J. Lucas
  • Date: 2012-04-20 15:35:36 UTC
  • mfrom: (10784.1.4 bug986016)
  • Revision ID: tarmac-20120420153536-020pcn5jkd3ci9ry
Work-around for Windows compiler problem; see:
http://stackoverflow.com/questions/9285657/sfinae-differentiation-between-signed-and-unsigned Approved: Rodolfo Ochoa, Paul J. Lucas

Show diffs side-by-side

added added

removed removed

Lines of Context:
299
299
// cases where the "signed-ness" of N1 and N2 differ such that the code is
300
300
// warning-free.
301
301
//
 
302
// Note: the use of "!!" is to work around a compiler problem on Windows;
 
303
// see: http://stackoverflow.com/questions/9285657/sfinae-differentiation-between-signed-and-unsigned
 
304
//
302
305
 
303
306
template<typename N1,typename N2> inline
304
307
typename std::enable_if<ZORBA_TR1_NS::is_signed<N1>::value
309
312
 
310
313
template<typename N1,typename N2> inline
311
314
typename std::enable_if<ZORBA_TR1_NS::is_signed<N1>::value
312
 
                     && ZORBA_TR1_NS::is_unsigned<N2>::value,bool>::type
 
315
                     && !!ZORBA_TR1_NS::is_unsigned<N2>::value,bool>::type
313
316
ge_min( N1 n1, N2 ) {
314
317
  return n1 >= 0;
315
318
}
316
319
 
317
320
template<typename N1,typename N2> inline
318
 
typename std::enable_if<ZORBA_TR1_NS::is_unsigned<N1>::value
 
321
typename std::enable_if<!!ZORBA_TR1_NS::is_unsigned<N1>::value
319
322
                     && ZORBA_TR1_NS::is_signed<N2>::value,bool>::type
320
323
ge_min( N1, N2 ) {
321
324
  return true;
322
325
}
323
326
 
324
327
template<typename N1,typename N2> inline
325
 
typename std::enable_if<ZORBA_TR1_NS::is_unsigned<N1>::value
326
 
                     && ZORBA_TR1_NS::is_unsigned<N2>::value,bool>::type
 
328
typename std::enable_if<!!ZORBA_TR1_NS::is_unsigned<N1>::value
 
329
                     && !!ZORBA_TR1_NS::is_unsigned<N2>::value,bool>::type
327
330
ge_min( N1, N2 ) {
328
331
  return true;
329
332
}
337
340
 
338
341
template<typename N1,typename N2> inline
339
342
typename std::enable_if<ZORBA_TR1_NS::is_signed<N1>::value
340
 
                     && ZORBA_TR1_NS::is_unsigned<N2>::value,bool>::type
 
343
                     && !!ZORBA_TR1_NS::is_unsigned<N2>::value,bool>::type
341
344
le_max( N1 n1, N2 ) {
342
345
  return n1 <= 0 || static_cast<N2>( n1 ) <= std::numeric_limits<N2>::max();
343
346
}
344
347
 
345
348
template<typename N1,typename N2> inline
346
 
typename std::enable_if<ZORBA_TR1_NS::is_unsigned<N1>::value
 
349
typename std::enable_if<!!ZORBA_TR1_NS::is_unsigned<N1>::value
347
350
                     && ZORBA_TR1_NS::is_signed<N2>::value,bool>::type
348
351
le_max( N1 n1, N2 ) {
349
352
  return n1 <= static_cast<N1>( std::numeric_limits<N2>::max() );
350
353
}
351
354
 
352
355
template<typename N1,typename N2> inline
353
 
typename std::enable_if<ZORBA_TR1_NS::is_unsigned<N1>::value
354
 
                     && ZORBA_TR1_NS::is_unsigned<N2>::value,bool>::type
 
356
typename std::enable_if<!!ZORBA_TR1_NS::is_unsigned<N1>::value
 
357
                     && !!ZORBA_TR1_NS::is_unsigned<N2>::value,bool>::type
355
358
le_max( N1 n1, N2 ) {
356
359
  return n1 <= std::numeric_limits<N2>::max();
357
360
}