Кресты / Говнокод #24652 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
class TaxStorage {
public:
  using TaxCode = Code<3>; // Code<int N, typename Storage = uint32_t> тип для маленьких строк
  using TaxType = Code<3>;
  using TaxId = std::tuple<TaxCode, TaxType>;
  using TaxMap = std::map<TaxId, int>

  using CityId = int;
  using TaxPointMap = std::unordered_map<CityId, TaxMap>;

  TaxMap forCityOrOther(const TaxPointMap& map, const CityId cityId) const {
    const auto found = map.find(cityId);
    return found == map.cend() ? map.at(OTHER_CITY) : *found; // должно быть found->second
  }
}

Dev: Ok GCC, tell me what is wrong.
GCC: /home/whatever/project/TaxStorage.h:102: error: incompatible operand types ('const std::unordered_map<int, std::map<std::tuple<Code<3, unsigned int>, Code<3, unsigned int> >, std::vector<unsigned long, std::allocator<unsigned long> >, std::less<std::tuple<Code<3, unsigned int>, Code<3, unsigned int> > >, std::allocator<std::pair<const std::tuple<Code<3, unsigned int>, Code<3, unsigned int> >, std::vector<unsigned long, std::allocator<unsigned long> > > > >, std::hash<int>, std::equal_to<int>, std::allocator<std::pair<const int, std::map<std::tuple<Code<3, unsigned int>, Code<3, unsigned int> >, std::vector<unsigned long, std::allocator<unsigned long> >, std::less<std::tuple<Code<3, unsigned int>, Code<3, unsigned int> > >, std::allocator<std::pair<const std::tuple<Code<3, unsigned int>, Code<3, unsigned int> >, std::vector<unsigned long, std::allocator<unsigned long> > > > > > > >::mapped_type' (aka 'const std::map<std::tuple<Code<3, unsigned int>, Code<3, unsigned int> >, std::vector<unsigned long, std::allocator<unsigned long> >, std::less<std::tuple<Code<3, unsigned int>, Code<3, unsigned int> > >, std::allocator<std::pair<const std::tuple<Code<3, unsigned int>, Code<3, unsigned int> >, std::vector<unsigned long, std::allocator<unsigned long> > > > >') and 'const std::pair<const int, std::map<std::tuple<Code<3, unsigned int>, Code<3, unsigned int> >, std::vector<unsigned long, std::allocator<unsigned long> >, std::less<std::tuple<Code<3, unsigned int>, Code<3, unsigned int> > >, std::allocator<std::pair<const std::tuple<Code<3, unsigned int>, Code<3, unsigned int> >, std::vector<unsigned long, std::allocator<unsigned long> > > > > >')

ДОКОЛЕ?!!

Запостил: Elvenfighter Elvenfighter, (Updated )

Комментарии (3) RSS

  • В глазах рябит. Кто-нибудь дочитал сообщение об ошибке до конца?
    Ответить
    • Было бы хорошо например так:

      /home/whatever/project/TaxStorage.h:102: error: incompatible operand types 'const TaxStorage::TaxMap&' and 'const TaxPointMap::value_type'
      /home/whatever/project/TaxStorage.h:102: note: with 'const TaxStorage::TaxMap&' being 'const std::unordered_map<int, std::map<std::tuple<Code<3, unsigned int>, Code<3, unsigned int> >, std::vector<unsigned long, std::allocator<unsigned long> >, std::less<std::tuple<Code<3, unsigned int>, Code<3, unsigned int> > >, std::allocator<std::pair<const std::tuple<Code<3, unsigned int>, Code<3, unsigned int> >, std::vector<unsigned long, std::allocator<unsigned long> > > > >, std::hash<int>, std::equal_to<int>, std::allocator<std::pair<const int, std::map<std::tuple<Code<3, unsigned int>, Code<3, unsigned int> >, std::vector<unsigned long, std::allocator<unsigned long> >, std::less<std::tuple<Code<3, unsigned int>, Code<3, unsigned int> > >, std::allocator<std::pair<const std::tuple<Code<3, unsigned int>, Code<3, unsigned int> >, std::vector<unsigned long, std::allocator<unsigned long> > > > > > > >::mapped_type' (aka 'const std::map<std::tuple<Code<3, unsigned int>, Code<3, unsigned int> >, std::vector<unsigned long, std::allocator<unsigned long> >, std::less<std::tuple<Code<3, unsigned int>, Code<3, unsigned int> > >, std::allocator<std::pair<const std::tuple<Code<3, unsigned int>, Code<3, unsigned int> >, std::vector<unsigned long, std::allocator<unsigned long> > > > >'
      /home/whatever/project/TaxStorage.h:102: note: with 'const TaxMap::value_type' being 'const std::pair<const int, std::map<std::tuple<Code<3, unsigned int>, Code<3, unsigned int> >, std::vector<unsigned long, std::allocator<unsigned long> >, std::less<std::tuple<Code<3, unsigned int>, Code<3, unsigned int> > >, std::allocator<std::pair<const std::tuple<Code<3, unsigned int>, Code<3, unsigned int> >, std::vector<unsigned long, std::allocator<unsigned long> > > > > >'
      Ответить
      • Да, так было бы понятнее. В оригинальном сообщении я глаза сломал, пока нашёл союз “and”, а уж чем отличается первый тип от второго, невозможно понять без рекурсивного разбора.
        Ответить

Добавить комментарий

Переведи на "PHP", guest!

    А не использовать ли нам bbcode?


    8