GithubHelp home page GithubHelp logo

ofats / meta_evo Goto Github PK

View Code? Open in Web Editor NEW
9.0 0.0 1.0 6 KB

Presentation materials for C++Siberia 2019 conference

C++ 100.00%
cpp templates template-metaprogramming constexpr type-list variadic-arguments

meta_evo's People

Contributors

ofats avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

xray3d

meta_evo's Issues

Не работает в MSVC17 operator == и operator !=

main.cpp:82: ошибка: C2593: неоднозначный "operator =="
main.cpp:19: может быть
bool operator ==<int,double,char>(type_pack<int,double,char>,type_pack<int,double,char>)
main.cpp:17: или
bool operator ==<int,double,char,int,double,char>(type_pack<int,double,char>,type_pack<int,double,char>)
main.cpp:83: при попытке сопоставить список аргументов
(type_pack<int,double,char>, type_pack<int,double,char>)

Я решил так.
template <class... Ts, class... Us, class T = disable_if_t<std::is_same_v<Ts..., Us...>>>
constexpr bool operator==(type_pack<Ts...>, type_pack<Us...>) { return false; }
`

Ошибка в MSVC17 в constexpr bool contains(type_pack<Ts...>)

main.cpp:180: ошибка: C2466: невозможно выделить память для массива постоянного нулевого размера
bool bs[]{ std::is_same<T, Ts>::value... };

Моё решение.

namespace good {

    // type-based
    template <class T, class... Ts>
    constexpr bool contains(type_pack<Ts...>)
    {
        bool res = false;
        if constexpr (sizeof...(Ts) > 0)
            bool bs[]{ std::is_same<T, Ts>::value... };
            for (bool b : bs) {
                res |= b;
            }
        }            
        return res;
    }
...

} // namespace good

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.