Skip to content

Add include for std_optional in date_time.hpp#297

Closed
dwithun-dev wants to merge 1 commit intomarzer:masterfrom
dwithun-dev:patch-1
Closed

Add include for std_optional in date_time.hpp#297
dwithun-dev wants to merge 1 commit intomarzer:masterfrom
dwithun-dev:patch-1

Conversation

@dwithun-dev
Copy link
Copy Markdown
Contributor

@dwithun-dev dwithun-dev commented Apr 14, 2026

At line 337 my clang++-21 was confused where the optional came from (absel::optional? or std::optional?), i added the header and it worked for me. I installed the library from "apt", it worked for me for like a week but i don't know why my compiler started throwing me the error.

/usr/include/toml++/impl/date_time.hpp:337:3: error: no template named 'optional'; did you mean 'absl::optional'? 337 | optionaltoml::time_offset offset; | ^ /usr/local/include/absl/types/optional.h:34:12: note: 'absl::optional' declared here 34 | using std::optional; | ^ 1 error generated. ninja: build stopped: subcommand failed. make: *** [Makefile:20: prof-user] Error 1

What does this change do?

Is it related to an exisiting bug report or feature request?

Pre-merge checklist

  • I've read CONTRIBUTING.md
  • I've rebased my changes against the current HEAD of origin/master (if necessary)
  • I've added new test cases to verify my change
  • I've regenerated toml.hpp (how-to)
  • I've updated any affected documentation
  • I've rebuilt and run the tests with at least one of:
    • Clang 8 or higher
    • GCC 8 or higher
    • MSVC 19.20 (Visual Studio 2019) or higher
  • I've added my name to the list of contributors in README.md

At line 337 my clang++-21 was confused where the optional came from (absel::optional? or std::optional?), i added the header and it worked for me. I installed the library from "apt", it worked for me for like a week but i don't know why my compiler started throwing me the error.

/usr/include/toml++/impl/date_time.hpp:337:3: error: no template named 'optional'; did you mean 'absl::optional'? 337 | optional<toml::time_offset> offset; | ^ /usr/local/include/absl/types/optional.h:34:12: note: 'absl::optional' declared here 34 | using std::optional; | ^ 1 error generated. ninja: build stopped: subcommand failed. make: *** [Makefile:20: prof-user] Error 1
Copy link
Copy Markdown
Owner

@marzer marzer left a comment

Choose a reason for hiding this comment

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

Hi, thanks for the contribution.

One fix to make first, and then please follow the pre-merge checklist in the PR description body.

#include "forward_declarations.hpp"
#include "print_to_stream.hpp"
#include "header_start.hpp"
#include <toml++/impl/std_optional.hpp>
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

  1. Change the include style to match those around it (i.e. use relative paths with quotes)
  2. Move it one line up, above "header_start.hpp"

@marzer
Copy link
Copy Markdown
Owner

marzer commented Apr 15, 2026

@dwithun-dev I don't understand, you closed this PR, opened a new one, then closed that too? Is there something I can help with?

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.

2 participants