stack_buf improvement after code review
This commit is contained in:
		@@ -24,10 +24,10 @@ public:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    stack_buf& operator=(const stack_buf& other) = delete;
 | 
					    stack_buf& operator=(const stack_buf& other) = delete;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    stack_buf(const stack_buf& other):stack_buf(other, false)
 | 
					    stack_buf(const stack_buf& other):stack_buf(other, delegate_copy_move{})
 | 
				
			||||||
    {}
 | 
					    {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    stack_buf(stack_buf&& other):stack_buf(other, true)
 | 
					    stack_buf(stack_buf&& other):stack_buf(other, delegate_copy_move{})
 | 
				
			||||||
    {        
 | 
					    {        
 | 
				
			||||||
        other.clear();
 | 
					        other.clear();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -89,15 +89,13 @@ public:
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
 | 
						struct delegate_copy_move {};
 | 
				
			||||||
	template<class T1>
 | 
						template<class T1>
 | 
				
			||||||
	stack_buf(T1&& other, bool is_rval)
 | 
						stack_buf(T1&& other, delegate_copy_move)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		_stack_size = other._stack_size;
 | 
							_stack_size = other._stack_size;
 | 
				
			||||||
        if (other.vector_used())
 | 
					        if (other.vector_used())
 | 
				
			||||||
		{
 | 
					            _v = std::forward<T1>(other)._v;
 | 
				
			||||||
			_v = is_rval? std::move(other._v) : other._v;
 | 
					 | 
				
			||||||
            //_v = std::forward<T1>(other)._v;
 | 
					 | 
				
			||||||
		}	
 | 
					 | 
				
			||||||
        else
 | 
					        else
 | 
				
			||||||
            std::copy_n(other._stack_array.begin(), other._stack_size, _stack_array.begin());        
 | 
					            std::copy_n(other._stack_array.begin(), other._stack_size, _stack_array.begin());        
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user