microsoft / microsoft/wil

Replace static_lazy<> with normal statics

Open
#471 3 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

improvement
Dominant language
C++
Stars
3k
Forks
300
Avg merge
19h 12m
Merged PRs (30d)
1

Description

https://github.com/microsoft/wil/blob/eb9eb355d6de431311d7f5ea3590c72d53741ccc/include/wil/Tracelogging.h#L188-L204

According to https://learn.microsoft.com/en-us/cpp/cpp/storage-classes-cpp?view=msvc-170, function-local "magic statics" are fully supported.

Instead of defining a custom static_lazy type, use the built-in support.

  1. Remove static_lazy<>
  2. On line 2283ish in the Instance() method:
static TraceLoggingClassName* Instance() WI_NOEXCEPT \
{ \
    static TraceLoggingClassName wrapper; \
    return wrapper; \
} \
friend class wil::details::static_lazy<TraceLoggingClassName>;

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with include/wil/Tracelogging.h at lines 188-204 and inspect the Instance() method around line 2283. Replace the custom static_lazy usage with the supported function-local static as described, then verify that the custom type and its friendship are no longer needed. Done means the requested references have been removed without changing the wrapper's behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
operating-systems
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.