Browse Source

add NR_CURRENT_FUNCTION and fixed iterator_adapter creation

master
Niklas Rosenstein 2 years ago
parent
commit
c163854e87
Signed by: NiklasRosenstein GPG Key ID: 06D269B33D25F6C6
2 changed files with 27 additions and 2 deletions
  1. + 3
    - 2
      include/NiklasRosenstein/iterator.hpp
  2. + 24
    - 0
      include/NiklasRosenstein/macros.h

+ 3
- 2
include/NiklasRosenstein/iterator.hpp

@ -98,6 +98,7 @@ namespace niklasrosenstein {
public:
using yield_type = typename detail::iterator::yield_type_t<T>;
static_assert(!std::is_same<yield_type, void>::value, "T::next() can not return void");
using holder_type = detail::iterator::holder_type<yield_type, move_value>;
/**
@ -168,13 +169,13 @@ namespace niklasrosenstein {
* not really mark the begin of the iteration, rather the current state of
* the iterator.
*/
inline iterator_adapter<T, move_value> begin() { return iterator_adapter<T>(static_cast<T*>(this)); }
inline iterator_adapter<T, move_value> begin() { return iterator_adapter<T, move_value>(static_cast<T*>(this)); }
/**
* Returns the sentinel #iterator_adapter that marks the end of the
* iteration.
*/
inline iterator_adapter<T, move_value> end() const { return iterator_adapter<T>(nullptr); }
inline iterator_adapter<T, move_value> end() const { return iterator_adapter<T, move_value>(nullptr); }
};
/**

+ 24
- 0
include/NiklasRosenstein/macros.h

@ -155,3 +155,27 @@
#elif !defined(NR_PLATFORM)
#warning "Unable to identify this platform, macro NR_PLATFORM stays undefined."
#endif
/**
* @macro NR_CURRENT_FUNCTION
*
* Copied from `BOOST_CURRENT_FUNCTION`.
*/
#if defined(__GNUC__) || (defined(__MWERKS__) && (__MWERKS__ >= 0x3000)) || (defined(__ICC) && (__ICC >= 600)) || defined(__ghs__)
# define NR_CURRENT_FUNCTION __PRETTY_FUNCTION__
#elif defined(__DMC__) && (__DMC__ >= 0x810)
# define NR_CURRENT_FUNCTION __PRETTY_FUNCTION__
#elif defined(__FUNCSIG__)
# define NR_CURRENT_FUNCTION __FUNCSIG__
#elif (defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 600)) || (defined(__IBMCPP__) && (__IBMCPP__ >= 500))
# define NR_CURRENT_FUNCTION __FUNCTION__
#elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x550)
# define NR_CURRENT_FUNCTION __FUNC__
#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901)
# define NR_CURRENT_FUNCTION __func__
#elif defined(__cplusplus) && (__cplusplus >= 201103)
# define NR_CURRENT_FUNCTION __func__
#else
# define NR_CURRENT_FUNCTION "(unknown)"
#endif

Loading…
Cancel
Save