Add support for incomplete types by localspook · Pull Request #4383 · fmtlib/fmt · GitHub
Skip to content

Add support for incomplete types - #4383

Closed
localspook wants to merge 2 commits into
fmtlib:masterfrom
localspook:incomplete_types
Closed

Add support for incomplete types#4383
localspook wants to merge 2 commits into
fmtlib:masterfrom
localspook:incomplete_types

Conversation

@localspook

@localspook localspook commented Mar 12, 2025

Copy link
Copy Markdown
Contributor

This just requires replacing the view base with an is_view type trait that can be queried on incomplete types.

Fixes #3180.

@vitaut vitaut left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. Overall looks good but let's not introduce a new test binary just for this and instead add a test case to format-test (I don't think we need to test interaction with color).

@localspook

Copy link
Copy Markdown
Contributor Author

@vitaut vitaut left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking more of it, it's quite convenient to inherit from view. I suggest keeping it by defaulting is_view to a SFINAE-friendly equivalent to is_base_of, something like:

struct view {};

template <typename T, typename Enable = void>
struct is_view : std::false_type {};

template <typename T>
struct is_view<
  T, std::void_t<decltype(static_cast<view&>(std::declval<T&>()))>>
    : std::true_type {};

@vitaut

vitaut commented Apr 20, 2025

Copy link
Copy Markdown
Contributor

@vitaut vitaut closed this Apr 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support Incomplete Types, somehow

2 participants