From f604be760defb0cae25b072c0fd4a78685380f73 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Wed, 14 Aug 2013 18:15:52 -0700 Subject: [PATCH] Add helper function for maps. Signed-off-by: Leonardo de Moura --- src/util/map.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/util/map.h diff --git a/src/util/map.h b/src/util/map.h new file mode 100644 index 0000000000..702d164c84 --- /dev/null +++ b/src/util/map.h @@ -0,0 +1,22 @@ +/* +Copyright (c) 2013 Microsoft Corporation. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. + +Author: Leonardo de Moura +*/ +#pragma once +#include + +namespace lean { +/** + \brief Helper function for inserting k->v into the map \c m. +*/ +template +void insert(M & m, typename M::key_type const & k, typename M::mapped_type const & v) { + auto p = m.insert(std::make_pair(k, v)); + if (!p.second) { + // m already contains an entry with key \c k. + p.first->second = v; + } +} +}