Skip to content

<spanstream>: Constructing ispanstream from string no longer compiles since VS 17.13 #5308

@Morddin

Description

@Morddin
C:\Dev>type repro.cpp
#include <string>
#include <spanstream>

int main()
{
   std::string s;
   std::ispanstream{s};
}
C:\Dev>cl /std:c++latest repro.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.43.34808 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

/std:c++latest is provided as a preview of language features from the latest C++
working draft, and we're eager to hear about bugs and suggestions for improvements.
However, note that these features are provided as-is without support, and subject
to changes or removal as the working draft evolves. See
https://go.microsoft.com/fwlink/?linkid=2045807 for details.

repro.cpp
repro.cpp(7): error C2440: '<function-style-cast>': cannot convert from 'initializer list' to 'std::ispanstream'
repro.cpp(7): note: 'std::basic_ispanstream<char,std::char_traits<char>>::basic_ispanstream': ambiguous call to overloaded function
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.43.34808\include\spanstream(210): note: could be 'std::basic_ispanstream<char,std::char_traits<char>>::basic_ispanstream(std::span<const _Elem,18446744073709551615>)'
        with
        [
            _Elem=char
        ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.43.34808\include\spanstream(207): note: or       'std::basic_ispanstream<char,std::char_traits<char>>::basic_ispanstream(std::span<_Elem,18446744073709551615>,std::ios_base::openmode)'
        with
        [
            _Elem=char
        ]
repro.cpp(7): note: while trying to match the argument list '(std::string)'

This regression is caused by #4938.

Note that std::ispanstream{std::as_const(s)} or std::ispanstream{std::span{s}} works correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfixedSomething works now, yay!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions