Skip to content

Improve the __is_derived_from_optional concept  #63530

Closed
@mordante

Description

@mordante

Tested with
Clang version 17.0.0 (++20230624042319+ee2bf319bc05-1~exp1~20230624042420.1017)

The issue looks similar to #62943 but that fix is this version of Clang. Testing this code with libc++'s std module

import std;
  
int main(int, char**) {
  int t{3};
  std::optional<int> op{3};
  return op <=> t;
}

Gives the following compiler output

libcxx/test/std/utilities/optional/optional.comp_with_t/compare.three_way.pass.cpp:6:13: error: use of overloaded operator '<=>' is ambiguous (with operand types 'std::optional<int>' and 'int')
    6 |   return op <=> t;
      |          ~~ ^   ~
/llvm/build/generic-module-std-cxx23/include/c++/v1/optional:1612:1: note: candidate function [with _Tp = int, _Up = int]
 1612 | operator<=>(const optional<_Tp>& __x, const _Up& __v) {
      | ^
/llvm/build/generic-module-std-cxx23/include/c++/v1/optional:1612:1: note: candidate function [with _Tp = int, _Up = int]
 1612 | operator<=>(const optional<_Tp>& __x, const _Up& __v) {
      | ^
/llvm/build/generic-module-std-cxx23/include/c++/v1/optional:1612:1: note: candidate function [with _Tp = int, _Up = int]
 1612 | operator<=>(const optional<_Tp>& __x, const _Up& __v) {
      | ^
/llvm/build/generic-module-std-cxx23/include/c++/v1/optional:1612:1: note: candidate function [with _Tp = int, _Up = int]
 1612 | operator<=>(const optional<_Tp>& __x, const _Up& __v) {
      | ^
/llvm/build/generic-module-std-cxx23/include/c++/v1/optional:1612:1: note: candidate function [with _Tp = int, _Up = int]
 1612 | operator<=>(const optional<_Tp>& __x, const _Up& __v) {
      | ^
1 error generated.

error: command failed with exit status: 1

This is a manual reduction of the file libcxx/test/std/utilities/optional/optional.comp_with_t/compare.three_way.pass.cpp

Metadata

Metadata

Assignees

Labels

libc++libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions