Skip to content

Ambiguous ‘Approx’ when using namespace Catch::Matchers #1968

@gatopeich

Description

@gatopeich

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

using namespace Catch::Matchers;

uint64_t value = <some_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<class T, class AllocComp, class AllocMatch> Catch::Matchers::Vector::ApproxMatcher<T, AllocComp, AllocMatch> Catch::Matchers::Approx(const std::vector<_Tp, _Alloc>&)
Vector::ApproxMatcher<T, AllocComp, AllocMatch> Approx( std::vector<T, AllocComp> 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions