Skip to content

Commit e7b3ade

Browse files
committed
Workaround for Visual Studio loss of CV qualifier bug
1 parent 1f661f5 commit e7b3ade

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

src/util/sharing_map.h

+13-16
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ Author: Daniel Poetzl
3939
CV typename sharing_mapt<keyT, valueT, hashT, predT>::ST \
4040
sharing_mapt<keyT, valueT, hashT, predT>
4141

42+
// Note: Due to a bug in Visual Studio we need to add an additional "const"
43+
// qualifier to the return values of insert(), place(), and find(). The type
44+
// defined in sharing_mapt already includes the const qualifier, but it is lost
45+
// when accessed from outside the class. This is fixed in Visual Studio 15.6.
46+
4247
/// A map implemented as a tree where subtrees can be shared between different
4348
/// maps.
4449
///
@@ -673,10 +678,8 @@ SHARING_MAPT2(, size_type)::erase_all(
673678
/// (possible values `false` or `unknown`)
674679
/// \return Pair of const reference to existing or newly inserted element, and
675680
/// boolean indicating if new element was inserted
676-
SHARING_MAPT2(, const_find_type)::insert(
677-
const key_type &k,
678-
const mapped_type &m,
679-
const tvt &key_exists)
681+
SHARING_MAPT2(const, const_find_type)
682+
::insert(const key_type &k, const mapped_type &m, const tvt &key_exists)
680683
{
681684
_sn_assert(!key_exists.is_true());
682685

@@ -697,9 +700,8 @@ SHARING_MAPT2(, const_find_type)::insert(
697700
}
698701

699702
// Insert element, return const reference
700-
SHARING_MAPT2(, const_find_type)::insert(
701-
const value_type &p,
702-
const tvt &key_exists)
703+
SHARING_MAPT2(const, const_find_type)
704+
::insert(const value_type &p, const tvt &key_exists)
703705
{
704706
return insert(p.first, p.second, key_exists);
705707
}
@@ -714,9 +716,7 @@ SHARING_MAPT2(, const_find_type)::insert(
714716
/// \param m: The mapped value to insert
715717
/// \return Pair of reference to existing or newly inserted element, and boolean
716718
/// indicating if new element was inserted
717-
SHARING_MAPT2(, find_type)::place(
718-
const key_type &k,
719-
const mapped_type &m)
719+
SHARING_MAPT2(const, find_type)::place(const key_type &k, const mapped_type &m)
720720
{
721721
node_type *c=get_container_node(k);
722722
_sm_assert(c!=nullptr);
@@ -733,8 +733,7 @@ SHARING_MAPT2(, find_type)::place(
733733
}
734734

735735
/// Insert element, return non-const reference
736-
SHARING_MAPT2(, find_type)::place(
737-
const value_type &p)
736+
SHARING_MAPT2(const, find_type)::place(const value_type &p)
738737
{
739738
return place(p.first, p.second);
740739
}
@@ -750,9 +749,7 @@ SHARING_MAPT2(, find_type)::place(
750749
/// (possible values `unknown` or `true`)
751750
/// \return Pair of reference to found value (or dummy value if not found), and
752751
/// boolean indicating if element was found.
753-
SHARING_MAPT2(, find_type)::find(
754-
const key_type &k,
755-
const tvt &key_exists)
752+
SHARING_MAPT2(const, find_type)::find(const key_type &k, const tvt &key_exists)
756753
{
757754
_sm_assert(!key_exists.is_false());
758755

@@ -778,7 +775,7 @@ SHARING_MAPT2(, find_type)::find(
778775
/// \param k: The key of the element to search
779776
/// \return Pair of const reference to found value (or dummy value if not
780777
/// found), and boolean indicating if element was found.
781-
SHARING_MAPT2(, const_find_type)::find(const key_type &k) const
778+
SHARING_MAPT2(const, const_find_type)::find(const key_type &k) const
782779
{
783780
const node_type *p=get_leaf_node(k);
784781

0 commit comments

Comments
 (0)