Seamlessly migrating  to
A modification of @Jerry's answer:

#pragma once

#if __has_include(&lt;optional&gt;)

#   include &lt;optional&gt;
namespace stdx {
  using namespace ::std;
}
#elif __has_include(&lt;experimental/optional&gt;)
#   include &lt;experimental/optional&gt;
namespace stdx {
  using namespace ::std;
  using namespace ::std::experimental;
}

#else
#   error &lt;experimental/optional&gt; and &lt;optional&gt; not found
#endif


this has the advantage that the same namespace can be used for all "experimental" features (stdx).

So stdx::optional and stdx::variant both work.

We have to only using namespace ::std::experimental; after at least one &lt;experimental/ header is included, as if it does not exist that is ill formed, and introducing one ourselves also makes the program ill formed.