Skip to content

Commit

Permalink
Merge pull request #226 from tetengo/cpp20
Browse files Browse the repository at this point in the history
Cpp20
  • Loading branch information
kaorut authored Jan 15, 2022
2 parents 4003b50 + 5e57386 commit 8e0b204
Show file tree
Hide file tree
Showing 83 changed files with 656 additions and 351 deletions.
9 changes: 5 additions & 4 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ AC_CONFIG_FILES([
])

AC_LANG([C++])
AX_CXX_COMPILE_STDCXX_17([noext], [mandatory])
#AX_CXX_COMPILE_STDCXX(17, [noext], [mandatory]) # C++20 is not supported yet.

#### Program Checks ####
AC_PROG_CXX
Expand All @@ -122,8 +122,8 @@ AC_ARG_WITH(
AC_CHECK_PROG(IWYU, include-what-you-use, include-what-you-use)
test -z $IWYU && \
AC_MSG_WARN([You cannot check the includes for lack of include-what-you-use.])
AC_SUBST([IWYU_OPTS_CXX], "-Xiwyu --max_line_length=200 -x c++ -std=c++17 -DIWYU")
AC_SUBST([IWYU_OPTS_C], "-Xiwyu --max_line_length=200 -x c -std=c17 -DIWYU")
AC_SUBST([IWYU_OPTS_CXX], "-Xiwyu --max_line_length=200 -x c++ -DIWYU")
AC_SUBST([IWYU_OPTS_C], "-Xiwyu --max_line_length=200 -x c -DIWYU")
AC_SUBST([IWYU_IMP_PATH], "kogyan/tool/iwyu_mappings.imp")

AC_ARG_WITH(
Expand Down Expand Up @@ -198,7 +198,8 @@ AC_HEADER_STDC
AC_SUBST([CPPFLAGS], "${CPPFLAGS} ${BOOST_CPPFLAGS}")

#### Compilation Options ####
AC_SUBST([CXXFLAGS], "${CXXFLAGS} -Werror -Wall -Wextra -pedantic-errors")
AC_SUBST([CXXFLAGS_IWYU], "${CXXFLAGS} -std=c++2a -Werror -Wall -Wextra -pedantic-errors")
AC_SUBST([CXXFLAGS], "${CXXFLAGS} -std=c++20 -Werror -Wall -Wextra -pedantic-errors")
AC_SUBST([CFLAGS], "${CFLAGS} -std=c17 -Werror -Wall -Wextra -pedantic-errors")

#### Output ####
Expand Down
4 changes: 1 addition & 3 deletions executable/setup/src/winmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

#include <Windows.h>

#include <boost/algorithm/string.hpp>

#include <tetengo/text/encoder.hpp>
#include <tetengo/text/encoding/utf16.hpp>

Expand Down Expand Up @@ -61,7 +59,7 @@ namespace
{
const auto msi_path = base_directory / msi_file_name;
auto parameters = std::wstring{ L"/i \"" } + msi_path.native() + std::wstring{ L"\"" };
if (boost::algorithm::starts_with(locale_name, "Japanese"))
if (locale_name.starts_with("Japanese"))
{
parameters += L" TRANSFORMS=\":ja.mst\"";
}
Expand Down
2 changes: 1 addition & 1 deletion kogyan
4 changes: 2 additions & 2 deletions library/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
# Copyright (C) 2019-2022 kaoru https://www.tetengo.org/

SUBDIRS = \
json \
lattice \
platform_dependent \
text \
json \
lattice \
property \
trie

Expand Down
2 changes: 1 addition & 1 deletion library/json/c/src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ IWYU_OPTS_CXX += -Xiwyu --mapping_file=${top_srcdir}/${IWYU_IMP_PATH}
iwyu: ${addsuffix .iwyuout, ${headers} ${sources}}

%.iwyuout: %
${IWYU} ${IWYU_OPTS_CXX} ${CPPFLAGS} ${libtetengo_json_la_CPPFLAGS} ${CXXFLAGS} $< 2> ${addsuffix .tmp, $@} || true
${IWYU} ${IWYU_OPTS_CXX} ${CPPFLAGS} ${libtetengo_json_la_CPPFLAGS} ${CXXFLAGS_IWYU} $< 2> ${addsuffix .tmp, $@} || true
mv -f ${addsuffix .tmp, $@} $@

.PHONY: clean-iwyu
Expand Down
2 changes: 1 addition & 1 deletion library/json/c/src/tetengo_json_element.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct tetengo_json_element_tag

explicit tetengo_json_element_tag(std::unique_ptr<tetengo::json::element>&& p_cpp_element) :
p_cpp_element_holder{ std::move(p_cpp_element) },
p_cpp_element{ p_cpp_element_holder.get() },
p_cpp_element{ std::to_address(p_cpp_element_holder) },
type{},
file_location{}
{}
Expand Down
2 changes: 1 addition & 1 deletion library/json/c/src/tetengo_json_jsonParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ const tetengo_json_element_t* tetengo_json_jsonParser_peek(const tetengo_json_js
}

p_parser->p_current_element = std::make_unique<tetengo_json_element_t>(&p_parser->p_cpp_parser->peek());
return p_parser->p_current_element.get();
return std::to_address(p_parser->p_current_element);
}
catch (...)
{
Expand Down
2 changes: 1 addition & 1 deletion library/json/c/src/tetengo_json_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ const tetengo_json_reader_t* tetengo_json_reader_baseReader(const tetengo_json_r

p_reader->p_base_reader_placeholder =
std::make_unique<tetengo_json_reader_t>(&p_reader->cpp_reader().base_reader());
return p_reader->p_base_reader_placeholder.get();
return std::to_address(p_reader->p_base_reader_placeholder);
}
catch (...)
{
Expand Down
2 changes: 1 addition & 1 deletion library/json/cpp/include/tetengo/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ iwyu: ${addsuffix .iwyuout, ${pkg_headers} ${extra_headers}}

%.iwyuout: %
mkdir -p ${dir $@}
${IWYU} ${IWYU_OPTS_CXX} ${CPPFLAGS} ${iwyu_CPPFLAGS} ${CXXFLAGS} $< 2> ${addsuffix .tmp, $@} || true
${IWYU} ${IWYU_OPTS_CXX} ${CPPFLAGS} ${iwyu_CPPFLAGS} ${CXXFLAGS_IWYU} $< 2> ${addsuffix .tmp, $@} || true
mv -f ${addsuffix .tmp, $@} $@

.PHONY: clean-iwyu
Expand Down
9 changes: 6 additions & 3 deletions library/json/cpp/include/tetengo/json/reader_iterator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,12 @@ namespace tetengo::json
*/
reader_iterator& operator++();

//! Makes operator++(int) visible.
using boost::stl_interfaces::iterator_interface<reader_iterator, std::input_iterator_tag, char, char>::
operator++;
/*!
\brief Postincrements the iterator.
\return The iterator before the incrementation.
*/
reader_iterator operator++(int);


private:
Expand Down
2 changes: 1 addition & 1 deletion library/json/cpp/src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ IWYU_OPTS_CXX += -Xiwyu --mapping_file=${top_srcdir}/${IWYU_IMP_PATH}
iwyu: ${addsuffix .iwyuout, ${headers} ${sources}}

%.iwyuout: %
${IWYU} ${IWYU_OPTS_CXX} ${CPPFLAGS} ${libtetengo_json_cpp_a_CPPFLAGS} ${CXXFLAGS} $< 2> ${addsuffix .tmp, $@} || true
${IWYU} ${IWYU_OPTS_CXX} ${CPPFLAGS} ${libtetengo_json_cpp_a_CPPFLAGS} ${CXXFLAGS_IWYU} $< 2> ${addsuffix .tmp, $@} || true
mv -f ${addsuffix .tmp, $@} $@

.PHONY: clean-iwyu
Expand Down
7 changes: 7 additions & 0 deletions library/json/cpp/src/tetengo.json.reader_iterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,12 @@ namespace tetengo::json
return *this;
}

reader_iterator reader_iterator::operator++(int)
{
reader_iterator original{ *this };
++(*this);
return original;
}


}
14 changes: 9 additions & 5 deletions library/json/test/src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,18 @@ check_PROGRAMS = test_tetengo.json

test_tetengo_json_CPPFLAGS = \
-I${top_srcdir}/library/json/c/include \
-I${top_srcdir}/library/json/cpp/include
-I${top_srcdir}/library/json/cpp/include \
-I${top_srcdir}/library/text/cpp/include
test_tetengo_json_LDFLAGS = \
-L${top_builddir}/library/json/c/src
-L${top_builddir}/library/json/c/src \
-L${top_builddir}/library/text/cpp/src
test_tetengo_json_LDADD = \
-ltetengo.json \
-ltetengo.text.cpp \
${BOOST_UNIT_TEST_FRAMEWORK_LIB}
test_tetengo_json_DEPENDENCIES = \
${top_builddir}/library/json/c/src/libtetengo.json.la
${top_builddir}/library/json/c/src/libtetengo.json.la \
${top_builddir}/library/text/cpp/src/libtetengo.text.noinst.la
test_tetengo_json_SOURCES = ${headers} ${sources}

TESTS = ${check_PROGRAMS}
Expand All @@ -51,11 +55,11 @@ iwyu: ${addsuffix .iwyuout, ${headers} ${sources}}
mv -f ${addsuffix .tmp, $@} $@

%.cpp.iwyuout: %.cpp
${IWYU} ${IWYU_OPTS_CXX} ${CPPFLAGS} ${test_tetengo_json_CPPFLAGS} ${CXXFLAGS} $< 2> ${addsuffix .tmp, $@} || true
${IWYU} ${IWYU_OPTS_CXX} ${CPPFLAGS} ${test_tetengo_json_CPPFLAGS} ${CXXFLAGS_IWYU} $< 2> ${addsuffix .tmp, $@} || true
mv -f ${addsuffix .tmp, $@} $@

%.hpp.iwyuout: %.hpp
${IWYU} ${IWYU_OPTS_CXX} ${CPPFLAGS} ${test_tetengo_json_CPPFLAGS} ${CXXFLAGS} $< 2> ${addsuffix .tmp, $@} || true
${IWYU} ${IWYU_OPTS_CXX} ${CPPFLAGS} ${test_tetengo_json_CPPFLAGS} ${CXXFLAGS_IWYU} $< 2> ${addsuffix .tmp, $@} || true
mv -f ${addsuffix .tmp, $@} $@

.PHONY: clean-iwyu
Expand Down
Loading

0 comments on commit 8e0b204

Please sign in to comment.