return *this;
}
+ GenericArg (GenericArg &&other) = default;
+ GenericArg &operator= (GenericArg &&other) = default;
+
bool is_error () const { return kind == Kind::Error; }
Kind get_kind () const { return kind; }
// copy constructor with vector clone
GenericArgs (GenericArgs const &other)
- : lifetime_args (other.lifetime_args), generic_args (other.generic_args),
- binding_args (other.binding_args), locus (other.locus)
- {}
+ : lifetime_args (other.lifetime_args), binding_args (other.binding_args),
+ locus (other.locus)
+ {
+ generic_args.clear ();
+ generic_args.reserve (other.generic_args.size ());
+ for (const auto &arg : other.generic_args)
+ {
+ generic_args.push_back (GenericArg (arg));
+ }
+ }
~GenericArgs () = default;
GenericArgs &operator= (GenericArgs const &other)
{
lifetime_args = other.lifetime_args;
- generic_args = other.generic_args;
binding_args = other.binding_args;
locus = other.locus;
+ generic_args.clear ();
+ generic_args.reserve (other.generic_args.size ());
+ for (const auto &arg : other.generic_args)
+ {
+ generic_args.push_back (GenericArg (arg));
+ }
+
return *this;
}
bool has_separating_scope_resolution;
NodeId node_id;
+public:
// Clone function implementation - not pure virtual as overrided by
// subclasses
virtual TypePathSegment *clone_type_path_segment_impl () const
node_id (Analysis::Mappings::get ()->get_next_node_id ())
{}
+ TypePathSegment (TypePathSegment const &other)
+ : ident_segment (other.ident_segment), locus (other.locus),
+ has_separating_scope_resolution (other.has_separating_scope_resolution),
+ node_id (other.node_id)
+ {}
+
+ TypePathSegment &operator= (TypePathSegment const &other)
+ {
+ ident_segment = other.ident_segment;
+ locus = other.locus;
+ has_separating_scope_resolution = other.has_separating_scope_resolution;
+ node_id = other.node_id;
+
+ return *this;
+ }
+
+ TypePathSegment (TypePathSegment &&other) = default;
+ TypePathSegment &operator= (TypePathSegment &&other) = default;
+
virtual std::string as_string () const { return ident_segment.as_string (); }
/* Returns whether the type path segment is in an error state. May be
std::move (binding_args)))
{}
+ // Copy constructor with vector clone
+ TypePathSegmentGeneric (TypePathSegmentGeneric const &other)
+ : TypePathSegment (other), generic_args (other.generic_args)
+ {}
+
+ // Overloaded assignment operator with vector clone
+ TypePathSegmentGeneric &operator= (TypePathSegmentGeneric const &other)
+ {
+ generic_args = other.generic_args;
+
+ return *this;
+ }
+
+ // move constructors
+ TypePathSegmentGeneric (TypePathSegmentGeneric &&other) = default;
+ TypePathSegmentGeneric &operator= (TypePathSegmentGeneric &&other) = default;
+
std::string as_string () const override;
void accept_vis (ASTVisitor &vis) override;
return generic_args;
}
-protected:
// Use covariance to override base class method
TypePathSegmentGeneric *clone_type_path_segment_impl () const override
{
return function_path;
}
-protected:
// Use covariance to override base class method
TypePathSegmentFunction *clone_type_path_segment_impl () const override
{
segments (std::move (path_segments)), locus (locus)
{}
- /* TODO: maybe make a shortcut constructor that has QualifiedPathType
- * elements as params */
-
// Copy constructor with vector clone
QualifiedPathInType (QualifiedPathInType const &other)
: path_type (other.path_type), locus (other.locus)
{
+ auto seg = other.associated_segment->clone_type_path_segment_impl ();
+ associated_segment = std::unique_ptr<TypePathSegment> (seg);
+
segments.reserve (other.segments.size ());
for (const auto &e : other.segments)
segments.push_back (e->clone_type_path_segment ());
// Overloaded assignment operator with vector clone
QualifiedPathInType &operator= (QualifiedPathInType const &other)
{
+ auto seg = other.associated_segment->clone_type_path_segment_impl ();
+ associated_segment = std::unique_ptr<TypePathSegment> (seg);
+
path_type = other.path_type;
locus = other.locus;
bool has_separating_scope_resolution;
SegmentType type;
+public:
// Clone function implementation - not pure virtual as overrided by subclasses
virtual TypePathSegment *clone_type_path_segment_impl () const
{
return SegmentType::GENERIC;
}
-protected:
// Use covariance to override base class method
TypePathSegmentGeneric *clone_type_path_segment_impl () const override
{
TypePathFunction &get_function_path () { return function_path; }
-protected:
// Use covariance to override base class method
TypePathSegmentFunction *clone_type_path_segment_impl () const override
{
segments (std::move (path_segments))
{}
- /* TODO: maybe make a shortcut constructor that has QualifiedPathType elements
- * as params */
-
// Copy constructor with vector clone
QualifiedPathInType (QualifiedPathInType const &other)
: TypeNoBounds (other.mappings, other.locus), path_type (other.path_type)
{
+ auto seg = other.associated_segment->clone_type_path_segment_impl ();
+ associated_segment = std::unique_ptr<TypePathSegment> (seg);
+
segments.reserve (other.segments.size ());
for (const auto &e : other.segments)
segments.push_back (e->clone_type_path_segment ());
-
- // Untested.
- gcc_unreachable ();
}
// Overloaded assignment operator with vector clone
QualifiedPathInType &operator= (QualifiedPathInType const &other)
{
+ auto seg = other.associated_segment->clone_type_path_segment_impl ();
+ associated_segment = std::unique_ptr<TypePathSegment> (seg);
+
path_type = other.path_type;
locus = other.locus;
mappings = other.mappings;