For example, let's say I have a function swap as follows:
class A {
// all member variables and member functions are defined.
// Given that A deleted both copy constructor and
// overloaded assignment operator for some trivial reasons
A(const A&) = delete;
A& operator=(const A &) = delete;
};
template<typename T>
void swap (T &a, T &b) {
T temp;
temp = a;
a = b;
b = temp;
}
Now I want swap() to work for all types other than objects of type A, this is because as I have some trivial reasons for which A have not implemented overloaded assignment operator or copy constructors.
For such cases can we write some assertion or exception handling so that we should get an error when swap() function is used for objects of type A.
If we can do this in both compile time and run time, please do state the both, it will help me understanding more.