<commit_before>/*
 * Copyright(c) Sophist Solutions, Inc. 1990-2015.  All rights reserved
 */
#ifndef _Stroika_Foundation_Common_Compare_h_
#define _Stroika_Foundation_Common_Compare_h_ 1

#include    "../StroikaPreComp.h"

#include    <functional>
#include    <memory>

#include    "../Configuration/Common.h"
#include    "../Configuration/Concepts.h"



/**
 * TODO:
 *      @todo   use http://en.cppreference.com/w/cpp/types/enable_if to make this work better
 *              So for example - we want something like:
 *                  enable_if<is_integral<T>> int compare (T, T) { return v1 - v2; }
 *
 */



namespace   Stroika {
    namespace   Foundation {
        namespace   Common {


            namespace Private_ {
                namespace Has_Operator_LessThan_Helper_ {
                    /*
                     *  This trick is based on code from
                     *      http://stackoverflow.com/questions/5768511/using-sfinae-to-check-for-global-operator
                     */
                    using       no  =   char;
                    using       yes =   char[2];
                    struct any_t {
                        template<typename T> any_t (T const&);
                    };
                    no operator< (any_t const&, any_t const&);
                    yes& test (bool);
                    no test (no);
                    template<typename T>
                    struct Has_Operator_LessThan_ {
                        static T const& s;
                        static T const& t;
                        static bool const value = sizeof(test (s < t)) == sizeof(yes);
                    };
                }
                namespace Has_Compare_Helper_ {
                    using namespace Configuration;
                    template <typename T>
                    struct  get_Compare_result {
                    private:
                        template    <typename X>
                        static auto check (X const& x) -> decltype (declval<X> ().Compare (declval<X> ()));
                        static substition_failure check (...);

                    public:
                        using type = decltype (check (std::declval<T> ()));
                    };
                }
            }


            /**
             *  has value member which is true iff 'T' supports the less than operator.
             */
            template    <typename T>
            struct  Has_Operator_LessThan :
                    Private_::Has_Operator_LessThan_Helper_::Has_Operator_LessThan_<T> {<commit_msg>todo comments on deprecating Has_Operator_LessThan<T>::value<commit_after>/*
 * Copyright(c) Sophist Solutions, Inc. 1990-2015.  All rights reserved
 */
#ifndef _Stroika_Foundation_Common_Compare_h_
#define _Stroika_Foundation_Common_Compare_h_ 1

#include    "../StroikaPreComp.h"

#include    <functional>
#include    <memory>

#include    "../Configuration/Common.h"
#include    "../Configuration/Concepts.h"



/**
 * TODO:
 *
 *      @todo   REPLACE
 *                  Has_Operator_LessThan<T>::value
 *              with:
 *                  Configuration::LessThanComparable<T> ()
 *              BUT - CANNOT DO until we have vc++ fixed for constexpr functions
 *
 *      @todo   use http://en.cppreference.com/w/cpp/types/enable_if to make this work better
 *              So for example - we want something like:
 *                  enable_if<is_integral<T>> int compare (T, T) { return v1 - v2; }
 *
 */



namespace   Stroika {
    namespace   Foundation {
        namespace   Common {


            namespace Private_ {
                namespace Has_Operator_LessThan_Helper_ {
                    /*
                     *  This trick is based on code from
                     *      http://stackoverflow.com/questions/5768511/using-sfinae-to-check-for-global-operator
                     */
                    using       no  =   char;
                    using       yes =   char[2];
                    struct any_t {
                        template<typename T> any_t (T const&);
                    };
                    no operator< (any_t const&, any_t const&);
                    yes& test (bool);
                    no test (no);
                    template<typename T>
                    struct Has_Operator_LessThan_ {
                        static T const& s;
                        static T const& t;
                        static bool const value = sizeof(test (s < t)) == sizeof(yes);
                    };
                }
                namespace Has_Compare_Helper_ {
                    using namespace Configuration;
                    template <typename T>
                    struct  get_Compare_result {
                    private:
                        template    <typename X>
                        static auto check (X const& x) -> decltype (declval<X> ().Compare (declval<X> ()));
                        static substition_failure check (...);

                    public:
                        using type = decltype (check (std::declval<T> ()));
                    };
                }
            }


            /**
             *  has value member which is true iff 'T' supports the less than operator.
             *
             *  TODO REPLACE
             *          Has_Operator_LessThan<T>::value
             *  with:
             *          Configuration::LessThanComparable<T> ()
             *
             *  BUT - CANNOT DO until we have vc++ fixed for constexpr functions
             */
            template    <typename T>
            struct  Has_Operator_LessThan :
                    Private_::Has_Operator_LessThan_Helper_::Has_Operator_LessThan_<T> {
{'fraction_non_alphanumeric': 0.08607994389901823, 'fraction_numerical': 0.006661991584852735, 'mean_word_length': 1.2398900667451904, 'pattern_counts': {'":': 0, '<': 38, '<?xml version=': 0, '>': 36, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1080382', 'n_tokens_mistral': 1505, 'n_tokens_neox': 1386, 'n_words': 364}