# define GC_ATTR_UNUSED
#endif
+#ifndef GC_ATTR_EXPLICIT
+# if (__cplusplus >= 201103L) || defined(CPPCHECK)
+# define GC_ATTR_EXPLICIT explicit
+# else
+# define GC_ATTR_EXPLICIT /* empty */
+# endif
+#endif
+
/* First some helpers to allow us to dispatch on whether or not a type
* is known to be pointer-free.
* These are private, except that the client may invoke the
gc_allocator(const gc_allocator&) throw() {}
# if !(GC_NO_MEMBER_TEMPLATES || 0 < _MSC_VER && _MSC_VER <= 1200)
// MSVC++ 6.0 do not support member templates
- template <class GC_Tp1> gc_allocator(const gc_allocator<GC_Tp1>&) throw() {}
+ template <class GC_Tp1> GC_ATTR_EXPLICIT
+ gc_allocator(const gc_allocator<GC_Tp1>&) throw() {}
# endif
~gc_allocator() throw() {}
gc_allocator_ignore_off_page(const gc_allocator_ignore_off_page&) throw() {}
# if !(GC_NO_MEMBER_TEMPLATES || 0 < _MSC_VER && _MSC_VER <= 1200)
// MSVC++ 6.0 do not support member templates
- template <class GC_Tp1>
+ template <class GC_Tp1> GC_ATTR_EXPLICIT
gc_allocator_ignore_off_page(const gc_allocator_ignore_off_page<GC_Tp1>&)
throw() {}
# endif
traceable_allocator(const traceable_allocator&) throw() {}
# if !(GC_NO_MEMBER_TEMPLATES || 0 < _MSC_VER && _MSC_VER <= 1200)
// MSVC++ 6.0 do not support member templates
- template <class GC_Tp1> traceable_allocator
- (const traceable_allocator<GC_Tp1>&) throw() {}
+ template <class GC_Tp1> GC_ATTR_EXPLICIT
+ traceable_allocator(const traceable_allocator<GC_Tp1>&) throw() {}
# endif
~traceable_allocator() throw() {}
# define ATTR_UNUSED /* empty */
#endif
+#ifndef GC_ATTR_EXPLICIT
+# if (__cplusplus >= 201103L) || defined(CPPCHECK)
+# define GC_ATTR_EXPLICIT explicit
+# else
+# define GC_ATTR_EXPLICIT /* empty */
+# endif
+#endif
+
class A {public:
/* An uncollectible class. */
- A( int iArg ): i( iArg ) {}
+ GC_ATTR_EXPLICIT A( int iArg ): i( iArg ) {}
void Test( int iArg ) {
my_assert( i == iArg );}
int i;};
class B: public GC_NS_QUALIFY(gc), public A { public:
/* A collectible class. */
- B( int j ): A( j ) {}
+ GC_ATTR_EXPLICIT B( int j ): A( j ) {}
~B() {
my_assert( deleting );}
static void Deleting( int on ) {
class C: public GC_NS_QUALIFY(gc_cleanup), public A { public:
/* A collectible class with cleanup and virtual multiple inheritance. */
- C( int levelArg ): A( levelArg ), level( levelArg ) {
+ GC_ATTR_EXPLICIT C( int levelArg ): A( levelArg ), level( levelArg ) {
nAllocated++;
if (level > 0) {
left = new C( level - 1 );
/* A collectible class with a static member function to be used as
an explicit clean-up function supplied to ::new. */
- D( int iArg ): i( iArg ) {
+ GC_ATTR_EXPLICIT D( int iArg ): i( iArg ) {
nAllocated++;}
static void CleanUp( void* obj, void* data ) {
D* self = static_cast<D*>(obj);