mirror of
https://github.com/catchorg/Catch2.git
synced 2025-01-16 07:08:01 +00:00
Compare commits
2 Commits
b1dcdc5032
...
f764ee3d30
Author | SHA1 | Date | |
---|---|---|---|
|
f764ee3d30 | ||
|
c190061001 |
@ -11,9 +11,9 @@ The easiest way to use Catch is to let it supply ```main()``` for you and handle
|
||||
|
||||
This is achieved by writing ```#define CATCH_CONFIG_MAIN``` before the ```#include "catch.hpp"``` in *exactly one* source file.
|
||||
|
||||
Sometimes, though, you need to write your own version of main(). You can do this by writing ```#define CATCH_CONFIG_RUNNER``` instead. Now you are free to write ```main()``` as normal and call into Catch yourself manually.
|
||||
Sometimes, though, you need to write your own version of main(). You can do this by writing ```#define CATCH_CONFIG_RUNNER``` instead. Now you are free to write ```main()``` as normal and call into Catch yourself manually. You now have a lot of flexibility - but here are three recipes to get your started:
|
||||
|
||||
You now have a lot of flexibility - but here are three recipes to get your started:
|
||||
**Important note: you can only provide `main` in the same file you defined `CATCH_CONFIG_RUNNER`.**
|
||||
|
||||
## Let Catch take full control of args and config
|
||||
|
||||
|
@ -469,20 +469,27 @@ namespace Catch {
|
||||
#endif // CATCH_CONFIG_ENABLE_VARIANT_STRINGMAKER
|
||||
|
||||
namespace Catch {
|
||||
struct not_this_one {}; // Tag type for detecting which begin/ end are being selected
|
||||
|
||||
// Import begin/ end from std here so they are considered alongside the fallback (...) overloads in this namespace
|
||||
// Import begin/ end from std here
|
||||
using std::begin;
|
||||
using std::end;
|
||||
|
||||
not_this_one begin( ... );
|
||||
not_this_one end( ... );
|
||||
namespace detail {
|
||||
template <typename...>
|
||||
struct void_type {
|
||||
using type = void;
|
||||
};
|
||||
|
||||
template <typename T, typename = void>
|
||||
struct is_range_impl : std::false_type {
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct is_range_impl<T, typename void_type<decltype(begin(std::declval<T>()))>::type> : std::true_type {
|
||||
};
|
||||
} // namespace detail
|
||||
|
||||
template <typename T>
|
||||
struct is_range {
|
||||
static const bool value =
|
||||
!std::is_same<decltype(begin(std::declval<T>())), not_this_one>::value &&
|
||||
!std::is_same<decltype(end(std::declval<T>())), not_this_one>::value;
|
||||
struct is_range : detail::is_range_impl<T> {
|
||||
};
|
||||
|
||||
#if defined(_MANAGED) // Managed types are never ranges
|
||||
|
Loading…
Reference in New Issue
Block a user