--- description: "Learn more about the C26476 USE_VARIANT C++ Core Guidelines Checker warning. Use a type-safe alternative to union, which is preferred in modern code." title: Warning C26476 USE_VARIANT ms.date: 04/29/2022 f1_keywords: ["C26476", "USE_VARIANT"] helpviewer_keywords: ["C26476"] ms.assetid: bb2b3b26-9a84-4d81-8bae-ad9a5577c8a6 author: kylereedmsft ms.author: kylereed ms.custom: kr2b-contr-experiment --- # Warning C26476 > `std::variant` provides a type-safe alternative to `union` and should be preferred in modern code. [C++ Core Guideline for this warning](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Ru-naked)