Giter Club home page Giter Club logo

idk's Introduction

ztd.idk

This is the IDK (Industrial Development Kit) library, part of the ZTD collection. The IDK is a small, useful toolbox of supplementary things, including:

  • The ztd.idk core library:
    • A small collection of type traits, optimizations, and other semi-niche utilities for accelerating development.
    • Small, header-only.
    • CMake: ztd::idk
  • The ztd.tag_invoke customization point library:
    • Modeled after C++ Proposal P1985.
    • Makes for a single extension point to be written, tag_invoke(...), whose first argument is the name of the extension point to be hooking into. E.g., tag_invoke(tag_t<lua_push>, ...).
    • Tiny, header-only.
    • CMake: ztd::tag_invoke
  • The ztd.version configuration macro library:
    • A formalization of the principles found in this post and this post.
    • Mistake-resistant configuration and default-on/off vs. deliberate on/off detection.
    • Infinitesimally tiny, header-only.
    • CMake: ztd::version
  • And more!

All of these utilities should be header-only, and come with CMake build files for ease of use. Simply depend on ztd::idk or ztd::tag_invoke. You can find the the library documentation here (https://ztdidk.rtfd.io).

idk's People

Contributors

miscco avatar nickelpro avatar thephd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

idk's Issues

Fixing Windows builds when using `target_link_libraries()`

The current cmake configuration for ztd.idk is not header-only, it produces a library from the files in the source directory.

This is a problem, because the API linkage flag that api.h expects to see (ZTD_DLL) isn't set by the build system, so the library is built without exporting any symbols. This makes the library unlinkable on Windows.

This is all fixable, but I need to know the intent. The docs refer to idk as header only and it appears to work entirely in header-only mode. So should we just not compile these files? Should we create two targets, one for header only and one that compiles and links the library correctly?

Once I know what the intent is I can handle fixing up the cmake stuff.

Compile fail on android

@ThePhD ,how are you? I want to add some projects of you to vcpkg, but fail to compile idk on android.
install-arm-neon-android-dbg-out.log
microsoft/vcpkg#34735
Error message:
/mnt/vcpkg-ci/buildtrees/ztd-idk/src/f54d488079-38e2ce903b.clean/include/ztd/idk/span.hpp:130:18: error: no member named 'operator==' in namespace 'nonstd'
using ::nonstd::operator==;
~~~~~~~~~~^
/mnt/vcpkg-ci/buildtrees/ztd-idk/src/f54d488079-38e2ce903b.clean/include/ztd/idk/span.hpp:131:18: error: no member named 'operator!=' in namespace 'nonstd'
using ::nonstd::operator!=;
~~~~~~~~~~^
/mnt/vcpkg-ci/buildtrees/ztd-idk/src/f54d488079-38e2ce903b.clean/include/ztd/idk/span.hpp:132:18: error: no member named 'operator<' in namespace 'nonstd'
using ::nonstd::operator<;
~~~~~~~~~~^
/mnt/vcpkg-ci/buildtrees/ztd-idk/src/f54d488079-38e2ce903b.clean/include/ztd/idk/span.hpp:133:18: error: no member named 'operator<=' in namespace 'nonstd'
using ::nonstd::operator<=;
~~~~~~~~~~^
/mnt/vcpkg-ci/buildtrees/ztd-idk/src/f54d488079-38e2ce903b.clean/include/ztd/idk/span.hpp:134:18: error: no member named 'operator>' in namespace 'nonstd'
using ::nonstd::operator>;
~~~~~~~~~~^
/mnt/vcpkg-ci/buildtrees/ztd-idk/src/f54d488079-38e2ce903b.clean/include/ztd/idk/span.hpp:135:18: error: no member named 'operator>=' in namespace 'nonstd'
using ::nonstd::operator>=;
~~~~~~~~~~^
In file included from /mnt/vcpkg-ci/buildtrees/ztd-idk/src/f54d488079-38e2ce903b.clean/source/ztd/idk/encoding_detection.c.cpp:35:
In file included from /mnt/vcpkg-ci/buildtrees/ztd-idk/src/f54d488079-38e2ce903b.clean/include/ztd/idk/encoding_name.hpp:39:
/mnt/vcpkg-ci/buildtrees/ztd-idk/src/f54d488079-38e2ce903b.clean/include/ztd/idk/char_traits.hpp:58:22: error: no type named 'mbstate_t' in namespace 'std'; did you mean simply 'mbstate_t'?
using state_type = ::std::mbstate_t;
^~~~~~~~~~~~~~~~
mbstate_t
/android-ndk-r25c/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/bits/mbstate_t.h:47:3: note: 'mbstate_t' declared here
} mbstate_t;
^
In file included from /mnt/vcpkg-ci/buildtrees/ztd-idk/src/f54d488079-38e2ce903b.clean/source/ztd/idk/encoding_detection.c.cpp:37:
/mnt/vcpkg-ci/buildtrees/ztd-idk/src/f54d488079-38e2ce903b.clean/include/ztd/idk/detail/posix.hpp:70:25: error: use of undeclared identifier 'nl_langinfo'
const char* __name = nl_langinfo(LC_CTYPE);
^
/mnt/vcpkg-ci/buildtrees/ztd-idk/src/f54d488079-38e2ce903b.clean/source/ztd/idk/encoding_detection.c.cpp:65:29: error: use of undeclared identifier 'nl_langinfo'
const char* __ctype_name = nl_langinfo(CODESET);
^
/mnt/vcpkg-ci/buildtrees/ztd-idk/src/f54d488079-38e2ce903b.clean/source/ztd/idk/encoding_detection.c.cpp:108:29: error: use of undeclared identifier 'nl_langinfo'
const char* __ctype_name = nl_langinfo(CODESET);
^
/mnt/vcpkg-ci/buildtrees/ztd-idk/src/f54d488079-38e2ce903b.clean/source/ztd/idk/encoding_detection.c.cpp:228:29: error: use of undeclared identifier 'nl_langinfo'
const char* __ctype_name = nl_langinfo(CODESET);
^
11 errors generated.

Replace `std::invoke` usages with a new `__ztd_detail::__invoke`

<functional> is a huge header, containing (but not limited to) hash, reference_wrapper, function, invoke and much more. Most of the time all these classes are not needed at the same place at the same time, so a #include <functional> may be something expensive, especially on headers (for example reference_wrapper.hpp). Thus I propose to add a new header on ztd/idk/detail named invoke.hpp which provides an implementation of std::invoke/std::invoke_result/std::is_invocable named __ztd_detail::{__invoke, __invoke_result, __is_invocable} and replace the use of the equivalent std:: classes over the library. A reference implementation of std::invoke can be found here.

undefined ztd::ranges::range_element_type_t

I got an error when compile with ztd.text (msvc 19.39 with c++latest) at this line
https://github.com/soasis/text/blob/fc30abbc3056a0ea69f2c6ef25221c3244bf31cf/include/ztd/text/detail/span_reconstruct.hpp#L90

Look like ::ztd::ranges::range_element_type_t is undefined when ZTD_IS_ON(ZTD_STD_LIBRARY_RANGES) at line 882 in adl.hpp is true

#if ZTD_IS_ON(ZTD_STD_LIBRARY_RANGES)
template <typename _Range>
using range_iterator_t = ::std::ranges::iterator_t<_Range>;
template <typename _Range>
using range_sentinel_t = ::std::ranges::sentinel_t<_Range>;
template <typename _Range>
using range_value_type_t = ::std::ranges::range_value_t<_Range>;
template <typename _Range>
using range_reference_t = ::std::ranges::range_reference_t<_Range>;
template <typename _Range>
using range_rvalue_reference_t = ::std::ranges::range_rvalue_reference_t<_Range>;
template <typename _Range>
using range_difference_type_t = ::std::ranges::range_difference_t<_Range>;
template <typename _Range>
using range_size_type_t = ::std::ranges::range_size_t<_Range>;
#else
template <typename _Range>
using range_iterator_t = ::std::remove_reference_t<decltype(::ztd::ranges::begin(
::std::declval<::std::add_lvalue_reference_t<_Range>>()))>;
template <typename _Range>
using range_sentinel_t = ::std::remove_reference_t<decltype(::ztd::ranges::end(
::std::declval<::std::add_lvalue_reference_t<_Range>>()))>;
template <typename _Range>
using range_value_type_t = iterator_value_type_t<range_iterator_t<_Range>>;
template <typename _Range>
using range_element_type_t = iterator_element_type_t<range_iterator_t<_Range>>;
template <typename _Range>
using range_reference_t = iterator_reference_t<range_iterator_t<_Range>>;
template <typename _Range>
using range_rvalue_reference_t = iterator_rvalue_reference_t<range_iterator_t<_Range>>;
template <typename _Range>
using range_difference_type_t = iterator_difference_type_t<range_iterator_t<_Range>>;
template <typename _Range>
using range_size_type_t = iterator_size_type_t<range_iterator_t<_Range>>;
#endif

I copy line 916 to 891 and it compiles.

Builds fail under clang w/ GNU Frontend on Win32

Build failure from a ztd-text include:

In file included from D:/a/vea/vea/vcpkg_installed/x64-windows/include\ztd/text.hpp:56:
D:/a/vea/vea/vcpkg_installed/x64-windows/include\ztd/text/encode_view.hpp:246:24: error: no variable template matches partial specialization
        inline constexpr bool enable_borrowed_range<::ztd::text::encode_view<_Encoding, _Range, _ErrorHandler,
                              ^
D:/a/vea/vea/vcpkg_installed/x64-windows/include\ztd/text/encode_view.hpp:247:14: error: no template named 'enable_borrowed_range' in namespace 'ztd::ranges'; did you mean 'std::ranges::enable_borrowed_range'?
                _State>> = ::ztd::ranges::enable_borrowed_range<_Range>;
                           ^~~~~~~~~~~~~~~
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.31.31103\include\xutility:1973:27: note: 'std::ranges::enable_borrowed_range' declared here
    inline constexpr bool enable_borrowed_range = false;
                          ^

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.