catchorg / catchorg/Catch2

Ambiguous ‘Approx’ when using namespace Catch::Matchers

Open
#1,968 0 comments 3 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
21.5k
Forks
3.5k
Avg merge
3d 16h
Merged PRs (30d)
2

Description

**Describe the bug**
Struggling with error: reference to ‘Approx’ is ambiguous on very simple code:

```
using namespace Catch::Matchers;

uint64_t value = ;
CHECK(value == Catch::Detail::Approx(0));
```
> error: reference to ‘Approx’ is ambiguous
> CHECK(value == Approx(id*1000.));
> 3rdParties/catch.hpp:3082:11: note: candidates are: class Catch::Detail::Approx
> class Approx {
> ^~~~~~
> In file included from tests/TestRest.cpp:12:0:
> 3rdParties/catch.hpp:3758:53: note: template Catch::Matchers::Vector::ApproxMatcher Catch::Matchers::Approx(const std::vector<_Tp, _Alloc>&)
> Vector::ApproxMatcher Approx( std::vector const& comparator ) {

**Expected behavior**
I tried many variations but the only thing that works is removing `using namespace Catch::Matchers`
Is there any other way to get it working?

**Reproduction steps**
Steps to reproduce the bug.

**Platform information:**

- OS: **Ubuntu 18.04**
- Compiler+version: **gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04)**
- Catch version: **v2.12.2**

**Additional context**
Compiler flags:
`-std=c++17 -O2 -g -Wall -Werror -D_GNU_SOURCE -fPIC -Wno-sign-compare`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.