Question: I am writing a class that needs to support both volatile and non-volatile instances (volatile instances use atomic operations, non-volatile instances use regular operations), and am wondering if I am going about it in the correct way. Here's a snippit of the class declaration so far:

```
class Yield {
public:
    Yield();
    Yield(Yield const &other);
    Yield(Yield const volatile &other);

    Yield &operator=(Yield const &other);
    Yield &operator=(Yield const volatile &other);

    Yield &operator+=(Yield const &other);
    Yield &operator+=(Yield const volatile &other);
    Yield volatile &operator+=(Yield const &other) volatile;
    Yield volatile &operator+=(Yield const volatile &other) volatile;

    // Other operators snipped...
};

```

* Question 1: When compiling with MSVC, I get the following warning:

`warning C4521: 'util::Yield' : multiple copy constructors specified`

Does this warning portend any problems in using this class? Or can it be safely ignored?
* Question 2: As it stands, all operators are overloaded for both a volatile and non-volatile `other` argument. I assume this is necessary in order to avoid slower volatile accesses for non-volatile instances? Is there an alternative to allow each method to be coded only twice (volatile lhs and non-volatile lhs) rather than 4 times (volatile and non-volatile lhs, each with volatile and non-volatile rhs)?

I hope putting these questions together is ok, otherwise please leave a comment and I can split them.
Thanks!

Answer: 
[Volatile does not do what you think it does](https://stackoverflow.com/questions/6866206/volatile-and-createthread/6866927#6866927).

Even with VC++'s special, non-standard `volatile` behavior, it results in slower code than writing it properly. Use `std::atomic`, or if that's not available then you've probably got platform-specific barrier, fence, and atomic intrinsics. VC++ has `_ReadWriteBarrier` and `_Interlocked` functions to help you.
> 
> The class has multiple copy constructors of a single type. This warning is informational; the constructors are callable in your program.
> 
> 
> 

From the msdn website: [Compiler Warning (level 3) C4521](http://msdn.microsoft.com/en-us/library/e02fwk4s.aspx)