Skip to content

"inline" linkage necessary #65

Open

Description

@aaron-michaux

The following lines in optional.hpp should have "inline" linkage. This is necessary for using <boost/optional/optional.hpp> in a module.

    const in_place_init_t in_place_init((in_place_init_t::init_tag()));

   const in_place_init_if_t
       in_place_init_if((in_place_init_if_t::init_tag()));

Activity

  1. aaron-michaux commented on Nov 21, 2018

    @aaron-michaux
    Author

    I'm not sure how this code could be correct in a header-only library without inline.

  2. akrzemi1 commented on Nov 21, 2018

    @akrzemi1
    Member

    global objects declared const have internal linkage.

  3. aaron-michaux commented on Nov 21, 2018

    @aaron-michaux
    Author
  4. gast128 commented on Nov 27, 2023

    @gast128

    Can't these be turned into inline constexpr variables with BOOST_INLINE_CONSTEXPR. I had 2 hits:

    • const in_place_init_t in_place_init ((in_place_init_t::init_tag()));
    • const in_place_init_if_t in_place_init_if ((in_place_init_if_t::init_tag()));
  5. akrzemi1 commented on Nov 27, 2023

    @akrzemi1
    Member

    Can't these be turned into inline constexpr variables with BOOST_INLINE_CONSTEXPR.

    They could in C++17. But this has to work in C++11. I could special-case it for C++17, but there have to be sufficient motivation. Can someone point me to the place (in the IS perhaps) that tells if/why the current implementation is incompatible with modules?

  6. gast128 commented on Nov 27, 2023

    @gast128

    They could in C++17. But this has to work in C++11

    I think BOOST_INLINE_CONSTEXPR expands to 'inline constexpr' when available and otherwise to 'const'. It may miss the 'static const' case though. Perhaps there is a Boost guideline.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions