[ox/std] Add IString::unsafeResize
This commit is contained in:
		
							
								
								
									
										14
									
								
								deps/ox/src/ox/std/istring.hpp
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										14
									
								
								deps/ox/src/ox/std/istring.hpp
									
									
									
									
										vendored
									
									
								
							@@ -81,6 +81,11 @@ class IString {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		constexpr ox::Error resize(size_t sz) noexcept;
 | 
							constexpr ox::Error resize(size_t sz) noexcept;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							/**
 | 
				
			||||||
 | 
							 * Resizes without clearing memory between current end and new end.
 | 
				
			||||||
 | 
							 */
 | 
				
			||||||
 | 
							constexpr ox::Error unsafeResize(size_t sz) noexcept;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		/**
 | 
							/**
 | 
				
			||||||
		 * Returns the capacity of bytes for this string.
 | 
							 * Returns the capacity of bytes for this string.
 | 
				
			||||||
		 */
 | 
							 */
 | 
				
			||||||
@@ -220,6 +225,15 @@ constexpr ox::Error IString<StrCap>::resize(size_t sz) noexcept {
 | 
				
			|||||||
	return {};
 | 
						return {};
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					template<std::size_t StrCap>
 | 
				
			||||||
 | 
					constexpr ox::Error IString<StrCap>::unsafeResize(size_t sz) noexcept {
 | 
				
			||||||
 | 
						if (sz > StrCap) [[unlikely]] {
 | 
				
			||||||
 | 
							return OxError(1, "Trying to extend IString beyond its cap");
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						m_size = sz;
 | 
				
			||||||
 | 
						return {};
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
template<size_t sz>
 | 
					template<size_t sz>
 | 
				
			||||||
struct MaybeView<ox::IString<sz>> {
 | 
					struct MaybeView<ox::IString<sz>> {
 | 
				
			||||||
	using type = ox::StringView;
 | 
						using type = ox::StringView;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user