TypeTraits.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
3  *
4  * Squid software is distributed under GPLv2+ license and includes
5  * contributions from numerous individuals and organizations.
6  * Please see the COPYING and CONTRIBUTORS files for details.
7  */
8 
9 #ifndef SQUID_SRC_BASE_TYPETRAITS_H
10 #define SQUID_SRC_BASE_TYPETRAITS_H
11 
12 #include <type_traits>
13 
14 namespace TypeTraits_ { // a hack to prevent "unintended ADL"
15 
16 // TODO: Extract reusable paradigms into other mixins (e.g., NonCopyable).
18 class Interface
19 {
20 public:
21  // ensures proper destruction via pointers to base interface classes
22  virtual ~Interface() = default;
23 
24  // prohibits copy/move assignment to prevent accidental object slicing
25  Interface &operator=(const Interface &) = delete;
26  Interface &operator=(Interface &&) = delete;
27 
28 protected: // prevents accidental creation of Interface instances
29 
30  // allows default-construction in kids
31  constexpr Interface() = default;
32 
33  // allows copy/move construction for kids convenience
34  Interface(const Interface &) = default;
35  Interface(Interface &&) = default;
36 };
37 
38 } // namespace TypeTraits_
39 
41 
42 #endif /* SQUID_SRC_BASE_TYPETRAITS_H */
43 
Interface & operator=(const Interface &)=delete
virtual ~Interface()=default
convenience base for any class with pure virtual method(s)
Definition: TypeTraits.h:18
constexpr Interface()=default
TypeTraits_::Interface Interface
Definition: TypeTraits.h:40

 

Introduction

Documentation

Support

Miscellaneous