DAW JSON Link
Loading...
Searching...
No Matches
daw_container_traits.h
Go to the documentation of this file.
1// Copyright (c) Darrell Wright
2//
3// Distributed under the Boost Software License, Version 1.0. (See accompanying
4// file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt)
5//
6// Official repository: https://github.com/beached/daw_json_link
7//
8
9#pragma once
10
12
14
15#include <daw/cpp_17.h>
16#include <daw/daw_cpp20_concept.h>
17#include <daw/daw_enable_requires.h>
18
19#include <array>
20#include <cstddef>
21#include <iterator>
22#include <type_traits>
23
24namespace daw::json {
25 inline namespace DAW_JSON_VER {
26 namespace concepts {
27 namespace container_detect {
29 is_container_v, (void)( std::begin( std::declval<T &>( ) ) ),
30 (void)( std::end( std::declval<T &>( ) ) ),
31 (void)( std::declval<typename T::value_type>( ) ),
32 (void)( std::declval<T &>( ).insert(
33 std::end( std::declval<T &>( ) ),
34 std::declval<typename T::value_type>( ) ) ) );
35 } // namespace container_detect
36
37 template<typename T>
38 DAW_REQUIRES( container_detect::is_container_v<T> )
39 struct container_traits<T DAW_ENABLEIF_S(
40 container_detect::is_container_v<T> )> : std::true_type {};
41
42 template<typename T, std::size_t N>
43 struct container_traits<std::array<T, N>> : std::true_type {};
44
46 template<typename T>
47 DAW_CPP20_CONCEPT is_container_v = container_traits<T>::value;
48 } // namespace concepts
49 } // namespace DAW_JSON_VER
50} // namespace daw::json
DAW_REQUIRES(daw::json::json_details::is_container_opted_into_json_iostreams_v< Container >) std
An opt in ostream interface for containers of types that have JSON mappings.
#define DAW_JSON_MAKE_REQ_TRAIT(Name,...)
DAW_CPP20_CONCEPT is_container_v
Is the type deduced or specialized as a container.
Customization point traits.
#define DAW_JSON_VER
The version string used in namespace definitions. Must be a valid namespace name.
Definition version.h:20