do not alias virtual_ptr in global namespace, 'aliases' namespace

This commit is contained in:
Jean-Louis Leroy
2025-06-14 11:55:29 -04:00
parent e92a241c73
commit 8ec027c55a
27 changed files with 58 additions and 11 deletions

View File

@@ -11,8 +11,7 @@
#include <boost/openmethod/shared_ptr.hpp>
#include <boost/openmethod/compiler.hpp>
using boost::openmethod::make_shared_virtual;
using boost::openmethod::shared_virtual_ptr;
using namespace boost::openmethod::aliases;
using std::cout;
using std::string;

View File

@@ -10,6 +10,8 @@
#include <boost/openmethod.hpp>
#include <boost/openmethod/compiler.hpp>
using boost::openmethod::virtual_ptr;
struct Character {
virtual ~Character() {
}

View File

@@ -12,6 +12,8 @@
#include <boost/openmethod.hpp>
#include <boost/openmethod/compiler.hpp>
using boost::openmethod::virtual_ptr;
struct Node {
virtual ~Node() {}
};

View File

@@ -14,8 +14,7 @@
#include <boost/openmethod/unique_ptr.hpp>
#include <boost/openmethod/compiler.hpp>
using boost::openmethod::unique_virtual_ptr;
using boost::openmethod::make_unique_virtual;
using namespace boost::openmethod::aliases;
struct Node {
virtual ~Node() {}

View File

@@ -9,6 +9,8 @@
#include <boost/openmethod.hpp>
#include <boost/openmethod/compiler.hpp>
using boost::openmethod::virtual_ptr;
class Thing {
public:
virtual ~Thing() {

View File

@@ -77,6 +77,8 @@ struct custom_policy : bom::registry<custom_rtti, bom::policies::vptr_vector> {
#include <boost/openmethod.hpp>
#include <boost/openmethod/compiler.hpp>
using boost::openmethod::virtual_ptr;
BOOST_OPENMETHOD(poke, (std::ostream&, virtual_ptr<Animal>), void);
BOOST_OPENMETHOD_OVERRIDE(

View File

@@ -10,6 +10,8 @@
#include <boost/openmethod.hpp>
#include <boost/openmethod/compiler.hpp>
using boost::openmethod::virtual_ptr;
struct Animal {
virtual ~Animal() = default;
};

View File

@@ -131,6 +131,8 @@ struct custom_policy : bom::registry<
#include <boost/openmethod.hpp>
#include <boost/openmethod/compiler.hpp>
using boost::openmethod::virtual_ptr;
BOOST_OPENMETHOD(poke, (std::ostream&, virtual_ptr<Animal>), void);
BOOST_OPENMETHOD_OVERRIDE(

View File

@@ -9,6 +9,8 @@
#include <string>
#include <boost/openmethod.hpp>
using boost::openmethod::virtual_ptr;
#ifdef FRIEND_ALL
// tag::friend_all[]

View File

@@ -9,6 +9,8 @@
#include <string>
#include <boost/openmethod.hpp>
using boost::openmethod::virtual_ptr;
#ifdef FRIEND_ALL
// tag::friend_all[]

View File

@@ -15,7 +15,8 @@ struct Animal {
virtual ~Animal() = default;
};
BOOST_OPENMETHOD(poke, (std::ostream&, virtual_ptr<Animal>), void);
BOOST_OPENMETHOD(
poke, (std::ostream&, boost::openmethod::virtual_ptr<Animal>), void);
} // namespace animals

View File

@@ -5,6 +5,8 @@
#include "cat.hpp"
using boost::openmethod::virtual_ptr;
namespace felines {
BOOST_OPENMETHOD_CLASSES(animals::Animal, Cat, Cheetah);

View File

@@ -8,7 +8,7 @@ namespace canines {
BOOST_OPENMETHOD_CLASSES(animals::Animal, Dog);
BOOST_OPENMETHOD_DEFINE_OVERRIDER(
poke, (std::ostream & os, virtual_ptr<Dog> dog), void) {
poke, (std::ostream & os, boost::openmethod::virtual_ptr<Dog> dog), void) {
os << dog->name << " barks";
}

View File

@@ -13,7 +13,7 @@ struct Dog : animals::Animal {
};
BOOST_OPENMETHOD_DECLARE_OVERRIDER(
poke, (std::ostream & os, virtual_ptr<Dog> dog), void);
poke, (std::ostream & os, boost::openmethod::virtual_ptr<Dog> dog), void);
} // namespace canines

View File

@@ -6,6 +6,8 @@
#include "cat.hpp"
#include "dog.hpp"
using boost::openmethod::virtual_ptr;
struct Bulldog : canines::Dog {
using Dog::Dog;
};

View File

@@ -31,6 +31,8 @@ struct Bulldog : Dog {
#include <iostream>
#include <boost/openmethod.hpp>
using boost::openmethod::virtual_ptr;
BOOST_OPENMETHOD(
poke, // method name
(std::ostream&, virtual_ptr<Animal>), // method signature

View File

@@ -16,6 +16,7 @@ using std::make_shared;
using std::shared_ptr;
using std::string;
using boost::openmethod::virtual_ptr;
using boost::openmethod::make_shared_virtual;
using boost::openmethod::shared_virtual_ptr;

View File

@@ -12,6 +12,8 @@
#include <boost/openmethod.hpp>
#include <boost/openmethod/compiler.hpp>
using boost::openmethod::virtual_ptr;
using namespace std;
struct Vehicle {

View File

@@ -133,6 +133,7 @@ struct Init {
namespace openmethods {
using namespace nodes;
using boost::openmethod::virtual_ptr;
BOOST_OPENMETHOD_CLASSES(Node, Number, Plus, Times);

View File

@@ -28,6 +28,8 @@ class Dolphin : public Animal {};
#include <boost/openmethod.hpp>
#include <boost/openmethod/compiler.hpp>
using boost::openmethod::virtual_ptr;
// Classes must be registered:
BOOST_OPENMETHOD_CLASSES(Animal, Dog, Cat, Dolphin);

View File

@@ -37,6 +37,8 @@ struct custom_registry : bom::default_registry::with<throw_if_not_implemented> {
#include <boost/openmethod.hpp>
#include <boost/openmethod/compiler.hpp>
using boost::openmethod::virtual_ptr;
BOOST_OPENMETHOD_CLASSES(Animal, Cat, Dog);
BOOST_OPENMETHOD(trick, (std::ostream&, virtual_ptr<Animal>), void);

View File

@@ -7,6 +7,8 @@
#include <boost/openmethod.hpp>
#include <boost/openmethod/compiler.hpp>
using boost::openmethod::virtual_ptr;
struct Animal {
virtual ~Animal() = default;
};

View File

@@ -9,8 +9,4 @@
#include <boost/openmethod/core.hpp>
#include <boost/openmethod/macros.hpp>
#ifndef BOOST_OPENMETHOD_DISABLE_GLOBAL_VIRTUAL_PTR
using boost::openmethod::virtual_ptr;
#endif
#endif // BOOST_OPENMETHOD_HPP

View File

@@ -1518,6 +1518,14 @@ void method<Name, auto(Parameters...)->ReturnType, Registry>::override_impl<
this->vp_type_ids);
}
namespace aliases {
using boost::openmethod::final_virtual_ptr;
using boost::openmethod::virtual_;
using boost::openmethod::virtual_ptr;
} // namespace aliases
} // namespace boost::openmethod
#ifdef _MSC_VER

View File

@@ -125,6 +125,11 @@ inline auto make_shared_virtual(T&&... args)
std::make_shared<Class>(std::forward<T>(args)...));
}
namespace aliases {
using boost::openmethod::shared_virtual_ptr;
using boost::openmethod::make_shared_virtual;
}
} // namespace boost::openmethod
#endif

View File

@@ -47,6 +47,11 @@ inline auto make_unique_virtual(T&&... args)
std::make_unique<Class>(std::forward<T>(args)...));
}
namespace aliases {
using boost::openmethod::unique_virtual_ptr;
using boost::openmethod::make_unique_virtual;
}
} // namespace boost::openmethod
#endif

View File

@@ -6,6 +6,8 @@
#include <boost/openmethod.hpp>
#include <boost/openmethod/compiler.hpp>
using boost::openmethod::virtual_ptr;
struct Role {
virtual ~Role() {
}