libzypp 17.31.23
Easy.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
12#ifndef ZYPP_BASE_EASY_H
13#define ZYPP_BASE_EASY_H
14
15#include <cstdio>
16#include <type_traits>
17
27#ifndef __GXX_EXPERIMENTAL_CXX0X__
28#define for_(IT,BEG,END) for ( __typeof__(BEG) IT = BEG, _for_end = END; IT != _for_end; ++IT )
29#else
30#define for_(IT,BEG,END) for ( auto IT = BEG, _for_end = END; IT != _for_end; ++IT )
31#endif
32#define for_each_(IT,CONT) for_( IT, (CONT).begin(), (CONT).end() )
33
41#define arrayBegin(A) (&A[0])
42#define arraySize(A) (sizeof(A)/sizeof(*A))
43#define arrayEnd(A) (&A[0] + arraySize(A))
44
51#define defConstStr(FNC,STR) inline const std::string & FNC { static const std::string val( STR ); return val; }
52
53#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
54#if GCC_VERSION < 40600 || not defined(__GXX_EXPERIMENTAL_CXX0X__)
55#define nullptr NULL
56#endif
57
59#define NON_COPYABLE(CLASS) \
60 CLASS( const CLASS & ) = delete; \
61 CLASS & operator=( const CLASS & ) = delete
62
64#define DEFAULT_COPYABLE(CLASS) \
65 CLASS( const CLASS & ) = default; \
66 CLASS & operator=( const CLASS & ) = default
67
69#define NON_MOVABLE(CLASS) \
70 CLASS( CLASS && ) = delete; \
71 CLASS & operator=( CLASS && ) = delete
72
74#define DEFAULT_MOVABLE(CLASS) \
75 CLASS( CLASS && ) = default; \
76 CLASS & operator=( CLASS && ) = default
77
79#define NON_COPYABLE_BUT_MOVE( CLASS ) \
80 NON_COPYABLE(CLASS); \
81 DEFAULT_MOVABLE(CLASS)
82
84#define NON_MOVABLE_BUT_COPY( CLASS ) \
85 NON_MOVABLE(CLASS); \
86 DEFAULT_COPYABLE(CLASS)
87
88
107template<typename TBase, typename TDerived>
108using disable_use_as_copy_ctor = typename std::enable_if<!std::is_base_of<TBase,typename std::remove_reference<TDerived>::type>::value>::type;
109
111namespace zypp
112{
114} // namespace zypp
116#endif // ZYPP_BASE_EASY_H
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
typename std::enable_if<!std::is_base_of< TBase, typename std::remove_reference< TDerived >::type >::value >::type disable_use_as_copy_ctor
Prevent an universal ctor to be chosen as copy ctor.
Definition: Easy.h:108