6

Suppose I want to make a new deduction guide making the following possible ?

std::string str;
std::basic_string_view sv = str;

Would that be an Ok customization ?

L. F.
  • 19,445
  • 8
  • 48
  • 82
darune
  • 10,480
  • 2
  • 24
  • 62

1 Answers1

15

[namespace.std]/2.4:

The behavior of a C++ program is undefined if it declares [...] a deduction guide for any standard library class template.

L. F.
  • 19,445
  • 8
  • 48
  • 82
  • Will leave the question open to see if anyone has a workaround as well. – darune Nov 22 '19 at 11:31
  • 3
    @darune Probably not. There is no user-defined type involved in the declaration `std::basic_string_view sv = str;`, so I don't think it's customizable. Maybe define your own `auto sv = view(str);`? – L. F. Nov 22 '19 at 11:57
  • 1
    @darune: Marking an answer as accepted does not "close" the question; people can (and do) still post answers on such questions. – Nicol Bolas Nov 22 '19 at 14:22