diff --git a/README.md b/README.md
index 598915f..e83392a 100644
--- a/README.md
+++ b/README.md
@@ -112,7 +112,12 @@ At default, *expected lite* uses `std::expected` if it is available and lets you
Define this to `nsel_EXPECTED_STD` to select `std::expected` as `nonstd::expected`. Define this to `nsel_EXPECTED_NONSTD` to select `nonstd::expected` as `nonstd::expected`. Default is undefined, which has the same effect as defining to `nsel_EXPECTED_DEFAULT`.
-Dnsel\_P0323R=7 *(default)*
-Define this to the proposal revision number to control the presence and behavior of features (see tables). Default is 7 for the latest revision.
+Define this to the proposal revision number to control the presence and behavior of features (see tables). Default is 7 for the latest revision.
+
+#### Define `WIN32_LEAN_AND_MEAN`
+
+-Dnsel\_CONFIG\_WIN32\_LEAN\_AND\_MEAN=1
+Define this to 0 if you want to omit automatic definition of `WIN32_LEAN_AND_MEAN`. Default is 1 when `_MSC_VER` is present.
#### Disable C++ exceptions
diff --git a/include/nonstd/expected.hpp b/include/nonstd/expected.hpp
index c3ee641..b58b20a 100644
--- a/include/nonstd/expected.hpp
+++ b/include/nonstd/expected.hpp
@@ -81,6 +81,12 @@
# define nsel_P2505R 5
#endif
+// Lean and mean inclusion of Windows.h, if applicable; default on for MSVC:
+
+#if !defined(nsel_CONFIG_WIN32_LEAN_AND_MEAN) && defined(_MSC_VER)
+# define nsel_CONFIG_WIN32_LEAN_AND_MEAN 1
+#endif
+
// Control presence of C++ exception handling (try and auto discover):
#ifndef nsel_CONFIG_NO_EXCEPTIONS
@@ -277,6 +283,12 @@ namespace nonstd {
// additional includes:
+#if nsel_CONFIG_WIN32_LEAN_AND_MEAN
+# ifndef WIN32_LEAN_AND_MEAN
+# define WIN32_LEAN_AND_MEAN
+# endif
+#endif
+
#if nsel_CONFIG_NO_EXCEPTIONS
# if nsel_CONFIG_NO_EXCEPTIONS_SEH
# include // for ExceptionCodes
diff --git a/test/expected-main.t.cpp b/test/expected-main.t.cpp
index 690662a..581322c 100644
--- a/test/expected-main.t.cpp
+++ b/test/expected-main.t.cpp
@@ -10,6 +10,9 @@
#define expected_PRESENT( x ) \
std::cout << #x << ": " << x << "\n"
+#define expected_DEFINED( x ) \
+ std::cout << #x << ": (defined)\n"
+
#define expected_ABSENT( x ) \
std::cout << #x << ": (undefined)\n"
@@ -35,7 +38,7 @@ CASE( "expected-lite version" "[.expected][.version]" )
expected_PRESENT( expected_lite_VERSION );
}
-CASE( "any configuration" "[.expected][.config]" )
+CASE( "expected-lite configuration" "[.expected][.config]" )
{
expected_PRESENT( nsel_HAVE_STD_EXPECTED );
expected_PRESENT( nsel_USES_STD_EXPECTED );
@@ -43,7 +46,9 @@ CASE( "any configuration" "[.expected][.config]" )
expected_PRESENT( nsel_EXPECTED_NONSTD );
expected_PRESENT( nsel_EXPECTED_STD );
expected_PRESENT( nsel_CONFIG_SELECT_EXPECTED );
+ expected_PRESENT( nsel_CONFIG_WIN32_LEAN_AND_MEAN );
expected_PRESENT( nsel_CONFIG_NO_EXCEPTIONS );
+ expected_PRESENT( nsel_CONFIG_NO_EXCEPTIONS_SEH );
expected_PRESENT( nsel_CPLUSPLUS );
}
@@ -84,6 +89,12 @@ CASE( "presence of C++ library features" "[.stdlibrary]" )
std::cout << "(Presence of C++ library features not available: using std::expected)\n";
#else
+#ifdef WIN32_LEAN_AND_MEAN
+ expected_DEFINED( WIN32_LEAN_AND_MEAN );
+#else
+ expected_ABSENT( WIN32_LEAN_AND_MEAN );
+#endif
+
#ifdef __cpp_exceptions
expected_PRESENT( __cpp_exceptions );
#else