Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the following code (from README, use with boostext::di) does not compile (clang 17, gcc 11) #41

Open
ralphjzhang opened this issue Mar 5, 2024 · 0 comments

Comments

@ralphjzhang
Copy link

#include <boost/di.hpp>
#include <boost/te.hpp>
#include <iostream>

namespace te = boost::te;
namespace di = boost::di;

struct Drawable : te::poly<Drawable> {
  using te::poly<Drawable>::poly;

  void draw(std::ostream &out) const {
    te::call([](auto const &self, auto &out) { self.draw(out); }, *this, out);
  }
};

struct Rect {
  void draw(std::ostream &out) const { out << "Rect" << std::endl; }
};

struct Circle {
  void draw(std::ostream &out) const { out << "Circle" << std::endl; }
};

class Example {
public:
  Example(Drawable const drawable, std::ostream &out)
      : drawable{drawable}, out{out} {}

  void draw() { drawable.draw(out); }

private:
  Drawable const drawable;
  std::ostream &out;
};

int main() {
  const auto injector = di::make_injector(di::bind<Drawable>.to<Circle>(),
                                          di::bind<std::ostream>.to(std::cout));

  injector.create<Example>().draw(); // prints Circle
}

Expected Behavior

Actual Behavior

clang error:

poly.cpp:40:12: warning: 'create' is deprecated: creatable constraint not satisfied [-Wdeprecated-declarations]
40 | injector.create().draw(); // prints Circle
| ^
inc/boost/di.hpp:2778:3: note: 'create' has been explicitly marked deprecated here
2778 | create
| ^
poly.cpp:40:12: warning: 'create<Example, 0>' is deprecated: creatable constraint not satisfied [-Wdeprecated-declarations]
40 | injector.create().draw(); // prints Circle
| ^
inc/boost/di.hpp:2775:3: note: 'create<Example, 0>' has been explicitly marked deprecated here
2775 | __BOOST_DI_DEPRECATED("creatable constraint not satisfied")
| ^
inc/boost/di.hpp:33:38: note: expanded from macro '__BOOST_DI_DEPRECATED'
33 | #define _BOOST_DI_DEPRECATED(...) [[deprecated(VA_ARGS)]]
| ^
inc/boost/di.hpp:1241:4: error: inline function 'boost::di::concepts::type::has_to_many_constructor_parameters::max<10>::error' is not defined [-Werror,-Wundefined-inline]
1241 | error(
= "increase BOOST_DI_CFG_CTOR_LIMIT_SIZE value or reduce number of constructor parameters");
| ^
inc/boost/di.hpp:1237:43: note: used here
1237 | return constraint_not_satisfied{}.error();
| ^
2 warnings and 1 error generated.

gcc linking error:

/usr/bin/ld: /tmp/ccU8Y1RZ.o: in function boost::ext::di::v1_3_0::concepts::type<Example>::has_to_many_constructor_parameters::max<10>::operator Example*() const': poly.cpp:(.text._ZNK5boost3ext2di6v1_3_08concepts4typeI7ExampleE34has_to_many_constructor_parameters3maxILi10EEcvPS5_Ev[_ZNK5boost3ext2di6v1_3_08concepts4typeI7ExampleE34has_to_many_constructor_parameters3maxILi10EEcvPS5_Ev]+0x3b): undefined reference to boost::ext::di::v1_3_0::concepts::type::has_to_many_constructor_parameters::max<10>::error(boost::ext::di::v1_3_0::_)'
collect2: error: ld returned 1 exit status

Steps to Reproduce the Problem

Specifications

  • Version:
  • Platform:
  • Subsystem:
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

No branches or pull requests

1 participant