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

formatter<string_view> incompatible with #include<variant> #861

Closed
jcelerier opened this issue Sep 15, 2018 · 2 comments
Closed

formatter<string_view> incompatible with #include<variant> #861

jcelerier opened this issue Sep 15, 2018 · 2 comments

Comments

@jcelerier
Copy link
Contributor

The following code works fine if #include <variant> is removed (tested with g++-8.2) :

#include <variant>
#include <fmt/format.h>

struct foo { };
namespace fmt
{
template <>
struct formatter<foo> final
    : formatter<string_view>
{
  template <typename ParseContext>
  constexpr auto parse(ParseContext &ctx) { return ctx.begin(); }

  template <typename FormatContext>
  auto format(const foo& e, FormatContext &ctx) {
    return formatter<string_view>::format("foo", ctx);
  }
};
}

int main() {
    fmt::format("{}", foo{});
}

The error is :

/usr/include/c++/8.2.1/variant: In instantiation of ‘constexpr decltype(auto) std::visit(_Visitor&&, _Variants&& ...) [with _Visitor = fmt::v5::arg_formatter<fmt::v5::output_range<std::back_insert_iterator<fmt::v5::internal::basic_buffer<char> >, char> >; _Variants = {fmt::v5::basic_format_arg<fmt::v5::basic_format_context<std::back_insert_iterator<fmt::v5::internal::basic_buffer<char> >, char> >}]’:
include/fmt/format.h:3234:17:   required from ‘decltype (ctx.out()) fmt::v5::formatter<T, Char, typename std::enable_if<fmt::v5::internal::format_type<typename fmt::v5::buffer_context<Char>::type, T>::value>::type>::format(const T&, FormatContext&) [with FormatContext = fmt::v5::basic_format_context<std::back_insert_iterator<fmt::v5::internal::basic_buffer<char> >, char>; T = fmt::v5::basic_string_view<char>; Char = char; typename std::enable_if<fmt::v5::internal::format_type<typename fmt::v5::buffer_context<Char>::type, T>::value>::type = void; decltype (ctx.out()) = std::back_insert_iterator<fmt::v5::internal::basic_buffer<char> >]’
test/array.cpp:16:53:   required from ‘auto fmt::v5::formatter<foo>::format(const foo&, FormatContext&) [with FormatContext = fmt::v5::basic_format_context<std::back_insert_iterator<fmt::v5::internal::basic_buffer<char> >, char>]’
include/fmt/core.h:580:5:   required from ‘static void fmt::v5::internal::value<Context>::format_custom_arg(const void*, Context&) [with T = foo; Context = fmt::v5::basic_format_context<std::back_insert_iterator<fmt::v5::internal::basic_buffer<char> >, char>]’
include/fmt/core.h:563:19:   required from ‘fmt::v5::internal::value<Context>::value(const T&) [with T = foo; Context = fmt::v5::basic_format_context<std::back_insert_iterator<fmt::v5::internal::basic_buffer<char> >, char>]’
include/fmt/core.h:591:58:   required from ‘constexpr fmt::v5::internal::init<Context, T, TYPE>::operator fmt::v5::internal::value<Context>() const [with Context = fmt::v5::basic_format_context<std::back_insert_iterator<fmt::v5::internal::basic_buffer<char> >, char>; T = const foo&; fmt::v5::internal::type TYPE = (fmt::v5::internal::type)13]’
include/fmt/core.h:995:35:   required from ‘typename std::enable_if<IS_PACKED, fmt::v5::internal::value<Context> >::type fmt::v5::internal::make_arg(const T&) [with bool IS_PACKED = true; Context = fmt::v5::basic_format_context<std::back_insert_iterator<fmt::v5::internal::basic_buffer<char> >, char>; T = foo; typename std::enable_if<IS_PACKED, fmt::v5::internal::value<Context> >::type = fmt::v5::internal::value<fmt::v5::basic_format_context<std::back_insert_iterator<fmt::v5::internal::basic_buffer<char> >, char> >]’
include/fmt/core.h:1053:51:   required from ‘fmt::v5::format_arg_store<Context, Args>::format_arg_store(const Args& ...) [with Context = fmt::v5::basic_format_context<std::back_insert_iterator<fmt::v5::internal::basic_buffer<char> >, char>; Args = {foo}]’
include/fmt/core.h:1383:40:   required from ‘std::__cxx11::basic_string<typename fmt::v5::internal::format_string_traits<S>::char_type> fmt::v5::format(const String&, const Args& ...) [with String = char [3]; Args = {foo}; typename fmt::v5::internal::format_string_traits<S>::char_type = char]’
test/array.cpp:22:28:   required from here
/usr/include/c++/8.2.1/variant:1375:23: error: ‘class fmt::v5::basic_format_arg<fmt::v5::basic_format_context<std::back_insert_iterator<fmt::v5::internal::basic_buffer<char> >, char> >’ has no member named ‘valueless_by_exception’
       if ((__variants.valueless_by_exception() || ...))
            ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/8.2.1/variant:1380:17: error: no matching function for call to ‘get<0>(fmt::v5::basic_format_arg<fmt::v5::basic_format_context<std::back_insert_iterator<fmt::v5::internal::basic_buffer<char> >, char> >)’
      std::get<0>(std::forward<_Variants>(__variants))...));
      ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/8.2.1/variant:37,
                 from test/array.cpp:1:
/usr/include/c++/8.2.1/utility:216:5: note: candidate: ‘template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(std::pair<_Tp1, _Tp2>&)’
     get(std::pair<_Tp1, _Tp2>& __in) noexcept
     ^~~
/usr/include/c++/8.2.1/utility:216:5: note:   template argument deduction/substitution failed:
In file included from test/array.cpp:1:
/usr/include/c++/8.2.1/variant:1380:17: note:   ‘fmt::v5::basic_format_arg<fmt::v5::basic_format_context<std::back_insert_iterator<fmt::v5::internal::basic_buffer<char> >, char> >’ is not derived from ‘std::pair<_Tp1, _Tp2>’
      std::get<0>(std::forward<_Variants>(__variants))...));
      ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/8.2.1/variant:37,
                 from test/array.cpp:1:
/usr/include/c++/8.2.1/utility:221:5: note: candidate: ‘template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&& std::get(std::pair<_Tp1, _Tp2>&&)’
     get(std::pair<_Tp1, _Tp2>&& __in) noexcept
     ^~~
/usr/include/c++/8.2.1/utility:221:5: note:   template argument deduction/substitution failed:
In file included from test/array.cpp:1:
/usr/include/c++/8.2.1/variant:1380:17: note:   ‘fmt::v5::basic_format_arg<fmt::v5::basic_format_context<std::back_insert_iterator<fmt::v5::internal::basic_buffer<char> >, char> >’ is not derived from ‘std::pair<_Tp1, _Tp2>’
      std::get<0>(std::forward<_Variants>(__variants))...));
      ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/8.2.1/variant:37,
                 from test/array.cpp:1:
/usr/include/c++/8.2.1/utility:226:5: note: candidate: ‘template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr const typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(const std::pair<_Tp1, _Tp2>&)’
     get(const std::pair<_Tp1, _Tp2>& __in) noexcept
     ^~~
/usr/include/c++/8.2.1/utility:226:5: note:   template argument deduction/substitution failed:
In file included from test/array.cpp:1:
/usr/include/c++/8.2.1/variant:1380:17: note:   ‘fmt::v5::basic_format_arg<fmt::v5::basic_format_context<std::back_insert_iterator<fmt::v5::internal::basic_buffer<char> >, char> >’ is not derived from ‘const std::pair<_Tp1, _Tp2>’
      std::get<0>(std::forward<_Variants>(__variants))...));
      ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/8.2.1/variant:37,
                 from test/array.cpp:1:
/usr/include/c++/8.2.1/utility:231:5: note: candidate: ‘template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr const typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&& std::get(const std::pair<_Tp1, _Tp2>&&)’
     get(const std::pair<_Tp1, _Tp2>&& __in) noexcept
     ^~~
/usr/include/c++/8.2.1/utility:231:5: note:   template argument deduction/substitution failed:
In file included from test/array.cpp:1:
/usr/include/c++/8.2.1/variant:1380:17: note:   ‘fmt::v5::basic_format_arg<fmt::v5::basic_format_context<std::back_insert_iterator<fmt::v5::internal::basic_buffer<char> >, char> >’ is not derived from ‘const std::pair<_Tp1, _Tp2>’
      std::get<0>(std::forward<_Variants>(__variants))...));
      ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/8.2.1/variant:37,
                 from test/array.cpp:1:
/usr/include/c++/8.2.1/utility:240:5: note: candidate: ‘template<class _Tp, class _Up> constexpr _Tp& std::get(std::pair<_T1, _T2>&)’
     get(pair<_Tp, _Up>& __p) noexcept
     ^~~
/usr/include/c++/8.2.1/utility:240:5: note:   template argument deduction/substitution failed:
/usr/include/c++/8.2.1/utility:245:5: note: candidate: ‘template<class _Tp, class _Up> constexpr const _Tp& std::get(const std::pair<_T1, _T2>&)’
     get(const pair<_Tp, _Up>& __p) noexcept
     ^~~
/usr/include/c++/8.2.1/utility:245:5: note:   template argument deduction/substitution failed:
/usr/include/c++/8.2.1/utility:250:5: note: candidate: ‘template<class _Tp, class _Up> constexpr _Tp&& std::get(std::pair<_T1, _T2>&&)’
     get(pair<_Tp, _Up>&& __p) noexcept
     ^~~
/usr/include/c++/8.2.1/utility:250:5: note:   template argument deduction/substitution failed:
/usr/include/c++/8.2.1/utility:255:5: note: candidate: ‘template<class _Tp, class _Up> constexpr const _Tp&& std::get(const std::pair<_T1, _T2>&&)’
     get(const pair<_Tp, _Up>&& __p) noexcept
     ^~~
/usr/include/c++/8.2.1/utility:255:5: note:   template argument deduction/substitution failed:
/usr/include/c++/8.2.1/utility:260:5: note: candidate: ‘template<class _Tp, class _Up> constexpr _Tp& std::get(std::pair<_Up, _Tp>&)’
     get(pair<_Up, _Tp>& __p) noexcept
     ^~~
/usr/include/c++/8.2.1/utility:260:5: note:   template argument deduction/substitution failed:
/usr/include/c++/8.2.1/utility:265:5: note: candidate: ‘template<class _Tp, class _Up> constexpr const _Tp& std::get(const std::pair<_Up, _Tp>&)’
     get(const pair<_Up, _Tp>& __p) noexcept
     ^~~
/usr/include/c++/8.2.1/utility:265:5: note:   template argument deduction/substitution failed:
/usr/include/c++/8.2.1/utility:270:5: note: candidate: ‘template<class _Tp, class _Up> constexpr _Tp&& std::get(std::pair<_Up, _Tp>&&)’
     get(pair<_Up, _Tp>&& __p) noexcept
     ^~~
/usr/include/c++/8.2.1/utility:270:5: note:   template argument deduction/substitution failed:
/usr/include/c++/8.2.1/utility:275:5: note: candidate: ‘template<class _Tp, class _Up> constexpr const _Tp&& std::get(const std::pair<_Up, _Tp>&&)’
     get(const pair<_Up, _Tp>&& __p) noexcept
     ^~~
/usr/include/c++/8.2.1/utility:275:5: note:   template argument deduction/substitution failed:
In file included from test/array.cpp:1:
/usr/include/c++/8.2.1/variant:1329:5: note: candidate: ‘template<long unsigned int _Np, class ... _Types> constexpr std::variant_alternative_t<_Np, std::variant<_Types ...> >& std::get(std::variant<_Types ...>&)’
     get(variant<_Types...>& __v)
     ^~~
/usr/include/c++/8.2.1/variant:1329:5: note:   template argument deduction/substitution failed:
/usr/include/c++/8.2.1/variant:1380:17: note:   ‘fmt::v5::basic_format_arg<fmt::v5::basic_format_context<std::back_insert_iterator<fmt::v5::internal::basic_buffer<char> >, char> >’ is not derived from ‘std::variant<_Types ...>’
      std::get<0>(std::forward<_Variants>(__variants))...));
      ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/8.2.1/variant:1340:5: note: candidate: ‘template<long unsigned int _Np, class ... _Types> constexpr std::variant_alternative_t<_Np, std::variant<_Types ...> >&& std::get(std::variant<_Types ...>&&)’
     get(variant<_Types...>&& __v)
     ^~~
/usr/include/c++/8.2.1/variant:1340:5: note:   template argument deduction/substitution failed:
/usr/include/c++/8.2.1/variant:1380:17: note:   ‘fmt::v5::basic_format_arg<fmt::v5::basic_format_context<std::back_insert_iterator<fmt::v5::internal::basic_buffer<char> >, char> >’ is not derived from ‘std::variant<_Types ...>’
      std::get<0>(std::forward<_Variants>(__variants))...));
      ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/8.2.1/variant:1351:5: note: candidate: ‘template<long unsigned int _Np, class ... _Types> constexpr std::variant_alternative_t<_Np, std::variant<_Types ...> >& std::get(const std::variant<_Types ...>&)’
     get(const variant<_Types...>& __v)
     ^~~
/usr/include/c++/8.2.1/variant:1351:5: note:   template argument deduction/substitution failed:
/usr/include/c++/8.2.1/variant:1380:17: note:   ‘fmt::v5::basic_format_arg<fmt::v5::basic_format_context<std::back_insert_iterator<fmt::v5::internal::basic_buffer<char> >, char> >’ is not derived from ‘const std::variant<_Types ...>’
      std::get<0>(std::forward<_Variants>(__variants))...));
      ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/8.2.1/variant:1362:5: note: candidate: ‘template<long unsigned int _Np, class ... _Types> constexpr std::variant_alternative_t<_Np, std::variant<_Types ...> >&& std::get(const std::variant<_Types ...>&&)’
     get(const variant<_Types...>&& __v)
     ^~~
/usr/include/c++/8.2.1/variant:1362:5: note:   template argument deduction/substitution failed:
/usr/include/c++/8.2.1/variant:1380:17: note:   ‘fmt::v5::basic_format_arg<fmt::v5::basic_format_context<std::back_insert_iterator<fmt::v5::internal::basic_buffer<char> >, char> >’ is not derived from ‘const std::variant<_Types ...>’
      std::get<0>(std::forward<_Variants>(__variants))...));
      ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/8.2.1/variant:881:27: note: candidate: ‘template<class _Tp, class ... _Types> constexpr _Tp& std::get(std::variant<_Types ...>&)’
     constexpr inline _Tp& get(variant<_Types...>& __v)
                           ^~~
/usr/include/c++/8.2.1/variant:881:27: note:   template argument deduction/substitution failed:
/usr/include/c++/8.2.1/variant:890:28: note: candidate: ‘template<class _Tp, class ... _Types> constexpr _Tp&& std::get(std::variant<_Types ...>&&)’
     constexpr inline _Tp&& get(variant<_Types...>&& __v)
                            ^~~
/usr/include/c++/8.2.1/variant:890:28: note:   template argument deduction/substitution failed:
/usr/include/c++/8.2.1/variant:900:33: note: candidate: ‘template<class _Tp, class ... _Types> constexpr const _Tp& std::get(const std::variant<_Types ...>&)’
     constexpr inline const _Tp& get(const variant<_Types...>& __v)
                                 ^~~
/usr/include/c++/8.2.1/variant:900:33: note:   template argument deduction/substitution failed:
/usr/include/c++/8.2.1/variant:909:34: note: candidate: ‘template<class _Tp, class ... _Types> constexpr const _Tp&& std::get(const std::variant<_Types ...>&&)’
     constexpr inline const _Tp&& get(const variant<_Types...>&& __v)
                                  ^~~
/usr/include/c++/8.2.1/variant:909:34: note:   template argument deduction/substitution failed:
/usr/include/c++/8.2.1/variant:1380:17: error: no matching function for call to ‘get<0>(fmt::v5::basic_format_arg<fmt::v5::basic_format_context<std::back_insert_iterator<fmt::v5::internal::basic_buffer<char> >, char> >)’
      std::get<0>(std::forward<_Variants>(__variants))...));
      ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/8.2.1/variant:37,
                 from test/array.cpp:1:
/usr/include/c++/8.2.1/utility:216:5: note: candidate: ‘template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(std::pair<_Tp1, _Tp2>&)’
     get(std::pair<_Tp1, _Tp2>& __in) noexcept
     ^~~
/usr/include/c++/8.2.1/utility:216:5: note:   template argument deduction/substitution failed:
In file included from test/array.cpp:1:
/usr/include/c++/8.2.1/variant:1380:17: note:   ‘fmt::v5::basic_format_arg<fmt::v5::basic_format_context<std::back_insert_iterator<fmt::v5::internal::basic_buffer<char> >, char> >’ is not derived from ‘std::pair<_Tp1, _Tp2>’
      std::get<0>(std::forward<_Variants>(__variants))...));
      ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/8.2.1/variant:37,
                 from test/array.cpp:1:
/usr/include/c++/8.2.1/utility:221:5: note: candidate: ‘template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&& std::get(std::pair<_Tp1, _Tp2>&&)’
     get(std::pair<_Tp1, _Tp2>&& __in) noexcept
     ^~~
/usr/include/c++/8.2.1/utility:221:5: note:   template argument deduction/substitution failed:
In file included from test/array.cpp:1:
/usr/include/c++/8.2.1/variant:1380:17: note:   ‘fmt::v5::basic_format_arg<fmt::v5::basic_format_context<std::back_insert_iterator<fmt::v5::internal::basic_buffer<char> >, char> >’ is not derived from ‘std::pair<_Tp1, _Tp2>’
      std::get<0>(std::forward<_Variants>(__variants))...));
      ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/8.2.1/variant:37,
                 from test/array.cpp:1:
/usr/include/c++/8.2.1/utility:226:5: note: candidate: ‘template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr const typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(const std::pair<_Tp1, _Tp2>&)’
     get(const std::pair<_Tp1, _Tp2>& __in) noexcept
     ^~~
/usr/include/c++/8.2.1/utility:226:5: note:   template argument deduction/substitution failed:
In file included from test/array.cpp:1:
/usr/include/c++/8.2.1/variant:1380:17: note:   ‘fmt::v5::basic_format_arg<fmt::v5::basic_format_context<std::back_insert_iterator<fmt::v5::internal::basic_buffer<char> >, char> >’ is not derived from ‘const std::pair<_Tp1, _Tp2>’
      std::get<0>(std::forward<_Variants>(__variants))...));
      ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/8.2.1/variant:37,
                 from test/array.cpp:1:
/usr/include/c++/8.2.1/utility:231:5: note: candidate: ‘template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr const typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&& std::get(const std::pair<_Tp1, _Tp2>&&)’
     get(const std::pair<_Tp1, _Tp2>&& __in) noexcept
     ^~~
/usr/include/c++/8.2.1/utility:231:5: note:   template argument deduction/substitution failed:
In file included from test/array.cpp:1:
/usr/include/c++/8.2.1/variant:1380:17: note:   ‘fmt::v5::basic_format_arg<fmt::v5::basic_format_context<std::back_insert_iterator<fmt::v5::internal::basic_buffer<char> >, char> >’ is not derived from ‘const std::pair<_Tp1, _Tp2>’
      std::get<0>(std::forward<_Variants>(__variants))...));
      ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/8.2.1/variant:37,
                 from test/array.cpp:1:
/usr/include/c++/8.2.1/utility:240:5: note: candidate: ‘template<class _Tp, class _Up> constexpr _Tp& std::get(std::pair<_T1, _T2>&)’
     get(pair<_Tp, _Up>& __p) noexcept
     ^~~
/usr/include/c++/8.2.1/utility:240:5: note:   template argument deduction/substitution failed:
/usr/include/c++/8.2.1/utility:245:5: note: candidate: ‘template<class _Tp, class _Up> constexpr const _Tp& std::get(const std::pair<_T1, _T2>&)’
     get(const pair<_Tp, _Up>& __p) noexcept
     ^~~
/usr/include/c++/8.2.1/utility:245:5: note:   template argument deduction/substitution failed:
/usr/include/c++/8.2.1/utility:250:5: note: candidate: ‘template<class _Tp, class _Up> constexpr _Tp&& std::get(std::pair<_T1, _T2>&&)’
     get(pair<_Tp, _Up>&& __p) noexcept
     ^~~
/usr/include/c++/8.2.1/utility:250:5: note:   template argument deduction/substitution failed:
/usr/include/c++/8.2.1/utility:255:5: note: candidate: ‘template<class _Tp, class _Up> constexpr const _Tp&& std::get(const std::pair<_T1, _T2>&&)’
     get(const pair<_Tp, _Up>&& __p) noexcept
     ^~~
/usr/include/c++/8.2.1/utility:255:5: note:   template argument deduction/substitution failed:
/usr/include/c++/8.2.1/utility:260:5: note: candidate: ‘template<class _Tp, class _Up> constexpr _Tp& std::get(std::pair<_Up, _Tp>&)’
     get(pair<_Up, _Tp>& __p) noexcept
     ^~~
/usr/include/c++/8.2.1/utility:260:5: note:   template argument deduction/substitution failed:
/usr/include/c++/8.2.1/utility:265:5: note: candidate: ‘template<class _Tp, class _Up> constexpr const _Tp& std::get(const std::pair<_Up, _Tp>&)’
     get(const pair<_Up, _Tp>& __p) noexcept
     ^~~
/usr/include/c++/8.2.1/utility:265:5: note:   template argument deduction/substitution failed:
/usr/include/c++/8.2.1/utility:270:5: note: candidate: ‘template<class _Tp, class _Up> constexpr _Tp&& std::get(std::pair<_Up, _Tp>&&)’
     get(pair<_Up, _Tp>&& __p) noexcept
     ^~~
/usr/include/c++/8.2.1/utility:270:5: note:   template argument deduction/substitution failed:
/usr/include/c++/8.2.1/utility:275:5: note: candidate: ‘template<class _Tp, class _Up> constexpr const _Tp&& std::get(const std::pair<_Up, _Tp>&&)’
     get(const pair<_Up, _Tp>&& __p) noexcept
     ^~~
/usr/include/c++/8.2.1/utility:275:5: note:   template argument deduction/substitution failed:
In file included from test/array.cpp:1:
/usr/include/c++/8.2.1/variant:1329:5: note: candidate: ‘template<long unsigned int _Np, class ... _Types> constexpr std::variant_alternative_t<_Np, std::variant<_Types ...> >& std::get(std::variant<_Types ...>&)’
     get(variant<_Types...>& __v)
     ^~~
/usr/include/c++/8.2.1/variant:1329:5: note:   template argument deduction/substitution failed:
/usr/include/c++/8.2.1/variant:1380:17: note:   ‘fmt::v5::basic_format_arg<fmt::v5::basic_format_context<std::back_insert_iterator<fmt::v5::internal::basic_buffer<char> >, char> >’ is not derived from ‘std::variant<_Types ...>’
      std::get<0>(std::forward<_Variants>(__variants))...));
      ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/8.2.1/variant:1340:5: note: candidate: ‘template<long unsigned int _Np, class ... _Types> constexpr std::variant_alternative_t<_Np, std::variant<_Types ...> >&& std::get(std::variant<_Types ...>&&)’
     get(variant<_Types...>&& __v)
     ^~~
/usr/include/c++/8.2.1/variant:1340:5: note:   template argument deduction/substitution failed:
/usr/include/c++/8.2.1/variant:1380:17: note:   ‘fmt::v5::basic_format_arg<fmt::v5::basic_format_context<std::back_insert_iterator<fmt::v5::internal::basic_buffer<char> >, char> >’ is not derived from ‘std::variant<_Types ...>’
      std::get<0>(std::forward<_Variants>(__variants))...));
      ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/8.2.1/variant:1351:5: note: candidate: ‘template<long unsigned int _Np, class ... _Types> constexpr std::variant_alternative_t<_Np, std::variant<_Types ...> >& std::get(const std::variant<_Types ...>&)’
     get(const variant<_Types...>& __v)
     ^~~
/usr/include/c++/8.2.1/variant:1351:5: note:   template argument deduction/substitution failed:
/usr/include/c++/8.2.1/variant:1380:17: note:   ‘fmt::v5::basic_format_arg<fmt::v5::basic_format_context<std::back_insert_iterator<fmt::v5::internal::basic_buffer<char> >, char> >’ is not derived from ‘const std::variant<_Types ...>’
      std::get<0>(std::forward<_Variants>(__variants))...));
      ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/8.2.1/variant:1362:5: note: candidate: ‘template<long unsigned int _Np, class ... _Types> constexpr std::variant_alternative_t<_Np, std::variant<_Types ...> >&& std::get(const std::variant<_Types ...>&&)’
     get(const variant<_Types...>&& __v)
     ^~~
/usr/include/c++/8.2.1/variant:1362:5: note:   template argument deduction/substitution failed:
/usr/include/c++/8.2.1/variant:1380:17: note:   ‘fmt::v5::basic_format_arg<fmt::v5::basic_format_context<std::back_insert_iterator<fmt::v5::internal::basic_buffer<char> >, char> >’ is not derived from ‘const std::variant<_Types ...>’
      std::get<0>(std::forward<_Variants>(__variants))...));
      ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/8.2.1/variant:881:27: note: candidate: ‘template<class _Tp, class ... _Types> constexpr _Tp& std::get(std::variant<_Types ...>&)’
     constexpr inline _Tp& get(variant<_Types...>& __v)
                           ^~~
/usr/include/c++/8.2.1/variant:881:27: note:   template argument deduction/substitution failed:
/usr/include/c++/8.2.1/variant:890:28: note: candidate: ‘template<class _Tp, class ... _Types> constexpr _Tp&& std::get(std::variant<_Types ...>&&)’
     constexpr inline _Tp&& get(variant<_Types...>&& __v)
                            ^~~
/usr/include/c++/8.2.1/variant:890:28: note:   template argument deduction/substitution failed:
/usr/include/c++/8.2.1/variant:900:33: note: candidate: ‘template<class _Tp, class ... _Types> constexpr const _Tp& std::get(const std::variant<_Types ...>&)’
     constexpr inline const _Tp& get(const variant<_Types...>& __v)
                                 ^~~
/usr/include/c++/8.2.1/variant:900:33: note:   template argument deduction/substitution failed:
/usr/include/c++/8.2.1/variant:909:34: note: candidate: ‘template<class _Tp, class ... _Types> constexpr const _Tp&& std::get(const std::variant<_Types ...>&&)’
     constexpr inline const _Tp&& get(const variant<_Types...>&& __v)
                                  ^~~
/usr/include/c++/8.2.1/variant:909:34: note:   template argument deduction/substitution failed:
/usr/include/c++/8.2.1/variant:1385:55: error: ‘class fmt::v5::basic_format_arg<fmt::v5::basic_format_context<std::back_insert_iterator<fmt::v5::internal::basic_buffer<char> >, char> >’ has no member named ‘index’
       auto __func_ptr = __vtable._M_access(__variants.index()...);
                                            ~~~~~~~~~~~^~~~~
In file included from test/array.cpp:2:
include/fmt/format.h: In instantiation of ‘decltype (ctx.out()) fmt::v5::formatter<T, Char, typename std::enable_if<fmt::v5::internal::format_type<typename fmt::v5::buffer_context<Char>::type, T>::value>::type>::format(const T&, FormatContext&) [with FormatContext = fmt::v5::basic_format_context<std::back_insert_iterator<fmt::v5::internal::basic_buffer<char> >, char>; T = fmt::v5::basic_string_view<char>; Char = char; typename std::enable_if<fmt::v5::internal::format_type<typename fmt::v5::buffer_context<Char>::type, T>::value>::type = void; decltype (ctx.out()) = std::back_insert_iterator<fmt::v5::internal::basic_buffer<char> >]’:
test/array.cpp:16:53:   required from ‘auto fmt::v5::formatter<foo>::format(const foo&, FormatContext&) [with FormatContext = fmt::v5::basic_format_context<std::back_insert_iterator<fmt::v5::internal::basic_buffer<char> >, char>]’
include/fmt/core.h:580:5:   required from ‘static void fmt::v5::internal::value<Context>::format_custom_arg(const void*, Context&) [with T = foo; Context = fmt::v5::basic_format_context<std::back_insert_iterator<fmt::v5::internal::basic_buffer<char> >, char>]’
include/fmt/core.h:563:19:   required from ‘fmt::v5::internal::value<Context>::value(const T&) [with T = foo; Context = fmt::v5::basic_format_context<std::back_insert_iterator<fmt::v5::internal::basic_buffer<char> >, char>]’
include/fmt/core.h:591:58:   required from ‘constexpr fmt::v5::internal::init<Context, T, TYPE>::operator fmt::v5::internal::value<Context>() const [with Context = fmt::v5::basic_format_context<std::back_insert_iterator<fmt::v5::internal::basic_buffer<char> >, char>; T = const foo&; fmt::v5::internal::type TYPE = (fmt::v5::internal::type)13]’
include/fmt/core.h:995:35:   required from ‘typename std::enable_if<IS_PACKED, fmt::v5::internal::value<Context> >::type fmt::v5::internal::make_arg(const T&) [with bool IS_PACKED = true; Context = fmt::v5::basic_format_context<std::back_insert_iterator<fmt::v5::internal::basic_buffer<char> >, char>; T = foo; typename std::enable_if<IS_PACKED, fmt::v5::internal::value<Context> >::type = fmt::v5::internal::value<fmt::v5::basic_format_context<std::back_insert_iterator<fmt::v5::internal::basic_buffer<char> >, char> >]’
include/fmt/core.h:1053:51:   required from ‘fmt::v5::format_arg_store<Context, Args>::format_arg_store(const Args& ...) [with Context = fmt::v5::basic_format_context<std::back_insert_iterator<fmt::v5::internal::basic_buffer<char> >, char>; Args = {foo}]’
include/fmt/core.h:1383:40:   required from ‘std::__cxx11::basic_string<typename fmt::v5::internal::format_string_traits<S>::char_type> fmt::v5::format(const String&, const Args& ...) [with String = char [3]; Args = {foo}; typename fmt::v5::internal::format_string_traits<S>::char_type = char]’
test/array.cpp:22:28:   required from here
include/fmt/format.h:3234:17: error: could not convert ‘std::visit<fmt::v5::arg_formatter<fmt::v5::output_range<std::back_insert_iterator<fmt::v5::internal::basic_buffer<char> >, char> >, fmt::v5::basic_format_arg<fmt::v5::basic_format_context<std::back_insert_iterator<fmt::v5::internal::basic_buffer<char> >, char> > >(fmt::v5::arg_formatter<fmt::v5::output_range<std::back_insert_iterator<fmt::v5::internal::basic_buffer<char> >, char> >((* & ctx), (&((fmt::v5::formatter<fmt::v5::basic_string_view<char> >*)this)->fmt::v5::formatter<fmt::v5::basic_string_view<char> >::specs_.fmt::v5::internal::dynamic_format_specs<char>::<anonymous>)), fmt::v5::internal::make_arg<fmt::v5::basic_format_context<std::back_insert_iterator<fmt::v5::internal::basic_buffer<char> >, char>, fmt::v5::basic_string_view<char> >((* & val)))’ from ‘void’ to ‘fmt::v5::internal::context_base<std::back_insert_iterator<fmt::v5::internal::basic_buffer<char> >, fmt::v5::basic_format_context<std::back_insert_iterator<fmt::v5::internal::basic_buffer<char> >, char>, char>::iterator’ {aka ‘std::back_insert_iterator<fmt::v5::internal::basic_buffer<char> >’}
     return visit(arg_formatter<range_type>(ctx, &specs_),
            ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                  internal::make_arg<FormatContext>(val));
                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[2]    5708 exit 1     LANG=C g++ test/array.cpp -I include -DFMT_HEADER_ONLY=1 -std=c++17
@vitaut
Copy link
Contributor

vitaut commented Sep 15, 2018

Should be fixed in 36c8d66. Thanks for reporting!

@jcelerier
Copy link
Contributor Author

ah, thanks for looking into it. I closed it because I noticed that on my machine I had two concurrent fmt, one in my repo and one in /usr/include installed by some package - removing the /usr/include one fixed my problems.

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

2 participants