Skip to content

wil::reg::try_get_value() is gated by _OPTIONAL_ and __cpp_lib_optional, but can't be re-included #489

Open
@fredemmott

Description

WIL has several features where the features available from <wil/feature.hpp> depend on which headers have already been included; for the majority of these, you can include the header again, but this doesn't work for <wil/registry.h> as the entire file is gated with a traditional include guard for __WIL_REGISTRY_INCLUDED

Concretely, given how other parts of WIL work, I would expect this to work but it does not:

#include <wil/registry.h> // << works if I delete this line
#include <optional>
#include <wil/registry.h>

// ...

auto x = wil::reg::try_get_value<T>(key, name);

This is problematic when other a different header includes <registry.h>.

Suggested fixes:

  • use the same pattern you're using in other parts of WIL to allow re-inclusion
  • alternatively/additionally, add support for 'tweak headers'

As an example of tweak headers, wil/registry.h could start with:

#if __has_include(<wil-reg.tweaks.h>)
#include <wil-reg.tweaks.h>
#endif

I could then make a wil-reg.tweaks.h be included in my build, and include <optional> in that header.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    improvementSomething that would improve the repo in some way

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions