| 
									
										
										
										
											2021-05-12 00:52:00 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | // A Scalar with internal representation T+1 so that zero is internally
 | 
					
						
							|  |  |  | // represented by T(1). This is used to test memory fill.
 | 
					
						
							|  |  |  | //
 | 
					
						
							| 
									
										
										
										
											2023-05-06 01:30:36 +08:00
										 |  |  | #pragma once
 | 
					
						
							| 
									
										
										
										
											2021-05-12 00:52:00 +08:00
										 |  |  | template <typename T> | 
					
						
							|  |  |  | class OffByOneScalar { | 
					
						
							|  |  |  |  public: | 
					
						
							|  |  |  |   OffByOneScalar() : val_(1) {} | 
					
						
							| 
									
										
										
										
											2023-05-06 01:30:36 +08:00
										 |  |  |   OffByOneScalar(const OffByOneScalar& other) = default; | 
					
						
							|  |  |  |   OffByOneScalar& operator=(const OffByOneScalar& other) = default; | 
					
						
							| 
									
										
										
										
											2023-12-06 05:22:55 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-12 00:52:00 +08:00
										 |  |  |   OffByOneScalar(T val) : val_(val + 1) {} | 
					
						
							|  |  |  |   OffByOneScalar& operator=(T val) { val_ = val + 1; } | 
					
						
							| 
									
										
										
										
											2023-12-06 05:22:55 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-12 00:52:00 +08:00
										 |  |  |   operator T() const { return val_ - 1; } | 
					
						
							| 
									
										
										
										
											2023-12-06 05:22:55 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-12 00:52:00 +08:00
										 |  |  |  private: | 
					
						
							|  |  |  |   T val_; | 
					
						
							|  |  |  | }; |