Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
XRay3D opened this issue Apr 15, 2020 · 0 comments
Open

Comments

@XRay3D
Copy link

XRay3D commented Apr 15, 2020

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant