seznam / SuperiorMySqlpp

SuperiorMySQL++
GNU Lesser General Public License v3.0
31 stars 20 forks source link

MSVC14 - string_view #21

Closed H1X4Dev closed 1 year ago

H1X4Dev commented 8 years ago

The following header;

#include <experimental/string_view>

is not existent in CMAKE + MSVC14 environment as shown in picture; http://i.imgur.com/AvrejUx.png

The following options have been appended to CMakeLists.txt;

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED on)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zm500")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")

Although, the header non existence still persists.

H1X4Dev commented 8 years ago

The following code is working by using BOOST 1.61 libraries;

// TODO: change 201701L when optional will become part of standard
#if __cplusplus >= 201701L
#include <string_view>
namespace SuperiorMySqlpp
{
    using StringView = std::string_view;
}
#else
#include <boost/utility/string_view.hpp>

namespace SuperiorMySqlpp
{
    using StringView = boost::string_view;

    inline namespace StringViewLiterals
    {
        inline boost::basic_string_view<char>
            operator""sv(const char* __str, size_t __len)
        {
            return boost::basic_string_view<char>{__str, __len};
        }
        inline boost::basic_string_view<wchar_t>
            operator""sv(const wchar_t* __str, size_t __len)
        {
            return boost::basic_string_view<wchar_t>{__str, __len};
        }
    }
}
#endif
majcl commented 8 years ago

Hi, maybe it would be better to use

elif _MSC_VER ...

or

elif __cpp_lib_experimental_string_view >=201411 (according to http://en.cppreference.com/w/cpp/experimental/basic_string_view)

Can you please try it?

H1X4Dev commented 8 years ago

This header does not exist in MSVC.