mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 16:22:43 +00:00 
			
		
		
		
	Everywhere: Mark Vector of mutable references as mutable
The point of a reference type is to behave just like the referred-to type. So, a Foo& should behave just like a Foo. In these cases, we had a const Vector. If it was a const Vector of Foo, iterating over the Vector would only permit taking const references to the individual Foos. However, we had a const Vector of Foo&. The behavior should not change. We should still only be permitted to take const references to the individual Foos. Otherwise, we would be allowed to mutate the individual Foos, which would mutate the elements of the const Vector. This wouldn't modify the stored pointers, but it would modify the objects that the references refer to. Since references should be transparent, this should not be legal. So it should be impossible to get mutable references into a const Vector. Since we need mutable references in these cases to call the mutating member functions, we need to mark the Vector as mutable as well.
This commit is contained in:
		
							parent
							
								
									294cbb7108
								
							
						
					
					
						commit
						19d9d5bfe1
					
				
					 4 changed files with 4 additions and 4 deletions
				
			
		|  | @ -698,7 +698,7 @@ NonnullRefPtr<GUI::Widget> build_performance_tab() | |||
|             cpu_graphs.append(cpu_graph); | ||||
|         } | ||||
|     } | ||||
|     ProcessModel::the().on_cpu_info_change = [cpu_graphs](const NonnullOwnPtrVector<ProcessModel::CpuInfo>& cpus) { | ||||
|     ProcessModel::the().on_cpu_info_change = [cpu_graphs](const NonnullOwnPtrVector<ProcessModel::CpuInfo>& cpus) mutable { | ||||
|         float sum_cpu = 0; | ||||
|         for (size_t i = 0; i < cpus.size(); ++i) { | ||||
|             cpu_graphs[i].add_value({ static_cast<size_t>(cpus[i].total_cpu_percent), static_cast<size_t>(cpus[i].total_cpu_percent_kernel) }); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 creator1creeper1
						creator1creeper1