The following code

```
#include <vector>
#include <string>
#include <iostream>

std::string const& at(std::vector<std::string> const& n, int i)
{
    return n[i];
}

std::vector<std::string> mkvec()
{
    std::vector<std::string> n;
    n.push_back("kagami");
    n.push_back("misao");
    return n;
}

int main()
{
    std::string const& s = at(mkvec(), 0);
    std::cout << s << std::endl; // D'oh!
    return 0;
}

```

may lead to crash because the original vector is already destructed there. In C++ 2011 (c++0x) after rvalue-reference is introduced in, a **deleted function** declaration can be used to completely forbid calls to `at` if the vector argument is an rvalue

```
std::string const& at(std::vector<std::string>&&, int) = delete;

```

That looks good, but the following code still cause crash

```
int main()
{
    std::string const& s = mkvec()[0];
    std::cout << s << std::endl; // D'oh!
    return 0;
}

```

because calls to member function `operator [] (size_type) const` of an rvalue object is still allowed. Is there any way can I forbid this kind of calls?

FIX:

The examples above is not what I did in real projects. I just wonder if C++ 2011 support any member function qualifying like

```
class A {
    void func() rvalue; // Then a call on an rvalue object goes to this overload
    void func() const;
};

```

FIX:

It's great, but I think C++ standard goes too far at this feature. Anyway, I have following code compiled on clang++ 2.9

```
#include <cstdio>

struct A {
    A() {}

    void func() &
    {
        puts("a");
    }

    void func() &&
    {
        puts("b");
    }

    void func() const &
    {
        puts("c");
    }
};

int main()
{
    A().func();
    A a;
    a.func();
    A const b;
    b.func();
    return 0;
}

```

Thanks a lot!