brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · 64c20ae Raw
49 lines · cpp
1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9// test forward10 11#include <utility>12 13#include "test_macros.h"14 15struct A16{17};18 19A source() {return A();}20const A csource() {return A();}21 22int main(int, char**)23{24    {25        (void)std::forward<A&>(source());  // expected-note {{requested here}}26        // expected-error-re@*:* 1 {{static assertion failed{{.*}}cannot forward an rvalue as an lvalue}}27    }28    {29        const A ca = A();30        std::forward<A&>(ca); // expected-error {{no matching function for call to 'forward'}}31    }32    {33        std::forward<A&>(csource());  // expected-error {{no matching function for call to 'forward'}}34    }35    {36        const A ca = A();37        std::forward<A>(ca); // expected-error {{no matching function for call to 'forward'}}38    }39    {40        std::forward<A>(csource()); // expected-error {{no matching function for call to 'forward'}}41    }42    {43        A a;44        std::forward(a); // expected-error {{no matching function for call to 'forward'}}45    }46 47  return 0;48}49