From 5e484862f2198b3501457f054f52228960d4d9a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Thu, 1 Feb 2018 20:29:18 +0100 Subject: [PATCH] Add Catch::is_range to documentation --- docs/tostring.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/docs/tostring.md b/docs/tostring.md index cfca0533..568c1c27 100644 --- a/docs/tostring.md +++ b/docs/tostring.md @@ -33,6 +33,23 @@ namespace Catch { } ``` +## Catch::is_range specialisation +As a fallback, Catch attempts to detect if the type can be iterated +(`begin(T)` and `end(T)` are valid) and if it can be, it is stringified +as a range. For certain types this can lead to infinite recursion, so +it can be disabled by specializing `Catch::is_range` like so: + +```cpp +namespace Catch { + template<> + struct is_range { + static const bool value = false; + }; +} + +``` + + ## Exceptions By default all exceptions deriving from `std::exception` will be translated to strings by calling the `what()` method. For exception types that do not derive from `std::exception` - or if `what()` does not return a suitable string - use `CATCH_TRANSLATE_EXCEPTION`. This defines a function that takes your exception type, by reference, and returns a string. It can appear anywhere in the code - it doesn't have to be in the same translation unit. For example: