Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Missing operator < for permission_level #655

Closed
conr2d opened this issue Sep 4, 2019 · 0 comments
Closed

Missing operator < for permission_level #655

conr2d opened this issue Sep 4, 2019 · 0 comments

Comments

@conr2d
Copy link
Contributor

conr2d commented Sep 4, 2019

operator < is not overloaded for permission_level, so some std containers of permission_level is not usable.

test.cpp:

#include <eosio/eosio.hpp>
#include <eosio/permission.hpp>

using namespace eosio;

class [[eosio::contract]] test : public contract {
public:
   using contract::contract;

   [[eosio::action]]
   void hi(permission_level p) {
      std::set<permission_level> s;
      s.insert(p);
   }
};

result:

$ eosio-cpp -o test.wasm test.cpp
In file included from /home/conr2d/contracts/test/test.cpp:1:
In file included from /usr/opt/eosio.cdt/1.6.2/bin/../include/eosiolib/contracts/eosio/eosio.hpp:6:
In file included from /usr/opt/eosio.cdt/1.6.2/bin/../include/eosiolib/contracts/eosio/../../contracts/eosio/action.hpp:9:
In file included from /usr/opt/eosio.cdt/1.6.2/bin/../include/eosiolib/core/eosio/datastream.hpp:6:
In file included from /usr/opt/eosio.cdt/1.6.2/bin/../include/eosiolib/contracts/eosio/../../core/eosio/check.hpp:8:
In file included from /usr/opt/eosio.cdt/1.6.2/bin/../include/libcxx/string:470:
In file included from /usr/opt/eosio.cdt/1.6.2/bin/../include/libcxx/string_view:169:
In file included from /usr/opt/eosio.cdt/1.6.2/bin/../include/libcxx/__string:56:
In file included from /usr/opt/eosio.cdt/1.6.2/bin/../include/libcxx/algorithm:643:
In file included from /usr/opt/eosio.cdt/1.6.2/bin/../include/libcxx/memory:650:
In file included from /usr/opt/eosio.cdt/1.6.2/bin/../include/libcxx/iterator:427:
/usr/opt/eosio.cdt/1.6.2/bin/../include/libcxx/__functional_base:55:21: error: invalid operands to binary expression ('const eosio::permission_level' and 'const eosio::permission_level')
        {return __x < __y;}
                ~~~ ^ ~~~
/usr/opt/eosio.cdt/1.6.2/bin/../include/libcxx/__tree:2007:17: note: in instantiation of member function 'std::__1::less<eosio::permission_level>::operator()' requested here
            if (value_comp()(__v, __nd->__value_))
                ^
/usr/opt/eosio.cdt/1.6.2/bin/../include/libcxx/__tree:2131:36: note: in instantiation of function template specialization 'std::__1::__tree<eosio::permission_level, std::__1::less<eosio::permission_level>, std::__1::allocator<eosio::permission_level> >::__find_equal<eosio::permission_level>' requested here
    __node_base_pointer& __child = __find_equal(__parent, __k);
                                   ^
/usr/opt/eosio.cdt/1.6.2/bin/../include/libcxx/__tree:1273:16: note: in instantiation of function template specialization 'std::__1::__tree<eosio::permission_level, std::__1::less<eosio::permission_level>, std::__1::allocator<eosio::permission_level> >::__emplace_unique_key_args<eosio::permission_level, const eosio::permission_level &>' requested here
        return __emplace_unique_key_args(_NodeTypes::__get_key(__v), __v);
               ^
/usr/opt/eosio.cdt/1.6.2/bin/../include/libcxx/set:599:25: note: in instantiation of member function 'std::__1::__tree<eosio::permission_level, std::__1::less<eosio::permission_level>, std::__1::allocator<eosio::permission_level> >::__insert_unique' requested here
        {return __tree_.__insert_unique(__v);}
                        ^
/home/conr2d/contracts/test/test.cpp:13:9: note: in instantiation of member function 'std::__1::set<eosio::permission_level, std::__1::less<eosio::permission_level>, std::__1::allocator<eosio::permission_level> >::insert' requested here
      s.insert(p);
        ^
/usr/opt/eosio.cdt/1.6.2/bin/../include/libcxx/utility:567:1: note: candidate template ignored: could not match 'pair<type-parameter-0-0, type-parameter-0-1>' against 'const eosio::permission_level'
operator< (const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
^
/usr/opt/eosio.cdt/1.6.2/bin/../include/eosiolib/core/eosio/fixed_bytes.hpp:323:9: note: candidate template ignored: could not match 'fixed_bytes<Size>' against 'const eosio::permission_level'
   bool operator <(const fixed_bytes<Size> &c1, const fixed_bytes<Size> &c2) {
        ^
Warning, empty ricardian clause file
Warning, empty ricardian clause file
Warning, action <hi> does not have a ricardian contract
1 error generated.
Error while processing /home/conr2d/contracts/test/test.cpp.
abigen error
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant