Code Monkey home page Code Monkey logo

Comments (5)

flyleier avatar flyleier commented on May 24, 2024 1

Does the whole test-suite still run?

Not all, the demo.cpp and example.cpp still run, but basic.cpp has a build error : C2679: binary '<<': no operator found which takes a right-hand operand of type 'const user_defined_container<int,3>', the error place:

//basic.cpp

SECTION("containers") {
    user_defined_container<int, 3> xs{{1, 2, 3}};
    CHECK(pretty_print(xs) == "{1, 2, 3}"); // error C2679
  }

Don't support user defined container, only STL container. if want to print user defined container, must overload operator <<, like this:

template <typename T, std::size_t N>
struct user_defined_container {
  T data[N];
  const T* begin() const { return data; }
  const T* end() const { return data + N; }

  const T* cbegin() const { return data+N-1; }
  const T* cend() const { return data-1; }

  std::size_t size() const { return N; }

  friend std::ostream & operator<<( std::ostream & os, const user_defined_container & value)
  {
      for(auto i = value.begin(); i != value.end(); ++i)
      {
          os << *i;
      }

      return os;
  }
};

It is appropriate for my project, So, I have no further changes.

from dbg-macro.

sharkdp avatar sharkdp commented on May 24, 2024

I'm sorry, but VS2015 is probably not supported. Newer versions should be, though.

# Linux
- { os: ubuntu-20.04, compiler: "g++", cpp_standard: "11", build_type: "Debug" }
- { os: ubuntu-20.04, compiler: "g++", cpp_standard: "14", build_type: "Debug" }
- { os: ubuntu-20.04, compiler: "g++", cpp_standard: "17", build_type: "Debug" }
- { os: ubuntu-20.04, compiler: "g++", cpp_standard: "17", build_type: "RelWithDebInfo" }
- { os: ubuntu-20.04, compiler: "clang++", cpp_standard: "11", build_type: "Debug" }
- { os: ubuntu-20.04, compiler: "clang++", cpp_standard: "14", build_type: "Debug" }
- { os: ubuntu-20.04, compiler: "clang++", cpp_standard: "17", build_type: "Debug" }
- { os: ubuntu-20.04, compiler: "clang++", cpp_standard: "17", build_type: "RelWithDebInfo" }
# MacOS
- { os: macos-latest, compiler: "clang++", cpp_standard: "17", build_type: "Debug" }
# Windows
# Note: we do not test for C++11 as MSVC does not support a C++11 version switch, see:
# https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
- { os: windows-2019, compiler: "cl", cpp_standard: "14", build_type: "Debug" }
- { os: windows-2019, compiler: "cl", cpp_standard: "17", build_type: "Debug" }
- { os: windows-2019, compiler: "cl", cpp_standard: "17", build_type: "RelWithDebInfo" }

from dbg-macro.

flyleier avatar flyleier commented on May 24, 2024

I'm sorry, but VS2015 is probably not supported. Newer versions should be, though.

# Linux
- { os: ubuntu-20.04, compiler: "g++", cpp_standard: "11", build_type: "Debug" }
- { os: ubuntu-20.04, compiler: "g++", cpp_standard: "14", build_type: "Debug" }
- { os: ubuntu-20.04, compiler: "g++", cpp_standard: "17", build_type: "Debug" }
- { os: ubuntu-20.04, compiler: "g++", cpp_standard: "17", build_type: "RelWithDebInfo" }
- { os: ubuntu-20.04, compiler: "clang++", cpp_standard: "11", build_type: "Debug" }
- { os: ubuntu-20.04, compiler: "clang++", cpp_standard: "14", build_type: "Debug" }
- { os: ubuntu-20.04, compiler: "clang++", cpp_standard: "17", build_type: "Debug" }
- { os: ubuntu-20.04, compiler: "clang++", cpp_standard: "17", build_type: "RelWithDebInfo" }
# MacOS
- { os: macos-latest, compiler: "clang++", cpp_standard: "17", build_type: "Debug" }
# Windows
# Note: we do not test for C++11 as MSVC does not support a C++11 version switch, see:
# https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
- { os: windows-2019, compiler: "cl", cpp_standard: "14", build_type: "Debug" }
- { os: windows-2019, compiler: "cl", cpp_standard: "17", build_type: "Debug" }
- { os: windows-2019, compiler: "cl", cpp_standard: "17", build_type: "RelWithDebInfo" }

Thanks for replay. I made some changes and dbg-macro is now available for use in my project. The changes are as follows

/*
template <typename T>
using detect_begin_t = decltype(detail::begin(std::declval<T>()));

template <typename T>
using detect_end_t = decltype(detail::end(std::declval<T>()));

template <typename T>
using detect_size_t = decltype(detail::size(std::declval<T>()));

template <typename T>
struct is_container {
  static constexpr bool value =
      is_detected<detect_begin_t, T>::value &&
      is_detected<detect_end_t, T>::value &&
      is_detected<detect_size_t, T>::value &&
      !std::is_same<std::string,
                    typename std::remove_cv<
                        typename std::remove_reference<T>::type>::type>::value;
};
*/

template<typename T, typename _ = void>
struct is_container : std::false_type {};

template<typename... Ts>
struct is_container_helper {};

template<typename T>
struct is_container<
        T,
        typename std::conditional<
        false,
        is_container_helper<
        typename std::decay<T>::type::value_type,
        typename std::decay<T>::type::size_type,
        typename std::decay<T>::type::allocator_type,
        typename std::decay<T>::type::iterator,
        typename std::decay<T>::type::const_iterator,
        decltype(std::declval<T>().size()),
decltype(std::declval<T>().begin()),
decltype(std::declval<T>().end()),
decltype(std::declval<T>().cbegin()),
decltype(std::declval<T>().cend())
>,
void
>::type
> : public std::true_type {};


template <typename T>
struct is_container<const std::valarray<T> &> : public std::true_type { };

template <typename T, std::size_t N>
struct is_container<const std::array<T, N> &> : public std::true_type { };

I did some tests in VS2015 and VS2019 and it worked fine.
There may be some limitations, but I hope that someone with this problem can be helped.

from dbg-macro.

sharkdp avatar sharkdp commented on May 24, 2024

Nice.

There may be some limitations, but I hope that someone with this problem can be helped.

Does the whole test-suite still run?

from dbg-macro.

sharkdp avatar sharkdp commented on May 24, 2024

I see - thank you for clarifying. In this case, I think we can close this and people running into the same error on old MSVC versions will hopefully find your solution.

from dbg-macro.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.