пользовательский литеральный оператор не найден (EOS-Docs-Smart Contract Development Data-Persistence) - PullRequest
0 голосов
/ 15 апреля 2020

После Сохранение данных EOS DOCS выдает ошибку. Ошибка запуталась, когда люди говорят: «Пользовательский литеральный оператор не найден»

typedef eosio::multi_index<"people"_n, person> address_index;

Версии

  • eosio 2.0.0
  • eosio.cdt 1.6.3
  • Ubuntu 16.04

Полный код см. Здесь

#include <eosio/eosio.hpp>

using namespace eosio;

class [[eosio::contract("addressbook")]] addressbook : public eosio::contract
{

public:
    addressbook(name receiver, name code, datastream<const char *> ds) : contract(receiver, code, ds) {}

    [[eosio::action]] void upsert(
        name user,
        std::string first_name,
        std::string last_name,
        std::string street,
        std::string city,
        std::string state)
    {
        require_auth(user);
        address_index addresses(get_self(), get_first_receiver().value);
        auto iterator = addresses.find(user.value);
        if (iterator == addresses.end())
        {
            addresses.emplace(user, [&](auto &row) {
                row.key = user;
                row.first_name = first_name;
                row.last_name = last_name;
                row.street = street;
                row.city = city;
                row.state = state;
            });
        }
        else
        {
            addresses.modify(iterator, user, [&](auto &row) {
                row.key = user;
                row.first_name = first_name;
                row.last_name = last_name;
                row.street = street;
                row.city = city;
                row.state = state;
            });
        }
    }

    [[eosio::action]] void erase(name user)
    {
        require_auth(user);

        address_index addresses(get_self(), get_first_receiver().value);

        auto iterator = addresses.find(user.value);
        check(iterator != addresses.end(), "Record does not exist");
        addresses.erase(iterator);
    }

private:
    struct [[eosio::table]] person
    {
        name key;
        std::string first_name;
        std::string last_name;
        std::string street;
        std::string city;
        std::string state;
        uint64_t primary_key() const { return key.value; }
    };
    typedef eosio::multi_index<"people"_n, person> address_index;
};
...