Skip to content

Commit f1cd773

Browse files
committed
Misc classes : Explicitly default copy/assign instead of defining one
1 parent 6a9291f commit f1cd773

File tree

12 files changed

+24
-57
lines changed

12 files changed

+24
-57
lines changed

include/IECore/InternedString.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,13 @@ class IECORE_API InternedString
6666

6767
inline InternedString();
6868
inline InternedString( const std::string &value );
69-
inline InternedString( const InternedString &other );
7069
inline InternedString( const char *value );
7170
inline InternedString( const char *value, size_t length );
7271

72+
InternedString( const InternedString &other ) = default;
73+
InternedString &operator= ( const InternedString &rhs ) = default;
74+
~InternedString() = default;
75+
7376
#if BOOST_VERSION > 105500
7477

7578
inline InternedString( const boost::string_view &value );
@@ -78,8 +81,6 @@ class IECORE_API InternedString
7881

7982
inline InternedString( int64_t number );
8083

81-
inline ~InternedString();
82-
8384
// The equality operators are extremely fast because they
8485
// need only compare the address of the internal string,
8586
// because it was made unique upon construction.

include/IECore/InternedString.inl

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,6 @@ inline InternedString::InternedString( const std::string &value )
4848
{
4949
}
5050

51-
inline InternedString::InternedString( const InternedString &other )
52-
: m_value( other.m_value )
53-
{
54-
}
55-
5651
inline InternedString::InternedString( const char *value )
5752
: m_value( internedString( value ) )
5853
{
@@ -77,10 +72,6 @@ inline InternedString::InternedString( int64_t number )
7772
{
7873
}
7974

80-
inline InternedString::~InternedString()
81-
{
82-
}
83-
8475
inline bool InternedString::operator != ( const InternedString &other ) const
8576
{
8677
return m_value!=other.m_value;

include/IECore/PathMatcher.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,11 @@ class IECORE_API PathMatcher
6868
};
6969

7070
PathMatcher();
71-
/// Copy constructor. Uses lazy-copy-on-write so
72-
/// that copies are cheap until edited.
73-
PathMatcher( const PathMatcher &other );
71+
/// We use lazy-copy-on-write so that copies are cheap until edited.
72+
/// This means we can use default copy and assignment
73+
PathMatcher( const PathMatcher &other ) = default;
74+
PathMatcher& operator= ( const PathMatcher &other ) = default;
75+
~PathMatcher() = default;
7476

7577
template<typename PathIterator>
7678
PathMatcher( PathIterator pathsBegin, PathIterator pathsEnd );

include/IECore/TransformationMatrix.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,10 @@ class IECORE_EXPORT TransformationMatrix
7575
/// Basic constructor for setting common parameters: scale, rotate and translate.
7676
TransformationMatrix( const Imath::Vec3< T > &s, const Imath::Euler< T > &r, const Imath::Vec3< T > &t );
7777

78-
/// Copy constructor
79-
TransformationMatrix( const TransformationMatrix &cp );
78+
/// Copying and assignment just sets all members, so we can use the defaults
79+
TransformationMatrix( const TransformationMatrix &cp ) = default;
80+
TransformationMatrix & operator= ( const TransformationMatrix &rhs ) = default;
81+
~TransformationMatrix() = default;
8082

8183
/// Returns the transform this object represents.
8284
Imath::Matrix44<T> transform( ) const;

include/IECore/TransformationMatrix.inl

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,6 @@ TransformationMatrix<T>::TransformationMatrix( const Imath::Vec3< T > &s, const
5151
{
5252
}
5353

54-
template <class T>
55-
TransformationMatrix<T>::TransformationMatrix( const TransformationMatrix &cp ) :
56-
scalePivot( cp.scalePivot ), scale( cp.scale ), shear( cp.shear ), scalePivotTranslation( cp.scalePivotTranslation ),
57-
rotatePivot( cp.rotatePivot ), rotationOrientation( cp.rotationOrientation ), rotate( cp.rotate ),
58-
rotatePivotTranslation( cp.rotatePivotTranslation ), translate( cp.translate )
59-
{
60-
}
61-
6254
template <class T>
6355
Imath::Matrix44<T> TransformationMatrix<T>::transform( ) const
6456
{

include/IECoreScene/PolygonIterator.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ class IECORESCENE_API PolygonIterator
6565
inline bool operator==( const PolygonIterator &rhs ) const;
6666
inline bool operator!=( const PolygonIterator &rhs ) const;
6767

68-
inline PolygonIterator &operator=( const PolygonIterator &rhs );
68+
PolygonIterator &operator=( const PolygonIterator &rhs ) = default;
69+
PolygonIterator( const PolygonIterator &p ) = default;
70+
~PolygonIterator() = default;
6971

7072
/// Returns an iterator to the beginning of the range of vertex interpolated values
7173
/// for this polygon. Typically you should pass PrimitiveVariable::data::readable()::begin()

include/IECoreScene/PolygonIterator.inl

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,6 @@ inline bool PolygonIterator::operator!=( const PolygonIterator &rhs ) const
7171
return ! operator==( rhs );
7272
}
7373

74-
inline PolygonIterator &PolygonIterator::operator=( const PolygonIterator &rhs )
75-
{
76-
m_vertexIndexIterator = rhs.m_vertexIndexIterator;
77-
m_numVerticesIterator = rhs.m_numVerticesIterator;
78-
m_faceVaryingOffset = rhs.m_faceVaryingOffset;
79-
return *this;
80-
}
81-
8274
template<typename ValueIterator>
8375
PolygonVertexIterator<ValueIterator> PolygonIterator::vertexBegin( ValueIterator valuesBegin ) const
8476
{

include/IECoreScene/PolygonVertexIterator.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ class PolygonVertexIterator
7171
bool operator==( const PolygonVertexIterator &rhs ) const;
7272
bool operator!=( const PolygonVertexIterator &rhs ) const;
7373

74-
PolygonVertexIterator &operator=( const PolygonVertexIterator &rhs );
74+
PolygonVertexIterator &operator=( const PolygonVertexIterator &rhs ) = default;
75+
PolygonVertexIterator( const PolygonVertexIterator &p ) = default;
76+
~PolygonVertexIterator() = default;
7577

7678
private :
7779

include/IECoreScene/PolygonVertexIterator.inl

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,6 @@ bool PolygonVertexIterator<VertexValueIterator, VertexIndexIterator>::operator!=
8888
return ! operator==( rhs );
8989
}
9090

91-
template<typename VertexValueIterator, typename VertexIndexIterator>
92-
PolygonVertexIterator<VertexValueIterator, VertexIndexIterator> &PolygonVertexIterator<VertexValueIterator, VertexIndexIterator>::operator=( const PolygonVertexIterator &rhs )
93-
{
94-
m_vertexValuesBegin = rhs.m_vertexValuesBegin;
95-
m_vertexIndexIterator = rhs.m_vertexIndexIterator;
96-
return *this;
97-
}
98-
9991
} // namespace IECoreScene
10092

10193
#endif // IECORESCENE_POLYGONVERTEXITERATOR_INL

include/IECoreScene/PrimitiveVariable.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,11 @@ struct IECORESCENE_API PrimitiveVariable
7272
PrimitiveVariable( Interpolation i, IECore::DataPtr d );
7373
/// Constructor - Data is not copied but referenced directly.
7474
PrimitiveVariable( Interpolation i, IECore::DataPtr d, IECore::IntVectorDataPtr indices );
75-
/// Shallow copy constructor - data is not copied just rereferenced
76-
PrimitiveVariable( const PrimitiveVariable &other );
75+
/// It's OK to make shallow copies where the data is not copied just rereferenced,
76+
/// so we can use default copy and assignment
77+
PrimitiveVariable( const PrimitiveVariable &other ) = default;
78+
PrimitiveVariable & operator= ( const PrimitiveVariable &rhs ) = default;
79+
~PrimitiveVariable() = default;
7780

7881
/// Copy constructor which optionally allows a deep copy of data
7982
/// to be taken.

0 commit comments

Comments
 (0)