]> git.apps.os.sepia.ceph.com Git - ceph.git/commit
osd: fix argument-dependent lookup of swap() 15124/head
authorCasey Bodley <cbodley@redhat.com>
Tue, 16 May 2017 22:18:47 +0000 (18:18 -0400)
committerCasey Bodley <cbodley@redhat.com>
Tue, 16 May 2017 22:47:04 +0000 (18:47 -0400)
commita21d411c9c5e1a277224ef1908d9a97cdf9805ca
tree1e3400fb3139b32ea5dc5029ebbbfddfad100e94
parent6f1bf0dd9b57362ffa8d4bdff3641ae87c6674ea
osd: fix argument-dependent lookup of swap()

because include/types.h has a 'using namespace std', the call to
::swap() had previously been selecting overloads from namespace std. but
once any other swap() functions are present in the global namespace,
argument-dependent lookup [1] will not consider those from std

for example, when common/sstring.hh has been included, its global swap()
function is the only overload considered, so calls to ::swap() result in
errors like this:

/home/cbodley/ceph/src/osd/osd_types.h: In member function ‘void ObjectModDesc::swap(ObjectModDesc&)’:
/home/cbodley/ceph/src/osd/osd_types.h:3135:56: error: no matching function for call to ‘swap(bool&, bool&)’
     ::swap(other.can_local_rollback, can_local_rollback);
                                                        ^
/home/cbodley/ceph/src/common/sstring.hh:589:6: note: candidate: template<class char_type, class size_type, size_type max_size> void swap(basic_sstring<char_type, size_type, Max>&, basic_sstring<char_type, size_type, Max>&)
 void swap(basic_sstring<char_type, size_type, max_size>& x,
      ^
/home/cbodley/ceph/src/common/sstring.hh:589:6: note:   template argument deduction/substitution failed:
/home/cbodley/ceph/src/osd/osd_types.h:3135:56: note:   mismatched types ‘basic_sstring<char_type, size_type, Max>’ and ‘bool’
     ::swap(other.can_local_rollback, can_local_rollback);

adding a `using std::swap;` to the calling scope and removing :: from
the call to `swap()` allows argument-dependent lookup to resolve the
overloads in both namespaces

[1] http://en.cppreference.com/w/cpp/language/adl

Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/osd/osd_types.cc
src/osd/osd_types.h