1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#pragma once

#include <utility>
#include <functional><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.

#include "internal/dev_env.hpp"


namespace uni {


template<class> struct virtual_combined_map {};

template<class Mapped, class... Keys>
struct virtual_combined_map<Mapped(Keys...)> {
    using key_type = std::tuple<Keys...>;
    using mapped_type = Mapped;
    using value_type = std::pair<key_type,mapped_type>;

  protected:
    std::function<Mapped(Keys...)> _f;

  public:
    virtual_combined_map() = default;

    template<class F>
    explicit virtual_combined_map(F&& f) noexcept(NO_EXCEPT) : _f(f) {};

    inline const auto* get_functor() const noexcept(NO_EXCEPT) { return this->_f; }
    inline auto* get_functor() noexcept(NO_EXCEPT) { return this->_f; }

    template<class F>
    inline auto& set_functor(F&& f) const noexcept(NO_EXCEPT) { return this->_f = f; }

    inline mapped_type operator()(const Keys&... key) const noexcept(NO_EXCEPT) {
        return this->_f(key...);
    }

    inline mapped_type operator[](const key_type& key) const noexcept(NO_EXCEPT) {<--- Parent function 'virtual_combined_map::operator[]'
        return std::apply(this->_f, key);
    }
};

template<class Key, class Mapped>
struct virtual_map : virtual_combined_map<Mapped(Key)> {
    using key_type = Key;
    using mapped_type = Mapped;
    using value_type = std::pair<key_type,mapped_type>;

    using virtual_combined_map<mapped_type(key_type)>::virtual_combined_map;

    inline mapped_type operator[](const key_type& key) const noexcept(NO_EXCEPT) {<--- Derived function 'virtual_map::operator[]'
        return this->_f(key);
    }
};

}; // namesapce uni