-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Closed
Labels
Description
The compiler is failing to find an appropriate overload for the fmt::join function that works with std::vector<int> or other
std::vector<xxx>.
Environment:
- MSVC 17.0
- CMake 3.30.2
- ninja 1.11.1
Error message:
C:\Users\leenhawk\Workspace\stamp2\main.cpp(137): error C2672: 'fmt::v11::join': no matching overloaded function found
C:\Users\leenhawk\Workspace\stamp2\cmake-build-debug\_deps\fmt-src\include\fmt\xchar.h(157): note: it could be 'fmt::v11::tuple_join_view<wchar_t,T...> fmt::v11::join(const std::tuple<_Types...> &,fmt::v11::basic_string_view<wchar_t>)'
C:\Users\leenhawk\Workspace\stamp2\main.cpp(137): note: 'fmt::v11::tuple_join_view<wchar_t,T...> fmt::v11::join(const std::tuple<_Types...> &,fmt::v11::basic_string_view<wchar_t>)': cannot deduce 'const std::tuple<_Types...> &' from 'const std::vector<std::string,std::allocator<std::string>>'
C:\Users\leenhawk\Workspace\stamp2\cmake-build-debug\_deps\fmt-src\include\fmt\xchar.h(151): note: or 'fmt::v11::join_view<const T*,const T*,wchar_t> fmt::v11::join(std::initializer_list<_Elem>,fmt::v11::basic_string_view<wchar_t>)'
C:\Users\leenhawk\Workspace\stamp2\main.cpp(137): note: 'fmt::v11::join_view<const T*,const T*,wchar_t> fmt::v11::join(std::initializer_list<_Elem>,fmt::v11::basic_string_view<wchar_t>)': cannot deduce 'std::initializer_list<_Elem>' from 'const std::vector<std::string,std::allocator<std::string>>'
C:\Users\leenhawk\Workspace\stamp2\cmake-build-debug\_deps\fmt-src\include\fmt\xchar.h(144): note: or 'fmt::v11::join_view<unknown-type,unknown-type,wchar_t> fmt::v11::join(Range &&,fmt::v11::basic_string_view<wchar_t>)'
C:\Users\leenhawk\Workspace\stamp2\main.cpp(137): note: 'initialization': cannot convert 'const char [3]' to 'fmt::v11::basic_string_view<wchar_t>'
C:\Users\leenhawk\Workspace\stamp2\main.cpp(137): note: 'fmt::v11::basic_string_view<wchar_t>::basic_string_view': no overloaded function can convert all argument types
C:\Users\leenhawk\Workspace\stamp2\cmake-build-debug\_deps\fmt-src\include\fmt\base.h(521): note: it could be 'fmt::v11::basic_string_view<wchar_t>::basic_string_view(const Char *)'
with
[
Char=wchar_t
]
C:\Users\leenhawk\Workspace\stamp2\main.cpp(137): note: 'fmt::v11::basic_string_view<wchar_t>::basic_string_view(const Char *)': cannot convert argument 1 from 'const char [3]' to 'const Char *'
with
[
Char=wchar_t
]
C:\Users\leenhawk\Workspace\stamp2\main.cpp(137): note: types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style castThe minimal reproducal example:
CMakeLists.txt
cmake_minimum_required(VERSION 3.30 FATAL_ERROR)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD "0e5b6991-d74f-4b3d-a41c-cf096e0b2508")
set(CMAKE_CXX_MODULE_STD 1)
project(main LANGUAGES CXX)
add_executable(main main.cpp)
include(FetchContent)
FetchContent_Declare(
fmt
GIT_REPOSITORY https://github.com/fmtlib/fmt
GIT_TAG 0c9fce2ffefecfdce794e1859584e25877b7b592) # 11.0.2
FetchContent_MakeAvailable(fmt)
#target_link_libraries(main fmt::fmt)
target_sources(main
PUBLIC FILE_SET CXX_MODULES
FILES
${fmt_SOURCE_DIR}/src/fmt.cc
)
target_include_directories(main PRIVATE ${fmt_SOURCE_DIR}/include)main.cpp
import fmt;
import std;
int main(int argc, char* argv[])
{
auto v = std::vector<int>{1, 2, 3};
fmt::print("{}", fmt::join(v, ", "));
return 0;
}