Fix clang compilation issue (#634) default tip
authorAlpar Juttner <alpar@cs.elte.hu>
Wed, 29 Jul 2020 14:56:10 +0200
changeset 1211a278d16bd2d0
parent 1210 da87dbdf3daf
Fix clang compilation issue (#634)
lemon/concepts/maps.h
     1.1 --- a/lemon/concepts/maps.h	Tue Jul 28 21:23:36 2020 +0200
     1.2 +++ b/lemon/concepts/maps.h	Wed Jul 29 14:56:10 2020 +0200
     1.3 @@ -49,7 +49,12 @@
     1.4  
     1.5        /// Returns the value associated with the given key.
     1.6        Value operator[](const Key &) const {
     1.7 -        return *(static_cast<Value *>(0)+1);
     1.8 +        // return *(static_cast<Value *>(0));
     1.9 +        // return *(static_cast<Value *>(0)+1);
    1.10 +        // return *(static_cast<Value *>(sizeof(Value)));
    1.11 +        // return *(reinterpret_cast<Value *>(0));
    1.12 +        // return *(reinterpret_cast<Value *>(0)+1);
    1.13 +        return *(reinterpret_cast<Value *>(sizeof(Value)));
    1.14        }
    1.15  
    1.16        template<typename _ReadMap>
    1.17 @@ -131,8 +136,7 @@
    1.18  
    1.19        /// Returns the value associated with the given key.
    1.20        Value operator[](const Key &) const {
    1.21 -        Value *r = 0;
    1.22 -        return *r;
    1.23 +        return *(reinterpret_cast<Value *>(sizeof(Value)));
    1.24        }
    1.25  
    1.26        /// Sets the value associated with the given key.
    1.27 @@ -172,14 +176,12 @@
    1.28  
    1.29        /// Returns a reference to the value associated with the given key.
    1.30        Reference operator[](const Key &) {
    1.31 -        Value *r = 0;
    1.32 -        return *r;
    1.33 +        return *(reinterpret_cast<Value *>(sizeof(Value)));
    1.34        }
    1.35  
    1.36        /// Returns a const reference to the value associated with the given key.
    1.37        ConstReference operator[](const Key &) const {
    1.38 -        Value *r = 0;
    1.39 -        return *r;
    1.40 +        return *(reinterpret_cast<Value *>(sizeof(Value)));
    1.41        }
    1.42  
    1.43        /// Sets the value associated with the given key.