From 1ab86305c15fe0ab080282e83b07e24ebb0f0bb7 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Fri, 2 Nov 2018 15:20:29 -0700 Subject: coding guidelines: Add .at() vs [] comment --- CODING.md | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'CODING.md') diff --git a/CODING.md b/CODING.md index 774e7d079..7b2dda931 100644 --- a/CODING.md +++ b/CODING.md @@ -84,6 +84,11 @@ Date: Tue Nov 22 16:19:38 2016 -0800 Reviewed-By: Martin Braun ``` +* Prefer `.at()` over `[]` for maps and vectors. Keep in mind that `[]` will + invoke a default constructor of the value type, whereas `.at()` will throw + an exception if the index doesn't exist -- which is usually the desired + behaviour. + ## Boost-specific Guidelines -- cgit v1.2.3