mirror of
				https://github.com/MaskRay/ccls.git
				synced 2025-11-03 22:04:24 +00:00 
			
		
		
		
	Fix some MSVC 2017 errors
Thanks to Dso Tsin!
This commit is contained in:
		
							parent
							
								
									cb06324c13
								
							
						
					
					
						commit
						c84895e39d
					
				@ -5,6 +5,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "serializer.hh"
 | 
					#include "serializer.hh"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <algorithm>
 | 
				
			||||||
#include <limits.h>
 | 
					#include <limits.h>
 | 
				
			||||||
#include <stdio.h>
 | 
					#include <stdio.h>
 | 
				
			||||||
#include <stdlib.h>
 | 
					#include <stdlib.h>
 | 
				
			||||||
@ -45,14 +46,10 @@ Range Range::FromString(const std::string &encoded) {
 | 
				
			|||||||
bool Range::Contains(int line, int column) const {
 | 
					bool Range::Contains(int line, int column) const {
 | 
				
			||||||
  if (line > INT16_MAX)
 | 
					  if (line > INT16_MAX)
 | 
				
			||||||
    return false;
 | 
					    return false;
 | 
				
			||||||
  Pos p{int16_t(line), int16_t(std::min(column, INT16_MAX))};
 | 
					  Pos p{(int16_t)line, (int16_t)std::min<int>(column, INT16_MAX)};
 | 
				
			||||||
  return !(p < start) && p < end;
 | 
					  return !(p < start) && p < end;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Range Range::RemovePrefix(Pos position) const {
 | 
					 | 
				
			||||||
  return {std::min(std::max(position, start), end), end};
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
std::string Range::ToString() {
 | 
					std::string Range::ToString() {
 | 
				
			||||||
  char buf[99];
 | 
					  char buf[99];
 | 
				
			||||||
  snprintf(buf, sizeof buf, "%d:%d-%d:%d", start.line + 1, start.column + 1,
 | 
					  snprintf(buf, sizeof buf, "%d:%d-%d:%d", start.line + 1, start.column + 1,
 | 
				
			||||||
 | 
				
			|||||||
@ -40,7 +40,6 @@ struct Range {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  bool Valid() const { return start.Valid(); }
 | 
					  bool Valid() const { return start.Valid(); }
 | 
				
			||||||
  bool Contains(int line, int column) const;
 | 
					  bool Contains(int line, int column) const;
 | 
				
			||||||
  Range RemovePrefix(Pos position) const;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  std::string ToString();
 | 
					  std::string ToString();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -64,12 +63,11 @@ void Reflect(Writer &visitor, Range &value);
 | 
				
			|||||||
namespace std {
 | 
					namespace std {
 | 
				
			||||||
template <> struct hash<ccls::Range> {
 | 
					template <> struct hash<ccls::Range> {
 | 
				
			||||||
  std::size_t operator()(ccls::Range x) const {
 | 
					  std::size_t operator()(ccls::Range x) const {
 | 
				
			||||||
    union U {
 | 
					    union {
 | 
				
			||||||
      ccls::Range range = {};
 | 
					      ccls::Range range;
 | 
				
			||||||
      uint64_t u64;
 | 
					      uint64_t u64;
 | 
				
			||||||
    } u;
 | 
					    } u{x};
 | 
				
			||||||
    static_assert(sizeof(ccls::Range) == 8);
 | 
					    static_assert(sizeof(ccls::Range) == 8);
 | 
				
			||||||
    u.range = x;
 | 
					 | 
				
			||||||
    return hash<uint64_t>()(u.u64);
 | 
					    return hash<uint64_t>()(u.u64);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user