Whether this code is valid depends on what type i has and if i is a user-defined type whether operator ~ is overload such a way that it returns a lvalue.
If i has some fundamental type as for example int then the code shall not be compiled because ~i is prvalue.
EDIT: it is a very bad idea to remove the original post.