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

std::array not working with gcc-9.1 / c++17 #41

Closed
SimonEbner opened this issue Jun 27, 2019 · 0 comments · Fixed by #44
Closed

std::array not working with gcc-9.1 / c++17 #41

SimonEbner opened this issue Jun 27, 2019 · 0 comments · Fixed by #44

Comments

@SimonEbner
Copy link

SimonEbner commented Jun 27, 2019

The following piece of code fails to compile:

#include <vector>
#include <array>
#include <dbg.h>

int main() {
 std::array<unsigned int, 256> x{};
 dbg(x);
}

The problem boils down to

dbg.h: In substitution of ‘template<class T> using detect_size_t = decltype (dbg_macro::detail::{anonymous}::size(declval<T>())) [with T = std::array<unsigned int, 256>]’:
test.cc:12:39:   required from here
dbg.h:205:36: error: call of overloaded ‘size(std::array<unsigned int, 256>)’ is ambiguous
  205 | using detect_size_t = decltype(size(std::declval<T>()));
      |                                ~~~~^~~~~~~~~~~~~~~~~~~
dbg.h:189:16: note: candidate: ‘constexpr decltype (c.size()) dbg_macro::detail::{anonymous}::size(const T&) [with T = std::array<unsigned int, 256>; decltype (c.size()) = long unsigned int]’
  189 | constexpr auto size(const T& c) -> decltype(c.size()) {
      |                ^~~~
In file included from /usr/include/c++/9/string:54,
                 from /usr/include/c++/9/stdexcept:39,
                 from /usr/include/c++/9/array:39,
                 from test.cc:1:
/usr/include/c++/9/bits/range_access.h:242:5: note: candidate: ‘constexpr decltype (__cont.size()) std::size(const _Container&) [with _Container = std::array<unsigned int, 256>; decltype (__cont.size()) = long unsigned int]’
  242 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~

Changing line 204 from:

template <typename T>
using detect_size_t = decltype(size(std::declval<T>()));

to

template <typename T>
using detect_size_t = decltype(std::declval<T>().size());

solves the problem for me

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

Successfully merging a pull request may close this issue.

1 participant