text:
//==================================================================================================
/*!
  @file

  @copyright 2016 NumScale SAS

  Distributed under the Boost Software License, Version 1.0.
  (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
*/
//==================================================================================================
#ifndef BOOST_SIMD_ARCH_COMMON_SIMD_FUNCTION_ROUND_HPP_INCLUDED
#define BOOST_SIMD_ARCH_COMMON_SIMD_FUNCTION_ROUND_HPP_INCLUDED
#include <boost/simd/detail/overload.hpp>

#include <boost/simd/meta/hierarchy/simd.hpp>
#include <boost/simd/constant/half.hpp>
#include <boost/simd/function/abs.hpp>
#include <boost/simd/function/ceil.hpp>
#include <boost/simd/function/logical_andnot.hpp>
#include <boost/simd/function/copysign.hpp>
#include <boost/simd/function/divides.hpp>
#include <boost/simd/function/inc.hpp>
#include <boost/simd/function/if_else.hpp>
#include <boost/simd/function/is_flint.hpp>
#include <boost/simd/function/is_greater.hpp>
#include <boost/simd/function/is_ltz.hpp>
#include <boost/simd/function/minus.hpp>
#include <boost/simd/function/multiplies.hpp>
#include <boost/simd/function/none.hpp>
#include <boost/simd/function/nearbyint.hpp>
#include <boost/simd/function/tenpower.hpp>
#include <boost/simd/function/trunc.hpp>
#include <boost/simd/function/unary_minus.hpp>
#include <boost/simd/function/splat.hpp>
#include <boost/mpl/equal_to.hpp>

namespace boost { namespace simd { namespace ext
{
   namespace bd = boost::dispatch;
   namespace bs = boost::simd;
   BOOST_DISPATCH_OVERLOAD(round_
                          , (typename A0, typename X)
                          , bd::cpu_
                          , bs::pack_<bd::integer_<A0>, X>
                          )
   {
      BOOST_FORCEINLINE A0 operator()( const A0& a0) const BOOST_NOEXCEPT
      {
        return a0;
      }
   };

   BOOST_DISPATCH_OVERLOAD_IF(round_
                          , (typename A0, typename X)
                          , (detail::is_native<X>)
                          , bd::cpu_
                          , bs::pack_<bd::floating_<A0>, X>
                          )
   {
      BOOST_FORCEINLINE A0 operator()( const A0& a0) const BOOST_NOEXCEPT
      {
        const A0 v = bs::abs(a0);
        const A0 c = bs::ceil(v);
        return if_else(v > Maxflint<A0>(), a0, copysign(if_dec(c-Half<A0>() > v, c), a0));
      }
   };

   BOOST_DISPATCH_OVERLOAD_IF(round_
                             , (typename A0, typename A1, typename X)
                             , (detail::is_native<X>)
                             , bd::cpu_
                             , bs::pack_<bd::single_<A0>, X>
                             , bs::pack_<bd::integer_<A1>, X>
                             )
   {
      BOOST_FORCEINLINE A0 operator()( const A0& a0, const  A1&  a1) const BOOST_NOEXCEPT
      {
        A0 fac = tenpower(a1);
        A0 tmp1 = round(a0*fac)/fac;
        return if_else(is_ltz(a1), round(tmp1), tmp1);
      }
   };

   BOOST_DISPATCH_OVERLOAD(round_
                          , (typename A0, typename A1, typename X)
                          , bd::cpu_
                          , bs::pack_<bd::floating_<A0>, X>
                          , bd::scalar_<bd::unsigned_<A1>>
                          )
   {
     BOOST_FORCEINLINE A0 operator()(A0 const & a0,  A1 const & a1) const
      {
        using itype_t = bd::as_integer_t<A0, unsigned>;
        return round(a0, splat<itype_t>(a1));
      }
   };

   BOOST_DISPATCH_OVERLOAD(round_
                          , (typename A0, typename X, typename A1)
                          , bd::cpu_
                          , bs::pack_<bd::floating_<A0>, X>
                          , bd::scalar_<bd::integer_<A1>>
                          )
   {
     BOOST_FORCEINLINE A0 operator()(A0 const & a0,  A1 const & a1) const
      {
        using itype_t = bd::as_integer_t<A0>;
        return round(a0, splat<itype_t>(a1));
      }
   };
} } }

#endif

ext: hpp

max_stars_repo_name: SylvainCorlay/pythran

max_issues_repo_name: SylvainCorlay/pythran

max_forks_repo_name: SylvainCorlay/pythran


text:
#include <boost/thread.hpp>
#include <boost/chrono.hpp>
#include <iostream>

void wait(int seconds)
{
  boost::this_thread::sleep_for(boost::chrono::seconds{seconds});
}

boost::timed_mutex mutex;

void thread1()
{
  using boost::this_thread::get_id;
  for (int i = 0; i < 5; ++i)
  {
    wait(1);
    boost::unique_lock<boost::timed_mutex> lock{mutex};
    std::cout << "Thread " << get_id() << ": " << i << std::endl;
    boost::timed_mutex *m = lock.release();
    m->unlock();
  }
}

void thread2()
{
  using boost::this_thread::get_id;
  for (int i = 0; i < 5; ++i)
  {
    wait(1);
    boost::unique_lock<boost::timed_mutex> lock{mutex,
      boost::try_to_lock};
    if (lock.owns_lock() || lock.try_lock_for(boost::chrono::seconds{1}))
    {
      std::cout << "Thread " << get_id() << ": " << i << std::endl;
    }
  }
}

int main()
{
  boost::thread t1{thread1};
  boost::thread t2{thread2};
  t1.join();
  t2.join();
}

ext: cpp

max_stars_repo_name: KwangjoJeong/Boost

max_issues_repo_name: KwangjoJeong/Boost

max_forks_repo_name: KwangjoJeong/Boost


text:
/**
 * Copyright (c) 2020 Melown Technologies SE
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * *  Redistributions of source code must retain the above copyright notice,
 *    this list of conditions and the following disclaimer.
 *
 * *  Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

#include <cstdlib>
#include <string>
#include <sstream>

#include <boost/test/unit_test.hpp>
#include <boost/optional.hpp>

#include "../streams.hpp"

#include "dbglog/dbglog.hpp"

BOOST_AUTO_TEST_CASE(utility_streams_printFirst_1)
{
    BOOST_TEST_MESSAGE("* Testing print first");

    boost::optional<std::string> emptyString;
    boost::optional<std::string> validString("valid");
    boost::optional<double> validDouble(1);

    {
        std::ostringstream output;
        output << utility::printFirst(emptyString, "NULL");
        LOG(info4) << "empty string: <" << output.str() << ">";
        BOOST_CHECK(output.str() == "NULL");
    }

    {
        std::ostringstream output;
        output << utility::printFirst(emptyString, validString, "NULL");
        LOG(info4) << "valid string: <" << output.str() << ">";
        BOOST_CHECK(output.str() == validString);
    }
}

max_stars_repo_name: ExploreWilder/libutility

max_issues_repo_name: ExploreWilder/libutility

max_forks_repo_name: ExploreWilder/libutility


text:
#pragma once

#if defined(_MSC_VER) && _MSC_VER >= 1400
#pragma warning(push)
#pragma warning(disable:4996)
#endif

#include <boost/signals2/signal.hpp>

#if defined(_MSC_VER) && _MSC_VER >= 1400
#pragma warning(pop)
#endif

#include <fc/thread/future.hpp>
#include <fc/thread/thread.hpp>

namespace fc {
#if !defined(BOOST_NO_TEMPLATE_ALIASES)
   template<typename T>
   using signal = boost::signals2::signal<T>;

   using scoped_connection = boost::signals2::scoped_connection;
#else
  /** Workaround for missing Template Aliases feature in the VS 2012.
      \warning Class defined below cannot have defined constructor (even base class has it)
      since it is impossible to reference directly template class arguments outside this class.
      This code will work until someone will use non-default constructor as it is defined in
      boost::signals2::signal.
  */
  template <class T>
  class signal : public boost::signals2::signal<T>
    {
    public:
    };
#endif

   template<typename T>
   inline T wait( boost::signals2::signal<void(T)>& sig, const microseconds& timeout_us=microseconds::maximum() ) {
     typename promise<T>::ptr p(new promise<T>("fc::signal::wait"));
     boost::signals2::scoped_connection c( sig.connect( [=]( T t ) { p->set_value(t); } ));
     return p->wait( timeout_us );
   }

   inline void wait( boost::signals2::signal<void()>& sig, const microseconds& timeout_us=microseconds::maximum() ) {
     promise<void>::ptr p(new promise<void>("fc::signal::wait"));
     boost::signals2::scoped_connection c( sig.connect( [=]() { p->set_value(); } ));
     p->wait( timeout_us );
   }
}

max_stars_repo_name: techsharesteam/techshares

max_issues_repo_name: techsharesteam/techshares

max_forks_repo_name: techsharesteam/techshares


text:
#define BOOST_TEST_MODULE AdvertisingPredictorTest

#include "AdvertisingPredictor.hpp"

#define BOOST_TEST_DYN_LINK
#include <boost/test/unit_test.hpp>
#include <boost/algorithm/string.hpp>

BOOST_AUTO_TEST_SUITE(AdvertisingPredictorSuite)

using namespace com::github::nimelo;
using namespace std;

BOOST_AUTO_TEST_CASE(Day_3)
{
  // Arrange
  size_t day = 3, expected_likers = 9;

  AdvertisingPredictor ap;
  // Act
  auto actual_likers = ap.predict(day);

  // Assert
  BOOST_CHECK_EQUAL(expected_likers, actual_likers);
}

BOOST_AUTO_TEST_CASE(Day_1)
{
  // Arrange
  size_t day = 1, expected_likers = 2;

  AdvertisingPredictor ap;
  // Act
  auto actual_likers = ap.predict(day);

  // Assert
  BOOST_CHECK_EQUAL(expected_likers, actual_likers);
}

BOOST_AUTO_TEST_CASE(Day_2)
{
  // Arrange
  size_t day = 2, expected_likers = 5;

  AdvertisingPredictor ap;
  // Act
  auto actual_likers = ap.predict(day);

  // Assert
  BOOST_CHECK_EQUAL(expected_likers, actual_likers);
}

BOOST_AUTO_TEST_SUITE_END()

ext: cc

max_stars_repo_name: Nimelo/hacker-rank

max_issues_repo_name: Nimelo/hacker-rank

max_forks_repo_name: Nimelo/hacker-rank